Skip to content

Delete Purchase Order

Permanently deletes a purchase order and all of its associated line items.


Request

DELETE /api/purchase-order/{id}

Required privilege: Procurement / Edit CSRF header required: X-XSRF-TOKEN

Path Parameters

Parameter Type Required Description
id integer Yes Internal PO identifier

Example Request

DELETE /api/purchase-order/42 HTTP/1.1
Host: acme.knosc.com
Cookie: access_token_cookie=<token>
X-XSRF-TOKEN: <csrf-token>

Behaviour

  • Cascade delete: All PurchaseOrderDetails records belonging to this PO are deleted together with the PO header.
  • Referential integrity check: If the PO is referenced by other records (e.g., receipts or integrations), the delete is rejected with PurchaseOrderList.StillInUse.

Response

Success

HTTP/1.1 200 OK

Error - PO Not Found

HTTP/1.1 400 Bad Request
Content-Type: application/json

{
  "Message": "PO #42 not found.",
  "Code": "PurchaseOrderList.NotFound"
}

Error - Still In Use

HTTP/1.1 400 Bad Request
Content-Type: application/json

{
  "Message": "PO #PO-2024-001 is still in use and cannot be deleted.",
  "Code": "PurchaseOrderList.StillInUse"
}

Code Examples

curl

CSRF=$(grep csrf_access_token cookies.txt | awk '{print $NF}')

curl -b cookies.txt -X DELETE https://acme.knosc.com/api/purchase-order/42 \
  -H "X-XSRF-TOKEN: $CSRF"

Python

csrf_token = session.cookies.get("csrf_access_token")

response = session.delete(
    "https://acme.knosc.com/api/purchase-order/42",
    headers={"X-XSRF-TOKEN": csrf_token},
)

if response.status_code == 200:
    print("PO deleted successfully.")
else:
    error = response.json()
    print(f"Error: {error['Code']} - {error['Message']}")