Requires orders access scope, marketplace_orders access scope or buyer_membership_orders access scope.

Creates a refund.


The input fields that are used in the mutation for creating a refund.


Was this section helpful?

The order associated with the created refund.

The created refund.

The list of errors that occurred from executing the mutation.


Was this section helpful?

Examples

Hide code
Copy
mutation M($input: RefundInput!) {
  refundCreate(input: $input) {
    userErrors {
      field
      message
    }
    refund {
      id
      note
      totalRefundedSet {
        presentmentMoney {
          amount
        }
      }
    }
  }
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-07/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation M($input: RefundInput!) { refundCreate(input: $input) { userErrors { field message } refund { id note totalRefundedSet { presentmentMoney { amount } } } } }",
 "variables": {
    "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"
        }
      ]
    }
  }
}'
const { admin } = await authenticate.admin(request);

const response = await admin.graphql(
  `#graphql
  mutation M($input: RefundInput!) {
    refundCreate(input: $input) {
      userErrors {
        field
        message
      }
      refund {
        id
        note
        totalRefundedSet {
          presentmentMoney {
            amount
          }
        }
      }
    }
  }`,
  {
    variables: {
      "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"
          }
        ]
      }
    },
  },
);

const data = await response.json();
session = ShopifyAPI::Auth::Session.new(
  shop: "your-development-store.myshopify.com",
  access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
  session: session
)

query = <<~QUERY
  mutation M($input: RefundInput!) {
    refundCreate(input: $input) {
      userErrors {
        field
        message
      }
      refund {
        id
        note
        totalRefundedSet {
          presentmentMoney {
            amount
          }
        }
      }
    }
  }
QUERY

variables = {
  "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 = client.query(query: query, variables: variables)
const client = new shopify.clients.Graphql({session});
const data = await client.query({
  data: {
    "query": `mutation M($input: RefundInput!) {
      refundCreate(input: $input) {
        userErrors {
          field
          message
        }
        refund {
          id
          note
          totalRefundedSet {
            presentmentMoney {
              amount
            }
          }
        }
      }
    }`,
    "variables": {
      "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"
          }
        ]
      }
    },
  },
});
use Shopify\Clients\Graphql;

$client = new Graphql("your-development-store.myshopify.com", $accessToken);
$query = <<<QUERY
  mutation M($input: RefundInput!) {
    refundCreate(input: $input) {
      userErrors {
        field
        message
      }
      refund {
        id
        note
        totalRefundedSet {
          presentmentMoney {
            amount
          }
        }
      }
    }
  }
QUERY;

$variables = [
  "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 = $client->query(["query" => $query, "variables" => $variables]);
Hide code
Input variables
Copy
{
  "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"
      }
    ]
  }
}
Hide code
Response
JSON
{
  "refundCreate": {
    "userErrors": [],
    "refund": {
      "id": "gid://shopify/Refund/929361464",
      "note": "Want to exchange for a different item",
      "totalRefundedSet": {
        "presentmentMoney": {
          "amount": "10.0"
        }
      }
    }
  }
}