When a user is ready to check out, POST to this endpoint to create a new order in theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/ALEJ4NDRO2025/urban-store/llms.txt
Use this file to discover all available pages before exploring further.
pending state. You may supply an explicit items array (useful when the frontend manages cart state locally) or omit it to have the server pull items directly from the user’s MongoDB cart. Either way, stock is decremented immediately and a branded HTML confirmation email is sent to the shipping address. The order expires in 5 minutes; if payment is not completed within that window the order is automatically cancelled and stock is restored.
Endpoint
Authentication
A valid JWT Bearer token is required in theAuthorization header. Returns 401 if the token is missing or invalid.
Request Body
An array of line-item objects to purchase. When provided, the server uses these items instead of the user’s cart stored in MongoDB. Each element must include the fields below. If omitted or empty, items are loaded from the authenticated user’s cart.
Destination and contact information for the order.
Free-text delivery instructions or comments. Included in the confirmation email when present.
Behavior
- Item resolution — If
itemsis a non-empty array, those items are used verbatim. Otherwise the server fetches the user’sCartdocument from MongoDB. A400is returned if the cart is missing or empty. - Order creation — A new
Orderdocument is saved withstatus: "pending"andexpires_atset to 5 minutes from now. - Stock decrement — For each line item the matching
Productis located byproduct_slug. Ifstock_by_variantcontains the key"<size>|<color>", that variant’s stock is decremented. Otherwise, the product’s generalstockfield is decremented. Stock floor is0. - Cart clear — If the DB cart was used (no
itemssupplied in the body), the cart is emptied after the order is created. - Confirmation email — A styled HTML email is sent to
shipping_address.emailwith the order number, itemised receipt, totals, and shipping address.
The order expires in 5 minutes (
expires_at). Your frontend should call POST /api/payments/create-payment-intent/ and complete Stripe checkout before this window closes, or the order will transition to cancelled on the next read.Request Example
Response — 201 Created
Error Responses
| Status | Condition |
|---|---|
401 Unauthorized | Token missing, malformed, or expired |
400 Bad Request | shipping_address not provided |
400 Bad Request | No items in the body and the user’s cart is empty or does not exist |