# Redeem a Subscription Bot Access Token for a Member

> Redeem a Telegram or Discord subscription bot access code for a named member using a platform ID string or an unambiguous linked user UUID.

Source: https://docs.botsubscription.com/api/access-tokens/redeem/

Apply a code to a named member of your <strong>Telegram subscription bot</strong> or <strong>Discord subscription bot</strong> from your project integration.

<ApiEndpoint method="POST" endpoint="/v2/projects/{project_id}/access-tokens/redeem" />

<ApiAuthorization type="Bearer API Key" />

**API key scope:** `access-tokens:redeem` (required for restricted keys).

<ApiSection title="Path Parameters">
  <ApiParameter name="project_id" type="string" required description="The UUID of the project." />
</ApiSection>

<ApiSection title="Request Body">
  <ApiParameter name="code" type="string" required description="The access code issued for this project." />
  <ApiParameter name="user_id" type="string" required description="Platform user ID as a string, or a user UUID linked to exactly one identity on this project's platform. JSON numbers are rejected." />
</ApiSection>

## Claim behavior and limits

`user_id` must be a **string** containing a platform user ID or a user UUID linked to exactly one identity on this project's platform. JSON numbers are rejected. An ambiguous UUID returns `409 AMBIGUOUS_PLATFORM_IDENTITY`; an unlinked UUID returns `403 PLATFORM_LINK_REQUIRED`.

Platform IDs are not checked remotely against Telegram or Discord. A mistyped ID consumes the code for that ID. Check the recipient before sending. This endpoint allows 60 requests per minute per acting API key and project.

## Membership and Telegram access

The token's plan determines which channel or role targets the membership grants. The member makes no payment, but redemption may still count toward the project owner's usage billing based on the plan's saved value.

For a new membership, the token duration runs from redemption. For an existing same-plan membership with a future expiry, the duration is added after that expiry. Redemption cannot shorten longer existing access.

To align a new membership with an external expiry, choose an initial token duration that ends before that expiry. Then [extend the selected membership](https://docs.botsubscription.com/api/memberships/extend/) using the returned `membership_id`. Extension only moves dates forward and cannot replace lifetime access with a finite expiry.

For Telegram, the bot delivers an access link; the member must join the channel themselves. Someone who has never started the bot may need to do so before delivery can complete. `fulfillment_pending: false` confirms delivery handling, not that the member has joined the channel.

## Retry recovery

Recurring billing may need provider confirmation before the extension is granted. With `202`, the returned dates describe existing access, not a completed new grant.

Retry the **same code for the same member** to recover an uncertain or pending result. A completed retry returns the original receipt with `already_claimed: true`. A different member receives `404`. Wait for an in-flight request to finish before retrying; concurrent attempts can temporarily return `404` or `409`.

For `billing_pending`, retry the same request or list by status to check progress. For `fulfillment_pending`, resolve platform access prerequisites, such as starting the Telegram bot or joining the configured Discord server, then retry the same code. Delivery can repeat after a lost acknowledgement, but retries never grant the duration twice.

If sending `Idempotency-Key`, retain the same key and request body for retries. Receipt recovery still uses the same code and member.

Start with [Prepare Tokens](https://docs.botsubscription.com/api/access-tokens/prepare/) for the issue-and-activate lifecycle. Use [List Tokens](https://docs.botsubscription.com/api/access-tokens/list/) to inspect token status after an uncertain result.

<Note>
Response examples use the [UTC ISO date format](https://docs.botsubscription.com/api/overview/#utc-iso-response-dates).
</Note>

<ApiSamplePane>

<ApiRequestSample title="Request">

```bash
curl -X POST "https://api.botsubscription.com/v2/projects/YOUR_PROJECT_ID/access-tokens/redeem" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: YOUR_UNIQUE_REQUEST_KEY" \
  -d '{
  "code": "YOUR_ACCESS_CODE",
  "user_id": "123456789012345678"
}'
```

```javascript
const response = await fetch("https://api.botsubscription.com/v2/projects/YOUR_PROJECT_ID/access-tokens/redeem", {
  method: 'POST',
  headers: {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json",
    "Idempotency-Key": "YOUR_UNIQUE_REQUEST_KEY"
  },
  body: JSON.stringify({
    "code": "YOUR_ACCESS_CODE",
    "user_id": "123456789012345678"
  })
});
const result = await response.json();
```

```python
import requests

response = requests.post(
    "https://api.botsubscription.com/v2/projects/YOUR_PROJECT_ID/access-tokens/redeem",
    headers={
        "Authorization": "Bearer YOUR_API_KEY",
        "Content-Type": "application/json",
        "Idempotency-Key": "YOUR_UNIQUE_REQUEST_KEY"
    },
    json={
        "code": "YOUR_ACCESS_CODE",
        "user_id": "123456789012345678"
    }
)
result = response.json()
```

```php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.botsubscription.com/v2/projects/YOUR_PROJECT_ID/access-tokens/redeem');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer YOUR_API_KEY',
    'Content-Type: application/json',
    'Idempotency-Key: YOUR_UNIQUE_REQUEST_KEY'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    'code' => 'YOUR_ACCESS_CODE',
    'user_id' => '123456789012345678'
]));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
```

</ApiRequestSample>

<ApiResponseTabs>
  <ApiResponse status={200} description="Access granted or original receipt replayed">

```json
{
  "ok": true,
  "request_id": "44444444-4444-4444-8444-444444444444",
  "method": "POST",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/access-tokens/redeem",
  "code": 200,
  "data": {
    "access_token_id": "11111111-1111-4111-8111-111111111111",
    "membership_id": "33333333-3333-4333-8333-333333333333",
    "membership_start_date": "2026-10-19T17:20:00.000Z",
    "membership_end_date": "2026-11-19T17:20:00.000Z",
    "already_claimed": false,
    "fulfillment_pending": false,
    "billing_pending": false
  }
}
```

  </ApiResponse>
  <ApiResponse status={202} description="Billing confirmation pending">

```json
{
  "ok": true,
  "request_id": "44444444-4444-4444-8444-444444444444",
  "method": "POST",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/access-tokens/redeem",
  "code": 202,
  "data": {
    "access_token_id": "11111111-1111-4111-8111-111111111111",
    "membership_id": "33333333-3333-4333-8333-333333333333",
    "membership_start_date": "2026-10-19T17:20:00.000Z",
    "membership_end_date": "2026-11-19T17:20:00.000Z",
    "already_claimed": false,
    "fulfillment_pending": true,
    "billing_pending": true
  }
}
```

  </ApiResponse>
  <ApiResponse status={422} description="Recipient ID must be a string">

```json
{
  "ok": false,
  "request_id": "44444444-4444-4444-8444-444444444444",
  "method": "POST",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/access-tokens/redeem",
  "code": 422,
  "errors": [
    {
      "message": "body: user_id is not a string",
      "error_code": "VALIDATION_ERROR"
    }
  ]
}
```

  </ApiResponse>
  <ApiResponse status={401} description="Invalid or expired API key">

```json
{
  "ok": false,
  "request_id": "44444444-4444-4444-8444-444444444444",
  "method": "POST",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/access-tokens/redeem",
  "code": 401,
  "error": {
    "message": "Invalid or expired authentication token.",
    "error_code": "UNAUTHORIZED"
  }
}
```

  </ApiResponse>
</ApiResponseTabs>

</ApiSamplePane>
