Skip to main content

Discount

Base path: /api/data/discount

POST /api/data/discount

Create a new discount.

Auth: Session cookie required Tenant: Scoped via x-tenant-id header (injected as tenantId from request context)

Request Body

FieldTypeRequiredDescription
codestringNoDiscount code (e.g. SAVE10)
typeenumYesPERCENT or AMOUNT
percentnumberConditionalPercentage (1–100). Required when type is PERCENT
amountCentsnumberConditionalFixed discount in cents. Required when type is AMOUNT
scopeobjectNoTargeting scope (see below)
lifecycleobjectNoActivation and usage limits (see below)

Scope object:

FieldTypeRequiredDescription
appliesToAllbooleanNoApply to all products (default true)
productIdsstring[]NoRestrict to specific product IDs
roleIdsstring[]NoRestrict to specific role IDs
customerIdsstring[]NoRestrict to specific customer IDs

Lifecycle object (create):

FieldTypeRequiredDescription
isActivebooleanNoWhether the discount is active (default true)
startsAtdateNoActivation date
endsAtdateNoExpiration date (must be after startsAt)
usageLimitnumberNoMaximum number of uses

Response (201)

Returns the created discount record.

Errors

StatusCondition
400Validation error, missing required conditional field, or DiscountError

GET /api/data/discount/:id

Retrieve a discount by ID.

Auth: Session cookie required Tenant: Scoped via x-tenant-id header

Response (200)

Returns the discount record.

Errors

StatusCondition
400Operation error
404Discount not found

PATCH /api/data/discount/:id

Update a discount by ID. All fields are optional.

Auth: Session cookie required Tenant: Scoped via x-tenant-id header

Request Body

FieldTypeRequiredDescription
codestringNoUpdated discount code
typeenumNoPERCENT or AMOUNT
percentnumberNoUpdated percentage
amountCentsnumberNoUpdated fixed amount in cents
scopeobjectNoUpdated targeting scope
lifecycleobjectNoUpdated lifecycle settings

Response (200)

Returns the updated discount record.

Errors

StatusCondition
400Validation error or DiscountError

DELETE /api/data/discount/:id

Remove a discount by ID.

Auth: Session cookie required Tenant: Scoped via x-tenant-id header

Response (204)

No content.

Errors

StatusCondition
400Operation error or DiscountError