Version: 2025-01
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation updateOrderMetafields($input: OrderInput!) { orderUpdate(input: $input) { order { 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 \"id\": \"gid://shopify/Metafield/1069228968\",\n \"value\": \"123\"\n }\n ],\n \"id\": \"gid://shopify/Order/148977776\"\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation updateOrderMetafields($input: OrderInput!) {\n orderUpdate(input: $input) {\n order {\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 \"id\": \"gid://shopify/Metafield/1069228968\",\n \"value\": \"123\"\n }\n ],\n \"id\": \"gid://shopify/Order/148977776\"\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 updateOrderMetafields($input: OrderInput!) {\n orderUpdate(input: $input) {\n order {\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\"}, {\"id\"=>\"gid://shopify/Metafield/1069228968\", \"value\"=>\"123\"}],\n \"id\": \"gid://shopify/Order/148977776\"\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 = <<<QUERY\n mutation updateOrderMetafields($input: OrderInput!) {\n orderUpdate(input: $input) {\n order {\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\n$variables = [\n \"input\" => [\n \"metafields\" => [{\"namespace\"=>\"my_field\", \"key\"=>\"delivery_instructions\", \"type\"=>\"single_line_text_field\", \"value\"=>\"leave on back porch\"}, {\"id\"=>\"gid://shopify/Metafield/1069228968\", \"value\"=>\"123\"}],\n \"id\" => \"gid://shopify/Order/148977776\",\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 updateOrderMetafields($input: OrderInput!) {\n orderUpdate(input: $input) {\n order {\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 \"id\": \"gid://shopify/Metafield/1069228968\",\n \"value\": \"123\"\n }\n ],\n \"id\": \"gid://shopify/Order/148977776\"\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation updateOrderMetafields($input: OrderInput!) {\n orderUpdate(input: $input) {\n order {\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" }, { "id": "gid://shopify/Metafield/1069228968", "value": "123" } ], "id": "gid://shopify/Order/148977776" } }
response: { "data": { "orderUpdate": { "order": { "id": "gid://shopify/Order/148977776", "metafields": { "edges": [ { "node": { "id": "gid://shopify/Metafield/1069228968", "namespace": "my_fields", "key": "purchase_order", "value": "123" } }, { "node": { "id": "gid://shopify/Metafield/1069228969", "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/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation OrderUpdate($input: OrderInput!) { orderUpdate(input: $input) { order { canMarkAsPaid cancelReason cancelledAt clientIp confirmed customer { displayName email } discountCodes } userErrors { field message } } }\",\n \"variables\": {\n \"input\": {\n \"id\": \"gid://shopify/Order/148977776\",\n \"email\": \"bob@example.com\",\n \"tags\": [\n \"foo\",\n \"bar\"\n ]\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation OrderUpdate($input: OrderInput!) {\n orderUpdate(input: $input) {\n order {\n canMarkAsPaid\n cancelReason\n cancelledAt\n clientIp\n confirmed\n customer {\n displayName\n email\n }\n discountCodes\n }\n userErrors {\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"id\": \"gid://shopify/Order/148977776\",\n \"email\": \"bob@example.com\",\n \"tags\": [\n \"foo\",\n \"bar\"\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 OrderUpdate($input: OrderInput!) {\n orderUpdate(input: $input) {\n order {\n canMarkAsPaid\n cancelReason\n cancelledAt\n clientIp\n confirmed\n customer {\n displayName\n email\n }\n discountCodes\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"id\": \"gid://shopify/Order/148977776\",\n \"email\": \"bob@example.com\",\n \"tags\": [\"foo\", \"bar\"]\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 = <<<QUERY\n mutation OrderUpdate($input: OrderInput!) {\n orderUpdate(input: $input) {\n order {\n canMarkAsPaid\n cancelReason\n cancelledAt\n clientIp\n confirmed\n customer {\n displayName\n email\n }\n discountCodes\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY;\n\n$variables = [\n \"input\" => [\n \"id\" => \"gid://shopify/Order/148977776\",\n \"email\" => \"bob@example.com\",\n \"tags\" => [\"foo\", \"bar\"],\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 OrderUpdate($input: OrderInput!) {\n orderUpdate(input: $input) {\n order {\n canMarkAsPaid\n cancelReason\n cancelledAt\n clientIp\n confirmed\n customer {\n displayName\n email\n }\n discountCodes\n }\n userErrors {\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"id\": \"gid://shopify/Order/148977776\",\n \"email\": \"bob@example.com\",\n \"tags\": [\n \"foo\",\n \"bar\"\n ]\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation OrderUpdate($input: OrderInput!) {\n orderUpdate(input: $input) {\n order {\n canMarkAsPaid\n cancelReason\n cancelledAt\n clientIp\n confirmed\n customer {\n displayName\n email\n }\n discountCodes\n }\n userErrors {\n field\n message\n }\n }\n}"
input: { "input": { "id": "gid://shopify/Order/148977776", "email": "bob@example.com", "tags": [ "foo", "bar" ] } }
response: { "data": { "orderUpdate": { "order": { "canMarkAsPaid": false, "cancelReason": null, "cancelledAt": null, "clientIp": "216.191.105.144", "confirmed": true, "customer": { "displayName": "Bob Bobsen", "email": "bob@example.com" }, "discountCodes": [] }, "userErrors": [] } } }