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

# Deactivate Coupon

> Permanently deactivate a coupon and all of its promotion codes

Deactivate a coupon. Buyers can no longer redeem it, and all of its promotion codes are deactivated with it. Every code is released and can be used again by a new coupon or promotion code.

```
POST /v1/actions/coupon/deactivate-coupon
```

**Authentication:** API Key

> [!WARNING]
>
> Deactivation is **permanent**. An inactive coupon cannot be reactivated, and coupons cannot be deleted. To offer the discount again, create a new coupon.

## Request Body

| Field | Type | Required | Description |
| - | - | - | - |
| `id` | string | Yes | Coupon ID (Short ID format `CPN_xxx`) |

## Example Request

```typescript SDK theme={"system"}
const { coupon } = await client.coupons.deactivate({ id: "CPN_5dXBtmF2HLlHfbPNm0Wcnz" });
console.log(coupon.status); // => "inactive"
```

```bash cURL theme={"system"}
MERCHANT_ID="MER_2aUyqjCzEIiEcYMKj7TZtw"
TIMESTAMP=$(date +%s)
BODY='{"id":"CPN_5dXBtmF2HLlHfbPNm0Wcnz"}'
BODY_HASH=$(echo -n "$BODY" | openssl dgst -sha256 -binary | base64 | tr -d '\n')
CANONICAL_REQUEST="POST
/v1/actions/coupon/deactivate-coupon
$TIMESTAMP
$BODY_HASH"

SIGNATURE=$(echo -n "$CANONICAL_REQUEST" | openssl dgst -sha256 -sign private_key.pem | base64 | tr -d '\n')

curl -X POST "https://api.waffo.ai/v1/actions/coupon/deactivate-coupon" \
  -H "Content-Type: application/json" \
  -H "X-Merchant-Id: $MERCHANT_ID" \
  -H "X-Timestamp: $TIMESTAMP" \
  -H "X-Signature: $SIGNATURE" \
  -d "$BODY"
```

```python Python theme={"system"}
import hashlib, time, base64, json, requests
from cryptography.hazmat.primitives import hashes, serialization
from cryptography.hazmat.primitives.asymmetric import padding

merchant_id = "MER_2aUyqjCzEIiEcYMKj7TZtw"
timestamp = str(int(time.time()))
body = {"id": "CPN_5dXBtmF2HLlHfbPNm0Wcnz"}

body_json = json.dumps(body, separators=(",", ":"))
body_hash = base64.b64encode(hashlib.sha256(body_json.encode()).digest()).decode()
path = "/v1/actions/coupon/deactivate-coupon"
canonical = f"POST\n{path}\n{timestamp}\n{body_hash}"

with open("private_key.pem", "rb") as f:
    private_key = serialization.load_pem_private_key(f.read(), password=None)

signature = base64.b64encode(
    private_key.sign(canonical.encode(), padding.PKCS1v15(), hashes.SHA256())
).decode()

resp = requests.post(
    f"https://api.waffo.ai{path}",
    headers={
        "Content-Type": "application/json",
        "X-Merchant-Id": merchant_id,
        "X-Timestamp": timestamp,
        "X-Signature": signature,
    },
    data=body_json,
)
print(resp.json())
```

## Success Response (200)

```json theme={"system"}
{
  "data": {
    "coupon": {
      "id": "CPN_5dXBtmF2HLlHfbPNm0Wcnz",
      "storeId": "STO_2aUyqjCzEIiEcYMKj7TZtw",
      "name": "Black Friday 20% off",
      "code": "BF2026",
      "status": "inactive",
      "discountType": "percentage",
      "percentOff": 20,
      "amountOff": null,
      "duration": "repeating",
      "durationInPeriods": 3,
      "productIds": [],
      "maxRedemptions": 1000,
      "redeemBy": "2026-12-01T00:00:00.000Z",
      "createdAt": "2026-11-01T08:00:00.000Z",
      "updatedAt": "2026-12-02T10:00:00.000Z"
    }
  }
}
```

## Response Fields

Same as [Create Coupon response](https://docs.waffo.ai/api-reference/endpoints/coupons/create-coupon.md), without `promotionCodes`.

> [!NOTE]
>
> Existing orders are not affected. Discounts already attached to subscriptions keep applying until the subscription's next plan change. Deactivating an already inactive coupon returns `200` with the coupon unchanged.

## Errors

> **Retry policy:** Never retry 4xx — fix the request and resubmit. Retry 5xx with exponential backoff (start 5s, max 3 attempts).

| Status | `errors[0].message` | What it means | Recommended handling |
| - | - | - | - |
| 400 | `Missing or invalid header: x-context-environment` | Environment header is missing or not `test` / `prod` | Set `X-Environment` to `test` or `prod` |
| 400 | `Invalid JSON body` | The body is not valid JSON | Fix the body, resubmit |
| 400 | `Missing required field: id` | `id` was omitted | Add `id`, resubmit |
| 400 | `Expected format: CPN_xxx, got "X"` | `id` is not a valid Short ID | Use a `CPN_` prefixed Short ID |
| 401 | `Authentication required` | Authentication failed | Verify API key, timestamp, and signature |
| 404 | `Coupon not found` | The coupon does not exist, belongs to another merchant, or is in the other environment | Verify the `id` and the environment of your API key |
| 409 | `Coupon is not active (status: pending)` | The coupon is `pending`: its Create Coupon request is still running, or was interrupted and the coupon has not been cleaned up yet | Wait for the Create Coupon request to finish, then retry. An interrupted coupon becomes `failed` once it is cleaned up, and then there is nothing to deactivate |
| 409 | `Coupon creation failed; there is nothing to deactivate` | The coupon is `failed`; it was never usable and its code is already released | Nothing to do |
| 500 | `Internal server error` | Unexpected server-side failure | Retry with exponential backoff (start 5s, max 3 attempts) |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.