createSalesOrder
Requires permission sales:sales_order:create.
Create a sales order. Line unitPrice is optional because the server prices each line; the order starts as DRAFT unless you send CONFIRMED or AWAITING_PAYMENT. Taxed lines need a valid tax method. Needs the sales order create permission, and the sales order confirm permission when status is CONFIRMED.
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 CreateSalesOrder($input: CreateSalesOrderInput!) {
createSalesOrder(input: $input) {
id
customerPoNumber
orderNumber
sourceQuoteNumber
trackingNumber
creatorName
billingAddress {
postalCode
city
country
state
street1
street2
}
}
}
curl -X POST "https://<api-host>/graphql" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
--data @- <<'EOF'
{
"query": "mutation CreateSalesOrder($input: CreateSalesOrderInput!) {\n createSalesOrder(input: $input) {\n id\n customerPoNumber\n orderNumber\n sourceQuoteNumber\n trackingNumber\n creatorName\n billingAddress {\n postalCode\n city\n country\n state\n street1\n street2\n }\n }\n}",
"variables": {
"input": {
"customerId": "string",
"discountAmount": 0,
"items": [
{
"discountPercent": 0,
"productId": "string",
"quantity": 0,
"taxAmount": 0,
"taxRate": 0,
"uomId": "string",
"variantId": "string"
}
],
"paymentTerms": "string",
"shippingAmount": 0
}
}
}
EOF
Variables:
{
"input": {
"customerId": "string",
"discountAmount": 0,
"items": [
{
"discountPercent": 0,
"productId": "string",
"quantity": 0,
"taxAmount": 0,
"taxRate": 0,
"uomId": "string",
"variantId": "string"
}
],
"paymentTerms": "string",
"shippingAmount": 0
}
}
Response:
{
"data": {
"createSalesOrder": {
"id": "id",
"customerPoNumber": "string",
"orderNumber": "string",
"sourceQuoteNumber": "string",
"trackingNumber": "string",
"creatorName": "string",
"billingAddress": {
"postalCode": "string",
"city": "string",
"country": "string",
"state": "string",
"street1": "string",
"street2": "string"
}
}
}
}
Create a sales order with one line item:
- GraphQL
- cURL
mutation CreateSalesOrder($input: CreateSalesOrderInput!) {
createSalesOrder(input: $input) {
id
orderNumber
status
currency
totalAmount
}
}
curl -X POST "https://<api-host>/graphql" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
--data @- <<'EOF'
{
"query": "mutation CreateSalesOrder($input: CreateSalesOrderInput!) {\n createSalesOrder(input: $input) {\n id\n orderNumber\n status\n currency\n totalAmount\n }\n}",
"variables": {
"input": {
"customerId": "CUSTOMER_ID",
"discountAmount": 0,
"items": [
{
"discountPercent": 0,
"productId": "PRODUCT_ID",
"quantity": 2,
"taxAmount": 0,
"taxRate": 0,
"uomId": "UOM_ID",
"variantId": "VARIANT_ID"
}
],
"paymentTerms": "PAYMENT_TERMS",
"shippingAmount": 0
}
}
}
EOF
Variables:
{
"input": {
"customerId": "CUSTOMER_ID",
"discountAmount": 0,
"items": [
{
"discountPercent": 0,
"productId": "PRODUCT_ID",
"quantity": 2,
"taxAmount": 0,
"taxRate": 0,
"uomId": "UOM_ID",
"variantId": "VARIANT_ID"
}
],
"paymentTerms": "PAYMENT_TERMS",
"shippingAmount": 0
}
}
Response:
{
"data": {
"createSalesOrder": {
"id": "SALES_ORDER_ID",
"orderNumber": "ORDER_NUMBER",
"status": "DRAFT",
"currency": "CURRENCY_CODE",
"totalAmount": 200
}
}
}
createSalesOrder(
input: CreateSalesOrderInput!
): SalesOrder!
Arguments
createSalesOrder.input ● CreateSalesOrderInput! non-null input
The order to create.
Type
SalesOrder object
A confirmed demand from a customer to ship goods, usually converted from a quote. Moves through confirmation, shipment, invoicing and payment.