Anchor to refundCreaterefund
refundCreate
mutation
Requires orders
access scope, access scope or
access scope.
Creates a refund.
Anchor to Arguments
Arguments
- Anchor to inputinput•Refund
Input! required The input fields that are used in the mutation for creating a refund.
Was this section helpful?
Anchor to RefundCreatePayload returnsRefundCreatePayload returns
- Anchor to orderorder•
The order associated with the created refund.
- Anchor to refundrefund•
The created refund.
- Anchor to userErrorsuser•
Errors [UserError!]! non-null The list of errors that occurred from executing the mutation.
Was this section helpful?
- Create a refund with a note and transaction, then return the total refund amount across all transactions
- Create a refund with shipping partially refunded. Then, return the total refund amount and information about the first two transactions.
- Creates a refund
- refundCreate reference
Examples
1const { admin } = await authenticate.admin(request);23const response = await admin.graphql(4 `#graphql5 mutation M($input: RefundInput!) {6 refundCreate(input: $input) {7 userErrors {8 field9 message10 }11 refund {12 id13 note14 totalRefundedSet {15 presentmentMoney {16 amount17 }18 }19 }20 }21 }`,22 {23 variables: {24 "input": {25 "orderId": "gid://shopify/Order/734509473",26 "note": "Want to exchange for a different item",27 "refundLineItems": [28 {29 "lineItemId": "gid://shopify/LineItem/25746870",30 "quantity": 231 }32 ],33 "transactions": [34 {35 "orderId": "gid://shopify/Order/734509473",36 "gateway": "foo",37 "kind": "REFUND",38 "amount": "10.0",39 "parentId": "gid://shopify/OrderTransaction/723599266"40 }41 ]42 }43 },44 },45);4647const data = await response.json();48
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/2025-01/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();
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"
}
]
}
},
},
});
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)
Input variables
JSON1{2 "input": {3 "orderId": "gid://shopify/Order/734509473",4 "note": "Want to exchange for a different item",5 "refundLineItems": [6 {7 "lineItemId": "gid://shopify/LineItem/25746870",8 "quantity": 29 }10 ],11 "transactions": [12 {13 "orderId": "gid://shopify/Order/734509473",14 "gateway": "foo",15 "kind": "REFUND",16 "amount": "10.0",17 "parentId": "gid://shopify/OrderTransaction/723599266"18 }19 ]20 }21}
Response
JSON1{2 "refundCreate": {3 "userErrors": [],4 "refund": {5 "id": "gid://shopify/Refund/929361479",6 "note": "Want to exchange for a different item",7 "totalRefundedSet": {8 "presentmentMoney": {9 "amount": "10.0"10 }11 }12 }13 }14}