API / Reference / Purchase Orders
Create purchase order
POST
https://api.light.inc/v1/purchase-orders
Creates a new purchase order
Nothing is required at creation — vendor, entity, owner and even lines may be empty; everything is checked at lock. At most 500 lines (PURCHASE_ORDER_LINES_COUNT_EXCEEDED). unitPrice is net; per-line taxAmount is computed from taxCodeId only once the order has a companyEntityId, and cannot be overridden. Most response fields marked required below are null on a fresh draft. States: IN_DRAFT → lock → APPROVED_ACCOUNTING_ENTRY_PENDING → OPEN (in the background, when the ERP confirms; erpNumber and documentKey appear then) → close → CLOSE_PENDING → CLOSED, or cancel → CANCEL_PENDING → CANCELLED, or reset → RESET_PENDING → IN_DRAFT. A wrong-state call fails with PURCHASE_ORDER_INVALID_STATE_TRANSITION.
Authorization
Send one of these on every request. See Authentication for how to get credentials.
- API key
Basic authentication header of the form Basic <api_key>, where <api_key> is your api key.
- Bearer token
Request body
application/json;charset=UTF-8
-
vendorIdstring · uuid -
companyEntityIdstring · uuid -
ownerIdstring · uuid -
currencystring -
purchaseOrderDatestring · date -
deliveryAddressstring -
deliveryDatestring · date -
descriptionstring -
linesarray of object-
descriptionstring -
costCenterIdstring · uuid -
accountIdstring · uuid -
taxCodeIdstring · uuid -
quantitynumber -
unitPriceinteger · int64 -
customPropertiesarray of object-
groupIdstring · uuidID of the custom property group.
-
valueIdsarray of string · uuidIDs of the selected custom property values. It behaves as a PUT operation, so if empty the existing ones will be effectively deleted.
Catalogue value ids for this group. Required; send
[](with an emptyinlineValues) to clear the group.SINGLE_SELECTandMULTI_SELECTgroups accept nothing else. See Custom properties on writes. -
inlineValuesarray of stringInline custom property values (used for TEXT/NUMERIC/DATE/etc. groups). It behaves as a PUT operation, so if empty or null the existing ones will be effectively deleted.
Literal values for
TEXT,NUMERIC,BOOLEANandDATEgroups, as strings (yyyy-MM-ddfor dates). Rejected on select groups withCUSTOM_PROPERTY_VALUE_TYPE_MISMATCH. See Custom properties on writes.
-
-
-
customPropertiesarray of object-
groupIdstring · uuidID of the custom property group.
-
valueIdsarray of string · uuidIDs of the selected custom property values. It behaves as a PUT operation, so if empty the existing ones will be effectively deleted.
Catalogue value ids for this group. Required; send
[](with an emptyinlineValues) to clear the group.SINGLE_SELECTandMULTI_SELECTgroups accept nothing else. See Custom properties on writes. -
inlineValuesarray of stringInline custom property values (used for TEXT/NUMERIC/DATE/etc. groups). It behaves as a PUT operation, so if empty or null the existing ones will be effectively deleted.
Literal values for
TEXT,NUMERIC,BOOLEANandDATEgroups, as strings (yyyy-MM-ddfor dates). Rejected on select groups withCUSTOM_PROPERTY_VALUE_TYPE_MISMATCH. See Custom properties on writes.
-
Response
-
idstring · uuid -
companyIdstring · uuid -
createdBystring · uuid -
companyEntityIdstring · uuid -
purchaseRequestIdstring · uuid -
statestring⚠️ This enum is not exhaustive; new values may be added in the future.
One of
IN_DRAFTRESET_PENDINGAPPROVED_ACCOUNTING_ENTRY_PENDINGOPENCLOSE_PENDINGCLOSEDCANCEL_PENDINGCANCELLED -
totalAmountinteger · int64 -
totalNetAmountinteger · int64 -
totalTaxAmountinteger · int64 -
erpNumberstringAssigned when the order reaches
OPEN, after the ERP confirms the lock in the background;nullbefore that. -
descriptionstring -
currencystring -
ownerIdstring · uuid -
vendorIdstring · uuid -
vendorEmailstring -
deliveryAddressstring -
deliveryDatestring · date -
documentKeystring -
failureContextobjectFailure context when vendor onboarding fails.
-
namestringThe error name
-
typestringThe error type
⚠️ This enum is not exhaustive; new values may be added in the future.
One of
BAD_REQUESTUNAUTHORIZEDFORBIDDENNOT_FOUNDCONFLICTUNPROCESSABLE_CONTENT -
errorsarray of objectList of errors providing details about what went wrong
-
typestringA string code identifying the error type
-
messagestringA human-readable message providing more details about the error
-
patharray of stringOptional path of the error when the error is for a specific field. Used mostly on BAD_REQUEST errors, that path will match the field name on the request object
-
contextobjectOptional context providing additional information about the error. This can include any relevant data that might help in understanding or resolving the error
-
-
-
editStatusstring⚠️ This enum is not exhaustive; new values may be added in the future.
ALL_EDITS_LOCKEDfromlockonwards;CORE_EDITS_LOCKEDon drafts created from a purchase request (vendor, entity, currency, line quantities and prices, and adding or removing lines are frozen). Not returned by the list endpoint.One of
ALL_EDITS_ALLOWEDALL_EDITS_LOCKEDCORE_EDITS_LOCKED -
purchaseOrderDatestring · date -
erpSyncedAtstring · date-time -
lockedAtstring · date-time -
closedAtstring · date-time -
cancelledAtstring · date-time -
createdAtstring · date-time -
updatedAtstring · date-time -
linesarray of object-
idstring · uuid -
companyIdstring · uuid -
purchaseOrderIdstring · uuid -
descriptionstring -
costCenterIdstring · uuid -
accountIdstring · uuid -
taxCodeIdstring · uuid -
quantitynumber -
unitPriceinteger · int64 -
amountinteger · int64 -
netAmountinteger · int64 -
createdAtstring · date-time -
updatedAtstring · date-time -
customPropertiesarray of object-
groupIdstring · uuidID of the custom property group
-
groupInternalNamestringInternal name of the custom property group
-
valuesarray of objectList of values. Note that this will be a single value unless the group input type supports multiple values
-
idstring · uuidUnique identifier for the object
-
groupIdstring · uuidID of the custom property group
-
groupInternalNamestringInternal name of the custom property group
-
companyIdstring · uuidID of the company
-
internalNamestringInternal name of the custom property value
-
labelstringLabel of the custom property value
-
contextstringContext/description of the custom property value
-
createdAtstring · date-timeTimestamp when the custom property value was created
-
updatedAtstring · date-timeTimestamp when the custom property value was last updated
-
-
-
-
customPropertiesarray of object-
groupIdstring · uuidID of the custom property group
-
groupInternalNamestringInternal name of the custom property group
-
valuesarray of objectList of values. Note that this will be a single value unless the group input type supports multiple values
-
idstring · uuidUnique identifier for the object
-
groupIdstring · uuidID of the custom property group
-
groupInternalNamestringInternal name of the custom property group
-
companyIdstring · uuidID of the company
-
internalNamestringInternal name of the custom property value
-
labelstringLabel of the custom property value
-
contextstringContext/description of the custom property value
-
createdAtstring · date-timeTimestamp when the custom property value was created
-
updatedAtstring · date-timeTimestamp when the custom property value was last updated
-
-