Skip to main content

POST /api/v1/coupons/verify

Validate a coupon code against a cart subtotal. Returns the discount details when the coupon is valid. Middleware: throttle:api.verification
Authentication: Not required

Request body

tenant_id
integer
required
Numeric tenant ID to scope the coupon lookup.
code
string
required
Coupon code string. Normalized to uppercase internally. Maximum 50 characters.
cart_subtotal
number
required
Current cart subtotal used to evaluate minimum spend requirements. Must be ≥ 0.

Response 200 OK

Coupon is valid. Response shape is determined by the coupon domain validation result.
valid
boolean
Always true on a 200 response.
discount_amount
number
Calculated discount to subtract from the cart subtotal.
coupon_type
string
One of: percentage, fixed, free_shipping.

Response 422 Unprocessable Entity

valid
boolean
Always false on a 422 response.
error
string
Human-readable error message.
error_code
string
Machine-readable rejection code. One of: not_found, expired, not_started, usage_limit, user_limit, min_spend, already_used, inactive, product_excluded, category_excluded.
curl -X POST https://yourdomain.com/api/v1/coupons/verify \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{"tenant_id": 1, "code": "BIENVENIDO20", "cart_subtotal": 150.00}'

Error responses

StatusCause
422Missing or invalid fields
422Coupon not found, expired, usage limit reached, minimum spend not met
429Verification rate limit exceeded

GET /api/v1/coupons

List all active public coupons for a tenant. Results are cached for 15 minutes. Middleware: throttle:api
Authentication: Not required

Query parameters

tenant_id
integer
required
Numeric tenant ID. Returns 400 when absent or zero.

Response 200 OK

success
boolean
true on success.
data
object[]
Array of valid coupon objects.
curl "https://yourdomain.com/api/v1/coupons?tenant_id=1" \
  -H "Accept: application/json"

Error responses

StatusCause
400tenant_id missing or zero

POST /api/v1/checkout/validate-coupon

Validate a coupon in the checkout context. Used during the checkout flow to apply discounts to a session cart. Middleware: throttle:api.verification
Authentication: Not required
This endpoint is handled by the CheckoutController. It behaves identically to POST /api/v1/coupons/verify for validation purposes but operates within the checkout session context.

POST /api/v1/checkout/remove-coupon

Remove a previously applied coupon from the checkout session. Middleware: throttle:api
Authentication: Not required

Response 200 OK

Confirmation that the coupon was removed from the session.

POST /api/v1/checkout/cart-summary

Sync a checkout session cart to the server and return a summary including subtotal. Used to keep server-side cart state consistent with the client before placing an order. Middleware: throttle:api
Authentication: Optional (pass Authorization header if logged in)

Request body

session_id
string
required
Client-generated session identifier for the cart.
items
object[]
required
Array of cart line items.
subtotal
number
required
Calculated cart subtotal from the client.

Response 200 OK

success
boolean
true
message
string
Cart synchronized successfully
subtotal
number
Echoed subtotal value.

POST /api/v1/checkout/hold-inventory

Reserve stock for cart items during the checkout process. Prevents overselling by locking inventory quantities for a short window while the customer completes payment. Route name: checkout.hold-inventory
Middleware: throttle:api
Authentication: Not required

Request body

items
object[]
required
Cart line items to hold. Each item must include product_id and quantity.
location_id
string
UUID of the location to hold inventory from. When omitted, the tenant’s active primary location is used automatically.

Response 200 OK

success
boolean
true
message
string
Confirmation that inventory holds were applied.

Response 400 Bad Request

Returned when no active primary location can be found for the tenant.

Error responses

StatusCause
400Missing or unresolvable tenant ID
400No active primary location found
422Validation failure on items structure

Build docs developers (and LLMs) love