Skip to content
Coursey CreativeSign in

POST /coupons/validate

/api/store/[slug]/coupons/validate

Validates a coupon code against the cart contents and customer email, returning the discount amount and eligible items without applying anything.

Public - no auth neededRate limit 30 requests per 60 seconds per client IP + slugHow authentication works

Path parameters

slugstringrequired

Business (store) slug; coupons are scoped to the business, so cross-tenant codes look identical to non-existent codes

Body parameters

codestringrequired

Coupon code, max 20 chars, pattern ^[a-zA-Z0-9]+$ (no dashes accepted on this endpoint).

customer_emailstringrequired

Customer's email (valid email) used for per-customer and first-time-only limit checks.

itemsarrayrequired

Cart lines; array (min 0) of objects { product_id: UUID, variant_id: UUID, price: positive number, quantity: positive integer }.

Responses

200

The request succeeded.

400

A field failed validation. The response names the fields that failed, not just the first.

404

No such store, or no such record inside it.

429

Too many requests. Back off and retry after the window in the response.

500

Something failed on our side. The response carries no detail; retry is safe on a GET.

What comes back

Always 200 for business-level results: valid coupon returns { valid: true, discount_amount, eligible_item_ids, adjusted_total, coupon_id }; invalid returns { valid: false, error, minimum_required?, eligible_subtotal? }. HTTP 400/404/429/500 only for malformed requests, unknown store, rate limiting, or server errors. CORS-enabled; OPTIONS preflight supported.