Refund

There are three major parts to a refund:

Before you create a refund, use the calculate endpoint to generate accurate refund transactions. Specify the line items that are being refunded, their quantity, and whether you're refunding shipping costs. You can then use the response in the body of the request to create the actual refund.

When you create a refund using the response from the calculate endpoint, you can set additional options, such as whether to notify the customer of the refund and whether to restock the line items to the store's inventory. You can refund less than the calculated amount for either shipping or the line items by setting a custom value for the amount property.

If a refund includes shipping costs, or if you choose to refund line items for less than their calculated amount, then an order adjustment is created automatically to account for the discrepancy in the store's financial reports.

What you can do with Refund

The Shopify API lets you do the following with the Refund resource. More detailed versions of these general actions may be available:

Refund properties

created_at
"created_at": "2008-01-10T11:00:00-05:00"

The date and time (ISO 8601 format) when the refund was created.

id
"id": 92738740

The unique identifier for the refund.

note
"note": "Item was damaged during shipping"

An optional note attached to a refund.

order_adjustments
"order_adjustments": [
  {
    "id": 4221763620,
    "order_id": 171016912932,
    "refund_id": 8244756516,
    "amount": "-8.00",
    "tax_amount": "0.00",
    "kind": "shipping_refund",
    "reason": "Shipping refund"
  }
]

A list of order adjustments attached to the refund. Order adjustments are generated to account for refunded shipping costs and differences between calculated and actual refund amounts. Each entry has the following properties:

  • id: The unique identifier for the order adjustment.
  • order_id: The unique identifier for the order that the order adjustment is associated with.
  • refund_id: The unique identifier for the refund that the order adjustment is associated with.
  • amount: The value of the discrepancy between the calculated refund and the actual refund. If the kind property's value is shipping_refund, then amount returns the value of shipping charges refunded to the customer.
  • tax_amount: The taxes that are added to amount, such as applicable shipping taxes added to a shipping refund.
  • kind: The order adjustment type. Valid values: shipping_refund and refund_discrepancy.
  • reason: The reason for the order adjustment. To set this value, include discrepancy_reason when you create a refund.

processed_at
"processed_at": "2007-01-10T11:00:00-05:00"

The date and time (ISO 8601 format) when the refund was imported. This value can be set to a date in the past when importing from other systems. If no value is provided, then it will be auto-generated \ as the current time in Shopify.

refund_line_items
"refund_line_items": [
  {
    "id": 209341123,
    "line_item": {},
    "line_item_id": 128323456,
    "quantity": 2,
    "location_id": 40642626,
    "restock_type": "return"
  }
]

A list of refunded line items. Each entry has the following properties:

  • id: The unique identifier of the line item in the refund.
  • line_item: A line item being returned.
  • line_item_id: The ID of the related line item in the order.
  • quantity: The quantity of the associated line item that was returned.
  • restock_type beta: How this refund line item affects inventory levels. Valid values:
    • no_restock: Refunding these items won't affect inventory. The number of fulfillable units for this line item will remain unchanged. For example, a refund payment can be issued but no items will be returned or made available for sale again.
    • cancel: The items have not yet been fulfilled. The canceled quantity will be added back to the available count. The number of fulfillable units for this line item will decrease.
    • return: The items were already delivered, and will be returned to the merchant. The returned quantity will be added back to the available count. The number of fulfillable units for this line item will remain unchanged.
    • legacy_restock: The deprecated restock property was used for this refund. These items were made available for sale again. This value is not accepted when creating new refunds.
  • location_id: The unique identifier of the location where the items will be restocked. Required when restock_type has the value return or cancel.

restock
deprecated
"restock": true

Whether to add the line items back to the store's inventory.

Provide a restock_type to influence how this refund affects inventory instead

transactions
"transactions": [
  {
    "id": 179259969,
    "order_id": 450789469,
    "amount": "209.00",
    "kind": "refund",
    "gateway": "shopify_payments",
    "status": "success",
    "message": null,
    "created_at": "2005-08-05T12:59:12-04:00",
    "test": false,
    "authorization": "authorization-key",
    "currency": "USD",
    "location_id": null,
    "user_id": null,
    "parent_id": 801038806,
    "device_id": null,
    "receipt": {},
    "error_code": null,
    "source_name": "web"
  }
]

A list of transactions involved in the refund. For more information, see the Transaction resource.

user_id
"user_id": 238478920

The unique identifier of the user who performed the refund.

Endpoints

GET /admin/orders/450789469/refunds.json
Retrieves a list of refunds for an order.
fields

Show only certain fields, specified by a comma-separated list of field names.

Retrieve all refunds from a specific order

GET /admin/orders/#{order_id}/refunds.json
View Response
HTTP/1.1 200 OK
{
  "refunds": [
    {
      "id": 509562969,
      "order_id": 450789469,
      "created_at": "2018-05-07T15:33:38-04:00",
      "note": "it broke during shipping",
      "user_id": 799407056,
      "processed_at": "2018-05-07T15:33:38-04:00",
      "restock": true,
      "refund_line_items": [
        {
          "id": 104689539,
          "quantity": 1,
          "line_item_id": 703073504,
          "location_id": 487838322,
          "restock_type": null,
          "subtotal": 195.67,
          "total_tax": 3.98,
          "line_item": {
            "id": 703073504,
            "variant_id": 457924702,
            "title": "IPod Nano - 8gb",
            "quantity": 1,
            "price": "199.00",
            "sku": "IPOD2008BLACK",
            "variant_title": "black",
            "vendor": null,
            "fulfillment_service": "manual",
            "product_id": 632910392,
            "requires_shipping": true,
            "taxable": true,
            "gift_card": false,
            "name": "IPod Nano - 8gb - black",
            "variant_inventory_management": "shopify",
            "properties": [],
            "product_exists": true,
            "fulfillable_quantity": 1,
            "grams": 200,
            "total_discount": "0.00",
            "fulfillment_status": null,
            "tax_lines": [
              {
                "title": "State Tax",
                "price": "3.98",
                "rate": 0.06
              }
            ]
          }
        },
        {
          "id": 709875399,
          "quantity": 1,
          "line_item_id": 466157049,
          "location_id": 487838322,
          "restock_type": null,
          "subtotal": 195.66,
          "total_tax": 3.98,
          "line_item": {
            "id": 466157049,
            "variant_id": 39072856,
            "title": "IPod Nano - 8gb",
            "quantity": 1,
            "price": "199.00",
            "sku": "IPOD2008GREEN",
            "variant_title": "green",
            "vendor": null,
            "fulfillment_service": "manual",
            "product_id": 632910392,
            "requires_shipping": true,
            "taxable": true,
            "gift_card": false,
            "name": "IPod Nano - 8gb - green",
            "variant_inventory_management": "shopify",
            "properties": [
              {
                "name": "Custom Engraving Front",
                "value": "Happy Birthday"
              },
              {
                "name": "Custom Engraving Back",
                "value": "Merry Christmas"
              }
            ],
            "product_exists": true,
            "fulfillable_quantity": 1,
            "grams": 200,
            "total_discount": "0.00",
            "fulfillment_status": null,
            "tax_lines": [
              {
                "title": "State Tax",
                "price": "3.98",
                "rate": 0.06
              }
            ]
          }
        }
      ],
      "transactions": [
        {
          "id": 179259969,
          "order_id": 450789469,
          "amount": "209.00",
          "kind": "refund",
          "gateway": "bogus",
          "status": "success",
          "message": null,
          "created_at": "2005-08-05T12:59:12-04:00",
          "test": false,
          "authorization": "authorization-key",
          "currency": "USD",
          "location_id": null,
          "user_id": null,
          "parent_id": 801038806,
          "device_id": null,
          "receipt": {},
          "error_code": null,
          "source_name": "web"
        }
      ],
      "order_adjustments": []
    }
  ]
}
GET /admin/orders/450789469/refunds/509562969.json
Retrieves a specific refund.
fields

Show only certain fields, specified by a comma-separated list of field names.

Retrieve a specific refund

GET /admin/orders/#{order_id}/refunds/#{refund_id}.json
View Response
HTTP/1.1 200 OK
{
  "refund": {
    "id": 509562969,
    "order_id": 450789469,
    "created_at": "2018-05-07T15:33:38-04:00",
    "note": "it broke during shipping",
    "user_id": 799407056,
    "processed_at": "2018-05-07T15:33:38-04:00",
    "restock": true,
    "refund_line_items": [
      {
        "id": 104689539,
        "quantity": 1,
        "line_item_id": 703073504,
        "location_id": 487838322,
        "restock_type": null,
        "subtotal": 195.67,
        "total_tax": 3.98,
        "line_item": {
          "id": 703073504,
          "variant_id": 457924702,
          "title": "IPod Nano - 8gb",
          "quantity": 1,
          "price": "199.00",
          "sku": "IPOD2008BLACK",
          "variant_title": "black",
          "vendor": null,
          "fulfillment_service": "manual",
          "product_id": 632910392,
          "requires_shipping": true,
          "taxable": true,
          "gift_card": false,
          "name": "IPod Nano - 8gb - black",
          "variant_inventory_management": "shopify",
          "properties": [],
          "product_exists": true,
          "fulfillable_quantity": 1,
          "grams": 200,
          "total_discount": "0.00",
          "fulfillment_status": null,
          "tax_lines": [
            {
              "title": "State Tax",
              "price": "3.98",
              "rate": 0.06
            }
          ]
        }
      },
      {
        "id": 709875399,
        "quantity": 1,
        "line_item_id": 466157049,
        "location_id": 487838322,
        "restock_type": null,
        "subtotal": 195.66,
        "total_tax": 3.98,
        "line_item": {
          "id": 466157049,
          "variant_id": 39072856,
          "title": "IPod Nano - 8gb",
          "quantity": 1,
          "price": "199.00",
          "sku": "IPOD2008GREEN",
          "variant_title": "green",
          "vendor": null,
          "fulfillment_service": "manual",
          "product_id": 632910392,
          "requires_shipping": true,
          "taxable": true,
          "gift_card": false,
          "name": "IPod Nano - 8gb - green",
          "variant_inventory_management": "shopify",
          "properties": [
            {
              "name": "Custom Engraving Front",
              "value": "Happy Birthday"
            },
            {
              "name": "Custom Engraving Back",
              "value": "Merry Christmas"
            }
          ],
          "product_exists": true,
          "fulfillable_quantity": 1,
          "grams": 200,
          "total_discount": "0.00",
          "fulfillment_status": null,
          "tax_lines": [
            {
              "title": "State Tax",
              "price": "3.98",
              "rate": 0.06
            }
          ]
        }
      }
    ],
    "transactions": [
      {
        "id": 179259969,
        "order_id": 450789469,
        "amount": "209.00",
        "kind": "refund",
        "gateway": "bogus",
        "status": "success",
        "message": null,
        "created_at": "2005-08-05T12:59:12-04:00",
        "test": false,
        "authorization": "authorization-key",
        "currency": "USD",
        "location_id": null,
        "user_id": null,
        "parent_id": 801038806,
        "device_id": null,
        "receipt": {},
        "error_code": null,
        "source_name": "web"
      }
    ],
    "order_adjustments": []
  }
}
POST /admin/orders/450789469/refunds/calculate.json

Calculates refund transactions based on line items and shipping. When you want to create a refund, you should first use the calculate endpoint to generate accurate refund transactions. Specify the line items that are being refunded, their quantity, and whether you're refunding shipping costs. You can then use the response in the body of the request to create the actual refund.

The response includes a transactions object with "kind": "suggested_refund", which must to be changed to "kind" : "refund" for the refund to be accepted.

shipping

Specify how much shipping to refund. It has the following properties:

  • full_refund: Whether to refund all remaining shipping.
  • amount: Set a specific amount to refund for shipping. Takes precedence over full_refund.
refund_line_items

A list of line item IDs and quantities to refund.

Calculate the refund for a line item and shipping

POST /admin/orders/#{order_id}/refunds/calculate.json
{
  "refund": {
    "shipping": {
      "full_refund": true
    },
    "refund_line_items": [
      {
        "line_item_id": 518995019,
        "quantity": 1
      }
    ]
  }
}
View Response
HTTP/1.1 200 OK
{
  "refund": {
    "shipping": {
      "amount": "5.00",
      "tax": "0.00",
      "maximum_refundable": "5.00"
    },
    "refund_line_items": [
      {
        "quantity": 1,
        "line_item_id": 518995019,
        "price": "199.00",
        "subtotal": "195.67",
        "total_tax": "3.98",
        "discounted_price": "199.00",
        "discounted_total_price": "199.00",
        "total_cart_discount_amount": "3.33"
      }
    ],
    "transactions": [
      {
        "order_id": 450789469,
        "amount": "41.94",
        "kind": "suggested_refund",
        "gateway": "bogus",
        "parent_id": 801038806,
        "maximum_refundable": "41.94"
      }
    ]
  }
}

Calculate a refund for a partial amount of shipping

POST /admin/orders/#{order_id}/refunds/calculate.json
{
  "refund": {
    "shipping": {
      "amount": 2.0
    }
  }
}
View Response
HTTP/1.1 200 OK
{
  "refund": {
    "shipping": {
      "amount": "2.00",
      "tax": "0.00",
      "maximum_refundable": "5.00"
    },
    "refund_line_items": [],
    "transactions": [
      {
        "order_id": 450789469,
        "amount": "2.00",
        "kind": "suggested_refund",
        "gateway": "bogus",
        "parent_id": 801038806,
        "maximum_refundable": "41.94"
      }
    ]
  }
}
POST /admin/orders/450789469/refunds.json

Creates a refund. Use the calculate endpoint to produce the transactions to submit.


restock

Whether to add the line items back to the store inventory.

notify

Whether to send a refund notification to the customer.

note

An optional note attached to a refund.

discrepancy_reason

An optional comment that explains a discrepancy between calculated and actual refund amounts. Used to populate the reason property of the resulting order adjustment object attached to the refund. Valid values: restock, damage, customer, and other.

shipping

Specify how much shipping to refund. It has the following properties:

  • full_refund: Whether to refund all remaining shipping.
  • amount: Set a specific amount to refund for shipping. Takes precedence over full_refund.
refund_line_items

A list of line item IDs and quantities to refund.

transactions

A list of transactions to process as refunds.

Create a refund for an order

POST /admin/orders/#{order_id}/refunds.json
{
  "refund": {
    "restock": true,
    "notify": true,
    "note": "wrong size",
    "shipping": {
      "full_refund": true
    },
    "refund_line_items": [
      {
        "line_item_id": 518995019,
        "quantity": 1
      }
    ],
    "transactions": [
      {
        "parent_id": 801038806,
        "amount": 41.94,
        "kind": "refund",
        "gateway": "bogus"
      }
    ]
  }
}
View Response
HTTP/1.1 201 Created
{
  "refund": {
    "id": 929361462,
    "order_id": 450789469,
    "created_at": "2018-05-07T15:49:16-04:00",
    "note": "wrong size",
    "user_id": null,
    "processed_at": "2018-05-07T15:49:16-04:00",
    "restock": true,
    "refund_line_items": [
      {
        "id": 1058498307,
        "quantity": 1,
        "line_item_id": 518995019,
        "location_id": 487838322,
        "restock_type": "legacy_restock",
        "subtotal": 195.67,
        "total_tax": 3.98,
        "line_item": {
          "id": 518995019,
          "variant_id": 49148385,
          "title": "IPod Nano - 8gb",
          "quantity": 1,
          "price": "199.00",
          "sku": "IPOD2008RED",
          "variant_title": "red",
          "vendor": null,
          "fulfillment_service": "manual",
          "product_id": 632910392,
          "requires_shipping": true,
          "taxable": true,
          "gift_card": false,
          "name": "IPod Nano - 8gb - red",
          "variant_inventory_management": "shopify",
          "properties": [],
          "product_exists": true,
          "fulfillable_quantity": 0,
          "grams": 200,
          "total_discount": "0.00",
          "fulfillment_status": null,
          "tax_lines": [
            {
              "title": "State Tax",
              "price": "3.98",
              "rate": 0.06
            }
          ]
        }
      }
    ],
    "transactions": [
      {
        "id": 1072844670,
        "order_id": 450789469,
        "amount": "41.94",
        "kind": "refund",
        "gateway": "bogus",
        "status": "success",
        "message": "Bogus Gateway: Forced success",
        "created_at": "2018-05-07T15:49:16-04:00",
        "test": true,
        "authorization": null,
        "currency": "USD",
        "location_id": null,
        "user_id": null,
        "parent_id": 801038806,
        "device_id": null,
        "receipt": {},
        "error_code": null,
        "source_name": "755357713"
      }
    ],
    "order_adjustments": []
  }
}

Refund a specific amount of shipping

POST /admin/orders/#{order_id}/refunds.json
{
  "refund": {
    "shipping": {
      "amount": 5.0
    },
    "transactions": [
      {
        "parent_id": 801038806,
        "amount": 5.0,
        "kind": "refund",
        "gateway": "bogus"
      }
    ]
  }
}
View Response
HTTP/1.1 201 Created
{
  "refund": {
    "id": 929361463,
    "order_id": 450789469,
    "created_at": "2018-05-07T15:49:19-04:00",
    "note": null,
    "user_id": null,
    "processed_at": "2018-05-07T15:49:19-04:00",
    "restock": false,
    "refund_line_items": [],
    "transactions": [
      {
        "id": 1072844671,
        "order_id": 450789469,
        "amount": "5.00",
        "kind": "refund",
        "gateway": "bogus",
        "status": "success",
        "message": "Bogus Gateway: Forced success",
        "created_at": "2018-05-07T15:49:19-04:00",
        "test": true,
        "authorization": null,
        "currency": "USD",
        "location_id": null,
        "user_id": null,
        "parent_id": 801038806,
        "device_id": null,
        "receipt": {},
        "error_code": null,
        "source_name": "755357713"
      }
    ],
    "order_adjustments": [
      {
        "id": 1030976842,
        "order_id": 450789469,
        "refund_id": 929361463,
        "amount": "-5.00",
        "tax_amount": "0.00",
        "kind": "shipping_refund",
        "reason": "Shipping refund"
      }
    ]
  }
}