> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stellartools.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Access

> Check whether a customer can access a product

The access endpoint tells you whether a customer is entitled to use a product — either because they have an active subscription or because they made a confirmed one-time payment. This is the check the AI SDK, LangChain, and UploadThing adapters run automatically, but you can call it directly from your own server-side logic.

## Check access

`GET /customers/{customer_id}/access/{product_id}`

Returns whether the customer has access to the product and the reason why.

```bash theme={null}
curl https://api.stellartools.dev/customers/cus_01jx.../access/prod_01jx... \
  -H "x-api-key: YOUR_API_KEY"
```

### Response

```json theme={null}
{
  "has_access": true,
  "grant": {
    "type": "subscription",
    "subscription_id": "sub_01jx...",
    "status": "active"
  }
}
```

```json theme={null}
{
  "has_access": true,
  "grant": {
    "type": "one_time",
    "payment_id": "pay_01jx..."
  }
}
```

```json theme={null}
{
  "has_access": false,
  "grant": null
}
```

**has\_access** `boolean`

Whether the customer is entitled to use the product.

**grant** `object | null`

The reason access was granted. `null` when `has_access` is false.

**grant fields**

**type** `"subscription" | "one_time"`

What kind of entitlement granted access.

**subscription\_id** `string`

Present when `type` is `"subscription"`. The subscription that is active.

**status** `string`

Present when `type` is `"subscription"`. The subscription status (`active`, `trialing`, or `paused`). Subscriptions scheduled to cancel remain `active` until `current_period_end`.

**payment\_id** `string`

Present when `type` is `"one_time"`. The confirmed payment that granted access.

## SDK usage

The `@stellartools/core` SDK exposes this as `customers.access.verify(customerId, productId)`:

```ts theme={null}
import { StellarTools } from "@stellartools/core";

const stellar = new StellarTools({ api_key: process.env.STELLAR_TOOLS_API_KEY! });

const { has_access, grant } = await stellar.customers.access.verify("cus_xxx", "prod_xxx");

if (!has_access) {
  throw new Error("Customer does not have access to this product");
}

// grant.type tells you whether it's a subscription or one-time payment
if (grant?.type === "subscription") {
  console.log("Active subscription:", grant.subscription_id);
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.