Skip to content
Hardcount
Run it locally
Pre-1.0 · one maintainer · Stripe and cards only · no SDKs (client libraries) yet · no production users yet. Docs describe v0.12.0 (30 Nov 2026) · What’s new →

Attach a refund made in Stripe to a credit note

POST
/v1/credit-notes/{id}/attach-stripe-refund
curl --request POST \
--url http://localhost:8080/v1/credit-notes/hc_cn_dbkrtc2q3gpgqfoq5c5g/attach-stripe-refund \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: 5f0c8a2e-7b1d-4c3e-9a6f-2d8b4e1c7a90' \
--data '{ "stripe_refund_id": "re_3QHk8cLkdIwHu7ix3d4e5f6a" }'

Makes a refund made in Stripe outside Hardcount the card refund of an issued credit note whose own refund failed: use it when you refunded in the Stripe dashboard what the note’s refund was for. Hardcount reads the refund from Stripe first. It must be of the payment that paid the invoice, not made by Hardcount, succeeded, and of exactly the note’s refund_amount_cents. The note then holds the refund (stripe_refund_id, refund_status, recorded_from_stripe), and a flagged row for it is marked recorded. No new credit note, no second tax reversal and no Stripe refund call. Hardcount never matches a refund to a note by amount on its own.

id
required
string

The issued credit note’s id (hc_cn_…).

Example

hc_cn_dbkrtc2q3gpgqfoq5c5g
Idempotency-Key
string
<= 255 characters

Makes the call safe to retry. Send a random UUID, and the same value on every retry. Keys are kept per account and mode, and every API key and dashboard user of the account shares them, so make a key unpredictable. A key over 255 characters is refused with 422 validation_error, param: Idempotency-Key. A request sent with a key runs to its end even if the client disconnects: retry with the same key for its answer. For 24 hours, a repeat from the same caller (the same API key or the same dashboard user) with the same key, method, path, query string and body gets the first response again, byte for byte, with an Idempotent-Replayed: true header, instead of running again. A first answer of 401, 403, 409, 422 or 503, or a 400 invalid JSON body, is not kept, so a retry with the same key runs again. A request to a path or method no route serves holds no key. A repeat sent while the first request is still running gets 409 with code conflict_idempotency at once: retry it in a moment with the same key. The same key from another caller, or with a different method, path, query string or body, is a 422 with code idempotency_error at once, even while the first request runs. The query string must match byte for byte. After 24 hours the key is free, and a request with it runs as new. The other error cases are in Idempotency. The usage routes do not take it: each usage event carries its own idempotency_key. The requests whose answer carries a secret shown only once (creating or rotating an API key, creating a webhook endpoint or rotating its signing secret, rotating a customer’s cost dashboard token, creating a card setup session) do not take it either: Hardcount does not keep that answer.

Example

5f0c8a2e-7b1d-4c3e-9a6f-2d8b4e1c7a90
Media typeapplication/json
object
stripe_refund_id
required

Stripe’s id of the refund you made (re_…).

string

Example

{
"stripe_refund_id": "re_3QHk8cLkdIwHu7ix3d4e5f6a"
}

The credit note, now holding the refund.

Media typeapplication/json

A credit note reduces what a customer owes on an invoice, or gives money back after it was paid. On an unpaid invoice it lowers amount_due_cents. On a paid invoice its total is split three ways: refund to the card (refund_amount_cents), credit to the customer’s balance (credit_amount_cents), and money returned another way (outside Stripe: out_of_band_amount_cents). Amounts are whole numbers in the currency’s minor unit (cents for USD). The credit note routes and POST /v1/invoices/{id}/refund return it.

object
id
required

Unique identifier of the credit note, starting hc_cn_.

string
tenant_id

The account the credit note belongs to. Absent when empty.

string
invoice_id
required

The invoice the note credits.

string
customer_id
required

The invoice’s customer.

string
credit_note_number
required

The number printed on the note: the account’s credit note prefix (default CN), a hyphen and a sequence padded to six digits, for example CN-000003. Test mode and live mode count separately. Set when the note is created, drafts included.

string
status
required

draft: created but not applied; it can be issued or voided. issued: applied to the invoice and final. voided: cancelled before it was issued.

string
Allowed values: draft issued voided
reason
required

Why the note was made, as given when it was created. A refund made with POST /v1/invoices/{id}/refund carries its refund reason (duplicate, fraudulent, requested_by_customer or other).

string
subtotal_cents
required

The credited amount without its tax, in the currency’s minor unit (cents for USD).

integer format: int64
tax_amount_cents
required

The tax part of the credited amount, in the currency’s minor unit (cents for USD). It is the invoice’s own tax share of the note, so crediting half of an invoice reverses half of its tax.

integer format: int64
total_cents
required

The credited amount with tax, in the currency’s minor unit (cents for USD): the sum of the note’s lines.

integer format: int64
refund_amount_cents
required

Part of the total refunded to the card that paid the invoice, in the currency’s minor unit (cents for USD). 0 on a note against an unpaid invoice.

integer format: int64
credit_amount_cents
required

Part of the total added to the customer’s credit balance, in the currency’s minor unit (cents for USD). 0 on a note against an unpaid invoice.

integer format: int64
out_of_band_amount_cents
required

Part of the total returned another way (outside Stripe: a bank transfer, cash, or the customer’s bank reversing the payment in a lost dispute), recorded for the books, in the currency’s minor unit (cents for USD). 0 on a note against an unpaid invoice.

integer format: int64
returned_another_way_at

When the note’s failed card refund was marked as returned another way (POST /v1/credit-notes/{id}/mark-returned-another-way), which moved it to out_of_band_amount_cents. Absent on every other note.

string format: date-time
commit_retired_cents

Prepaid commit credits this note retired, in the currency’s minor unit (cents for USD). Absent on other notes.

integer format: int64
currency
required

The invoice’s currency, uppercase.

string
issued_at

When the note was issued. Absent until it is issued.

string format: date-time
voided_at

When the note was voided. Absent unless it is voided.

string format: date-time
refund_status
required

The refund part’s state at Stripe. none: no refund was sent (no refund part, or the note is not issued yet); an issued note with a refund part stays none only when its refund’s result was not recorded. pending: Stripe has not finished it. succeeded and failed: Stripe’s answer. unknown: Stripe gave no clear answer (a timeout, a network error, a Stripe 5xx, a 409 or a 429), so the customer may already be refunded. Don’t refund it again in the Stripe Dashboard. Retry it with POST /v1/credit-notes/{id}/retry-refund, which looks for the refund at Stripe first and then resends the same request with the same idempotency key.

string
Allowed values: none pending succeeded failed unknown
stripe_refund_id

The Stripe refund (re_…) of the refund part. Absent until Stripe made one.

string
recorded_from_stripe
required

True when the card refund is a refund made in Stripe outside Hardcount: recorded from Stripe’s refund webhook, linked with stripe_refund_id at create, or attached with POST /v1/credit-notes/{id}/attach-stripe-refund. Hardcount made no refund call for it; stripe_refund_id names the refund.

boolean
bill_to_snapshot

What an issued invoice or credit note prints about its buyer. It is copied from the customer and the billing profile when the document is issued, so a later edit to either does not change it. The printed name is legal_name when set, otherwise display_name.

object
display_name
required

The customer’s display name when the document was issued.

string
legal_name

The billing profile’s legal name. Absent when none was set.

string
email

The customer’s email address. Absent when none was set.

string
address_line1

First address line of the billing profile. Absent when none was set.

string
address_line2

Second address line of the billing profile. Absent when none was set.

string
city

City of the billing profile. Absent when none was set.

string
state

State or region of the billing profile. Absent when none was set.

string
postal_code

Postal code of the billing profile. Absent when none was set.

string
country

Country of the billing profile, as a two-letter ISO 3166 code. Absent when none was set.

string
tax_id

On an invoice, the tax ID its tax was calculated with when set, otherwise the billing profile’s tax ID at issue. Absent when there is none.

string
tax_id_type

The kind of tax ID, as the billing profile stores it. Absent when none was set.

string
supplier_snapshot

What an issued invoice or credit note prints about its seller: your company details from the account settings, copied when the document was issued. A later change to the settings does not change it. Every field is absent when the setting was empty.

object
name

Your company name.

string
email

Your company’s contact email.

string
phone

Your company’s phone number.

string
address_line1

First line of your company address.

string
address_line2

Second line of your company address.

string
city

City of your company address.

string
state

State or region of your company address.

string
postal_code

Postal code of your company address.

string
country

Country of your company address.

string
tax_id

Your company’s tax ID.

string
tax_transaction_id

The tax provider’s reversal transaction, set when the note is issued against an invoice whose tax the provider recorded. Absent otherwise.

string
tax_reversal_pending
required

True while the credit note’s tax reversal at Stripe Tax is still owed. Set when a note with an amount is issued on an invoice Stripe Tax taxed, and cleared when the reversal is recorded, normally within the same request. It stays true while a failed reversal is retried, and while the invoice’s own tax is not yet recorded at Stripe. If the invoice’s tax is never recorded at Stripe, the flag stays true and no reversal is made.

boolean
metadata

Extra key-value data stored with the note. No API request sets it; it is absent when empty.

object
key
additional properties
any
created_at
required

When the note was created.

string format: date-time
recorded_at

The real-world time the note was created. Absent on notes created before releases recorded it.

string format: date-time
updated_at
required

When the note last changed.

string format: date-time

Example

{
"id": "hc_cn_dbkrtc2q3gpgqfoq5c5g",
"tenant_id": "hc_ten_dajqj02q3gpgqfoq5c00",
"invoice_id": "hc_inv_dbj84b2q3gpgqfoq5c40",
"customer_id": "hc_cus_dakhnk2q3gpgqfoq5c0g",
"credit_note_number": "CN-000003",
"status": "issued",
"reason": "requested_by_customer",
"subtotal_cents": 3750,
"tax_amount_cents": 0,
"total_cents": 3750,
"refund_amount_cents": 3750,
"credit_amount_cents": 0,
"out_of_band_amount_cents": 0,
"currency": "USD",
"issued_at": "2026-11-03T10:15:00Z",
"refund_status": "succeeded",
"stripe_refund_id": "re_3QHk8cLkdIwHu7ix3d4e5f6a",
"recorded_from_stripe": true,
"bill_to_snapshot": {
"display_name": "Acme Inc",
"legal_name": "Acme Incorporated",
"email": "billing@acme.example",
"address_line1": "100 Market Street",
"city": "San Francisco",
"state": "CA",
"postal_code": "94105",
"country": "US"
},
"supplier_snapshot": {
"name": "Example Labs Inc",
"email": "billing@examplelabs.example",
"address_line1": "1 Congress Avenue",
"city": "Austin",
"state": "TX",
"postal_code": "78701",
"country": "US"
},
"tax_reversal_pending": false,
"created_at": "2026-11-03T10:15:00Z",
"recorded_at": "2026-11-03T10:15:00Z",
"updated_at": "2026-11-06T09:30:00Z"
}

The body is not one valid JSON value, it is not a JSON object, it is empty where the operation needs one, or a field has the wrong JSON type (such as a string where a number belongs). This answer is not kept for an Idempotency-Key: send the corrected request with the same key.

Media typeapplication/json

The body of an error answer. error.type is the broad class, error.code is the exact reason for your code to branch on, and error.message is a sentence for a person. Quote error.request_id when you ask for help.

object
error

What went wrong.

object
type
required

One of invalid_request_error, authentication_error, rate_limit_error or api_error. Every error the API answers has this shape, including an unknown path (404, code route_not_found) and a method the path does not take (405, code method_not_allowed, with an Allow header). The few exceptions are listed in Errors.

string
code
required

The exact reason, such as validation_error, not_found, already_exists, invalid_state or a more specific code the operation lists. Branch on this, not on message.

string
message
required

What went wrong, written for a person to read.

string
request_id
required

The id of the request that produced this answer (req_…). It is normally the same value as the Hardcount-Request-Id response header. On an answer replayed for a repeated Idempotency-Key, the body is the first request’s, so this is the first request’s id, while the Hardcount-Request-Id header holds the new request’s id.

string
param

The request field or query parameter the error is about. Sent only when the error names one.

A request body may hold only the fields its operation lists, spelled and cased as listed. Any other field, or one the server sets (such as id), is refused with 422 and param naming it. An operation with no request body lists no fields: send no body, {} or null. The Stripe and Postmark webhooks and the LiteLLM callback take their sender’s body as it comes.

string

Example

{
"error": {
"type": "invalid_request_error",
"code": "invalid_request",
"message": "invalid JSON body",
"request_id": "req_dbjg652q3gpgqfoq5cd0"
}
}

No valid credential: the API key or session is missing, wrong, expired or revoked. With no API key and no valid session cookie, the message starts with missing credentials. A wrong, expired and revoked key all get the same message, invalid or expired API key.

Media typeapplication/json

The body of an error answer. error.type is the broad class, error.code is the exact reason for your code to branch on, and error.message is a sentence for a person. Quote error.request_id when you ask for help.

object
error

What went wrong.

object
type
required

One of invalid_request_error, authentication_error, rate_limit_error or api_error. Every error the API answers has this shape, including an unknown path (404, code route_not_found) and a method the path does not take (405, code method_not_allowed, with an Allow header). The few exceptions are listed in Errors.

string
code
required

The exact reason, such as validation_error, not_found, already_exists, invalid_state or a more specific code the operation lists. Branch on this, not on message.

string
message
required

What went wrong, written for a person to read.

string
request_id
required

The id of the request that produced this answer (req_…). It is normally the same value as the Hardcount-Request-Id response header. On an answer replayed for a repeated Idempotency-Key, the body is the first request’s, so this is the first request’s id, while the Hardcount-Request-Id header holds the new request’s id.

string
param

The request field or query parameter the error is about. Sent only when the error names one.

A request body may hold only the fields its operation lists, spelled and cased as listed. Any other field, or one the server sets (such as id), is refused with 422 and param naming it. An operation with no request body lists no fields: send no body, {} or null. The Stripe and Postmark webhooks and the LiteLLM callback take their sender’s body as it comes.

string

Example

{
"error": {
"type": "authentication_error",
"code": "unauthorized",
"message": "invalid or expired API key",
"request_id": "req_dbjg652q3gpgqfoq5cd0"
}
}

The credential is valid but may not call this route. A usage-only key (hc_ingest_…) can only send usage, read a customer’s live credit balance and call GET /v1/whoami; use a secret key. The message names the permission the key lacks. A browser request that would change data (POST, PUT, PATCH or DELETE) from a page on another site gets this 403 too, with the message cross-site request blocked.

Media typeapplication/json

The body of an error answer. error.type is the broad class, error.code is the exact reason for your code to branch on, and error.message is a sentence for a person. Quote error.request_id when you ask for help.

object
error

What went wrong.

object
type
required

One of invalid_request_error, authentication_error, rate_limit_error or api_error. Every error the API answers has this shape, including an unknown path (404, code route_not_found) and a method the path does not take (405, code method_not_allowed, with an Allow header). The few exceptions are listed in Errors.

string
code
required

The exact reason, such as validation_error, not_found, already_exists, invalid_state or a more specific code the operation lists. Branch on this, not on message.

string
message
required

What went wrong, written for a person to read.

string
request_id
required

The id of the request that produced this answer (req_…). It is normally the same value as the Hardcount-Request-Id response header. On an answer replayed for a repeated Idempotency-Key, the body is the first request’s, so this is the first request’s id, while the Hardcount-Request-Id header holds the new request’s id.

string
param

The request field or query parameter the error is about. Sent only when the error names one.

A request body may hold only the fields its operation lists, spelled and cased as listed. Any other field, or one the server sets (such as id), is refused with 422 and param naming it. An operation with no request body lists no fields: send no body, {} or null. The Stripe and Postmark webhooks and the LiteLLM callback take their sender’s body as it comes.

string

Example

{
"error": {
"type": "authentication_error",
"code": "forbidden",
"message": "insufficient permissions: this key type does not have customer:read access",
"request_id": "req_dbjg652q3gpgqfoq5cd0"
}
}

No credit note with this id in this account and mode.

Media typeapplication/json

The body of an error answer. error.type is the broad class, error.code is the exact reason for your code to branch on, and error.message is a sentence for a person. Quote error.request_id when you ask for help.

object
error

What went wrong.

object
type
required

One of invalid_request_error, authentication_error, rate_limit_error or api_error. Every error the API answers has this shape, including an unknown path (404, code route_not_found) and a method the path does not take (405, code method_not_allowed, with an Allow header). The few exceptions are listed in Errors.

string
code
required

The exact reason, such as validation_error, not_found, already_exists, invalid_state or a more specific code the operation lists. Branch on this, not on message.

string
message
required

What went wrong, written for a person to read.

string
request_id
required

The id of the request that produced this answer (req_…). It is normally the same value as the Hardcount-Request-Id response header. On an answer replayed for a repeated Idempotency-Key, the body is the first request’s, so this is the first request’s id, while the Hardcount-Request-Id header holds the new request’s id.

string
param

The request field or query parameter the error is about. Sent only when the error names one.

A request body may hold only the fields its operation lists, spelled and cased as listed. Any other field, or one the server sets (such as id), is refused with 422 and param naming it. An operation with no request body lists no fields: send no body, {} or null. The Stripe and Postmark webhooks and the LiteLLM callback take their sender’s body as it comes.

string

Example

{
"error": {
"type": "invalid_request_error",
"code": "not_found",
"message": "credit note not found",
"request_id": "req_dbjg652q3gpgqfoq5cd0"
}
}

Code invalid_state. The note is not issued or its refund did not fail, another note already holds the refund, its row was decided another way, or the note changed since it was read.

Media typeapplication/json

The body of an error answer. error.type is the broad class, error.code is the exact reason for your code to branch on, and error.message is a sentence for a person. Quote error.request_id when you ask for help.

object
error

What went wrong.

object
type
required

One of invalid_request_error, authentication_error, rate_limit_error or api_error. Every error the API answers has this shape, including an unknown path (404, code route_not_found) and a method the path does not take (405, code method_not_allowed, with an Allow header). The few exceptions are listed in Errors.

string
code
required

The exact reason, such as validation_error, not_found, already_exists, invalid_state or a more specific code the operation lists. Branch on this, not on message.

string
message
required

What went wrong, written for a person to read.

string
request_id
required

The id of the request that produced this answer (req_…). It is normally the same value as the Hardcount-Request-Id response header. On an answer replayed for a repeated Idempotency-Key, the body is the first request’s, so this is the first request’s id, while the Hardcount-Request-Id header holds the new request’s id.

string
param

The request field or query parameter the error is about. Sent only when the error names one.

A request body may hold only the fields its operation lists, spelled and cased as listed. Any other field, or one the server sets (such as id), is refused with 422 and param naming it. An operation with no request body lists no fields: send no body, {} or null. The Stripe and Postmark webhooks and the LiteLLM callback take their sender’s body as it comes.

string

Example

{
"error": {
"type": "invalid_request_error",
"code": "invalid_state",
"message": "a refund made in Stripe can be attached only to an issued credit note whose card refund failed",
"request_id": "req_dbjg652q3gpgqfoq5cd0"
}
}

The body is over the 1 MB limit. Send a smaller body. The answer is the same with or without an Idempotency-Key, and it is not kept for the key: the same key works for the smaller request.

Media typeapplication/json

The body of an error answer. error.type is the broad class, error.code is the exact reason for your code to branch on, and error.message is a sentence for a person. Quote error.request_id when you ask for help.

object
error

What went wrong.

object
type
required

One of invalid_request_error, authentication_error, rate_limit_error or api_error. Every error the API answers has this shape, including an unknown path (404, code route_not_found) and a method the path does not take (405, code method_not_allowed, with an Allow header). The few exceptions are listed in Errors.

string
code
required

The exact reason, such as validation_error, not_found, already_exists, invalid_state or a more specific code the operation lists. Branch on this, not on message.

string
message
required

What went wrong, written for a person to read.

string
request_id
required

The id of the request that produced this answer (req_…). It is normally the same value as the Hardcount-Request-Id response header. On an answer replayed for a repeated Idempotency-Key, the body is the first request’s, so this is the first request’s id, while the Hardcount-Request-Id header holds the new request’s id.

string
param

The request field or query parameter the error is about. Sent only when the error names one.

A request body may hold only the fields its operation lists, spelled and cased as listed. Any other field, or one the server sets (such as id), is refused with 422 and param naming it. An operation with no request body lists no fields: send no body, {} or null. The Stripe and Postmark webhooks and the LiteLLM callback take their sender’s body as it comes.

string

Example

{
"error": {
"type": "invalid_request_error",
"code": "payload_too_large",
"message": "The request body is larger than the 1 MB limit. Send a smaller body.",
"request_id": "req_dbjg652q3gpgqfoq5cd0"
}
}

Code validation_error. stripe_refund_id is missing; Stripe has no such refund in this mode; the refund is not of this invoice’s payment, was made by Hardcount, has not succeeded, or is in another currency or of another amount (param stripe_refund_id); or the body has an unknown field.

Media typeapplication/json

The body of an error answer. error.type is the broad class, error.code is the exact reason for your code to branch on, and error.message is a sentence for a person. Quote error.request_id when you ask for help.

object
error

What went wrong.

object
type
required

One of invalid_request_error, authentication_error, rate_limit_error or api_error. Every error the API answers has this shape, including an unknown path (404, code route_not_found) and a method the path does not take (405, code method_not_allowed, with an Allow header). The few exceptions are listed in Errors.

string
code
required

The exact reason, such as validation_error, not_found, already_exists, invalid_state or a more specific code the operation lists. Branch on this, not on message.

string
message
required

What went wrong, written for a person to read.

string
request_id
required

The id of the request that produced this answer (req_…). It is normally the same value as the Hardcount-Request-Id response header. On an answer replayed for a repeated Idempotency-Key, the body is the first request’s, so this is the first request’s id, while the Hardcount-Request-Id header holds the new request’s id.

string
param

The request field or query parameter the error is about. Sent only when the error names one.

A request body may hold only the fields its operation lists, spelled and cased as listed. Any other field, or one the server sets (such as id), is refused with 422 and param naming it. An operation with no request body lists no fields: send no body, {} or null. The Stripe and Postmark webhooks and the LiteLLM callback take their sender’s body as it comes.

string

Example

{
"error": {
"type": "invalid_request_error",
"code": "validation_error",
"message": "this refund is not of the payment that paid this invoice",
"request_id": "req_dbjg652q3gpgqfoq5cd0",
"param": "stripe_refund_id"
}
}

Too many requests. Wait for the number of seconds in Retry-After, then retry. The answers that pass the limit carry the X-RateLimit-* headers too.

Each API key has its own limit, by default 1,000 requests a minute (HARDCOUNT_RATE_LIMIT_GENERAL_PER_MIN), and 1,000 a second on the usage routes (HARDCOUNT_RATE_LIMIT_INGEST_PER_SEC). The dashboard sessions of one account share one limit per mode. The routes under /v1/auth and /v1/bootstrap (sign-in, password reset, invite accept, setup) count per client address, by default 100 a minute (HARDCOUNT_RATE_LIMIT_AUTH_PER_MIN). The public invoice, payment-update and cost-dashboard pages allow 60 a minute per client address.

Media typeapplication/json

The body of an error answer. error.type is the broad class, error.code is the exact reason for your code to branch on, and error.message is a sentence for a person. Quote error.request_id when you ask for help.

object
error

What went wrong.

object
type
required

One of invalid_request_error, authentication_error, rate_limit_error or api_error. Every error the API answers has this shape, including an unknown path (404, code route_not_found) and a method the path does not take (405, code method_not_allowed, with an Allow header). The few exceptions are listed in Errors.

string
code
required

The exact reason, such as validation_error, not_found, already_exists, invalid_state or a more specific code the operation lists. Branch on this, not on message.

string
message
required

What went wrong, written for a person to read.

string
request_id
required

The id of the request that produced this answer (req_…). It is normally the same value as the Hardcount-Request-Id response header. On an answer replayed for a repeated Idempotency-Key, the body is the first request’s, so this is the first request’s id, while the Hardcount-Request-Id header holds the new request’s id.

string
param

The request field or query parameter the error is about. Sent only when the error names one.

A request body may hold only the fields its operation lists, spelled and cased as listed. Any other field, or one the server sets (such as id), is refused with 422 and param naming it. An operation with no request body lists no fields: send no body, {} or null. The Stripe and Postmark webhooks and the LiteLLM callback take their sender’s body as it comes.

string

Example

{
"error": {
"type": "rate_limit_error",
"code": "rate_limited",
"message": "too many requests — please retry after the rate limit resets",
"request_id": "req_dbjg652q3gpgqfoq5cd0"
}
}
Retry-After
integer
Example
12

Seconds to wait before the next request can pass, rounded up to a whole second and at least 1.

X-RateLimit-Limit
integer
Example
1000

How many requests the limit allows in its period (a minute, or a second on the usage routes).

X-RateLimit-Remaining
integer
Example
0

How many requests are left in the current period.

X-RateLimit-Reset
integer format: int64
Example
1793870460

When the whole limit is available again, as Unix seconds. One request may pass sooner; Retry-After says when.

Code provider_error. Stripe could not be asked about the refund, for example because Stripe is not connected for this mode. Nothing changed.

Media typeapplication/json

The body of an error answer. error.type is the broad class, error.code is the exact reason for your code to branch on, and error.message is a sentence for a person. Quote error.request_id when you ask for help.

object
error

What went wrong.

object
type
required

One of invalid_request_error, authentication_error, rate_limit_error or api_error. Every error the API answers has this shape, including an unknown path (404, code route_not_found) and a method the path does not take (405, code method_not_allowed, with an Allow header). The few exceptions are listed in Errors.

string
code
required

The exact reason, such as validation_error, not_found, already_exists, invalid_state or a more specific code the operation lists. Branch on this, not on message.

string
message
required

What went wrong, written for a person to read.

string
request_id
required

The id of the request that produced this answer (req_…). It is normally the same value as the Hardcount-Request-Id response header. On an answer replayed for a repeated Idempotency-Key, the body is the first request’s, so this is the first request’s id, while the Hardcount-Request-Id header holds the new request’s id.

string
param

The request field or query parameter the error is about. Sent only when the error names one.

A request body may hold only the fields its operation lists, spelled and cased as listed. Any other field, or one the server sets (such as id), is refused with 422 and param naming it. An operation with no request body lists no fields: send no body, {} or null. The Stripe and Postmark webhooks and the LiteLLM callback take their sender’s body as it comes.

string

Example

{
"error": {
"type": "api_error",
"code": "provider_error",
"message": "Payment provider rejected the request. Please retry; if the problem persists, contact support.",
"request_id": "req_dbjg652q3gpgqfoq5cd0"
}
}

Stuck, or found a bug? Ask in Discussions · Open an issue