# Validate Coupon - Check Discount Code Eligibility via API

> Validate a coupon code and preview the discount. Check if a coupon is valid for a specific user.

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

Check if a coupon code is valid for a specific user and purchase amount before applying it. The response shows whether the coupon is eligible, the calculated discount, and the final price—or the reasons why the coupon cannot be used.

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

<ApiAuthorization type="Bearer API Key" />

**API key scope:** `coupons:read` (required for restricted keys).

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

<ApiSection title="Request Body">
  <ApiParameter name="coupon_id" type="string" description="Coupon UUID. Either coupon_id or code is required." />
  <ApiParameter name="code" type="string" description="Coupon code (case-insensitive). Either code or coupon_id is required." />
  <ApiParameter name="amount" type="string|number" required description="Current checkout amount to evaluate. Prefer an exact decimal string; JSON numbers must satisfy the numeric precision limits. Used for inclusive minimum/maximum spend checks." />
  <ApiParameter name="currency" type="string" required description="The currency of the amount (e.g., USD)." />
  <ApiParameter name="user_id" type="string" required description="Customer platform user ID. Required for project API-key requests; used to evaluate per-user limits and audience scope." />
  <ApiParameter name="plan_id" type="string" description="Plan being purchased, used for plan_scope checks. Omit for top-up previews." />
  <ApiParameter name="is_renewal" type="boolean" description="Whether the purchase is a renewal, used for renewal_constraint." />
  <ApiParameter name="is_churned" type="boolean" description="Whether the user is churned, used for renewal_constraint." />
  <ApiParameter name="context" type="object" description="Additional eligibility hints: is_invitee, is_new_user." />
</ApiSection>

Spend limits compare this request's `amount` and `currency` with the coupon's configured bounds. An amount equal to either bound qualifies. A mismatched currency does not trigger conversion. Failed checks can return `eligible: false` with `MIN_SPEND_NOT_MET`, `MAX_SPEND_EXCEEDED`, `MIN_SPEND_CURRENCY_MISMATCH` or `MAX_SPEND_CURRENCY_MISMATCH` in `reasons`.

The amount follows the [decimal input rules](https://docs.botsubscription.com/api/overview/#decimal-amounts). Discounts are calculated with decimal arithmetic and rounded to the currency's precision. A discount covering the entire checkout leaves exactly `"0"`. A positive remainder below the smallest currency unit makes the coupon ineligible with `REMAINDER_BELOW_MINOR_UNIT` and `applied_amount: "0"`; for example, `"10.006"` USD minus a `"10"` discount cannot leave a payable `"0.006"` USD balance.

An unsupported currency returns `eligible: false` with `CURRENCY_UNSUPPORTED` and `applied_amount: "0"`. If the lifetime-revenue calculation exceeds the backend's aggregation limit, a revenue-dependent rule returns `LIFETIME_REVENUE_NOT_MATCHED` rather than treating unknown revenue as zero. These are eligibility results under HTTP `200`, not successful coupon applications. The schema permits nullable `applied_amount`, but these two currency-related refusals return `"0"`; `final_amount` remains the original amount, not the rejected remainder.

<ApiSamplePane>

<ApiRequestSample title="Request">

```bash
curl -X POST "https://api.botsubscription.com/v2/projects/f47ac10b-58cc-4372-a567-0e02b2c3d479/coupons/validate" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "code": "SUMMER2024",
    "user_id": "123456789",
    "amount": "29.99",
    "currency": "USD",
    "plan_id": "b2c9f6f0-7a47-4c2e-9a0e-4a4fa1d8c1c4"
  }'
```

```javascript
const project_id = 'f47ac10b-58cc-4372-a567-0e02b2c3d479';
const response = await fetch(`https://api.botsubscription.com/v2/projects/${project_id}/coupons/validate`, {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    code: 'SUMMER2024',
    user_id: '123456789',
    amount: '29.99',
    currency: 'USD',
    plan_id: 'b2c9f6f0-7a47-4c2e-9a0e-4a4fa1d8c1c4'
  })
});
const data = await response.json();
```

```python
import requests

project_id = 'f47ac10b-58cc-4372-a567-0e02b2c3d479'
response = requests.post(
    f'https://api.botsubscription.com/v2/projects/{project_id}/coupons/validate',
    headers={
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json'
    },
    json={
        'code': 'SUMMER2024',
        'user_id': '123456789',
        'amount': '29.99',
        'currency': 'USD',
        'plan_id': 'b2c9f6f0-7a47-4c2e-9a0e-4a4fa1d8c1c4'
    }
)
data = response.json()
```

```php
$project_id = 'f47ac10b-58cc-4372-a567-0e02b2c3d479';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.botsubscription.com/v2/projects/{$project_id}/coupons/validate");
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([
    'code' => 'SUMMER2024',
    'user_id' => '123456789',
    'amount' => '29.99',
    'currency' => 'USD',
    'plan_id' => 'b2c9f6f0-7a47-4c2e-9a0e-4a4fa1d8c1c4'
]));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
```

</ApiRequestSample>

<ApiResponseTabs>
  <ApiResponse status={200} description="Coupon eligible">

```json
{
  "ok": true,
  "request_id": "11111111-1111-1111-1111-111111111111",
  "method": "POST",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/coupons/validate",
  "code": 200,
  "data": {
    "coupon_id": "11111111-1111-1111-1111-111111111111",
    "eligible": true,
    "reasons": [],
    "original_amount": "29.99",
    "applied_amount": "6",
    "final_amount": "23.99",
    "currency": "USD"
  }
}
```

  </ApiResponse>
  <ApiResponse status={200} description="Checkout amount below the minimum spend">

```json
{
  "ok": true,
  "request_id": "11111111-1111-1111-1111-111111111111",
  "method": "POST",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/coupons/validate",
  "code": 200,
  "data": {
    "coupon_id": "11111111-1111-1111-1111-111111111111",
    "eligible": false,
    "reasons": [
      "MIN_SPEND_NOT_MET"
    ],
    "original_amount": "0.5",
    "applied_amount": null,
    "final_amount": "0.5",
    "currency": "USD"
  }
}
```

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

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

  </ApiResponse>
  <ApiResponse status={200} description="Coupon leaves less than the smallest currency unit">

```json
{
  "ok": true,
  "request_id": "44444444-4444-4444-8444-444444444444",
  "method": "POST",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/coupons/validate",
  "code": 200,
  "data": {
    "coupon_id": "cccccccc-cccc-4ccc-8ccc-cccccccccccc",
    "eligible": false,
    "reasons": [
      "REMAINDER_BELOW_MINOR_UNIT"
    ],
    "original_amount": "10.006",
    "applied_amount": "0",
    "final_amount": "10.006",
    "currency": "USD"
  }
}
```

  </ApiResponse>
  <ApiResponse status={200} description="Full discount covers an amount with extra precision">

```json
{
  "ok": true,
  "request_id": "44444444-4444-4444-8444-444444444444",
  "method": "POST",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/coupons/validate",
  "code": 200,
  "data": {
    "coupon_id": "cccccccc-cccc-4ccc-8ccc-cccccccccccc",
    "eligible": true,
    "reasons": [],
    "original_amount": "10.006",
    "applied_amount": "10.006",
    "final_amount": "0",
    "currency": "USD"
  }
}
```

  </ApiResponse>
  <ApiResponse status={200} description="Coupon currency is unsupported">

```json
{
  "ok": true,
  "request_id": "44444444-4444-4444-8444-444444444444",
  "method": "POST",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/coupons/validate",
  "code": 200,
  "data": {
    "coupon_id": "cccccccc-cccc-4ccc-8ccc-cccccccccccc",
    "eligible": false,
    "reasons": [
      "CURRENCY_UNSUPPORTED"
    ],
    "original_amount": "29.99",
    "applied_amount": "0",
    "final_amount": "29.99",
    "currency": "ZZZ"
  }
}
```

  </ApiResponse>
  <ApiResponse status={422} description="Project API key request omitted user_id">

```json
{
  "ok": false,
  "request_id": "44444444-4444-4444-8444-444444444444",
  "method": "POST",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/coupons/validate",
  "code": 422,
  "error": {
    "message": "user_id parameter is required for admin access",
    "error_code": "VALIDATION_ERROR"
  }
}
```

  </ApiResponse>
</ApiResponseTabs>

</ApiSamplePane>
