Skip to content

Delete Purchase Order Detail Line

Deletes a single line item from a purchase order. If the deleted line is the last line item on its parent PO, the parent PO is also deleted automatically.


Request

DELETE /api/purchase-order-details/{id}

Required: Authenticated session CSRF header required: X-XSRF-TOKEN

Path Parameters

Parameter Type Required Description
id integer Yes Internal line item identifier (id from the details array)

Example Request

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

Behaviour

  • Last line rule: If deleting this line item would leave the parent PO with zero items, the parent PurchaseOrderList record is also deleted.
  • Referential integrity: If the line item is referenced by other records, the delete is rejected with PurchaseOrderDetails.StillInUse.

Response

Success

HTTP/1.1 200 OK

Error - Not Found

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

{
  "Message": "PO Detail #101 not found.",
  "Code": "PurchaseOrderDetails.NotFound"
}

Error - Still In Use

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

{
  "Message": "PO Detail #101 is still in use and cannot be deleted.",
  "Code": "PurchaseOrderDetails.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-details/101 \
  -H "X-XSRF-TOKEN: $CSRF"

Python

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

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

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