# Archive Coupon - Retire a Discount Code via API

> Archive a coupon on a Telegram or Discord subscription bot project without deleting its redemption history.

Source: https://docs.botsubscription.com/api/coupons/archive/

Archive a coupon to take it out of circulation while keeping its redemption history and configuration intact. An archived coupon can no longer be applied to new purchases; use [Unarchive Coupon](https://docs.botsubscription.com/api/coupons/unarchive/) to bring it back.

<ApiEndpoint method="PATCH" endpoint="/v2/projects/{project_id}/coupons/{coupon_id}/archive" />

<ApiAuthorization type="Bearer API Key" />

**API key access:** Unrestricted project API key required. Restricted keys cannot call this endpoint.

<ApiSection title="Path Parameters">
  <ApiParameter name="project_id" type="string" required description="The unique identifier of the project." />
  <ApiParameter name="coupon_id" type="string" required description="The unique identifier of the coupon to archive." />
</ApiSection>

<ApiSamplePane>

<ApiRequestSample title="Request">

```bash
curl -X PATCH "https://api.botsubscription.com/v2/projects/YOUR_PROJECT_ID/coupons/11111111-1111-1111-1111-111111111111/archive" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

```javascript
const project_id = 'YOUR_PROJECT_ID';
const coupon_id = '11111111-1111-1111-1111-111111111111';
const response = await fetch(`https://api.botsubscription.com/v2/projects/${project_id}/coupons/${coupon_id}/archive`, {
  method: 'PATCH',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY'
  }
});
```

```python
import requests

project_id = 'YOUR_PROJECT_ID'
coupon_id = '11111111-1111-1111-1111-111111111111'
response = requests.patch(
    f'https://api.botsubscription.com/v2/projects/{project_id}/coupons/{coupon_id}/archive',
    headers={'Authorization': 'Bearer YOUR_API_KEY'}
)
```

```php
$project_id = 'YOUR_PROJECT_ID';
$coupon_id = '11111111-1111-1111-1111-111111111111';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.botsubscription.com/v2/projects/{$project_id}/coupons/{$coupon_id}/archive");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH');
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer YOUR_API_KEY']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
```

</ApiRequestSample>

<ApiResponseTabs>
  <ApiResponse status={204} description="Coupon archived">

No response body.

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

```json
{
  "ok": false,
  "request_id": "11111111-1111-1111-1111-111111111111",
  "method": "PATCH",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/coupons/11111111-1111-1111-1111-111111111111/archive",
  "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": "PATCH",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/coupons/cccccccc-cccc-4ccc-8ccc-cccccccccccc/archive",
  "code": 401,
  "error": {
    "message": "Invalid or expired authentication token.",
    "error_code": "UNAUTHORIZED"
  }
}
```

  </ApiResponse>
</ApiResponseTabs>

</ApiSamplePane>
