Esenda

Refunds

Refund a whole order or selected line items

Refund a whole order, or one or more of its line items in full or in part. An order can have more than one refund.

Endpoint

POST /v2/partner/orders/{shortcode}/{order_id}/refunds

Use the production or sandbox base URL from API conventions.

Path parameters

ParameterTypeRequiredDescription
shortcodeStringYesThe organisation's shortcode.
order_idUUIDYesThe order to refund.

Headers

HeaderRequiredValue
AuthorizationYesBearer <ACCESS_TOKEN>
Content-TypeYes, with a bodyapplication/json. Not needed for a whole-order refund sent with no body.
Idempotency-KeyYesUnique per refund request, for example a UUID. Repeating a request with the same key returns the original refund rather than creating a new one. See idempotency.

Request body

FieldTypeRequiredDescription
line_itemsArrayNoThe line items to refund, at least one, each listed once. Leave out to refund the whole order. See line items to refund.
reasonStringNoFree text, up to 60 characters.

Line items to refund

FieldTypeRequiredDescription
line_item_idUUIDYesThe line item to refund.
amountIntegerNoAmount in minor units (pence), at least 1. Defaults to the line item's remaining refundable amount.

How refunds work

  • With no line_items, whatever is still refundable on every line item is refunded. Line items that are already fully refunded are left out.
  • With line_items, only the line items listed are refunded, each for its amount or what's left on it. A single request can refund several line items.
  • A line item can be refunded more than once, up to its amount in total.
  • The order must be completed or partially_refunded, and must have line items. Orders created without line_items can't be refunded through the API.
  • Refunds through the API cover GBP card payments.
  • A refund comes out of the payout route the line item was paid into, and shows as a deduction on that route's next payout.
  • esenda fees aren't returned.
  • The refund is requested from the payment provider, so it starts as pending. The outcome is confirmed through the order.updated webhook, which lists the order's successful refunds.
  • Repeating a request with the same Idempotency-Key returns the original refund with 200. A new refund returns 201. Reusing a key for a different request returns 422.

Examples

Refund a whole order

POST /v2/partner/orders/ABCSCH/001a7b06-6ca9-4c05-8d6a-df5d9d9db7e3/refunds
Authorization: Bearer <ACCESS_TOKEN>
Content-Type: application/json
Idempotency-Key: 7c9e6679-7425-40de-944b-e07fc1f90ae7
{
  "reason": "Pupil left"
}

Refund one or more line items

POST /v2/partner/orders/ABCSCH/001a7b06-6ca9-4c05-8d6a-df5d9d9db7e3/refunds
Authorization: Bearer <ACCESS_TOKEN>
Content-Type: application/json
Idempotency-Key: 16fd2706-8baf-433b-82eb-8c7fada847da

The first line item is refunded for 5000 pence. The second has no amount, so what's left on it is refunded.

{
  "line_items": [
    {
      "line_item_id": "5b2e8f1a-3c4d-4e6f-8a9b-0c1d2e3f4a5b",
      "amount": 5000
    },
    {
      "line_item_id": "9d3c1e7b-6a52-4f08-b1d4-2e8a7c5f0b36"
    }
  ],
  "reason": "Trip partly cancelled"
}

Response

Returns 201 Created with the refund object. A repeated request with the same Idempotency-Key returns 200 OK with the original refund.

FieldTypeDescription
refund_idStringRefund identifier.
order_idStringThe order being refunded.
amountIntegerTotal refund amount in minor units (pence).
statusStringpending, refunded or refund_failed.
reasonString | nullRefund reason, if provided.
line_itemsArrayThe line items refunded, and how much on each. See refunded line item.
date_createdStringISO 8601 timestamp when the refund was created.

Refunded line item

FieldTypeDescription
line_item_idStringThe line item refunded.
amountIntegerAmount refunded on the line item, in pence.

A whole-order refund has one entry for each line item that had something left to refund.

{
  "refund_id": "cb03882b-25a0-45e8-b6f1-aa5cd303f88d",
  "order_id": "001a7b06-6ca9-4c05-8d6a-df5d9d9db7e3",
  "amount": 5000,
  "status": "pending",
  "reason": "Trip partly cancelled",
  "line_items": [
    {
      "line_item_id": "5b2e8f1a-3c4d-4e6f-8a9b-0c1d2e3f4a5b",
      "amount": 5000
    }
  ],
  "date_created": "2026-11-05T10:14:00.131483Z"
}

The refunds array on the orders list and in the order.updated webhook uses a similar object, but only for successful refunds.

See errors for the error response format.

On this page