Skip to main content
POST
/
api
/
public
/
v1
/
promotion-codes
/
create
curl --request POST \
  --url https://app.localhost:3000/api/public/v1/promotion-codes/create \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "code": "SUMMER20",
  "promotionId": "promo_123",
  "usageLimit": 100,
  "expiresAt": "2025-08-31T23:59:59.000Z",
  "firstTimeCustomersOnly": false,
  "description": "Summer sale 20% off code"
}
'
{
  "id": "pc_123",
  "code": "SUMMER20",
  "promotionId": "promo_123",
  "storeId": "store_123",
  "active": true,
  "usageCount": 0,
  "usageLimit": 100,
  "firstTimeCustomersOnly": false,
  "expiresAt": "2025-08-31T23:59:59.000Z"
}

Authorizations

Authorization
string
header
required

Enter your API key as: Bearer your-api-key

Body

application/json
code
string
required

The coupon code value

Minimum string length: 1
promotionId
string
required

The promotion this code is linked to

customerId
string

Optional customer ID to restrict the code to a specific customer

usageLimit
number

Maximum number of times this code can be used

expiresAt
string<date-time>

Expiration date of the code

firstTimeCustomersOnly
boolean
default:false

Whether the code is restricted to first-time customers

emailPattern
string

Email pattern to restrict code usage (e.g. '*@company.com')

description
string

Internal description of the code

metadata
string

Additional metadata as a JSON string

Response

Successful response

id
string
code
string
promotionId
string
storeId
string
customerId
string | null
active
boolean
usageCount
number
usageLimit
number | null
firstTimeCustomersOnly
boolean
emailPattern
string | null
description
string | null
metadata
string | null
expiresAt
string<date-time> | null
createdAt
string<date-time>