# Revoke a Subscription Bot Access Token

> Revoke an unused Telegram or Discord subscription bot access token by ID without terminating an existing membership.

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

Disable an unused access code for your <strong>Telegram subscription bot</strong> or <strong>Discord subscription bot</strong>. Revocation does not terminate a membership already granted by a code.

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

<ApiAuthorization type="Bearer API Key" />

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

<ApiSection title="Path Parameters">
  <ApiParameter name="project_id" type="string" required description="The UUID of the project." />
  <ApiParameter name="access_token_id" type="string" required description="UUID of the activated access token to revoke." />
</ApiSection>

## Behavior and recovery

Only activated, unused tokens can be revoked. An already revoked token returns `204` again. A redeemed token or one reserved for pending billing returns `409`. An unknown or unactivated token ID returns `404`.

Find IDs through [List Tokens](https://docs.botsubscription.com/api/access-tokens/list/). To end an existing membership, use [Delete Membership](https://docs.botsubscription.com/api/memberships/delete/).

<ApiSamplePane>

<ApiRequestSample title="Request">

```bash
curl -X DELETE "https://api.botsubscription.com/v2/projects/YOUR_PROJECT_ID/access-tokens/YOUR_ACCESS_TOKEN_ID" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

```javascript
const response = await fetch("https://api.botsubscription.com/v2/projects/YOUR_PROJECT_ID/access-tokens/YOUR_ACCESS_TOKEN_ID", {
  method: 'DELETE',
  headers: {
    "Authorization": "Bearer YOUR_API_KEY"
  }
});
// 204 No Content on success; no JSON body to parse.
```

```python
import requests

response = requests.delete(
    "https://api.botsubscription.com/v2/projects/YOUR_PROJECT_ID/access-tokens/YOUR_ACCESS_TOKEN_ID",
    headers={
        "Authorization": "Bearer YOUR_API_KEY"
    }
)
# 204 No Content on success; no JSON body to parse.
```

```php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.botsubscription.com/v2/projects/YOUR_PROJECT_ID/access-tokens/YOUR_ACCESS_TOKEN_ID');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer YOUR_API_KEY'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
// 204 No Content on success; no JSON body to parse.
```

</ApiRequestSample>

<ApiResponseTabs>
  <ApiResponse status={204} description="Token revoked or already revoked">

No response body is returned.

  </ApiResponse>
  <ApiResponse status={409} description="Token redeemed or billing pending">

```json
{
  "ok": false,
  "request_id": "44444444-4444-4444-8444-444444444444",
  "method": "DELETE",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/access-tokens/22222222-2222-4222-8222-222222222222",
  "code": 409,
  "error": {
    "error_code": "CONFLICT",
    "message": "The access token cannot be revoked."
  }
}
```

  </ApiResponse>
  <ApiResponse status={404} description="Activated token not found">

```json
{
  "ok": false,
  "request_id": "44444444-4444-4444-8444-444444444444",
  "method": "DELETE",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/access-tokens/22222222-2222-4222-8222-222222222222",
  "code": 404,
  "error": {
    "error_code": "NOT_FOUND",
    "message": "Requested resource could not be found."
  }
}
```

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

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

  </ApiResponse>
</ApiResponseTabs>

</ApiSamplePane>
