Skip to content
PharmaFlow Knowledgebase
Esc
↑↓navigate↵open⌘Jpreview

Create a purchase order

Admin and branch manager. Raises a purchase order with its line items in one transaction. The supplier and branch must exist and be active, and the order opens as DRAFT and is audited.

POST/api/v1/purchase-orders
Authorization
AuthorizationBearer token (JWT) · headerrequired

JWT from POST /api/v1/auth/login sent as Authorization Bearer.

Request body
requiredapplication/json
supplier_idstringrequired
min length 1
branch_idstringrequired
min length 1
expected_datestring | null
notesstring
default: ""
itemsobject[]required
min items 1
Show properties
Array of object
medicine_idstringrequired
min length 1
ordered_qtyintegerrequired
min -9007199254740991 · max 9007199254740991
agreed_unit_costnumberrequired
Responses
201

Purchase order drafted

idstringrequired
statusstringrequired
created_atstringrequired
400

The request body fails validation

detailstringrequired
401

Not authenticated

detailstringrequired
403

Access forbidden for this role

detailstringrequired
404

Supplier not found, or branch not found

detailstringrequired
Try it
Server
Authorization
Bodyapplication/json
Request
curl -X POST 'http://localhost:8000/api/v1/purchase-orders' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "supplier_id": "string",
  "branch_id": "string",
  "expected_date": "string",
  "notes": "",
  "items": [
    {
      "medicine_id": "string",
      "ordered_qty": -9007199254740991,
      "agreed_unit_cost": 0
    }
  ]
}'
Response
{
  "id": "string",
  "status": "string",
  "created_at": "string"
}