---
title: "Grants a customer access to a product or tier."
---

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

Path: Sherpo merchant API › customer

`POST /v1/stores/{store}/grants`

## Authentication

- `bearer`, http, header `Authorization`, scopes: `customer:write`

## Path parameters

- `store` (`grantAccess.path.store`; string, required) — The store's id.

## Header parameters

- `Idempotency-Key` (`grantAccess.header.Idempotency-Key`; string, optional) — Repeats within 24 hours answer the first result; the same key with other arguments is a conflict.
  - minLength 1; maxLength 255; pattern `^[\x21-\x7E]+$`

## Request body

_Required._

- `customer` (`grantAccess.customer`; any of, required) — By id, or by email: whoever the address reaches, else its invited customer.
  - any of: `object`, `object`
- `product` (`grantAccess.product`; any of, required)
  - any of: `object`, `object`
- `tier` (`grantAccess.tier`; any of, required)
  - any of: `object`, `null`
- `ends_at` (`grantAccess.ends_at`; any of, optional)
  - any of: `string`, `null`
- `reason` (`grantAccess.reason`; any of, optional)
  - any of: `string`, `null`

## Example request

```json
{
  "customer": {
    "id": "string"
  },
  "product": {
    "id": "string"
  },
  "tier": {
    "id": "string"
  },
  "ends_at": "string",
  "reason": "string"
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url 'https://api.sherpo.io/merchant/v1/stores/<store>/grants' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "customer": {
    "id": "string"
  },
  "product": {
    "id": "string"
  },
  "tier": {
    "id": "string"
  },
  "ends_at": "string",
  "reason": "string"
}
'
```

### TypeScript

```typescript
const url = 'https://api.sherpo.io/merchant/v1/stores/<store>/grants';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json', Authorization: 'Bearer <token>'},
  body: JSON.stringify({
    customer: {id: 'string'},
    product: {id: 'string'},
    tier: {id: 'string'},
    ends_at: 'string',
    reason: 'string'
  })
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://api.sherpo.io/merchant/v1/stores/<store>/grants"

payload = {
    "customer": { "id": "string" },
    "product": { "id": "string" },
    "tier": { "id": "string" },
    "ends_at": "string",
    "reason": "string"
}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 200

Grants a customer access to a product or tier.

#### Example

```json
{
  "token_id": "string",
  "customer": {
    "id": "string",
    "name": "string",
    "email": "string",
    "phone": "string",
    "erased": true
  },
  "product": {
    "id": "string",
    "slug": "string",
    "path": "string",
    "url": "string",
    "title": "string",
    "category": "string",
    "deleted": true
  },
  "tier": {
    "id": "string",
    "name": "string"
  },
  "id": "string",
  "customer_id": "string",
  "product_id": "string",
  "tier_id": "string",
  "source_kind": "string",
  "source_ref": "string",
  "grant_reason": "string",
  "settlement_id": "string",
  "valid_from": "string",
  "ends_at": "string",
  "end_reason": "string",
  "status": "string",
  "revocable": true,
  "granted_by": "string",
  "occurred_at": "string",
  "recorded_at": "string"
}
```

- `token_id` (`grantAccess.response.200.token_id`; any of, required)
  - any of: `string`, `null`
- `customer` (`grantAccess.response.200.customer`; any of, required)
  - any of: `object`, `null`
- `product` (`grantAccess.response.200.product`; any of, required)
  - any of: `object`, `null`
- `tier` (`grantAccess.response.200.tier`; any of, required)
  - any of: `object`, `null`
- `id` (`grantAccess.response.200.id`; string, required)
- `customer_id` (`grantAccess.response.200.customer_id`; string, required)
- `product_id` (`grantAccess.response.200.product_id`; string, required)
- `tier_id` (`grantAccess.response.200.tier_id`; any of, required)
  - any of: `string`, `null`
- `source_kind` (`grantAccess.response.200.source_kind`; string, required)
- `source_ref` (`grantAccess.response.200.source_ref`; any of, required)
  - any of: `string`, `null`
- `grant_reason` (`grantAccess.response.200.grant_reason`; any of, required)
  - any of: `string`, `null`
- `settlement_id` (`grantAccess.response.200.settlement_id`; any of, required)
  - any of: `string`, `null`
- `valid_from` (`grantAccess.response.200.valid_from`; any of, required)
  - any of: `string`, `null`
- `ends_at` (`grantAccess.response.200.ends_at`; any of, required)
  - any of: `string`, `null`
- `end_reason` (`grantAccess.response.200.end_reason`; any of, required)
  - any of: `string`, `null`
- `status` (`grantAccess.response.200.status`; string, required) — Where it stands now: not begun, standing, or how it ended.
- `revocable` (`grantAccess.response.200.revocable`; boolean, required) — Whether `revokeGrant` may still end it.
- `granted_by` (`grantAccess.response.200.granted_by`; any of, required)
  - any of: `string`, `null`
- `occurred_at` (`grantAccess.response.200.occurred_at`; any of, required)
  - any of: `string`, `null`
- `recorded_at` (`grantAccess.response.200.recorded_at`; any of, required)
  - any of: `string`, `null`

### default

A problem; see https://api.sherpo.io/merchant/docs/errors.

#### Example

```json
{
  "type": "http://example.com",
  "title": "string",
  "status": 0,
  "detail": "string",
  "code": "string",
  "context": {},
  "reached_core": true,
  "core_answer": "string"
}
```

- `type` (`grantAccess.response.default.type`; string, required)
  - format `uri`
- `title` (`grantAccess.response.default.title`; string, required)
- `status` (`grantAccess.response.default.status`; integer, required)
- `detail` (`grantAccess.response.default.detail`; string, required)
- `code` (`grantAccess.response.default.code`; string, optional)
- `context` (`grantAccess.response.default.context`; object, optional)
- `reached_core` (`grantAccess.response.default.reached_core`; boolean, optional)
- `core_answer` (`grantAccess.response.default.core_answer`; string, optional)


Source: https://docs.sherpo.io/merchant-api/reference/grant-access/index.md
