appCreatePurchaseOrder
Requires permission purchase:purchase_order:create.
Create a DRAFT purchase order from an installed app. Send the supplier and lines (variant, unit, quantity, and optionally the supplier's agreed unit cost); the server sets tax, totals, currency, rate and dates, and a person approves the order. Needs write_purchasing.
Errors: a failed call returns a GraphQL errors entry, not a field on the result, and data may be null or partial. Read the entry's extensions.code and message; every shape and code is in the Error reference.
Example:
- GraphQL
- cURL
mutation AppCreatePurchaseOrder($input: AppCreatePurchaseOrderInput!) {
appCreatePurchaseOrder(input: $input) {
id
orderNumber
supplierCode
trackingCode
creatorName
projectName
creditLimitOverride {
baseCurrency
limit
projected
}
}
}
curl -X POST "https://<api-host>/graphql" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
--data @- <<'EOF'
{
"query": "mutation AppCreatePurchaseOrder($input: AppCreatePurchaseOrderInput!) {\n appCreatePurchaseOrder(input: $input) {\n id\n orderNumber\n supplierCode\n trackingCode\n creatorName\n projectName\n creditLimitOverride {\n baseCurrency\n limit\n projected\n }\n }\n}",
"variables": {
"input": {
"lines": [
{
"quantity": 0,
"uomId": "id",
"variantId": "id"
}
],
"supplierId": "id"
}
}
}
EOF
Variables:
{
"input": {
"lines": [
{
"quantity": 0,
"uomId": "id",
"variantId": "id"
}
],
"supplierId": "id"
}
}
Response:
{
"data": {
"appCreatePurchaseOrder": {
"id": "id",
"orderNumber": "string",
"supplierCode": "string",
"trackingCode": "string",
"creatorName": "string",
"projectName": "string",
"creditLimitOverride": {
"baseCurrency": "string",
"limit": 0,
"projected": 0
}
}
}
}
appCreatePurchaseOrder(
input: AppCreatePurchaseOrderInput!
): PurchaseOrder!
Arguments
appCreatePurchaseOrder.input ● AppCreatePurchaseOrderInput! non-null input
The purchase order.
Type
PurchaseOrder object
A purchase order raised with a supplier.