Skip to main content
POST
Apply coupon to order

Request

Headers

This endpoint requires authentication. Only the order owner can apply coupons to their orders.

Body parameters

Successful response

Response fields

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:
  1. Order is updated with the coupon ID and discount amount
  2. Coupon usage count is incremented globally
  3. 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

Always call the /coupons/verify endpoint first to validate the coupon and show the discount amount to the user before applying it to the order.
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

Authorization
string
header
required

JWT issued by the Salesive Store API for authenticated shoppers.

x-shop-id
string
header
required

Optional storefront identifier sent as a header to scope responses to a specific shop. Try It requests remember this value once provided.

Headers

x-shop-id
string

Optional identifier that scopes responses to a specific storefront when the referer cannot be inferred.

Body

application/json
orderId
string
required

Order ID to apply the coupon to.

Example:

"67890abcdef1234567890abc"

code
string
required

Coupon code to apply (case-insensitive).

Example:

"SUMMER20"

Response

Coupon applied successfully.

status
integer
required
Example:

200

success
boolean
required
Example:

true

message
string
required
Example:

"Coupon applied successfully"

data
object
required