# Give access to what people bought

> Let your own app open a course, a membership or a download to the people who bought it on your ESTAGE site — and close it when a subscription ends.

Source: https://support.estage.com/give-access-to-what-people-bought
Part of the ESTAGE Support help center (https://support.estage.com). Full knowledge base: https://support.estage.com/llms-full.txt

---

When someone buys a product on your site, ESTAGE records the order. Your app can read it through the API and decide what to open for that person — no need to copy every order by hand.

## Before you start

- An [API key](https://support.estage.com/create-and-manage-api-keys) with **Contacts → Read** and **Orders → Read**.
- The request goes from **server code**, never from a web page.

## What a person has access to

One request answers "what may this person open right now":

```bash
curl https://api.estage.com/v1/contacts/<contact id>/products \
  -H "ESTAGE-API-Key: $ESTAGE_API_KEY"
```

You get one row per product of your site the person has an order for:

- **`access_active`** — `true` while a purchase opens the product: not refunded and not past its end date.
- **`expires_at`** — when access ends; empty for a one-time purchase that never ends. A cancelled subscription keeps its date, in the past.
- **`payment_status`**, **`subscription_id`**, **`order_id`**, **`purchased_at`** — the purchase behind it.

Open the product when `access_active` is `true`; close it otherwise. A contact you only know by email: find their id with `GET /v1/contacts?email=…`.

## Every purchase

`GET /v1/orders?kind=product` lists every product purchase and subscription of the project, newest first. Add `email=…` for one person, or `updated_after=…` to pick up only what changed since your last check — a refund, a cancellation, a new end date.

Store orders (with shipping) come in the same list with `kind: "commerce"`. Refunds, cancellations and shipping work on store orders only.

## Hear about it at once

Instead of asking every few minutes, [subscribe a webhook](https://support.estage.com/receive-crm-events-in-your-app-webhooks) to `order.paid`, `order.refunded` and `order.cancelled`. Each message names the order (`order.id`, `order.kind`) and the contact; then read `/v1/contacts/<id>/products` for the person's current access.
