# refundCreate - admin-graphql - MUTATION Version: 2025-01 ## Description Creates a refund. ### Access Scopes `orders` access scope, `marketplace_orders` access scope or `buyer_membership_orders` access scope. ## Arguments * [input](/docs/api/admin-graphql/2025-01/input-objects/RefundInput): RefundInput! - The input fields that are used in the mutation for creating a refund. ## Returns * [order](/docs/api/admin-graphql/2025-01/objects/Order): Order The order associated with the created refund. * [refund](/docs/api/admin-graphql/2025-01/objects/Refund): Refund The created refund. * [userErrors](/docs/api/admin-graphql/2025-01/objects/UserError): UserError! The list of errors that occurred from executing the mutation. ## Examples ### Create a refund with a note and transaction, then return the total refund amount across all transactions 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 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" 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}" #### Graphql 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" } ] } } #### Graphql Response { "data": { "refundCreate": { "userErrors": [], "refund": { "id": "gid://shopify/Refund/929361479", "note": "Want to exchange for a different item", "totalRefundedSet": { "presentmentMoney": { "amount": "10.0" } } } } } } ### Create a refund with shipping partially refunded. Then, return the total refund amount and information about the first two transactions. 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 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" 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}" #### Graphql 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" } } } #### Graphql 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" } } ] } } } } } ### Creates a refund 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 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" 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}" #### Graphql Input { "input": { "orderId": "gid://shopify/Order/734509473", "refundLineItems": [ { "lineItemId": "gid://shopify/LineItem/25746870", "quantity": 1 } ], "transactions": [] } } #### Graphql Response { "data": { "refundCreate": { "refund": { "id": "gid://shopify/Refund/929361480", "totalRefundedSet": { "presentmentMoney": { "amount": "0.0", "currencyCode": "CAD" } } }, "userErrors": [] } } }