# orderUpdate - admin-graphql - MUTATION Version: 2025-01 ## Description Updates the fields of an order. ### Access Scopes `write_orders` access scope or `write_marketplace_orders` access scope. Also: The app must have the write_pos_staff_member_event_attribution_overrides scope to assign events to another staff member. ## Arguments * [input](/docs/api/admin-graphql/2025-01/input-objects/OrderInput): OrderInput! - The input for the mutation. ## Returns * [order](/docs/api/admin-graphql/2025-01/objects/Order): Order The updated order. * [userErrors](/docs/api/admin-graphql/2025-01/objects/UserError): UserError! The list of errors that occurred from executing the mutation. ## Examples ### Create a new metafield and update another on an existing order 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" 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}" #### Graphql 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" } } #### Graphql 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": [] } } } ### Update an order 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" 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}" #### Graphql Input { "input": { "id": "gid://shopify/Order/148977776", "email": "bob@example.com", "tags": [ "foo", "bar" ] } } #### Graphql 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": [] } } }