Update Purchase Order¶
Updates an existing purchase order header and replaces its line items. The request body follows the same schema as Create Purchase Order.
Request¶
Required privilege: Procurement / Edit
Content-Type: application/json
CSRF header required: X-XSRF-TOKEN
Path Parameters¶
| Parameter | Type | Required | Description |
|---|---|---|---|
id |
integer | Yes | Internal PO identifier (id from list or get response) |
Request Body¶
The request body is identical to Create Purchase Order. Include all line items in the details array - existing lines not present in the payload may be removed.
To retain an existing line item, include its id (and PO Details Id). To add a new line item, set id to null.
{
"PO List Number": "PO-2024-001",
"PO List Document Status": "Shipped",
"PO List Order Date": "2024-03-01",
"Supplier Number": "SUP-007",
"Purchase Order Id": 42,
"details": [
{
"id": 101,
"PO Details Id": 101,
"Item Number": "ITEM-A",
"Sub Item Number": null,
"Warehouse Number": "WH-01",
"Ship From Number": "SF-01",
"PO Details Price": 12.50,
"PO Details Quantity": 200,
"PO Details Document Status": "Shipped",
"PO Details Tracking": "BOL-789456",
"PO Details Order Date": "2024-03-01",
"PO Details Ship Date": "2024-03-08",
"PO Details ETA Date": "2024-03-15",
"PO Details Actual Ship Date": "2024-03-08",
"PO Details Actual Delivery Date": null
},
{
"id": null,
"PO Details Id": null,
"Item Number": "ITEM-C",
"Sub Item Number": null,
"Warehouse Number": "WH-01",
"Ship From Number": "SF-01",
"PO Details Price": 5.00,
"PO Details Quantity": 50,
"PO Details Document Status": "Open",
"PO Details Order Date": "2024-03-01",
"PO Details Ship Date": "2024-03-22",
"PO Details ETA Date": "2024-03-28"
}
]
}
Validation¶
All validation rules from Create Purchase Order apply, plus:
| Rule | Error Code |
|---|---|
PO with the given id must exist |
PurchaseOrderList.NotFound |
Response¶
Success - Immediate¶
HTTP/1.1 200 OK
Content-Type: application/json
{
"message": "Purchase order updated successfully.",
"notification_type": "Success"
}
Success - Queued¶
HTTP/1.1 200 OK
Content-Type: application/json
{
"message": "Changes will be visible after the integration is done.",
"notification_type": "Warning"
}
Error¶
HTTP/1.1 400 Bad Request
Content-Type: application/json
{
"Message": "PO #42 not found.",
"Code": "PurchaseOrderList.NotFound"
}
Code Examples¶
curl¶
CSRF=$(grep csrf_access_token cookies.txt | awk '{print $NF}')
curl -b cookies.txt -X PUT https://acme.knosc.com/api/purchase-order/42 \
-H "Content-Type: application/json" \
-H "X-XSRF-TOKEN: $CSRF" \
-d '{
"PO List Number": "PO-2024-001",
"PO List Document Status": "Shipped",
"PO List Order Date": "2024-03-01",
"Supplier Number": "SUP-007",
"Purchase Order Id": 42,
"details": [
{
"id": 101,
"PO Details Id": 101,
"Item Number": "ITEM-A",
"Warehouse Number": "WH-01",
"Ship From Number": "SF-01",
"PO Details Quantity": 200,
"PO Details Document Status": "Shipped",
"PO Details Tracking": "BOL-789456",
"PO Details Order Date": "2024-03-01",
"PO Details Ship Date": "2024-03-08",
"PO Details ETA Date": "2024-03-15",
"PO Details Actual Ship Date": "2024-03-08"
}
]
}'
Python¶
csrf_token = session.cookies.get("csrf_access_token")
po_id = 42
payload = {
"PO List Number": "PO-2024-001",
"PO List Document Status": "Shipped",
"PO List Order Date": "2024-03-01",
"Supplier Number": "SUP-007",
"Purchase Order Id": po_id,
"details": [
{
"id": 101,
"PO Details Id": 101,
"Item Number": "ITEM-A",
"Sub Item Number": None,
"Warehouse Number": "WH-01",
"Ship From Number": "SF-01",
"PO Details Price": 12.50,
"PO Details Quantity": 200,
"PO Details Document Status": "Shipped",
"PO Details Tracking": "BOL-789456",
"PO Details Order Date": "2024-03-01",
"PO Details Ship Date": "2024-03-08",
"PO Details ETA Date": "2024-03-15",
"PO Details Actual Ship Date": "2024-03-08",
"PO Details Actual Delivery Date": None,
}
],
}
response = session.put(
f"https://acme.knosc.com/api/purchase-order/{po_id}",
headers={"X-XSRF-TOKEN": csrf_token},
json=payload,
)
print(response.json())
Related¶
- Create Purchase Order - Full field reference
- Delete Purchase Order
- Move Lines - Move line items between POs without a full update