Data Structure
List Orders
Retrieve a paginated list of orders.Query Parameters
The API supports the following query parameters using Spatie Query Builder:Filtering
- Simple Filters:
- Range Filters:
- Multiple Values:
- Complex Filters:
Including Relationships
You can include related models in the response:site- The site this order belongs touser- The user who created this orderdocuments- All documents in this ordertransactions- All transactions for this order
Sorting
Sort results by one or multiple fields:created_atupdated_attotalstatusdocuments_counttransactions_count
Selecting Fields
Select specific fields to return:Append Computed Attributes
Include computed attributes in the response:pending_documents_countfailed_documents_counttotal_refundedprocessing_time
Pagination
Control the number of results per page:Create Order
Create a new order record.Validation Rules
| Field | Rules |
|---|---|
| documents | Required, array, min:1 |
| documents.*.type | Required, valid document type |
| documents.*.company_id | Required, exists in companies |
| documents.*.employee_id | Required, exists in employees |
| documents.*.content | Required, valid JSON |
| payment.processor | Required, valid processor |
| payment.amount | Required, numeric, min:0 |
Get Order
Retrieve details of a specific order.Cancel Order
Cancel an order if it’s in a cancellable state.Relationships
BelongsTo Relationships
site- The site this order belongs touser- The user who created this order
HasMany Relationships
documents- All documents in this ordertransactions- All transactions associated with this order
Order Status Flow
Security Considerations
- Order Access
- Orders are site-scoped
- Users can only access their own orders
- Payment information is encrypted
- Order history is immutable
- Payment Security
- Payment processor tokens are encrypted
- Amounts are validated against documents
- Refunds require special permissions
- Transaction logs are maintained
Error Handling
HTTP Status Codes
- 401 Unauthenticated
- 403 Unauthorized
- 404 Not Found
- 422 Validation Error
Best Practices
- Order Creation
- Validate all document data before creation
- Ensure proper payment information
- Use idempotency keys for requests
- Handle concurrent order creation
- Security
- Implement rate limiting
- Monitor unusual order patterns
- Regular security audits
- Maintain PCI compliance if handling cards
- Performance
- Cache order status when possible
- Use background jobs for processing
- Implement proper database indexes
- Monitor order processing times
- Compliance
- Maintain detailed audit logs
- Follow data retention policies
- Regular compliance reviews
- Document all status changes

