Version: unstable
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/unstable/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation draftOrderCreate($input: DraftOrderInput!) { draftOrderCreate(input: $input) { draftOrder { id } } }\",\n \"variables\": {\n \"input\": {\n \"customerId\": \"gid://shopify/Customer/544365967\",\n \"note\": \"Test draft order\",\n \"email\": \"test.user@shopify.com\",\n \"taxExempt\": true,\n \"tags\": [\n \"foo\",\n \"bar\"\n ],\n \"shippingLine\": {\n \"title\": \"Custom Shipping\",\n \"price\": 4.55\n },\n \"shippingAddress\": {\n \"address1\": \"123 Main St\",\n \"city\": \"Waterloo\",\n \"province\": \"Ontario\",\n \"country\": \"Canada\",\n \"zip\": \"A1A 1A1\"\n },\n \"billingAddress\": {\n \"address1\": \"456 Main St\",\n \"city\": \"Toronto\",\n \"province\": \"Ontario\",\n \"country\": \"Canada\",\n \"zip\": \"Z9Z 9Z9\"\n },\n \"appliedDiscount\": {\n \"description\": \"damaged\",\n \"value\": 5.0,\n \"amount\": 5.0,\n \"valueType\": \"FIXED_AMOUNT\",\n \"title\": \"Custom\"\n },\n \"lineItems\": [\n {\n \"title\": \"Custom product\",\n \"originalUnitPrice\": 14.99,\n \"quantity\": 5,\n \"appliedDiscount\": {\n \"description\": \"wholesale\",\n \"value\": 5.0,\n \"amount\": 3.74,\n \"valueType\": \"PERCENTAGE\",\n \"title\": \"Fancy\"\n },\n \"weight\": {\n \"value\": 1,\n \"unit\": \"KILOGRAMS\"\n },\n \"customAttributes\": [\n {\n \"key\": \"color\",\n \"value\": \"Gold\"\n },\n {\n \"key\": \"material\",\n \"value\": \"Plastic\"\n }\n ]\n },\n {\n \"variantId\": \"gid://shopify/ProductVariant/43729076\",\n \"quantity\": 2\n }\n ],\n \"customAttributes\": [\n {\n \"key\": \"name\",\n \"value\": \"Achilles\"\n },\n {\n \"key\": \"city\",\n \"value\": \"Troy\"\n }\n ]\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation draftOrderCreate($input: DraftOrderInput!) {\n draftOrderCreate(input: $input) {\n draftOrder {\n id\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"customerId\": \"gid://shopify/Customer/544365967\",\n \"note\": \"Test draft order\",\n \"email\": \"test.user@shopify.com\",\n \"taxExempt\": true,\n \"tags\": [\n \"foo\",\n \"bar\"\n ],\n \"shippingLine\": {\n \"title\": \"Custom Shipping\",\n \"price\": 4.55\n },\n \"shippingAddress\": {\n \"address1\": \"123 Main St\",\n \"city\": \"Waterloo\",\n \"province\": \"Ontario\",\n \"country\": \"Canada\",\n \"zip\": \"A1A 1A1\"\n },\n \"billingAddress\": {\n \"address1\": \"456 Main St\",\n \"city\": \"Toronto\",\n \"province\": \"Ontario\",\n \"country\": \"Canada\",\n \"zip\": \"Z9Z 9Z9\"\n },\n \"appliedDiscount\": {\n \"description\": \"damaged\",\n \"value\": 5.0,\n \"amount\": 5.0,\n \"valueType\": \"FIXED_AMOUNT\",\n \"title\": \"Custom\"\n },\n \"lineItems\": [\n {\n \"title\": \"Custom product\",\n \"originalUnitPrice\": 14.99,\n \"quantity\": 5,\n \"appliedDiscount\": {\n \"description\": \"wholesale\",\n \"value\": 5.0,\n \"amount\": 3.74,\n \"valueType\": \"PERCENTAGE\",\n \"title\": \"Fancy\"\n },\n \"weight\": {\n \"value\": 1,\n \"unit\": \"KILOGRAMS\"\n },\n \"customAttributes\": [\n {\n \"key\": \"color\",\n \"value\": \"Gold\"\n },\n {\n \"key\": \"material\",\n \"value\": \"Plastic\"\n }\n ]\n },\n {\n \"variantId\": \"gid://shopify/ProductVariant/43729076\",\n \"quantity\": 2\n }\n ],\n \"customAttributes\": [\n {\n \"key\": \"name\",\n \"value\": \"Achilles\"\n },\n {\n \"key\": \"city\",\n \"value\": \"Troy\"\n }\n ]\n }\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation draftOrderCreate($input: DraftOrderInput!) {\n draftOrderCreate(input: $input) {\n draftOrder {\n id\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"customerId\": \"gid://shopify/Customer/544365967\",\n \"note\": \"Test draft order\",\n \"email\": \"test.user@shopify.com\",\n \"taxExempt\": true,\n \"tags\": [\"foo\", \"bar\"],\n \"shippingLine\": {\n \"title\": \"Custom Shipping\",\n \"price\": 4.55\n },\n \"shippingAddress\": {\n \"address1\": \"123 Main St\",\n \"city\": \"Waterloo\",\n \"province\": \"Ontario\",\n \"country\": \"Canada\",\n \"zip\": \"A1A 1A1\"\n },\n \"billingAddress\": {\n \"address1\": \"456 Main St\",\n \"city\": \"Toronto\",\n \"province\": \"Ontario\",\n \"country\": \"Canada\",\n \"zip\": \"Z9Z 9Z9\"\n },\n \"appliedDiscount\": {\n \"description\": \"damaged\",\n \"value\": 5.0,\n \"amount\": 5.0,\n \"valueType\": \"FIXED_AMOUNT\",\n \"title\": \"Custom\"\n },\n \"lineItems\": [{\"title\"=>\"Custom product\", \"originalUnitPrice\"=>14.99, \"quantity\"=>5, \"appliedDiscount\"=>{\"description\"=>\"wholesale\", \"value\"=>5.0, \"amount\"=>3.74, \"valueType\"=>\"PERCENTAGE\", \"title\"=>\"Fancy\"}, \"weight\"=>{\"value\"=>1, \"unit\"=>\"KILOGRAMS\"}, \"customAttributes\"=>[{\"key\"=>\"color\", \"value\"=>\"Gold\"}, {\"key\"=>\"material\", \"value\"=>\"Plastic\"}]}, {\"variantId\"=>\"gid://shopify/ProductVariant/43729076\", \"quantity\"=>2}],\n \"customAttributes\": [{\"key\"=>\"name\", \"value\"=>\"Achilles\"}, {\"key\"=>\"city\", \"value\"=>\"Troy\"}]\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<[\n \"customerId\" => \"gid://shopify/Customer/544365967\",\n \"note\" => \"Test draft order\",\n \"email\" => \"test.user@shopify.com\",\n \"taxExempt\" => true,\n \"tags\" => [\"foo\", \"bar\"],\n \"shippingLine\" => [\n \"title\" => \"Custom Shipping\",\n \"price\" => 4.55,\n ],\n \"shippingAddress\" => [\n \"address1\" => \"123 Main St\",\n \"city\" => \"Waterloo\",\n \"province\" => \"Ontario\",\n \"country\" => \"Canada\",\n \"zip\" => \"A1A 1A1\",\n ],\n \"billingAddress\" => [\n \"address1\" => \"456 Main St\",\n \"city\" => \"Toronto\",\n \"province\" => \"Ontario\",\n \"country\" => \"Canada\",\n \"zip\" => \"Z9Z 9Z9\",\n ],\n \"appliedDiscount\" => [\n \"description\" => \"damaged\",\n \"value\" => 5.0,\n \"amount\" => 5.0,\n \"valueType\" => \"FIXED_AMOUNT\",\n \"title\" => \"Custom\",\n ],\n \"lineItems\" => [{\"title\"=>\"Custom product\", \"originalUnitPrice\"=>14.99, \"quantity\"=>5, \"appliedDiscount\"=>{\"description\"=>\"wholesale\", \"value\"=>5.0, \"amount\"=>3.74, \"valueType\"=>\"PERCENTAGE\", \"title\"=>\"Fancy\"}, \"weight\"=>{\"value\"=>1, \"unit\"=>\"KILOGRAMS\"}, \"customAttributes\"=>[{\"key\"=>\"color\", \"value\"=>\"Gold\"}, {\"key\"=>\"material\", \"value\"=>\"Plastic\"}]}, {\"variantId\"=>\"gid://shopify/ProductVariant/43729076\", \"quantity\"=>2}],\n \"customAttributes\" => [{\"key\"=>\"name\", \"value\"=>\"Achilles\"}, {\"key\"=>\"city\", \"value\"=>\"Troy\"}],\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation draftOrderCreate($input: DraftOrderInput!) {\n draftOrderCreate(input: $input) {\n draftOrder {\n id\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"customerId\": \"gid://shopify/Customer/544365967\",\n \"note\": \"Test draft order\",\n \"email\": \"test.user@shopify.com\",\n \"taxExempt\": true,\n \"tags\": [\n \"foo\",\n \"bar\"\n ],\n \"shippingLine\": {\n \"title\": \"Custom Shipping\",\n \"price\": 4.55\n },\n \"shippingAddress\": {\n \"address1\": \"123 Main St\",\n \"city\": \"Waterloo\",\n \"province\": \"Ontario\",\n \"country\": \"Canada\",\n \"zip\": \"A1A 1A1\"\n },\n \"billingAddress\": {\n \"address1\": \"456 Main St\",\n \"city\": \"Toronto\",\n \"province\": \"Ontario\",\n \"country\": \"Canada\",\n \"zip\": \"Z9Z 9Z9\"\n },\n \"appliedDiscount\": {\n \"description\": \"damaged\",\n \"value\": 5.0,\n \"amount\": 5.0,\n \"valueType\": \"FIXED_AMOUNT\",\n \"title\": \"Custom\"\n },\n \"lineItems\": [\n {\n \"title\": \"Custom product\",\n \"originalUnitPrice\": 14.99,\n \"quantity\": 5,\n \"appliedDiscount\": {\n \"description\": \"wholesale\",\n \"value\": 5.0,\n \"amount\": 3.74,\n \"valueType\": \"PERCENTAGE\",\n \"title\": \"Fancy\"\n },\n \"weight\": {\n \"value\": 1,\n \"unit\": \"KILOGRAMS\"\n },\n \"customAttributes\": [\n {\n \"key\": \"color\",\n \"value\": \"Gold\"\n },\n {\n \"key\": \"material\",\n \"value\": \"Plastic\"\n }\n ]\n },\n {\n \"variantId\": \"gid://shopify/ProductVariant/43729076\",\n \"quantity\": 2\n }\n ],\n \"customAttributes\": [\n {\n \"key\": \"name\",\n \"value\": \"Achilles\"\n },\n {\n \"key\": \"city\",\n \"value\": \"Troy\"\n }\n ]\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation draftOrderCreate($input: DraftOrderInput!) {\n draftOrderCreate(input: $input) {\n draftOrder {\n id\n }\n }\n}"
input: { "input": { "customerId": "gid://shopify/Customer/544365967", "note": "Test draft order", "email": "test.user@shopify.com", "taxExempt": true, "tags": [ "foo", "bar" ], "shippingLine": { "title": "Custom Shipping", "price": 4.55 }, "shippingAddress": { "address1": "123 Main St", "city": "Waterloo", "province": "Ontario", "country": "Canada", "zip": "A1A 1A1" }, "billingAddress": { "address1": "456 Main St", "city": "Toronto", "province": "Ontario", "country": "Canada", "zip": "Z9Z 9Z9" }, "appliedDiscount": { "description": "damaged", "value": 5.0, "amount": 5.0, "valueType": "FIXED_AMOUNT", "title": "Custom" }, "lineItems": [ { "title": "Custom product", "originalUnitPrice": 14.99, "quantity": 5, "appliedDiscount": { "description": "wholesale", "value": 5.0, "amount": 3.74, "valueType": "PERCENTAGE", "title": "Fancy" }, "weight": { "value": 1, "unit": "KILOGRAMS" }, "customAttributes": [ { "key": "color", "value": "Gold" }, { "key": "material", "value": "Plastic" } ] }, { "variantId": "gid://shopify/ProductVariant/43729076", "quantity": 2 } ], "customAttributes": [ { "key": "name", "value": "Achilles" }, { "key": "city", "value": "Troy" } ] } }
response: { "data": { "draftOrderCreate": { "draftOrder": { "id": "gid://shopify/DraftOrder/1069920564" } } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/unstable/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation draftOrderCreate($input: DraftOrderInput!) { draftOrderCreate(input: $input) { draftOrder { id marketName presentmentCurrencyCode totalPriceSet { shopMoney { amount currencyCode } presentmentMoney { amount currencyCode } } } } }\",\n \"variables\": {\n \"input\": {\n \"customerId\": \"gid://shopify/Customer/544365967\",\n \"note\": \"Test draft order\",\n \"email\": \"test.user@shopify.com\",\n \"taxExempt\": true,\n \"tags\": [\n \"foo\",\n \"bar\"\n ],\n \"shippingLine\": {\n \"title\": \"Custom Shipping\",\n \"price\": 4.55\n },\n \"shippingAddress\": {\n \"address1\": \"123 Main St\",\n \"city\": \"Waterloo\",\n \"province\": \"Ontario\",\n \"country\": \"Canada\",\n \"zip\": \"A1A 1A1\"\n },\n \"billingAddress\": {\n \"address1\": \"456 Main St\",\n \"city\": \"Toronto\",\n \"province\": \"Ontario\",\n \"country\": \"Canada\",\n \"zip\": \"Z9Z 9Z9\"\n },\n \"appliedDiscount\": {\n \"description\": \"damaged\",\n \"value\": 5.0,\n \"amount\": 5.0,\n \"valueType\": \"FIXED_AMOUNT\",\n \"title\": \"Custom\"\n },\n \"lineItems\": [\n {\n \"title\": \"Custom product\",\n \"originalUnitPrice\": 14.99,\n \"quantity\": 5,\n \"appliedDiscount\": {\n \"description\": \"wholesale\",\n \"value\": 5.0,\n \"amount\": 3.74,\n \"valueType\": \"PERCENTAGE\",\n \"title\": \"Fancy\"\n },\n \"weight\": {\n \"value\": 1,\n \"unit\": \"KILOGRAMS\"\n },\n \"customAttributes\": [\n {\n \"key\": \"color\",\n \"value\": \"Gold\"\n },\n {\n \"key\": \"material\",\n \"value\": \"Plastic\"\n }\n ]\n },\n {\n \"variantId\": \"gid://shopify/ProductVariant/43729076\",\n \"quantity\": 2\n }\n ],\n \"presentmentCurrencyCode\": \"CAD\",\n \"customAttributes\": [\n {\n \"key\": \"name\",\n \"value\": \"Achilles\"\n },\n {\n \"key\": \"city\",\n \"value\": \"Troy\"\n }\n ]\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation draftOrderCreate($input: DraftOrderInput!) {\n draftOrderCreate(input: $input) {\n draftOrder {\n id\n marketName\n presentmentCurrencyCode\n totalPriceSet {\n shopMoney {\n amount\n currencyCode\n }\n presentmentMoney {\n amount\n currencyCode\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"customerId\": \"gid://shopify/Customer/544365967\",\n \"note\": \"Test draft order\",\n \"email\": \"test.user@shopify.com\",\n \"taxExempt\": true,\n \"tags\": [\n \"foo\",\n \"bar\"\n ],\n \"shippingLine\": {\n \"title\": \"Custom Shipping\",\n \"price\": 4.55\n },\n \"shippingAddress\": {\n \"address1\": \"123 Main St\",\n \"city\": \"Waterloo\",\n \"province\": \"Ontario\",\n \"country\": \"Canada\",\n \"zip\": \"A1A 1A1\"\n },\n \"billingAddress\": {\n \"address1\": \"456 Main St\",\n \"city\": \"Toronto\",\n \"province\": \"Ontario\",\n \"country\": \"Canada\",\n \"zip\": \"Z9Z 9Z9\"\n },\n \"appliedDiscount\": {\n \"description\": \"damaged\",\n \"value\": 5.0,\n \"amount\": 5.0,\n \"valueType\": \"FIXED_AMOUNT\",\n \"title\": \"Custom\"\n },\n \"lineItems\": [\n {\n \"title\": \"Custom product\",\n \"originalUnitPrice\": 14.99,\n \"quantity\": 5,\n \"appliedDiscount\": {\n \"description\": \"wholesale\",\n \"value\": 5.0,\n \"amount\": 3.74,\n \"valueType\": \"PERCENTAGE\",\n \"title\": \"Fancy\"\n },\n \"weight\": {\n \"value\": 1,\n \"unit\": \"KILOGRAMS\"\n },\n \"customAttributes\": [\n {\n \"key\": \"color\",\n \"value\": \"Gold\"\n },\n {\n \"key\": \"material\",\n \"value\": \"Plastic\"\n }\n ]\n },\n {\n \"variantId\": \"gid://shopify/ProductVariant/43729076\",\n \"quantity\": 2\n }\n ],\n \"presentmentCurrencyCode\": \"CAD\",\n \"customAttributes\": [\n {\n \"key\": \"name\",\n \"value\": \"Achilles\"\n },\n {\n \"key\": \"city\",\n \"value\": \"Troy\"\n }\n ]\n }\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation draftOrderCreate($input: DraftOrderInput!) {\n draftOrderCreate(input: $input) {\n draftOrder {\n id\n marketName\n presentmentCurrencyCode\n totalPriceSet {\n shopMoney {\n amount\n currencyCode\n }\n presentmentMoney {\n amount\n currencyCode\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"customerId\": \"gid://shopify/Customer/544365967\",\n \"note\": \"Test draft order\",\n \"email\": \"test.user@shopify.com\",\n \"taxExempt\": true,\n \"tags\": [\"foo\", \"bar\"],\n \"shippingLine\": {\n \"title\": \"Custom Shipping\",\n \"price\": 4.55\n },\n \"shippingAddress\": {\n \"address1\": \"123 Main St\",\n \"city\": \"Waterloo\",\n \"province\": \"Ontario\",\n \"country\": \"Canada\",\n \"zip\": \"A1A 1A1\"\n },\n \"billingAddress\": {\n \"address1\": \"456 Main St\",\n \"city\": \"Toronto\",\n \"province\": \"Ontario\",\n \"country\": \"Canada\",\n \"zip\": \"Z9Z 9Z9\"\n },\n \"appliedDiscount\": {\n \"description\": \"damaged\",\n \"value\": 5.0,\n \"amount\": 5.0,\n \"valueType\": \"FIXED_AMOUNT\",\n \"title\": \"Custom\"\n },\n \"lineItems\": [{\"title\"=>\"Custom product\", \"originalUnitPrice\"=>14.99, \"quantity\"=>5, \"appliedDiscount\"=>{\"description\"=>\"wholesale\", \"value\"=>5.0, \"amount\"=>3.74, \"valueType\"=>\"PERCENTAGE\", \"title\"=>\"Fancy\"}, \"weight\"=>{\"value\"=>1, \"unit\"=>\"KILOGRAMS\"}, \"customAttributes\"=>[{\"key\"=>\"color\", \"value\"=>\"Gold\"}, {\"key\"=>\"material\", \"value\"=>\"Plastic\"}]}, {\"variantId\"=>\"gid://shopify/ProductVariant/43729076\", \"quantity\"=>2}],\n \"presentmentCurrencyCode\": \"CAD\",\n \"customAttributes\": [{\"key\"=>\"name\", \"value\"=>\"Achilles\"}, {\"key\"=>\"city\", \"value\"=>\"Troy\"}]\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<[\n \"customerId\" => \"gid://shopify/Customer/544365967\",\n \"note\" => \"Test draft order\",\n \"email\" => \"test.user@shopify.com\",\n \"taxExempt\" => true,\n \"tags\" => [\"foo\", \"bar\"],\n \"shippingLine\" => [\n \"title\" => \"Custom Shipping\",\n \"price\" => 4.55,\n ],\n \"shippingAddress\" => [\n \"address1\" => \"123 Main St\",\n \"city\" => \"Waterloo\",\n \"province\" => \"Ontario\",\n \"country\" => \"Canada\",\n \"zip\" => \"A1A 1A1\",\n ],\n \"billingAddress\" => [\n \"address1\" => \"456 Main St\",\n \"city\" => \"Toronto\",\n \"province\" => \"Ontario\",\n \"country\" => \"Canada\",\n \"zip\" => \"Z9Z 9Z9\",\n ],\n \"appliedDiscount\" => [\n \"description\" => \"damaged\",\n \"value\" => 5.0,\n \"amount\" => 5.0,\n \"valueType\" => \"FIXED_AMOUNT\",\n \"title\" => \"Custom\",\n ],\n \"lineItems\" => [{\"title\"=>\"Custom product\", \"originalUnitPrice\"=>14.99, \"quantity\"=>5, \"appliedDiscount\"=>{\"description\"=>\"wholesale\", \"value\"=>5.0, \"amount\"=>3.74, \"valueType\"=>\"PERCENTAGE\", \"title\"=>\"Fancy\"}, \"weight\"=>{\"value\"=>1, \"unit\"=>\"KILOGRAMS\"}, \"customAttributes\"=>[{\"key\"=>\"color\", \"value\"=>\"Gold\"}, {\"key\"=>\"material\", \"value\"=>\"Plastic\"}]}, {\"variantId\"=>\"gid://shopify/ProductVariant/43729076\", \"quantity\"=>2}],\n \"presentmentCurrencyCode\" => \"CAD\",\n \"customAttributes\" => [{\"key\"=>\"name\", \"value\"=>\"Achilles\"}, {\"key\"=>\"city\", \"value\"=>\"Troy\"}],\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation draftOrderCreate($input: DraftOrderInput!) {\n draftOrderCreate(input: $input) {\n draftOrder {\n id\n marketName\n presentmentCurrencyCode\n totalPriceSet {\n shopMoney {\n amount\n currencyCode\n }\n presentmentMoney {\n amount\n currencyCode\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"customerId\": \"gid://shopify/Customer/544365967\",\n \"note\": \"Test draft order\",\n \"email\": \"test.user@shopify.com\",\n \"taxExempt\": true,\n \"tags\": [\n \"foo\",\n \"bar\"\n ],\n \"shippingLine\": {\n \"title\": \"Custom Shipping\",\n \"price\": 4.55\n },\n \"shippingAddress\": {\n \"address1\": \"123 Main St\",\n \"city\": \"Waterloo\",\n \"province\": \"Ontario\",\n \"country\": \"Canada\",\n \"zip\": \"A1A 1A1\"\n },\n \"billingAddress\": {\n \"address1\": \"456 Main St\",\n \"city\": \"Toronto\",\n \"province\": \"Ontario\",\n \"country\": \"Canada\",\n \"zip\": \"Z9Z 9Z9\"\n },\n \"appliedDiscount\": {\n \"description\": \"damaged\",\n \"value\": 5.0,\n \"amount\": 5.0,\n \"valueType\": \"FIXED_AMOUNT\",\n \"title\": \"Custom\"\n },\n \"lineItems\": [\n {\n \"title\": \"Custom product\",\n \"originalUnitPrice\": 14.99,\n \"quantity\": 5,\n \"appliedDiscount\": {\n \"description\": \"wholesale\",\n \"value\": 5.0,\n \"amount\": 3.74,\n \"valueType\": \"PERCENTAGE\",\n \"title\": \"Fancy\"\n },\n \"weight\": {\n \"value\": 1,\n \"unit\": \"KILOGRAMS\"\n },\n \"customAttributes\": [\n {\n \"key\": \"color\",\n \"value\": \"Gold\"\n },\n {\n \"key\": \"material\",\n \"value\": \"Plastic\"\n }\n ]\n },\n {\n \"variantId\": \"gid://shopify/ProductVariant/43729076\",\n \"quantity\": 2\n }\n ],\n \"presentmentCurrencyCode\": \"CAD\",\n \"customAttributes\": [\n {\n \"key\": \"name\",\n \"value\": \"Achilles\"\n },\n {\n \"key\": \"city\",\n \"value\": \"Troy\"\n }\n ]\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation draftOrderCreate($input: DraftOrderInput!) {\n draftOrderCreate(input: $input) {\n draftOrder {\n id\n marketName\n presentmentCurrencyCode\n totalPriceSet {\n shopMoney {\n amount\n currencyCode\n }\n presentmentMoney {\n amount\n currencyCode\n }\n }\n }\n }\n}"
input: { "input": { "customerId": "gid://shopify/Customer/544365967", "note": "Test draft order", "email": "test.user@shopify.com", "taxExempt": true, "tags": [ "foo", "bar" ], "shippingLine": { "title": "Custom Shipping", "price": 4.55 }, "shippingAddress": { "address1": "123 Main St", "city": "Waterloo", "province": "Ontario", "country": "Canada", "zip": "A1A 1A1" }, "billingAddress": { "address1": "456 Main St", "city": "Toronto", "province": "Ontario", "country": "Canada", "zip": "Z9Z 9Z9" }, "appliedDiscount": { "description": "damaged", "value": 5.0, "amount": 5.0, "valueType": "FIXED_AMOUNT", "title": "Custom" }, "lineItems": [ { "title": "Custom product", "originalUnitPrice": 14.99, "quantity": 5, "appliedDiscount": { "description": "wholesale", "value": 5.0, "amount": 3.74, "valueType": "PERCENTAGE", "title": "Fancy" }, "weight": { "value": 1, "unit": "KILOGRAMS" }, "customAttributes": [ { "key": "color", "value": "Gold" }, { "key": "material", "value": "Plastic" } ] }, { "variantId": "gid://shopify/ProductVariant/43729076", "quantity": 2 } ], "presentmentCurrencyCode": "CAD", "customAttributes": [ { "key": "name", "value": "Achilles" }, { "key": "city", "value": "Troy" } ] } }
response: { "data": { "draftOrderCreate": { "draftOrder": { "id": "gid://shopify/DraftOrder/1069920541", "marketName": "Primary market", "presentmentCurrencyCode": "CAD", "totalPriceSet": { "shopMoney": { "amount": "95.29", "currencyCode": "USD" }, "presentmentMoney": { "amount": "119.11", "currencyCode": "CAD" } } } } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/unstable/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation DraftOrderCreate($input: DraftOrderInput!) { draftOrderCreate(input: $input) { draftOrder { id note2 email taxesIncluded currencyCode invoiceSentAt createdAt updatedAt taxExempt completedAt name status lineItems(first: 10) { edges { node { id variant { id title } product { id } name sku vendor quantity requiresShipping taxable isGiftCard fulfillmentService { type } weight { unit value } taxLines { title source rate ratePercentage priceSet { presentmentMoney { amount currencyCode } shopMoney { amount currencyCode } } } appliedDiscount { title value valueType } name custom id } } } shippingAddress { firstName address1 phone city zip province country lastName address2 company latitude longitude name country countryCodeV2 provinceCode } billingAddress { firstName address1 phone city zip province country lastName address2 company latitude longitude name country countryCodeV2 provinceCode } invoiceUrl appliedDiscount { title value valueType } order { id customAttributes { key value } } shippingLine { id title carrierIdentifier custom code deliveryCategory source discountedPriceSet { presentmentMoney { amount currencyCode } shopMoney { amount currencyCode } } } taxLines { channelLiable priceSet { presentmentMoney { amount currencyCode } shopMoney { amount currencyCode } } rate ratePercentage source title } tags customer { id email smsMarketingConsent { consentCollectedFrom consentUpdatedAt marketingOptInLevel marketingState } emailMarketingConsent { consentUpdatedAt marketingOptInLevel marketingState } createdAt updatedAt firstName lastName state amountSpent { amount currencyCode } lastOrder { id name currencyCode } note verifiedEmail multipassIdentifier taxExempt tags phone taxExemptions defaultAddress { id firstName lastName company address1 address2 city province country zip phone name provinceCode countryCodeV2 } } } userErrors { field message } } }\",\n \"variables\": {\n \"input\": {\n \"customerId\": \"gid://shopify/Customer/544365967\",\n \"lineItems\": [\n {\n \"variantId\": \"gid://shopify/ProductVariant/43729076\",\n \"quantity\": 2\n }\n ]\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation DraftOrderCreate($input: DraftOrderInput!) {\n draftOrderCreate(input: $input) {\n draftOrder {\n id\n note2\n email\n taxesIncluded\n currencyCode\n invoiceSentAt\n createdAt\n updatedAt\n taxExempt\n completedAt\n name\n status\n lineItems(first: 10) {\n edges {\n node {\n id\n variant {\n id\n title\n }\n product {\n id\n }\n name\n sku\n vendor\n quantity\n requiresShipping\n taxable\n isGiftCard\n fulfillmentService {\n type\n }\n weight {\n unit\n value\n }\n taxLines {\n title\n source\n rate\n ratePercentage\n priceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n }\n appliedDiscount {\n title\n value\n valueType\n }\n name\n custom\n id\n }\n }\n }\n shippingAddress {\n firstName\n address1\n phone\n city\n zip\n province\n country\n lastName\n address2\n company\n latitude\n longitude\n name\n country\n countryCodeV2\n provinceCode\n }\n billingAddress {\n firstName\n address1\n phone\n city\n zip\n province\n country\n lastName\n address2\n company\n latitude\n longitude\n name\n country\n countryCodeV2\n provinceCode\n }\n invoiceUrl\n appliedDiscount {\n title\n value\n valueType\n }\n order {\n id\n customAttributes {\n key\n value\n }\n }\n shippingLine {\n id\n title\n carrierIdentifier\n custom\n code\n deliveryCategory\n source\n discountedPriceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n }\n taxLines {\n channelLiable\n priceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n rate\n ratePercentage\n source\n title\n }\n tags\n customer {\n id\n email\n smsMarketingConsent {\n consentCollectedFrom\n consentUpdatedAt\n marketingOptInLevel\n marketingState\n }\n emailMarketingConsent {\n consentUpdatedAt\n marketingOptInLevel\n marketingState\n }\n createdAt\n updatedAt\n firstName\n lastName\n state\n amountSpent {\n amount\n currencyCode\n }\n lastOrder {\n id\n name\n currencyCode\n }\n note\n verifiedEmail\n multipassIdentifier\n taxExempt\n tags\n phone\n taxExemptions\n defaultAddress {\n id\n firstName\n lastName\n company\n address1\n address2\n city\n province\n country\n zip\n phone\n name\n provinceCode\n countryCodeV2\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"customerId\": \"gid://shopify/Customer/544365967\",\n \"lineItems\": [\n {\n \"variantId\": \"gid://shopify/ProductVariant/43729076\",\n \"quantity\": 2\n }\n ]\n }\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation DraftOrderCreate($input: DraftOrderInput!) {\n draftOrderCreate(input: $input) {\n draftOrder {\n id\n note2\n email\n taxesIncluded\n currencyCode\n invoiceSentAt\n createdAt\n updatedAt\n taxExempt\n completedAt\n name\n status\n lineItems(first: 10) {\n edges {\n node {\n id\n variant {\n id\n title\n }\n product {\n id\n }\n name\n sku\n vendor\n quantity\n requiresShipping\n taxable\n isGiftCard\n fulfillmentService {\n type\n }\n weight {\n unit\n value\n }\n taxLines {\n title\n source\n rate\n ratePercentage\n priceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n }\n appliedDiscount {\n title\n value\n valueType\n }\n name\n custom\n id\n }\n }\n }\n shippingAddress {\n firstName\n address1\n phone\n city\n zip\n province\n country\n lastName\n address2\n company\n latitude\n longitude\n name\n country\n countryCodeV2\n provinceCode\n }\n billingAddress {\n firstName\n address1\n phone\n city\n zip\n province\n country\n lastName\n address2\n company\n latitude\n longitude\n name\n country\n countryCodeV2\n provinceCode\n }\n invoiceUrl\n appliedDiscount {\n title\n value\n valueType\n }\n order {\n id\n customAttributes {\n key\n value\n }\n }\n shippingLine {\n id\n title\n carrierIdentifier\n custom\n code\n deliveryCategory\n source\n discountedPriceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n }\n taxLines {\n channelLiable\n priceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n rate\n ratePercentage\n source\n title\n }\n tags\n customer {\n id\n email\n smsMarketingConsent {\n consentCollectedFrom\n consentUpdatedAt\n marketingOptInLevel\n marketingState\n }\n emailMarketingConsent {\n consentUpdatedAt\n marketingOptInLevel\n marketingState\n }\n createdAt\n updatedAt\n firstName\n lastName\n state\n amountSpent {\n amount\n currencyCode\n }\n lastOrder {\n id\n name\n currencyCode\n }\n note\n verifiedEmail\n multipassIdentifier\n taxExempt\n tags\n phone\n taxExemptions\n defaultAddress {\n id\n firstName\n lastName\n company\n address1\n address2\n city\n province\n country\n zip\n phone\n name\n provinceCode\n countryCodeV2\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"customerId\": \"gid://shopify/Customer/544365967\",\n \"lineItems\": [{\"variantId\"=>\"gid://shopify/ProductVariant/43729076\", \"quantity\"=>2}]\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<[\n \"customerId\" => \"gid://shopify/Customer/544365967\",\n \"lineItems\" => [{\"variantId\"=>\"gid://shopify/ProductVariant/43729076\", \"quantity\"=>2}],\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation DraftOrderCreate($input: DraftOrderInput!) {\n draftOrderCreate(input: $input) {\n draftOrder {\n id\n note2\n email\n taxesIncluded\n currencyCode\n invoiceSentAt\n createdAt\n updatedAt\n taxExempt\n completedAt\n name\n status\n lineItems(first: 10) {\n edges {\n node {\n id\n variant {\n id\n title\n }\n product {\n id\n }\n name\n sku\n vendor\n quantity\n requiresShipping\n taxable\n isGiftCard\n fulfillmentService {\n type\n }\n weight {\n unit\n value\n }\n taxLines {\n title\n source\n rate\n ratePercentage\n priceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n }\n appliedDiscount {\n title\n value\n valueType\n }\n name\n custom\n id\n }\n }\n }\n shippingAddress {\n firstName\n address1\n phone\n city\n zip\n province\n country\n lastName\n address2\n company\n latitude\n longitude\n name\n country\n countryCodeV2\n provinceCode\n }\n billingAddress {\n firstName\n address1\n phone\n city\n zip\n province\n country\n lastName\n address2\n company\n latitude\n longitude\n name\n country\n countryCodeV2\n provinceCode\n }\n invoiceUrl\n appliedDiscount {\n title\n value\n valueType\n }\n order {\n id\n customAttributes {\n key\n value\n }\n }\n shippingLine {\n id\n title\n carrierIdentifier\n custom\n code\n deliveryCategory\n source\n discountedPriceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n }\n taxLines {\n channelLiable\n priceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n rate\n ratePercentage\n source\n title\n }\n tags\n customer {\n id\n email\n smsMarketingConsent {\n consentCollectedFrom\n consentUpdatedAt\n marketingOptInLevel\n marketingState\n }\n emailMarketingConsent {\n consentUpdatedAt\n marketingOptInLevel\n marketingState\n }\n createdAt\n updatedAt\n firstName\n lastName\n state\n amountSpent {\n amount\n currencyCode\n }\n lastOrder {\n id\n name\n currencyCode\n }\n note\n verifiedEmail\n multipassIdentifier\n taxExempt\n tags\n phone\n taxExemptions\n defaultAddress {\n id\n firstName\n lastName\n company\n address1\n address2\n city\n province\n country\n zip\n phone\n name\n provinceCode\n countryCodeV2\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"customerId\": \"gid://shopify/Customer/544365967\",\n \"lineItems\": [\n {\n \"variantId\": \"gid://shopify/ProductVariant/43729076\",\n \"quantity\": 2\n }\n ]\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation DraftOrderCreate($input: DraftOrderInput!) {\n draftOrderCreate(input: $input) {\n draftOrder {\n id\n note2\n email\n taxesIncluded\n currencyCode\n invoiceSentAt\n createdAt\n updatedAt\n taxExempt\n completedAt\n name\n status\n lineItems(first: 10) {\n edges {\n node {\n id\n variant {\n id\n title\n }\n product {\n id\n }\n name\n sku\n vendor\n quantity\n requiresShipping\n taxable\n isGiftCard\n fulfillmentService {\n type\n }\n weight {\n unit\n value\n }\n taxLines {\n title\n source\n rate\n ratePercentage\n priceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n }\n appliedDiscount {\n title\n value\n valueType\n }\n name\n custom\n id\n }\n }\n }\n shippingAddress {\n firstName\n address1\n phone\n city\n zip\n province\n country\n lastName\n address2\n company\n latitude\n longitude\n name\n country\n countryCodeV2\n provinceCode\n }\n billingAddress {\n firstName\n address1\n phone\n city\n zip\n province\n country\n lastName\n address2\n company\n latitude\n longitude\n name\n country\n countryCodeV2\n provinceCode\n }\n invoiceUrl\n appliedDiscount {\n title\n value\n valueType\n }\n order {\n id\n customAttributes {\n key\n value\n }\n }\n shippingLine {\n id\n title\n carrierIdentifier\n custom\n code\n deliveryCategory\n source\n discountedPriceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n }\n taxLines {\n channelLiable\n priceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n rate\n ratePercentage\n source\n title\n }\n tags\n customer {\n id\n email\n smsMarketingConsent {\n consentCollectedFrom\n consentUpdatedAt\n marketingOptInLevel\n marketingState\n }\n emailMarketingConsent {\n consentUpdatedAt\n marketingOptInLevel\n marketingState\n }\n createdAt\n updatedAt\n firstName\n lastName\n state\n amountSpent {\n amount\n currencyCode\n }\n lastOrder {\n id\n name\n currencyCode\n }\n note\n verifiedEmail\n multipassIdentifier\n taxExempt\n tags\n phone\n taxExemptions\n defaultAddress {\n id\n firstName\n lastName\n company\n address1\n address2\n city\n province\n country\n zip\n phone\n name\n provinceCode\n countryCodeV2\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n}"
input: { "input": { "customerId": "gid://shopify/Customer/544365967", "lineItems": [ { "variantId": "gid://shopify/ProductVariant/43729076", "quantity": 2 } ] } }
response: { "data": { "draftOrderCreate": { "draftOrder": { "id": "gid://shopify/DraftOrder/1069920482", "note2": null, "email": "bob@example.com", "taxesIncluded": false, "currencyCode": "USD", "invoiceSentAt": null, "createdAt": "2024-11-05T17:06:32Z", "updatedAt": "2024-11-05T17:06:32Z", "taxExempt": false, "completedAt": null, "name": "#D11", "status": "OPEN", "lineItems": { "edges": [ { "node": { "id": "gid://shopify/DraftOrderLineItem/1066630390", "variant": { "id": "gid://shopify/ProductVariant/43729076", "title": "151cm" }, "product": { "id": "gid://shopify/Product/108828309" }, "name": "Draft - 151cm", "sku": "draft-151", "vendor": "Arbor", "quantity": 2, "requiresShipping": true, "taxable": true, "isGiftCard": false, "fulfillmentService": { "type": "MANUAL" }, "weight": { "unit": "KILOGRAMS", "value": 1.0 }, "taxLines": [ { "title": "GST", "source": null, "rate": 0.07, "ratePercentage": 7.0, "priceSet": { "presentmentMoney": { "amount": "1.81", "currencyCode": "CAD" }, "shopMoney": { "amount": "1.81", "currencyCode": "USD" } } }, { "title": "PST", "source": null, "rate": 0.08, "ratePercentage": 8.0, "priceSet": { "presentmentMoney": { "amount": "2.08", "currencyCode": "CAD" }, "shopMoney": { "amount": "2.08", "currencyCode": "USD" } } } ], "appliedDiscount": null, "custom": false } } ] }, "shippingAddress": null, "billingAddress": null, "invoiceUrl": "https://www.snowdevil.ca/26371970/invoices/de1ceff23e969c3286923e42184302cc", "appliedDiscount": null, "order": null, "shippingLine": null, "taxLines": [ { "channelLiable": null, "priceSet": { "presentmentMoney": { "amount": "1.81", "currencyCode": "CAD" }, "shopMoney": { "amount": "1.81", "currencyCode": "USD" } }, "rate": 0.07, "ratePercentage": 7.0, "source": null, "title": "GST" }, { "channelLiable": null, "priceSet": { "presentmentMoney": { "amount": "2.08", "currencyCode": "CAD" }, "shopMoney": { "amount": "2.08", "currencyCode": "USD" } }, "rate": 0.08, "ratePercentage": 8.0, "source": null, "title": "PST" } ], "tags": [], "customer": { "id": "gid://shopify/Customer/544365967", "email": "bob@example.com", "smsMarketingConsent": { "consentCollectedFrom": "OTHER", "consentUpdatedAt": "2021-06-16T17:31:44Z", "marketingOptInLevel": "SINGLE_OPT_IN", "marketingState": "SUBSCRIBED" }, "emailMarketingConsent": { "consentUpdatedAt": "2005-06-16T15:00:11Z", "marketingOptInLevel": "SINGLE_OPT_IN", "marketingState": "SUBSCRIBED" }, "createdAt": "2005-06-15T15:57:11Z", "updatedAt": "2005-06-16T15:57:11Z", "firstName": "Bob", "lastName": "Bobsen", "state": "ENABLED", "amountSpent": { "amount": "8305.6", "currencyCode": "USD" }, "lastOrder": null, "note": null, "verifiedEmail": true, "multipassIdentifier": null, "taxExempt": false, "tags": [ "Bob", "Canadian", "Léon", "Noël" ], "phone": "+13125551212", "taxExemptions": [], "defaultAddress": { "id": "gid://shopify/MailingAddress/544365967?model_name=CustomerAddress", "firstName": "Bob", "lastName": "Bobsen", "company": "", "address1": "123 Amoebobacterieae St", "address2": "", "city": "Ottawa", "province": "Ontario", "country": "Canada", "zip": "K2P0V6", "phone": "+1(613)555-1212", "name": "Bob Bobsen", "provinceCode": "ON", "countryCodeV2": "CA" } } }, "userErrors": [] } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/unstable/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation createDraftOrderMetafields($input: DraftOrderInput!) { draftOrderCreate(input: $input) { draftOrder { id metafields(first: 3) { edges { node { id namespace key value } } } } userErrors { message field } } }\",\n \"variables\": {\n \"input\": {\n \"metafields\": [\n {\n \"namespace\": \"my_field\",\n \"key\": \"delivery_instructions\",\n \"type\": \"single_line_text_field\",\n \"value\": \"leave on back porch\"\n }\n ],\n \"lineItems\": [\n {\n \"title\": \"small wheel\",\n \"quantity\": 1,\n \"originalUnitPrice\": \"10\"\n }\n ]\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation createDraftOrderMetafields($input: DraftOrderInput!) {\n draftOrderCreate(input: $input) {\n draftOrder {\n id\n metafields(first: 3) {\n edges {\n node {\n id\n namespace\n key\n value\n }\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"metafields\": [\n {\n \"namespace\": \"my_field\",\n \"key\": \"delivery_instructions\",\n \"type\": \"single_line_text_field\",\n \"value\": \"leave on back porch\"\n }\n ],\n \"lineItems\": [\n {\n \"title\": \"small wheel\",\n \"quantity\": 1,\n \"originalUnitPrice\": \"10\"\n }\n ]\n }\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation createDraftOrderMetafields($input: DraftOrderInput!) {\n draftOrderCreate(input: $input) {\n draftOrder {\n id\n metafields(first: 3) {\n edges {\n node {\n id\n namespace\n key\n value\n }\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"metafields\": [{\"namespace\"=>\"my_field\", \"key\"=>\"delivery_instructions\", \"type\"=>\"single_line_text_field\", \"value\"=>\"leave on back porch\"}],\n \"lineItems\": [{\"title\"=>\"small wheel\", \"quantity\"=>1, \"originalUnitPrice\"=>\"10\"}]\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<[\n \"metafields\" => [{\"namespace\"=>\"my_field\", \"key\"=>\"delivery_instructions\", \"type\"=>\"single_line_text_field\", \"value\"=>\"leave on back porch\"}],\n \"lineItems\" => [{\"title\"=>\"small wheel\", \"quantity\"=>1, \"originalUnitPrice\"=>\"10\"}],\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation createDraftOrderMetafields($input: DraftOrderInput!) {\n draftOrderCreate(input: $input) {\n draftOrder {\n id\n metafields(first: 3) {\n edges {\n node {\n id\n namespace\n key\n value\n }\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"metafields\": [\n {\n \"namespace\": \"my_field\",\n \"key\": \"delivery_instructions\",\n \"type\": \"single_line_text_field\",\n \"value\": \"leave on back porch\"\n }\n ],\n \"lineItems\": [\n {\n \"title\": \"small wheel\",\n \"quantity\": 1,\n \"originalUnitPrice\": \"10\"\n }\n ]\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation createDraftOrderMetafields($input: DraftOrderInput!) {\n draftOrderCreate(input: $input) {\n draftOrder {\n id\n metafields(first: 3) {\n edges {\n node {\n id\n namespace\n key\n value\n }\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n}"
input: { "input": { "metafields": [ { "namespace": "my_field", "key": "delivery_instructions", "type": "single_line_text_field", "value": "leave on back porch" } ], "lineItems": [ { "title": "small wheel", "quantity": 1, "originalUnitPrice": "10" } ] } }
response: { "data": { "draftOrderCreate": { "draftOrder": { "id": "gid://shopify/DraftOrder/1069920582", "metafields": { "edges": [ { "node": { "id": "gid://shopify/Metafield/1069229056", "namespace": "my_field", "key": "delivery_instructions", "value": "leave on back porch" } } ] } }, "userErrors": [] } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/unstable/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation draftOrderCreate($input: DraftOrderInput!) { draftOrderCreate(input: $input) { draftOrder { id } userErrors { message field } } }\",\n \"variables\": {\n \"input\": {\n \"purchasingEntity\": {\n \"purchasingCompany\": {\n \"companyId\": \"gid://shopify/Company/426793626\",\n \"companyLocationId\": \"gid://shopify/CompanyLocation/441870438\",\n \"companyContactId\": \"gid://shopify/CompanyContact/207808057\"\n }\n },\n \"note\": \"Test B2B draft order\",\n \"email\": \"test.b2b.user@shopify.com\",\n \"shippingLine\": {\n \"title\": \"Custom Shipping\",\n \"price\": 4.55\n },\n \"shippingAddress\": {\n \"address1\": \"555 Main St\",\n \"city\": \"Waterloo\",\n \"province\": \"Ontario\",\n \"country\": \"Canada\",\n \"zip\": \"B1B 1B1\"\n },\n \"billingAddress\": {\n \"address1\": \"556 Main St\",\n \"city\": \"Toronto\",\n \"province\": \"Ontario\",\n \"country\": \"Canada\",\n \"zip\": \"D9D DZD\"\n },\n \"lineItems\": [\n {\n \"variantId\": \"gid://shopify/ProductVariant/43729076\",\n \"quantity\": 5\n }\n ]\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation draftOrderCreate($input: DraftOrderInput!) {\n draftOrderCreate(input: $input) {\n draftOrder {\n id\n }\n userErrors {\n message\n field\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"purchasingEntity\": {\n \"purchasingCompany\": {\n \"companyId\": \"gid://shopify/Company/426793626\",\n \"companyLocationId\": \"gid://shopify/CompanyLocation/441870438\",\n \"companyContactId\": \"gid://shopify/CompanyContact/207808057\"\n }\n },\n \"note\": \"Test B2B draft order\",\n \"email\": \"test.b2b.user@shopify.com\",\n \"shippingLine\": {\n \"title\": \"Custom Shipping\",\n \"price\": 4.55\n },\n \"shippingAddress\": {\n \"address1\": \"555 Main St\",\n \"city\": \"Waterloo\",\n \"province\": \"Ontario\",\n \"country\": \"Canada\",\n \"zip\": \"B1B 1B1\"\n },\n \"billingAddress\": {\n \"address1\": \"556 Main St\",\n \"city\": \"Toronto\",\n \"province\": \"Ontario\",\n \"country\": \"Canada\",\n \"zip\": \"D9D DZD\"\n },\n \"lineItems\": [\n {\n \"variantId\": \"gid://shopify/ProductVariant/43729076\",\n \"quantity\": 5\n }\n ]\n }\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation draftOrderCreate($input: DraftOrderInput!) {\n draftOrderCreate(input: $input) {\n draftOrder {\n id\n }\n userErrors {\n message\n field\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"purchasingEntity\": {\n \"purchasingCompany\": {\n \"companyId\": \"gid://shopify/Company/426793626\",\n \"companyLocationId\": \"gid://shopify/CompanyLocation/441870438\",\n \"companyContactId\": \"gid://shopify/CompanyContact/207808057\"\n }\n },\n \"note\": \"Test B2B draft order\",\n \"email\": \"test.b2b.user@shopify.com\",\n \"shippingLine\": {\n \"title\": \"Custom Shipping\",\n \"price\": 4.55\n },\n \"shippingAddress\": {\n \"address1\": \"555 Main St\",\n \"city\": \"Waterloo\",\n \"province\": \"Ontario\",\n \"country\": \"Canada\",\n \"zip\": \"B1B 1B1\"\n },\n \"billingAddress\": {\n \"address1\": \"556 Main St\",\n \"city\": \"Toronto\",\n \"province\": \"Ontario\",\n \"country\": \"Canada\",\n \"zip\": \"D9D DZD\"\n },\n \"lineItems\": [{\"variantId\"=>\"gid://shopify/ProductVariant/43729076\", \"quantity\"=>5}]\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<[\n \"purchasingEntity\" => [\n \"purchasingCompany\" => [\n \"companyId\" => \"gid://shopify/Company/426793626\",\n \"companyLocationId\" => \"gid://shopify/CompanyLocation/441870438\",\n \"companyContactId\" => \"gid://shopify/CompanyContact/207808057\",\n ],\n ],\n \"note\" => \"Test B2B draft order\",\n \"email\" => \"test.b2b.user@shopify.com\",\n \"shippingLine\" => [\n \"title\" => \"Custom Shipping\",\n \"price\" => 4.55,\n ],\n \"shippingAddress\" => [\n \"address1\" => \"555 Main St\",\n \"city\" => \"Waterloo\",\n \"province\" => \"Ontario\",\n \"country\" => \"Canada\",\n \"zip\" => \"B1B 1B1\",\n ],\n \"billingAddress\" => [\n \"address1\" => \"556 Main St\",\n \"city\" => \"Toronto\",\n \"province\" => \"Ontario\",\n \"country\" => \"Canada\",\n \"zip\" => \"D9D DZD\",\n ],\n \"lineItems\" => [{\"variantId\"=>\"gid://shopify/ProductVariant/43729076\", \"quantity\"=>5}],\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation draftOrderCreate($input: DraftOrderInput!) {\n draftOrderCreate(input: $input) {\n draftOrder {\n id\n }\n userErrors {\n message\n field\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"purchasingEntity\": {\n \"purchasingCompany\": {\n \"companyId\": \"gid://shopify/Company/426793626\",\n \"companyLocationId\": \"gid://shopify/CompanyLocation/441870438\",\n \"companyContactId\": \"gid://shopify/CompanyContact/207808057\"\n }\n },\n \"note\": \"Test B2B draft order\",\n \"email\": \"test.b2b.user@shopify.com\",\n \"shippingLine\": {\n \"title\": \"Custom Shipping\",\n \"price\": 4.55\n },\n \"shippingAddress\": {\n \"address1\": \"555 Main St\",\n \"city\": \"Waterloo\",\n \"province\": \"Ontario\",\n \"country\": \"Canada\",\n \"zip\": \"B1B 1B1\"\n },\n \"billingAddress\": {\n \"address1\": \"556 Main St\",\n \"city\": \"Toronto\",\n \"province\": \"Ontario\",\n \"country\": \"Canada\",\n \"zip\": \"D9D DZD\"\n },\n \"lineItems\": [\n {\n \"variantId\": \"gid://shopify/ProductVariant/43729076\",\n \"quantity\": 5\n }\n ]\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation draftOrderCreate($input: DraftOrderInput!) {\n draftOrderCreate(input: $input) {\n draftOrder {\n id\n }\n userErrors {\n message\n field\n }\n }\n}"
input: { "input": { "purchasingEntity": { "purchasingCompany": { "companyId": "gid://shopify/Company/426793626", "companyLocationId": "gid://shopify/CompanyLocation/441870438", "companyContactId": "gid://shopify/CompanyContact/207808057" } }, "note": "Test B2B draft order", "email": "test.b2b.user@shopify.com", "shippingLine": { "title": "Custom Shipping", "price": 4.55 }, "shippingAddress": { "address1": "555 Main St", "city": "Waterloo", "province": "Ontario", "country": "Canada", "zip": "B1B 1B1" }, "billingAddress": { "address1": "556 Main St", "city": "Toronto", "province": "Ontario", "country": "Canada", "zip": "D9D DZD" }, "lineItems": [ { "variantId": "gid://shopify/ProductVariant/43729076", "quantity": 5 } ] } }
response: { "data": { "draftOrderCreate": { "draftOrder": { "id": "gid://shopify/DraftOrder/1069920586" }, "userErrors": [] } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/unstable/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation draftOrderCreate($input: DraftOrderInput!) { draftOrderCreate(input: $input) { draftOrder { id } userErrors { message field } } }\",\n \"variables\": {\n \"input\": {\n \"lineItems\": []\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation draftOrderCreate($input: DraftOrderInput!) {\n draftOrderCreate(input: $input) {\n draftOrder {\n id\n }\n userErrors {\n message\n field\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"lineItems\": []\n }\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation draftOrderCreate($input: DraftOrderInput!) {\n draftOrderCreate(input: $input) {\n draftOrder {\n id\n }\n userErrors {\n message\n field\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"lineItems\": []\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<[\n \"lineItems\" => [],\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation draftOrderCreate($input: DraftOrderInput!) {\n draftOrderCreate(input: $input) {\n draftOrder {\n id\n }\n userErrors {\n message\n field\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"lineItems\": []\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation draftOrderCreate($input: DraftOrderInput!) {\n draftOrderCreate(input: $input) {\n draftOrder {\n id\n }\n userErrors {\n message\n field\n }\n }\n}"
input: { "input": { "lineItems": [] } }
response: { "data": { "draftOrderCreate": { "draftOrder": null, "userErrors": [ { "message": "Add at least 1 product", "field": null } ] } } }