Overview / Stock & supply / Create a purchase order

Create a purchase order

post https://api.flactrum.com/v1/purchase-orders
Required scope purchases.write
Success status201
Returns One PurchaseOrder object

Request body

FieldTypeDescription
supplier_id * string —
branch_id string|null —
warehouse_id string|null —
code string|null Generated when omitted; unique within the brand.
status string —
expected_at string|null —
note string|null —
items array Replaces every line. Each entry is {stock_item_id, ordered_quantity, unit_price, received_quantity?, purchase_unit_id?}. Line and order totals are calculated.

Response fields

FieldTypeDescription
id string —
code string —
supplier_id string —
branch_id string|null —
warehouse_id string|null —
status string —
total_amount number Always derived from the lines; it cannot be written directly.
items array —

Examples

Recorded from the test suite — these are real requests and their real responses.

curl -X POST 'https://api.flactrum.com/v1/purchase-orders' \
  -H 'Authorization: Bearer flk_your_key:your_secret' \
  -H 'Content-Type: application/json' \
  -d '{
    "supplier_id": "01m43mzm0rvy02zyfn5hc1zmf9",
    "branch_id": "01m43mzm05sety6gtbg1kwg62k",
    "items": [
        {
            "stock_item_id": "01m43mzm0eg82jh2t1rhvakj09",
            "ordered_quantity": 25000,
            "unit_price": 0.048
        }
    ]
}'

HTTP 201 · application/json

{
    "data": {
        "id": "01m43mzm12ex4a55v2er82tchm",
        "code": "TS-261004-BILV",
        "supplier_id": "01m43mzm0rvy02zyfn5hc1zmf9",
        "branch_id": "01m43mzm05sety6gtbg1kwg62k",
        "warehouse_id": null,
        "status": "draft",
        "total_amount": 1200,
        "note": null,
        "requested_at": "2026-10-04T14:27:13+00:00",
        "approved_at": null,
        "shipped_at": null,
        "expected_at": null,
        "received_at": null,
        "item_count": 1,
        "items": [
            {
                "id": "01m43mzm15hnxsbc3qr0k3h157",
                "stock_item_id": "01m43mzm0eg82jh2t1rhvakj09",
                "purchase_unit_id": null,
                "ordered_quantity": 25000,
                "received_quantity": null,
                "unit_price": 0.05,
                "total_price": 1200
            }
        ],
        "created_at": "2026-10-04T14:27:13+00:00",
        "updated_at": "2026-10-04T14:27:13+00:00"
    }
}