# Clone Coupon - Duplicate a Discount Code via API

> Duplicate an existing coupon on a Telegram or Discord subscription bot project, optionally overriding its code or discount.

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

Create a new coupon from an existing one. Every field on the source coupon is copied over; any field you supply in the request body overrides the corresponding value on the new coupon.

Source amounts in exponent notation are converted to plain decimal strings when their value can be preserved exactly. The clone must satisfy the [coupon creation rules](https://docs.botsubscription.com/api/coupons/create/), including exact percentage bounds and decimal precision. A source coupon that can be read may require overrides to produce a valid clone. Invalid clones return `422 VALIDATION_ERROR` instead of rounding their values.

<ApiEndpoint method="POST" endpoint="/v2/projects/{project_id}/coupons/{coupon_id}/clone" />

<ApiAuthorization type="Bearer API Key" />

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

If the source coupon is archived and the request body does not set `status`, the new coupon is created archived as well.

Omitted `starts_at` and `ends_at` overrides inherit the source bounds. Explicit `null` clears a bound.

<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 source coupon to clone." />
</ApiSection>

<ApiSection title="Request Body">
  <ApiParameter name="display_name" type="string" description="Name for the new coupon. Defaults to the source coupon's name." />
  <ApiParameter name="code" type="string" description="Code for the new coupon. Defaults to the source coupon's code—if it collides with an active coupon, the codes share the same usage limit and redemption counter." />
  <ApiParameter name="description" type="string" description="Overrides the source coupon's description." />
  <ApiParameter name="percentage" type="string|number|null" description="Overrides the percentage with a value strictly greater than 0 and at most 100. Prefer an exact decimal string." />
  <ApiParameter name="amount" type="string|number|null" description="Overrides the source coupon's flat discount amount." />
  <ApiParameter name="currency" type="string" description="Overrides the source coupon's currency." />
  <ApiParameter name="min_spend_amount" type="string | number | null" description="Override the inclusive minimum checkout amount using an unsigned decimal string or nonnegative number. Null removes the minimum bound." />
  <ApiParameter name="min_spend_currency" type="string | null" description="Minimum-spend currency override: 3 to 9 uppercase ASCII letters or digits." />
  <ApiParameter name="max_spend_amount" type="string | number | null" description="Override the inclusive maximum checkout amount using an unsigned decimal string or nonnegative number. Null removes the maximum bound." />
  <ApiParameter name="max_spend_currency" type="string | null" description="Maximum-spend currency override: 3 to 9 uppercase ASCII letters or digits." />
  <ApiParameter name="usage_limit" type="integer" description="Overrides the source coupon's usage limit." />
  <ApiParameter name="starts_at" type="number | string | null" description="Override the start with 13-digit Unix milliseconds as a number or digit string. Send null for no bound. ISO dates and seconds are not accepted." />
  <ApiParameter name="ends_at" type="number | string | null" description="Override the end with 13-digit Unix milliseconds as a number or digit string. Send null for no bound. ISO dates and seconds are not accepted." />
  <ApiParameter name="metadata" type="object" description="Overrides the source coupon's metadata." />
</ApiSection>

Numeric coupon values follow the [decimal input contract](https://docs.botsubscription.com/api/overview/#decimal-amounts). A nullable value may be cleared only when the resulting coupon still satisfies its type requirements.

Omitted spend overrides inherit the source configuration. The resulting coupon is checked against the [creation rules](https://docs.botsubscription.com/api/coupons/create/), including required currencies, matching minimum/maximum currencies and an ordered, inclusive spend range.

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

## Recover a saved creation

If the response fails, check `Resource-Created` and `Response-Validation-Failed` before repeating the operation. Preserve the original request and retry key. A nonreplayable result can identify the saved resource in `error.details`; retrieve it before considering another create. See [creation outcome recovery](https://docs.botsubscription.com/api/overview/#creation-outcomes-after-a-failed-response).

<ApiSamplePane>

<ApiRequestSample title="Request">

```bash
curl -X POST "https://api.botsubscription.com/v2/projects/YOUR_PROJECT_ID/coupons/11111111-1111-1111-1111-111111111111/clone" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "display_name": "Summer Sale (Reissue)",
    "code": "SUMMER2024-B"
  }'
```

```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}/clone`, {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    display_name: 'Summer Sale (Reissue)',
    code: 'SUMMER2024-B'
  })
});
const data = await response.json();
```

```python
import requests

project_id = 'YOUR_PROJECT_ID'
coupon_id = '11111111-1111-1111-1111-111111111111'
response = requests.post(
    f'https://api.botsubscription.com/v2/projects/{project_id}/coupons/{coupon_id}/clone',
    headers={
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json'
    },
    json={
        'display_name': 'Summer Sale (Reissue)',
        'code': 'SUMMER2024-B'
    }
)
data = response.json()
```

```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}/clone");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer YOUR_API_KEY',
    'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    'display_name' => 'Summer Sale (Reissue)',
    'code' => 'SUMMER2024-B'
]));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
```

</ApiRequestSample>

<ApiResponseTabs>
  <ApiResponse status={201} description="Coupon cloned">

```json
{
  "ok": true,
  "request_id": "11111111-1111-1111-1111-111111111111",
  "method": "POST",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/coupons/11111111-1111-1111-1111-111111111111/clone",
  "code": 201,
  "data": {
    "coupon_id": "22222222-2222-2222-2222-222222222222",
    "code": "SUMMER2024-B",
    "display_name": "Summer Sale (Reissue)",
    "description": "Summer promotion discount",
    "coupon_type": "percentage",
    "percentage": "20",
    "auto_apply": false,
    "status": "active",
    "total_redemptions": 0,
    "total_reservations": 0,
    "invitee_mode": "all",
    "renewal_constraint": "any",
    "payment_count_comparator": "any",
    "lifetime_revenue_comparator": "any",
    "plan_scope": "all",
    "starts_at": "2024-06-01T00:00:00.000Z",
    "ends_at": "2024-08-31T23:59:59.000Z",
    "created_at": "2024-08-31T10:40:00.000Z",
    "metadata": {},
    "min_spend_amount": "1",
    "min_spend_currency": "USD",
    "max_spend_amount": "100",
    "max_spend_currency": "USD"
  }
}
```

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

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

  </ApiResponse>
<ApiResponse status={201} description="Fixed-amount coupon">

```json
{
  "ok": true,
  "request_id": "11111111-1111-1111-1111-111111111111",
  "method": "POST",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/coupons/11111111-1111-1111-1111-111111111111/clone",
  "code": 201,
  "data": {
    "coupon_id": "22222222-2222-2222-2222-222222222222",
    "code": "FIXED10",
    "display_name": "Ten dollar discount",
    "description": "Summer promotion discount",
    "coupon_type": "fixed",
    "auto_apply": false,
    "status": "active",
    "total_redemptions": 0,
    "total_reservations": 0,
    "invitee_mode": "all",
    "renewal_constraint": "any",
    "payment_count_comparator": "any",
    "lifetime_revenue_comparator": "any",
    "plan_scope": "all",
    "starts_at": "2024-06-01T00:00:00.000Z",
    "ends_at": "2024-08-31T23:59:59.000Z",
    "created_at": "2024-08-31T10:40:00.000Z",
    "metadata": {},
    "min_spend_amount": "1",
    "min_spend_currency": "USD",
    "max_spend_amount": "100",
    "max_spend_currency": "USD",
    "amount": "10",
    "currency": "USD"
  }
}
```

</ApiResponse>
<ApiResponse status={409} description="Created resource response cannot be replayed">

```json
{
  "ok": false,
  "request_id": "44444444-4444-4444-8444-444444444444",
  "method": "POST",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/coupons/55555555-5555-4555-8555-555555555555/clone",
  "code": 409,
  "error": {
    "error_code": "IDEMPOTENCY_RESPONSE_NOT_REPLAYABLE",
    "message": "A request with this Idempotency-Key was already processed, but its response cannot be replayed",
    "details": [
      {
        "resource_type": "coupon",
        "resource_id": "55555555-5555-4555-8555-555555555555"
      }
    ]
  }
}
```

</ApiResponse>
</ApiResponseTabs>

</ApiSamplePane>
