Apply coupon to order
Coupons
Apply coupon to order
Apply a validated coupon code to a pending order and automatically calculate the discount.
POST
Apply coupon to order
Request
Headers
| Header | Type | Description |
|---|---|---|
Content-Type | string | Always set to application/json. |
x-shop-id | string | Shop identifier to associate the user with your store. |
Authorization | string | Bearer token for authenticated user (required). |
Body parameters
| Field | Type | Required | Description |
|---|---|---|---|
orderId | string | Yes | Order ID to apply the coupon to. |
code | string | Yes | Coupon code to apply (case-insensitive). |
Successful response
Response fields
| Field | Type | Description |
|---|---|---|
order._id | string | Order identifier. |
order.orderId | number | Human-readable order number. |
order.subtotal | number | Order subtotal before shipping and discount. |
order.shippingCost | number | Shipping cost for the order. |
order.discount | number | Discount amount applied by the coupon. |
order.total | number | Final order total (subtotal + shipping - discount). |
order.coupon | object | Applied coupon details. |
Validation checks
The endpoint performs comprehensive validations before applying the coupon:Order exists and belongs to the authenticated user
Order is in
pending status (cannot apply to completed/cancelled orders)Order does not already have a coupon applied
Coupon exists and is active
Coupon belongs to the specified shop
Coupon is within valid date range
Global usage limit has not been exceeded
Per-user usage limit has not been exceeded
Order meets minimum amount requirement
Side effects
When a coupon is successfully applied:- Order is updated with the coupon ID and discount amount
- Coupon usage count is incremented globally
- Order total is recalculated with the discount applied
Error responses
Order not found
Unauthorized access
Coupon already applied
Invalid order status
Invalid coupon
Best practices
Once a coupon is applied to an order, it cannot be removed or replaced.
Ensure the user confirms the coupon application before calling this
endpoint.
Authorizations
JWT issued by the Salesive Store API for authenticated shoppers.
Optional storefront identifier sent as a header to scope responses to a specific shop. Try It requests remember this value once provided.
Headers
Optional identifier that scopes responses to a specific storefront when the referer cannot be inferred.
Body
application/json

