---
title: "Records a refund of an order, optionally revoking what it granted."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.sherpo.io/llms.txt
> Use this file to discover all available pages before exploring further.

Path: Sherpo merchant API › transaction

`POST /v1/stores/{store}/orders/{order}/refunds`

## Authentication

- `bearer`, http, header `Authorization`, scopes: `transaction:write`

## Path parameters

- `store` (`recordRefund.path.store`; string, required) — The store's id.
- `order` (`recordRefund.path.order`; string, required)
  - minLength 1

## Header parameters

- `Idempotency-Key` (`recordRefund.header.Idempotency-Key`; string, optional) — Repeats within 24 hours answer the first result; the same key with other arguments is a conflict.
  - minLength 1; maxLength 255; pattern `^[\x21-\x7E]+$`

## Request body

_Required._

- `settlement` (`recordRefund.settlement`; object, required)
  - `id` (`recordRefund.settlement.id`; string, required)
    - minLength 1; maxLength 512
- `amount` (`recordRefund.amount`; integer, required)
  - min 1
- `reason` (`recordRefund.reason`; any of, optional)
  - any of: `string`, `null`
- `processor_ref` (`recordRefund.processor_ref`; any of, optional)
  - any of: `string`, `null`
- `allocations` (`recordRefund.allocations`; array<object>, optional)
  - `order_item` (`recordRefund.allocations.order_item`; object, required)
    - `id` (`recordRefund.allocations.order_item.id`; string, required)
      - minLength 1; maxLength 512
  - `amount` (`recordRefund.allocations.amount`; integer, required)
    - min 0
  - `guests` (`recordRefund.allocations.guests`; array<object>, optional) — The guest tickets of an event's line this refund ends, each giving its seat back.
    - `id` (`recordRefund.allocations.guests.id`; string, required)
      - minLength 1; maxLength 512

## Example request

```json
{
  "settlement": {
    "id": "string"
  },
  "amount": 1,
  "reason": "string",
  "processor_ref": "string",
  "allocations": [
    {
      "order_item": {
        "id": "string"
      },
      "amount": 0,
      "guests": [
        {
          "id": "string"
        }
      ]
    }
  ]
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url 'https://api.sherpo.io/merchant/v1/stores/<store>/orders/<order>/refunds' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "settlement": {
    "id": "string"
  },
  "amount": 1,
  "reason": "string",
  "processor_ref": "string",
  "allocations": [
    {
      "order_item": {
        "id": "string"
      },
      "amount": 0,
      "guests": [
        {
          "id": "string"
        }
      ]
    }
  ]
}
'
```

### TypeScript

```typescript
const url = 'https://api.sherpo.io/merchant/v1/stores/<store>/orders/<order>/refunds';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json', Authorization: 'Bearer <token>'},
  body: JSON.stringify({
    settlement: {id: 'string'},
    amount: 1,
    reason: 'string',
    processor_ref: 'string',
    allocations: [{order_item: {id: 'string'}, amount: 0, guests: [{id: 'string'}]}]
  })
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://api.sherpo.io/merchant/v1/stores/<store>/orders/<order>/refunds"

payload = {
    "settlement": { "id": "string" },
    "amount": 1,
    "reason": "string",
    "processor_ref": "string",
    "allocations": [
        {
            "order_item": { "id": "string" },
            "amount": 0,
            "guests": [{ "id": "string" }]
        }
    ]
}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 201

Records a refund of an order, optionally revoking what it granted.

#### Example

```json
{
  "allocations": [
    {
      "currency": "string",
      "exponent": 0,
      "refund_id": "string",
      "order_item_id": "string",
      "amount": 0
    }
  ],
  "id": "string",
  "settlement_id": "string",
  "order_id": "string",
  "processor_ref": "string",
  "amount": 0,
  "currency": "string",
  "exponent": 0,
  "reason": "string",
  "occurred_at": "string",
  "recorded_at": "string"
}
```

- `allocations` (`recordRefund.response.201.allocations`; array<object>, required)
  - `currency` (`recordRefund.response.201.allocations.currency`; string, required)
  - `exponent` (`recordRefund.response.201.allocations.exponent`; any of, required)
    - any of: `number`, `null`
  - `refund_id` (`recordRefund.response.201.allocations.refund_id`; string, required)
  - `order_item_id` (`recordRefund.response.201.allocations.order_item_id`; string, required)
  - `amount` (`recordRefund.response.201.allocations.amount`; any of, required)
    - any of: `number`, `null`
- `id` (`recordRefund.response.201.id`; string, required)
- `settlement_id` (`recordRefund.response.201.settlement_id`; string, required)
- `order_id` (`recordRefund.response.201.order_id`; string, required)
- `processor_ref` (`recordRefund.response.201.processor_ref`; any of, required)
  - any of: `string`, `null`
- `amount` (`recordRefund.response.201.amount`; any of, required)
  - any of: `number`, `null`
- `currency` (`recordRefund.response.201.currency`; string, required)
- `exponent` (`recordRefund.response.201.exponent`; any of, required)
  - any of: `number`, `null`
- `reason` (`recordRefund.response.201.reason`; any of, required)
  - any of: `string`, `null`
- `occurred_at` (`recordRefund.response.201.occurred_at`; any of, required)
  - any of: `string`, `null`
- `recorded_at` (`recordRefund.response.201.recorded_at`; any of, required)
  - any of: `string`, `null`

### default

A problem; see https://api.sherpo.io/merchant/docs/errors.

#### Example

```json
{
  "type": "http://example.com",
  "title": "string",
  "status": 0,
  "detail": "string",
  "code": "string",
  "context": {},
  "reached_core": true,
  "core_answer": "string"
}
```

- `type` (`recordRefund.response.default.type`; string, required)
  - format `uri`
- `title` (`recordRefund.response.default.title`; string, required)
- `status` (`recordRefund.response.default.status`; integer, required)
- `detail` (`recordRefund.response.default.detail`; string, required)
- `code` (`recordRefund.response.default.code`; string, optional)
- `context` (`recordRefund.response.default.context`; object, optional)
- `reached_core` (`recordRefund.response.default.reached_core`; boolean, optional)
- `core_answer` (`recordRefund.response.default.core_answer`; string, optional)


Source: https://docs.sherpo.io/merchant-api/reference/record-refund/index.md
