Version: 2024-04
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation M($input: RefundInput!) { refundCreate(input: $input) { userErrors { field message } refund { id note totalRefundedSet { presentmentMoney { amount } } } } }\",\n \"variables\": {\n \"input\": {\n \"orderId\": \"gid://shopify/Order/734509473\",\n \"note\": \"Want to exchange for a different item\",\n \"refundLineItems\": [\n {\n \"lineItemId\": \"gid://shopify/LineItem/25746870\",\n \"quantity\": 2\n }\n ],\n \"transactions\": [\n {\n \"orderId\": \"gid://shopify/Order/734509473\",\n \"gateway\": \"foo\",\n \"kind\": \"REFUND\",\n \"amount\": \"10.0\",\n \"parentId\": \"gid://shopify/OrderTransaction/723599266\"\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 M($input: RefundInput!) {\n refundCreate(input: $input) {\n userErrors {\n field\n message\n }\n refund {\n id\n note\n totalRefundedSet {\n presentmentMoney {\n amount\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"orderId\": \"gid://shopify/Order/734509473\",\n \"note\": \"Want to exchange for a different item\",\n \"refundLineItems\": [\n {\n \"lineItemId\": \"gid://shopify/LineItem/25746870\",\n \"quantity\": 2\n }\n ],\n \"transactions\": [\n {\n \"orderId\": \"gid://shopify/Order/734509473\",\n \"gateway\": \"foo\",\n \"kind\": \"REFUND\",\n \"amount\": \"10.0\",\n \"parentId\": \"gid://shopify/OrderTransaction/723599266\"\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 M($input: RefundInput!) {\n refundCreate(input: $input) {\n userErrors {\n field\n message\n }\n refund {\n id\n note\n totalRefundedSet {\n presentmentMoney {\n amount\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"orderId\": \"gid://shopify/Order/734509473\",\n \"note\": \"Want to exchange for a different item\",\n \"refundLineItems\": [{\"lineItemId\"=>\"gid://shopify/LineItem/25746870\", \"quantity\"=>2}],\n \"transactions\": [{\"orderId\"=>\"gid://shopify/Order/734509473\", \"gateway\"=>\"foo\", \"kind\"=>\"REFUND\", \"amount\"=>\"10.0\", \"parentId\"=>\"gid://shopify/OrderTransaction/723599266\"}]\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 \"orderId\" => \"gid://shopify/Order/734509473\",\n \"note\" => \"Want to exchange for a different item\",\n \"refundLineItems\" => [{\"lineItemId\"=>\"gid://shopify/LineItem/25746870\", \"quantity\"=>2}],\n \"transactions\" => [{\"orderId\"=>\"gid://shopify/Order/734509473\", \"gateway\"=>\"foo\", \"kind\"=>\"REFUND\", \"amount\"=>\"10.0\", \"parentId\"=>\"gid://shopify/OrderTransaction/723599266\"}],\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 M($input: RefundInput!) {\n refundCreate(input: $input) {\n userErrors {\n field\n message\n }\n refund {\n id\n note\n totalRefundedSet {\n presentmentMoney {\n amount\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"orderId\": \"gid://shopify/Order/734509473\",\n \"note\": \"Want to exchange for a different item\",\n \"refundLineItems\": [\n {\n \"lineItemId\": \"gid://shopify/LineItem/25746870\",\n \"quantity\": 2\n }\n ],\n \"transactions\": [\n {\n \"orderId\": \"gid://shopify/Order/734509473\",\n \"gateway\": \"foo\",\n \"kind\": \"REFUND\",\n \"amount\": \"10.0\",\n \"parentId\": \"gid://shopify/OrderTransaction/723599266\"\n }\n ]\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation M($input: RefundInput!) {\n refundCreate(input: $input) {\n userErrors {\n field\n message\n }\n refund {\n id\n note\n totalRefundedSet {\n presentmentMoney {\n amount\n }\n }\n }\n }\n}"
input: { "input": { "orderId": "gid://shopify/Order/734509473", "note": "Want to exchange for a different item", "refundLineItems": [ { "lineItemId": "gid://shopify/LineItem/25746870", "quantity": 2 } ], "transactions": [ { "orderId": "gid://shopify/Order/734509473", "gateway": "foo", "kind": "REFUND", "amount": "10.0", "parentId": "gid://shopify/OrderTransaction/723599266" } ] } }
response: { "data": { "refundCreate": { "userErrors": [], "refund": { "id": "gid://shopify/Refund/929361479", "note": "Want to exchange for a different item", "totalRefundedSet": { "presentmentMoney": { "amount": "10.0" } } } } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation M($input: RefundInput!) { refundCreate(input: $input) { userErrors { field message } refund { id totalRefundedSet { presentmentMoney { amount } } transactions(first: 2) { edges { node { amountSet { presentmentMoney { amount } } status } } } } } }\",\n \"variables\": {\n \"input\": {\n \"orderId\": \"gid://shopify/Order/734509473\",\n \"transactions\": [\n {\n \"orderId\": \"gid://shopify/Order/734509473\",\n \"parentId\": \"gid://shopify/OrderTransaction/723599266\",\n \"kind\": \"REFUND\",\n \"gateway\": \"foo\",\n \"amount\": \"16.99\"\n }\n ],\n \"shipping\": {\n \"amount\": \"6.99\"\n }\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation M($input: RefundInput!) {\n refundCreate(input: $input) {\n userErrors {\n field\n message\n }\n refund {\n id\n totalRefundedSet {\n presentmentMoney {\n amount\n }\n }\n transactions(first: 2) {\n edges {\n node {\n amountSet {\n presentmentMoney {\n amount\n }\n }\n status\n }\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"orderId\": \"gid://shopify/Order/734509473\",\n \"transactions\": [\n {\n \"orderId\": \"gid://shopify/Order/734509473\",\n \"parentId\": \"gid://shopify/OrderTransaction/723599266\",\n \"kind\": \"REFUND\",\n \"gateway\": \"foo\",\n \"amount\": \"16.99\"\n }\n ],\n \"shipping\": {\n \"amount\": \"6.99\"\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 M($input: RefundInput!) {\n refundCreate(input: $input) {\n userErrors {\n field\n message\n }\n refund {\n id\n totalRefundedSet {\n presentmentMoney {\n amount\n }\n }\n transactions(first: 2) {\n edges {\n node {\n amountSet {\n presentmentMoney {\n amount\n }\n }\n status\n }\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"orderId\": \"gid://shopify/Order/734509473\",\n \"transactions\": [{\"orderId\"=>\"gid://shopify/Order/734509473\", \"parentId\"=>\"gid://shopify/OrderTransaction/723599266\", \"kind\"=>\"REFUND\", \"gateway\"=>\"foo\", \"amount\"=>\"16.99\"}],\n \"shipping\": {\n \"amount\": \"6.99\"\n }\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 \"orderId\" => \"gid://shopify/Order/734509473\",\n \"transactions\" => [{\"orderId\"=>\"gid://shopify/Order/734509473\", \"parentId\"=>\"gid://shopify/OrderTransaction/723599266\", \"kind\"=>\"REFUND\", \"gateway\"=>\"foo\", \"amount\"=>\"16.99\"}],\n \"shipping\" => [\n \"amount\" => \"6.99\",\n ],\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 M($input: RefundInput!) {\n refundCreate(input: $input) {\n userErrors {\n field\n message\n }\n refund {\n id\n totalRefundedSet {\n presentmentMoney {\n amount\n }\n }\n transactions(first: 2) {\n edges {\n node {\n amountSet {\n presentmentMoney {\n amount\n }\n }\n status\n }\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"orderId\": \"gid://shopify/Order/734509473\",\n \"transactions\": [\n {\n \"orderId\": \"gid://shopify/Order/734509473\",\n \"parentId\": \"gid://shopify/OrderTransaction/723599266\",\n \"kind\": \"REFUND\",\n \"gateway\": \"foo\",\n \"amount\": \"16.99\"\n }\n ],\n \"shipping\": {\n \"amount\": \"6.99\"\n }\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation M($input: RefundInput!) {\n refundCreate(input: $input) {\n userErrors {\n field\n message\n }\n refund {\n id\n totalRefundedSet {\n presentmentMoney {\n amount\n }\n }\n transactions(first: 2) {\n edges {\n node {\n amountSet {\n presentmentMoney {\n amount\n }\n }\n status\n }\n }\n }\n }\n }\n}"
input: { "input": { "orderId": "gid://shopify/Order/734509473", "transactions": [ { "orderId": "gid://shopify/Order/734509473", "parentId": "gid://shopify/OrderTransaction/723599266", "kind": "REFUND", "gateway": "foo", "amount": "16.99" } ], "shipping": { "amount": "6.99" } } }
response: { "data": { "refundCreate": { "userErrors": [], "refund": { "id": "gid://shopify/Refund/929361478", "totalRefundedSet": { "presentmentMoney": { "amount": "16.99" } }, "transactions": { "edges": [ { "node": { "amountSet": { "presentmentMoney": { "amount": "16.99" } }, "status": "SUCCESS" } } ] } } } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation RefundCreate($input: RefundInput!) { refundCreate(input: $input) { refund { id totalRefundedSet { presentmentMoney { amount currencyCode } } } userErrors { field message } } }\",\n \"variables\": {\n \"input\": {\n \"orderId\": \"gid://shopify/Order/734509473\",\n \"refundLineItems\": [\n {\n \"lineItemId\": \"gid://shopify/LineItem/25746870\",\n \"quantity\": 1\n }\n ],\n \"transactions\": []\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation RefundCreate($input: RefundInput!) {\n refundCreate(input: $input) {\n refund {\n id\n totalRefundedSet {\n presentmentMoney {\n amount\n currencyCode\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"orderId\": \"gid://shopify/Order/734509473\",\n \"refundLineItems\": [\n {\n \"lineItemId\": \"gid://shopify/LineItem/25746870\",\n \"quantity\": 1\n }\n ],\n \"transactions\": []\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 RefundCreate($input: RefundInput!) {\n refundCreate(input: $input) {\n refund {\n id\n totalRefundedSet {\n presentmentMoney {\n amount\n currencyCode\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"orderId\": \"gid://shopify/Order/734509473\",\n \"refundLineItems\": [{\"lineItemId\"=>\"gid://shopify/LineItem/25746870\", \"quantity\"=>1}],\n \"transactions\": []\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 \"orderId\" => \"gid://shopify/Order/734509473\",\n \"refundLineItems\" => [{\"lineItemId\"=>\"gid://shopify/LineItem/25746870\", \"quantity\"=>1}],\n \"transactions\" => [],\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 RefundCreate($input: RefundInput!) {\n refundCreate(input: $input) {\n refund {\n id\n totalRefundedSet {\n presentmentMoney {\n amount\n currencyCode\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"orderId\": \"gid://shopify/Order/734509473\",\n \"refundLineItems\": [\n {\n \"lineItemId\": \"gid://shopify/LineItem/25746870\",\n \"quantity\": 1\n }\n ],\n \"transactions\": []\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation RefundCreate($input: RefundInput!) {\n refundCreate(input: $input) {\n refund {\n id\n totalRefundedSet {\n presentmentMoney {\n amount\n currencyCode\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n}"
input: { "input": { "orderId": "gid://shopify/Order/734509473", "refundLineItems": [ { "lineItemId": "gid://shopify/LineItem/25746870", "quantity": 1 } ], "transactions": [] } }
response: { "data": { "refundCreate": { "refund": { "id": "gid://shopify/Refund/929361480", "totalRefundedSet": { "presentmentMoney": { "amount": "0.0", "currencyCode": "CAD" } } }, "userErrors": [] } } }