Credits

Refund a credit charge

Gives a charge back to its credit account. The paywall middleware calls this when the request a charge paid for failed (your handler threw or answered 400 or higher). A charge can be refunded once; a second refund returns 409 with type invalid_state. Rate limit: 600 per minute per API key, counted separately from charges.

POST
/api/v1/credits/charges/{id}/refund

Authorization

bearerAuth
headerAuthorizationBearer <token>

A live API key, sk_live_ followed by 32 base58 characters.

Path Parameters

id*string

The charge id (cru_…) returned by the charge.

Header Parameters

Idempotency-Key?string

A unique string of 1 to 255 characters for this operation. A key belongs to the business across every endpoint for 24 hours, so give each operation its own key, for example invoice-order-1042 and refund-order-1042, not the order id alone. A retry with the same key on the same endpoint and with the same body returns the stored response with the header Idempotent-Replayed: true. The same key with a different body or on another endpoint returns 409 idempotency_conflict. Errors are not stored, so a request that failed can be retried with the same key, even with a corrected body. While the first request with a key is still running, a retry gets 409 idempotency_conflict with Retry-After: 1.

Length1 <= length <= 255

Response Body

The refunded charge, with the balance after the refund.

application/json
  1. response
id*string

Charge id, starting with cru_; pass it to the refund endpoint to give the charge back.

object*string
amount*string

Amount charged in USD with 6 decimals.

refunded?boolean

Present and true on the refund endpoint's answer.

balance*string

Balance in USD with 6 decimals after this charge or refund.

currency*string
Example Request
curl -X POST 'https://example.com/api/v1/credits/charges/string/refund'
Example Response
{  "id": "string",  "object": "credit_charge",  "amount": "string",  "refunded": true,  "balance": "string",  "currency": "USD"}