Refund the GoCardless collection of an invoice
POST/api/v1/invoices/:invoice_id/gocardless_refund
Refunds the invoice's settled GoCardless collection IN FULL and issues the matching credit note once the refund settles or, if it never does, 45 days after it was paid. A refund replacing one whose funds came back carries the credit note already issued, from creation. Partial refunds are not supported. Takes no request body: the amount is the collection's own. A 201 means the refund was accepted by GoCardless, not that the money has arrived - poll GET on this same path and read status and settled_at. Requires the gocardless_payment feature and a company whose offer allows sales.
Request
Responses
- 201
- 403
- 409
- 422
- 429
The refund was requested.
Response Headers
Present, and always true, when this response is the stored reply to an earlier call bearing the same Idempotency-Key. No refund was requested by the request that received it. Absent on the call that actually requested one.
The access token does not carry the write scope, the gocardless_payment feature is not enabled for the invoice's workspace, or the token's application may not write to this invoice. Unlike a 422, this refusal is about the caller, never about the collection - nothing was sent to GoCardless.
This Idempotency-Key cannot serve this request. code says which of three: idempotency_key_reuse - the key already served a request whose body differed from this one, so resend the original request byte for byte under the SAME key to replay it, and read this path before any new key, as below; idempotency_key_consumed - an earlier call bearing this key FINISHED, was refused with connector_error or unavailable after the refund was submitted, and the key stays spent for its 24 hours. Nothing is running, so do not poll; idempotency_request_in_progress - an earlier call bearing this key is still running, or ended with its outcome unknown, so retry with the SAME key within its 24 hours, which replays the first call's response once it completes. No refund was issued by this call in any case. If it still answers this code, or the 24 hours have passed (the same key then runs the request again), GET this path to see what the first one did before sending anything else - never resend blindly. A refund it reports as created or paid is the one you asked for. A requested refund is one whose outcome at GoCardless was never observed: it keeps its key spent for 24 hours, and the GET keeps reporting it, because only a new request settles it. To resume, send the refund again under a NEW key: the API first asks GoCardless, marks a refund GoCardless holds as created and refuses the duplicate with already_refunded, removes a claim GoCardless does not hold once it is over 10 minutes old (then sends the refund), and refuses with already_refunded while the claim is younger or GoCardless cannot be read - retry later.
The refund was refused. When the Idempotency-Key header is missing, code is validation_failed and details.idempotency_key says so; nothing was attempted and the key is not consumed. Otherwise code is always operation_failed; branch on details.reason_code, which is stable and never translated. Whether a retry is safe depends on which value you get, so read the four groups below rather than the code alone.
Eligibility - nothing was sent to GoCardless. These are decided before any network call, so no refund exists on the GoCardless side and retrying once the cause is fixed is safe: no_refundable_payment, payment_required (the eligibility check was reached with no collection to examine at all - this endpoint answers no_refundable_payment for that situation, so treat the two identically), payment_not_settled, safer_refund_period (GoCardless refuses a refund within 7 days of the collection), already_refunded, multiple_settled_collections, payment_amount_mismatch, payment_currency_mismatch, document_not_referenceable, sales_capability_not_allowed, no_invoice_pattern, missing_legal_mentions, refunds_not_enabled, creditor_status_unavailable. On missing_legal_mentions the remaining details keys name the company invoicing settings to fill in before retrying.
No usable connection - nothing was sent either. no_connection: the company's GoCardless account is not connected, or its authorization has been revoked. Reconnect it, then retry.
Review workspace - nothing was sent, and a retry will not succeed. review_workspace: the invoice belongs to the Scribee store-review workspace, which sends nothing to GoCardless. It is refused before any check or network call, every time.
Sent, outcome not established. connector_error (GoCardless answered with an error) and unavailable (GoCardless could not be reached, or did not answer in time) are both raised AFTER the refund was submitted. GoCardless may hold the refund. Do NOT blind-retry: GET this same path first, and treat any refund it reports as the one you asked for.
The key follows that same split. An eligibility, no_connection or review_workspace refusal releases the Idempotency-Key, so retrying with the same key once the cause is fixed is served normally. connector_error and unavailable hold it for the full 24 hours: a retry bearing that key is answered 409 idempotency_key_consumed, which is the signal to GET this path rather than to resend blindly; a refund it still reports as requested is resumed under a NEW key, as the 409 describes.
rate_limited: this OAuth application went over the partner API limit, 300 requests per minute per OAuth application, shared by every authenticated operation, every access token of the application and its calls to the MCP endpoint /mcp, which count against the same window. Nothing was done; retry after Retry-After seconds.
Response Headers
Seconds to wait before retrying.