createPurchaseOrder
Requires permission purchase:purchase_order:create.
Creates a purchase order for a supplier. The organization must have a base currency configured and every line needs a variant. The order is dated today unless you hold the permission to backdate it, and a payment term is checked when you enter it. Needs the purchase orders feature on your plan.
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 CreatePurchaseOrder($input: CreatePurchaseOrderInput!) {
createPurchaseOrder(input: $input) {
id
orderNumber
supplierCode
trackingCode
creatorName
projectName
items {
id
productName
uomName
variantName
createdAt
canceledQuantity
}
}
}
curl -X POST "https://<api-host>/graphql" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
--data @- <<'EOF'
{
"query": "mutation CreatePurchaseOrder($input: CreatePurchaseOrderInput!) {\n createPurchaseOrder(input: $input) {\n id\n orderNumber\n supplierCode\n trackingCode\n creatorName\n projectName\n items {\n id\n productName\n uomName\n variantName\n createdAt\n canceledQuantity\n }\n }\n}",
"variables": {
"input": {
"discountAmount": 0,
"exchangeRate": 0,
"freightAmount": 0,
"items": [
{
"discountPercent": 0,
"productId": "string",
"quantity": 0,
"shippingAmount": 0,
"surchargeAmount": 0,
"taxRate": 0,
"unitPrice": 0,
"uomId": "string"
}
],
"paymentTerms": "string",
"shippingAmount": 0,
"supplierId": "string",
"surchargeAmount": 0
}
}
}
EOF
Variables:
{
"input": {
"discountAmount": 0,
"exchangeRate": 0,
"freightAmount": 0,
"items": [
{
"discountPercent": 0,
"productId": "string",
"quantity": 0,
"shippingAmount": 0,
"surchargeAmount": 0,
"taxRate": 0,
"unitPrice": 0,
"uomId": "string"
}
],
"paymentTerms": "string",
"shippingAmount": 0,
"supplierId": "string",
"surchargeAmount": 0
}
}
Response:
{
"data": {
"createPurchaseOrder": {
"id": "id",
"orderNumber": "string",
"supplierCode": "string",
"trackingCode": "string",
"creatorName": "string",
"projectName": "string",
"items": [
{
"id": "id",
"productName": "string",
"uomName": "string",
"variantName": "string",
"createdAt": "2025-01-15T00:00:00Z",
"canceledQuantity": 0
}
]
}
}
}
Create a purchase order with one line item:
- GraphQL
- cURL
mutation CreatePurchaseOrder($input: CreatePurchaseOrderInput!) {
createPurchaseOrder(input: $input) {
id
orderNumber
status
totalAmount
}
}
curl -X POST "https://<api-host>/graphql" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
--data @- <<'EOF'
{
"query": "mutation CreatePurchaseOrder($input: CreatePurchaseOrderInput!) {\n createPurchaseOrder(input: $input) {\n id\n orderNumber\n status\n totalAmount\n }\n}",
"variables": {
"input": {
"supplierId": "SUPPLIER_ID",
"paymentTerms": "PAYMENT_TERMS",
"discountAmount": 0,
"exchangeRate": 1,
"freightAmount": 0,
"shippingAmount": 0,
"surchargeAmount": 0,
"items": [
{
"productId": "PRODUCT_ID",
"uomId": "UOM_ID",
"quantity": 10,
"unitPrice": 50,
"discountPercent": 0,
"taxRate": 0,
"shippingAmount": 0,
"surchargeAmount": 0
}
]
}
}
}
EOF
Variables:
{
"input": {
"supplierId": "SUPPLIER_ID",
"paymentTerms": "PAYMENT_TERMS",
"discountAmount": 0,
"exchangeRate": 1,
"freightAmount": 0,
"shippingAmount": 0,
"surchargeAmount": 0,
"items": [
{
"productId": "PRODUCT_ID",
"uomId": "UOM_ID",
"quantity": 10,
"unitPrice": 50,
"discountPercent": 0,
"taxRate": 0,
"shippingAmount": 0,
"surchargeAmount": 0
}
]
}
}
Response:
{
"data": {
"createPurchaseOrder": {
"id": "PURCHASE_ORDER_ID",
"orderNumber": "ORDER_NUMBER",
"status": "DRAFT",
"totalAmount": 500
}
}
}
createPurchaseOrder(
input: CreatePurchaseOrderInput!
): PurchaseOrder!
Arguments
createPurchaseOrder.input ● CreatePurchaseOrderInput! non-null input
The details of the purchase order to create.
Type
PurchaseOrder object
A purchase order raised with a supplier.