Skip to main content

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 a multipart/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.
  • postingTime and requiredBy are both derived from purchaseDate.

📋 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 supplier table to retrieve supplier names.
  • Sorting, searching, and pagination are all supported.
  • This endpoint is ideal for displaying purchase order lists in dashboards.

Status Values

The doc_status field in purchase orders can have the following values:

Common Error Codes


Business Logic

Purchase Order Creation Flow

  1. User creates a purchase order with supplier, date, status, and items
  2. Purchase order is created with updateStock = true by default
  3. postingTime and requiredBy are automatically set from purchaseDate
  4. Purchase order items are linked to the purchase order
  5. User must have access to the store via userStoreRelation

Purchase Order Retrieval Flow

  1. System validates user has access to the store
  2. Retrieves purchase orders with supplier information (via join)
  3. Applies filters, search, and sorting
  4. Returns paginated results with metadata