Overview
Create a new order for the authenticated user. The order is automatically associated with the tenant specified in the X-Tenant-ID header.Authorization
- User must be authenticated with a valid Bearer token
- User must be a member of the tenant
- Requires X-Tenant-ID header
Tenant Scoping
Orders are automatically associated with the tenant from the X-Tenant-ID header. The system ensures that:- Products in the order belong to the same tenant
- The delivery address belongs to the authenticated user
- All data is isolated per tenant
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| address_id | integer | Yes | ID of the delivery address (must exist in user_addresses) |
| payment_type | integer | Yes | Payment method identifier |
| total_amount | number | Yes | Total order amount (must be >= 0) |
| order_items | array | Yes | Array of order items (minimum 1 item) |
| order_items[].product_id | integer | Yes | Product ID (must exist in products table) |
| order_items[].qty | integer | Yes | Quantity (must be >= 1) |
| order_items[].amount | number | Yes | Item amount (must be >= 0) |
| order_items[].size | string | No | Product size/variant |
| order_items[].notes | string | No | Special instructions for this item |
Example Usage
Success Response
Error Responses
Validation Error (422)
Server Error (500)
Notes
- The order is created within a database transaction for data integrity
- If any part of the order creation fails, the entire transaction is rolled back
- All order items are validated before creation
- The authenticated user is automatically set as the order owner