Purchase Order API
The Purchase Order API allows you to create purchase orders and retrieve a paginated list of all purchase orders for a store. Purchase orders track orders from suppliers before they are fulfilled.All endpoints require authentication via Bearer token in the Authorization header. Users must have access to the store via
userStoreRelation.Base URL
📦 1. Create Purchase Order
Endpoint
Description
Creates a new purchase order with its associated items. This endpoint accepts amultipart/form-data request with a JSON string under the key jsonData.
Required Headers
The request is restricted to users linked to the store via
userStoreRelation. The store ID should be derived from the authenticated user’s store relations.Body Parameters
The jsonData field must contain a JSON string in this format:
Example Requests
Success Response (200)
Error Responses
403 Forbidden
400 Bad Request
Notes
- The request is restricted to users linked to the store via
userStoreRelation. - Automatically sets timestamps and initializes
updateStock = true. postingTimeandrequiredByare both derived frompurchaseDate.
📋 2. Get All Purchase Orders
Endpoint
Description
Returns a paginated list of all purchase orders for a specific store. This endpoint supports filtering, searching, sorting, and pagination.Required Headers
Query Parameters
Example Requests
Success Response (200)
Error Responses
403 Forbidden
400 Bad Request
Notes
- Requires store-level permission (validated by
userStoreRelation). - Joins with the
suppliertable to retrieve supplier names. - Sorting, searching, and pagination are all supported.
- This endpoint is ideal for displaying purchase order lists in dashboards.
Status Values
Thedoc_status field in purchase orders can have the following values:
Common Error Codes
Business Logic
Purchase Order Creation Flow
- User creates a purchase order with supplier, date, status, and items
- Purchase order is created with
updateStock = trueby default postingTimeandrequiredByare automatically set frompurchaseDate- Purchase order items are linked to the purchase order
- User must have access to the store via
userStoreRelation
Purchase Order Retrieval Flow
- System validates user has access to the store
- Retrieves purchase orders with supplier information (via join)
- Applies filters, search, and sorting
- Returns paginated results with metadata
Related APIs
- Purchase Invoice API - Create and manage purchase invoices
- Stores API - Manage stores and store access