Skip to content

Move Purchase Order Lines

Moves one or more line items from a source purchase order to a target purchase order. The target can be an existing PO or a new PO created on the fly.


Request

PUT /api/purchase-order-details-move-lines

Required privilege: Procurement / Edit Content-Type: application/json CSRF header required: X-XSRF-TOKEN


Request Body

{
  "moves": [
    {
      "id": 101,
      "Old Purchase Order List Id": 42,
      "New Purchase Order List Id": 55
    },
    {
      "id": 102,
      "Old Purchase Order List Id": 42,
      "New Purchase Order List Id": 55
    }
  ]
}

To move lines into a new PO (created automatically), omit New Purchase Order List Id and provide New Purchase Order List Number instead:

{
  "moves": [
    {
      "id": 103,
      "Old Purchase Order List Id": 42,
      "New Purchase Order List Number": "PO-2024-NEW"
    }
  ]
}

Request Fields

Field Type Required Description
moves array Yes List of line moves. Must be non-empty
moves[].id integer Yes Internal ID of the PurchaseOrderDetails line to move
moves[].Old Purchase Order List Id integer Yes Source PO identifier
moves[].New Purchase Order List Id integer Conditional Target PO identifier. Required unless creating a new PO
moves[].New Purchase Order List Number string Conditional If provided, a new PO with this number is created as the target

All entries in moves must share the same source and target PO. You cannot move lines from multiple source POs in a single request.


Behaviour

  • Lines are moved atomically.
  • If the source PO has no remaining lines after the move, the source PO header is not automatically deleted - use Delete Purchase Order explicitly.
  • If tables are locked during an integration run, the operation is queued and executed in the background.

Response

Success - Immediate

HTTP/1.1 200 OK
Content-Type: application/json

{
  "message": "Update successful",
  "rows_updated": 2
}

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 - Move to Existing PO

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

curl -b cookies.txt -X PUT https://acme.knosc.com/api/purchase-order-details-move-lines \
  -H "Content-Type: application/json" \
  -H "X-XSRF-TOKEN: $CSRF" \
  -d '{
    "moves": [
      {
        "id": 101,
        "Old Purchase Order List Id": 42,
        "New Purchase Order List Id": 55
      }
    ]
  }'

curl - Move to New PO

curl -b cookies.txt -X PUT https://acme.knosc.com/api/purchase-order-details-move-lines \
  -H "Content-Type: application/json" \
  -H "X-XSRF-TOKEN: $CSRF" \
  -d '{
    "moves": [
      {
        "id": 101,
        "Old Purchase Order List Id": 42,
        "New Purchase Order List Number": "PO-2024-SPLIT"
      }
    ]
  }'

Python

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

# Move two lines from PO 42 to PO 55
response = session.put(
    "https://acme.knosc.com/api/purchase-order-details-move-lines",
    headers={"X-XSRF-TOKEN": csrf_token},
    json={
        "moves": [
            {"id": 101, "Old Purchase Order List Id": 42, "New Purchase Order List Id": 55},
            {"id": 102, "Old Purchase Order List Id": 42, "New Purchase Order List Id": 55},
        ]
    },
)
print(response.json())