RevKeen Docs
Api reference

Create a discount

Create a new discount code.


Related endpoints

  • GET /discounts — List discounts
  • GET /discounts/{id} — Get discount by ID
  • PATCH /discounts/{id} — Update a discount
  • DELETE /discounts/{id} — Delete a discount

Common errors

  • 400 invalid_request — malformed payload or failed validation.
  • 401 unauthenticated — missing, malformed, or revoked API key.

Idempotency

Pass an Idempotency-Key header (UUID v4 recommended) to make retries safe. Keys are valid for 24 hours; see the idempotency guide.

POST
/discounts
x-api-key<token>

Your RevKeen API key (powered by Unkey). Get it from Dashboard > Settings > API Keys. Use rk_sandbox_* for test mode and rk_live_* for production.

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

curl -X POST "https://api.revkeen.com/v2/discounts" \  -H "x-api-key: $REVKEEN_API_KEY" \  -H "Content-Type: application/json" \  -d '{    "code": "SUMMER20",    "name": "Summer Sale 20% Off",    "description": "20% off for summer promotion",    "discount_type": "percentage",    "discount_value": 20,    "applies_to": "all",    "scope": "entire_order",    "product_ids": [      "string"    ],    "max_redemptions": 100,    "max_redemptions_per_user": 1,    "valid_from": "2024-06-01T00:00:00Z",    "valid_until": "2024-08-31T23:59:59Z",    "recurring_type": "once",    "recurring_cycles": 3,    "first_time_customer": false  }'
{
  "data": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "code": "SUMMER20",
    "name": "Summer Sale 20% Off",
    "description": "20% off for summer promotion",
    "discount_type": "percentage",
    "discount_value": 20,
    "applies_to": "all",
    "product_ids": null,
    "max_redemptions": 100,
    "current_redemptions": 25,
    "valid_from": "2024-06-01T00:00:00Z",
    "valid_until": "2024-08-31T23:59:59Z",
    "recurring_type": "once",
    "recurring_cycles": null,
    "first_time_customer": false,
    "is_active": true,
    "created_at": "2024-01-14T08:00:00Z",
    "updated_at": "2024-01-14T08:00:00Z"
  }
}
Empty
Empty