Create a purchase order

Operation ID: createPurchaseOrder

Group: Accounting › Purchase Orders

Open in the interactive reference

POST /accounting/purchase-orders

Retry-safe: A write that accepts Idempotency-Key: repeating a request with the same key replays the stored answer instead of executing twice.

Creates a purchase order. The order is created with its lines, and the response contains only its id. The order starts as 'pendingApproval' and then goes through your tenant's approval policy, which approves it at once when no approvers are configured.

Each line is an item line or an expense line, set by isItem. An item line is priced by quantity times price and uses itemId and unitOfMeasureId. An expense line is priced by editableAmount and uses accountId.

Every amount is a plain decimal in the order's currency.

To see the order, including its poNumber, use GET accounting/purchase-orders/:id.

Parameters

Name In Type Required Description
Api-Version header string · v1 yes The API version this request targets, named by its public identifier. Required on every request; omitting it, or naming a version this company does not have, is answered with 400. This document describes version v1.
Idempotency-Key header string no An opaque caller-chosen string (1-255 characters) that makes this request safe to retry. Repeating the same key with an identical request body replays the original response instead of re-executing - but only once that original request succeeded; a failed attempt re-executes on retry. Repeating the key with a different body is answered with 422. A key still in flight is answered with 409 - as is a key whose original request was interrupted before it finished, for a few minutes afterwards, until that attempt is presumed dead. A completed response stays replayable for 24 hours. The key is scoped to the caller, not to the action: reusing it for a different action is answered with 409 or 422 rather than treated independently. On read actions this header is ignored. On write actions that cannot offer the guarantee it is answered with 400 IDEMPOTENCY_NOT_SUPPORTED rather than silently ignored.

Request body

Required, application/json: createPurchaseOrderInput.

Field Type Required Description
entityId string yes The legal entity that owns the order. See id on GET base/entities. Example: "8f2c1d40-5a6b-4c7d-9e80-1f2a3b4c5d6e".
vendorId string yes The vendor the order is placed with. See id on GET accounting/vendors/:id. Example: "3b7d5e9c-1a24-4f80-9c6d-2e8f70b13a45".
currency string yes The currency of the order. Format ISO 4217, for example 'USD'. Governs every line amount. Example: "USD".
description string no The description of the order, shown to the vendor. Example: "Q4 office supplies".
internalDescription string no An internal description of the order, not shown to the vendor.
externalMemo string no A memo printed on vendor-facing documents.
externalPONumber string no The reference number this order has in the upstream system.
paymentTerms string no The payment-terms code agreed with the vendor, for example 'net30'.
startDate date no The date the order starts. Use format YYYY-MM-DD.
endDate date no The date the order ends. Use format YYYY-MM-DD.
needByDate date no The date the goods or services are required by. Use format YYYY-MM-DD. Example: "2026-10-15".
requestedById string no The employee who requested the order. There is no endpoint for it.
purchaseTypeId string no The purchase type of the order, for example 'New purchase'. Must be an active type. See id on GET accounting/purchase-types/:id.
lines array<object> yes The lines this order places. At least one is required. Example: [{"isItem":false,"description":"Stationery","editableAmount":"450.00"}].
lines[].isItem boolean yes Whether this is an item line. True for an item line, priced by quantity times price. False for an expense line, priced by editableAmount.
lines[].description string no A description of what is being ordered.
lines[].itemId string no The item being ordered. Expected on an item line.
lines[].accountId string no The ledger account the line is booked to. See id on GET accounting/accounts/:id. Expected on an expense line.
lines[].unitOfMeasureId string no The unit the quantity is expressed in. Expected on an item line.
lines[].departmentId string no The department the cost is allocated to. See id on GET people/departments/:id.
lines[].quantity decimal no The ordered quantity, as a decimal. Expected on an item line.
lines[].price decimal no The unit price, in the order currency, as a decimal. Expected on an item line.
lines[].editableAmount decimal no The manually entered line amount, in the order currency, as a decimal. Expected on an expense line.
lines[].startDate date no The date this line starts. Use format YYYY-MM-DD.
lines[].endDate date no The date this line ends. Use format YYYY-MM-DD.
lines[].estimatedDeliveryDate date no The expected delivery date for this line. Use format YYYY-MM-DD.
attachments array<object> no Files to attach to the order. Upload each file first and send its reference as file.
attachments[].fileName string no The display name of the attached file. Defaults to the uploaded file's name. Required with fileId.
attachments[].fileId string no Deprecated: an already-stored file's identifier. Use file instead. Send exactly one of file or fileId.
attachments[].file file no The file, as the upload reference returned by POST /public/files/{namespace}/createPurchaseOrder (multipart/form-data, Api-Version header). {namespace} is the segment after /public/api/ in your base URL. Upload right before this call: a reference works only for createPurchaseOrder, only for you, and for a few minutes. Up to 15 MB each; accepted types: pdf, tiff, jpeg, jpg, png, xls, xlsx, csv, xml, doc, docx, heic, heif.
{
  "entityId": "8f2c1d40-5a6b-4c7d-9e80-1f2a3b4c5d6e",
  "vendorId": "3b7d5e9c-1a24-4f80-9c6d-2e8f70b13a45",
  "currency": "USD",
  "lines": [
    {
      "isItem": false,
      "description": "Stationery",
      "editableAmount": "450.00"
    }
  ]
}

Response

200 Success

Under data (createPurchaseOrderOutput):

Field Type Required Description
id string yes The unique identifier for the created purchase order. Example: "9c4e1b70-8d25-4a63-b19f-5e7c02da3846".
{
  "data": {
    "id": "9c4e1b70-8d25-4a63-b19f-5e7c02da3846"
  },
  "diagnostics": [
    {
      "code": "<code>",
      "message": "<message>",
      "severity": "error",
      "path": [
        "<path>"
      ],
      "details": "<details>"
    }
  ]
}

Files

Response headers

Errors

Code Status
INVALID_ATTACHMENT 400
UNSUPPORTED_FILE_TYPE 400
REFERENCE_NOT_FOUND 400
PURCHASE_TYPES_DISABLED 400
PURCHASE_TYPE_NOT_ACTIVE 400
TOO_MANY_LINES 400
IDEMPOTENCY_KEY_CONFLICT 409
IDEMPOTENCY_PAYLOAD_MISMATCH 422

Statuses