Skip to navigation

Create Refund

View as Markdown

Create a refund for a payment intent or an invoice.

By payment_intent_id, the refund reverses the latest succeeded charge. By invoice_id, it reverses the charge that settled the invoice — and when that invoice has no cash left to reverse (settled entirely from customer credit, or its cash already fully refunded) it returns the credit still applied to the invoice instead: the refund then has charge_id null, amount_atom 0 and the value in credit_restored_atom.

Authentication

AuthorizationBearer

Bearer authentication of the form Bearer <token>, where token is your auth token.

Path parameters

account_idstringRequired

Headers

Idempotency-Keystring or nullOptional>=8 characters
A unique key for this request. A retry with the same key returns the first response instead of running again, for 24 hours. Keys are per caller.

Request

This endpoint expects an object.
payment_intent_idstring or nullOptional

ID of the payment intent to refund. The API auto-resolves the latest succeeded processor attempt.

invoice_idstring or nullOptional

ID of the invoice to refund. The API resolves the payment allocation and auto-resolves the succeeded processor attempt. Errors if the invoice was paid by multiple payment intents. An invoice settled entirely from customer credit, or whose cash has already been fully refunded, is refunded as credit alone: the refund has charge_id null and amount_atom 0, and credit_restored_atom carries what went back to the customer’s balance.

amount_atominteger or nullOptional

Total value to return, in atoms — filled cash first. For an invoice settled partly from customer credit this covers both legs: the excess over the cash leg comes back as credit (see credit_restored_atom on the response). If not provided, the full refundable cash on the charge, and nothing else: once that cash is gone an omitted amount is refused (RFR14), and the credit still applied comes back only for a stated amount. An invoice settled entirely from credit has no charge, so there an omitted amount returns all the credit still applied.

currencyenum or nullOptional
Currency code. If not provided, uses charge currency.
reasonenumOptional
Reason for the refund
metadatamap from strings to any or nullOptional

Additional metadata (max 10KB when serialized)

refunded_out_of_bandbooleanOptionalDefaults to false

Set to true if refund was already processed externally (e.g., in Stripe dashboard). This records the refund without calling the payment processor.

Response

Successful Response
idstring
ID of the refund
account_idstring
ID of the account
amount_atominteger

Cash refunded in atoms — what was reversed at the payment processor. For an invoice settled partly from customer credit this is the cash leg only; see credit_restored_atom for the rest. 0 for a refund that returned credit only.

credit_restored_atominteger

Customer credit returned to the balance by this refund, in atoms. Non-zero only when the invoice was settled partly from credit and the refund asked for more than its cash leg: refunds draw the cash down first, and the excess comes back as credit. Sum this with amount_atom for the total value returned to the customer. Always 0 until the refund has succeeded — a pending refund has returned nothing yet.

currencyenum

Currency code (e.g., USD)

statusenum
Status of a refund throughout its lifecycle.
Allowed values:
created_atdatetime
updated_atdatetime
charge_idstring or nullOptional

ID of the original charge. Null for a refund that returned credit only — an invoice settled entirely from the customer’s balance, or one whose cash had already been fully refunded — because no processor charge was reversed. Such a refund carries invoice_id instead; one of the two is always set.

invoice_idstring or nullOptional

ID of the invoice the refund was requested against, when it was created with invoice_id. Null for a refund requested by payment_intent_id, which may have settled several invoices. When the payment behind this invoice settled several invoices, the credit leg is restored across all of them oldest invoice (lowest id) first, so the credit may have come back on a sibling invoice rather than this one.

reasonenum or nullOptional
Reason for initiating a refund.
processor_refund_idstring or nullOptional

Processor’s refund ID (e.g., Stripe’s re_xxx)

failure_codestring or nullOptional
failure_messagestring or nullOptional
acquirer_reference_numberstring or nullOptional

The refund’s Acquirer Reference Number (ARN): the number the cardholder’s bank traces the refund with. Not the charge’s ARN. Null until the processor publishes it, often days after the refund succeeds, and always null for processors that do not report one.

processed_atdatetime or nullOptional
metadatamap from strings to any or nullOptional
issued_bystring or nullOptional

Who issued the refund, as a display label, not an identifier: the dashboard user’s current email (else their name, or their user id if the user was deleted), ‘API key “<description>”’ (‘API key’ when it has none), or, for one made in the customer portal, the customer’s email (else their name, or their customer id). The refund’s issuer even after the processor settles it, which PaymentKit records on its own. Null for a refund PaymentKit created itself (one found already refunded at the processor, a migrated one) and for a refund created before this was recorded. Do not parse it.

Errors

422
Unprocessable Entity Error