Create a credit note
const url = 'http://localhost:8080/v1/credit-notes';const options = { method: 'POST', headers: { 'Idempotency-Key': '5f0c8a2e-7b1d-4c3e-9a6f-2d8b4e1c7a90', Authorization: 'Bearer <token>', 'Content-Type': 'application/json' }, body: '{"invoice_id":"hc_inv_dbj84b2q3gpgqfoq5c40","reason":"Service outage on Oct 14","lines":[{"description":"Credit for the Oct 14 outage","quantity":1,"unit_amount_cents":1000}],"credit_amount_cents":1000}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url http://localhost:8080/v1/credit-notes \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --header 'Idempotency-Key: 5f0c8a2e-7b1d-4c3e-9a6f-2d8b4e1c7a90' \ --data '{ "invoice_id": "hc_inv_dbj84b2q3gpgqfoq5c40", "reason": "Service outage on Oct 14", "lines": [ { "description": "Credit for the Oct 14 outage", "quantity": 1, "unit_amount_cents": 1000 } ], "credit_amount_cents": 1000 }'Creates a credit note against a finalized or paid invoice. A
credit note is a document that reduces what the customer owes, or
gives money back after payment. There are two shapes.
Lines, for most invoices. Send lines; their amounts include tax,
and the note’s tax is its share of the invoice’s tax.
- On an unpaid invoice, leave the three
*_fields out: the note lowers the amount due when it is issued. It can be at most the amount due plus the customer credit applied.amount_ cents - On a paid invoice, split the note’s total across
refund_(back to the card),amount_ cents credit_(to the customer’s credit balance) andamount_ cents out_(returned another way, outside Stripe). The three must add up to the total. With all three 0, the whole note goes to the credit balance, or to the channelof_ band_ amount_ cents refund_names. The refund part can be at most what was paid by card less the refunds on earlier notes.type - All notes on an invoice together can be at most its total.
- The note is a
draftuntil you issue it, unlessauto_is true. Issuing applies it (seeissue POST /).v1/ credit-notes/ {id}/ issue
Commit relief, for paid top-ups only (billing_ topup).
Commit relief takes back the credit a customer has not used and gives
back its cash. Send commit_ and no lines. Unused credit is
what is left of the top-up’s credit now (usable up to its expiry
instant), but no more than the customer’s balance in its currency
less the usage not invoiced yet. Hardcount retires the credit and
works out the cash to give back at the price the customer paid for
it, so a discounted top-up is refunded at the discounted rate, never
at face value. The note is created and issued in one step. Its cash
goes to the card or out of band, never to the credit balance; the
card gets at most what it paid less every refund of that payment,
refunds made in Stripe included. Relief is refused while the
customer’s bank holds a chargeback on the payment (an appeal
included). After the bank won it, nothing more goes to the card:
send the cash as out_, once the loss’s own
credit note is written. An unpaid top-up granted no credit: void it
to withdraw it.
A note with stripe_ records a refund already made in
Stripe; see that field. On a top-up it also takes back the unused
credit the refund paid for (commit_). Nothing is
emailed; send the note with POST /.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Header Parameters
Section titled “Header Parameters”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_, 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_ 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_ 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_.
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-2d8b4e1c7a90Request Bodyrequired
Section titled “Request Bodyrequired”object
The invoice to credit. It must be finalized or paid.
Why you are crediting, printed on the note. Required for a
line-based note. For a relief, commit_ wins;
this one is used when that is empty, and commit_
is the reason when both are empty.
The credited amounts, tax included. At least one line for a line-based note; none with commit_.
object
Optional. The invoice line this credit line reverses. It must be a line of this invoice.
The text printed on the line.
How many units, 1 or more.
Credit per unit, tax included, in the currency’s minor unit (cents for USD). 1 or more.
Part of the total refunded to the card, in the currency’s minor unit (cents for USD). Paid invoices only. Not with commit_relief; put the relief’s split inside commit_relief.
Part of the total added to the customer’s credit balance, in the currency’s minor unit (cents for USD). Paid invoices only. Not with commit_relief.
Part of the total returned another way (outside Stripe), in the currency’s minor unit (cents for USD). Paid invoices only. Not with commit_relief; put the relief’s split inside commit_relief.
Older single-channel form. On a paid invoice whose three
*_ fields are all 0, refund or credit
puts the whole note in that channel. Not with commit_relief.
True issues the note in the same call. If the issue fails, the draft is voided and the error is returned. Defaults to false (the note stays a draft).
Links a refund made in Stripe outside Hardcount as this
note’s card refund, like Stripe’s refunds[]: Hardcount
reads the refund from Stripe and calls nothing else
there for it. The refund must be of the payment that paid
this invoice, not made by Hardcount, and succeeded;
refund_ must be its amount,
credit_ 0, and auto_ true (the
note is issued at once). The caps on the invoice still
apply. A refund Hardcount flagged on the invoice
(refunded_) is then marked recorded. It may
be a refund made before the customer’s bank won a
dispute on the payment. On a top-up the note also takes
back the unused credit the refund paid for, at the price
paid, and all of it when the refund returns the last of
the payment (commit_). Not with
commit_relief.
Mutually exclusive with lines and credit_amount_cents. The
relief’s split goes in here, not at the top level: a top-level
refund_, out_ or
refund_ is a 422. Example, all the unused credit
returned another way (outside Stripe):
{"invoice_.
object
Optional. Defaults to the top-level invoice_id.
Optional. Wins over the top-level reason. When both
are empty, the note’s reason is Unused prepaid credit refunded.
Credit to retire, in the currency’s minor unit (cents
for USD), from 1 to the unused credit, and no more
than the cash the payment has left to return pays
for. Above either is a 422 that names the figure. An
amount whose cash returns the last of the payment is
a 422 asking for retire_, which takes all the
unused credit.
Retire all the unused credit at the moment the relief runs, so credit the customer spends meanwhile is not counted. retire_ is then ignored.
Optional. Part of the cash refunded to the card. With out_ it must add up to the cash Hardcount works out. When both are left out, the cash goes to the card if the invoice was paid by card, otherwise out of band.
Optional. Part of the cash returned another way (outside Stripe).
Example
{ "invoice_id": "hc_inv_dbj84b2q3gpgqfoq5c40", "reason": "Service outage on Oct 14", "lines": [ { "description": "Credit for the Oct 14 outage", "quantity": 1, "unit_amount_cents": 1000 } ], "credit_amount_cents": 1000}Responses
Section titled “Responses”The credit note, a draft unless auto_ was true or it is a commit relief.
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_. On a paid invoice its total is split three ways:
refund to the card (refund_), credit to the customer’s
balance (credit_), and money returned another way
(outside Stripe: out_). Amounts are whole numbers in the
currency’s minor unit (cents for USD). The credit note routes and
POST / return it.
object
Unique identifier of the credit note, starting hc_cn_.
The account the credit note belongs to. Absent when empty.
The invoice the note credits.
The invoice’s customer.
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.
draft: created but not applied; it can be issued or voided.
issued: applied to the invoice and final. voided: cancelled
before it was issued.
Why the note was made, as given when it was created. A refund
made with POST / carries its refund
reason (duplicate, fraudulent, requested_ or
other).
The credited amount without its tax, in the currency’s minor unit (cents for USD).
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.
The credited amount with tax, in the currency’s minor unit (cents for USD): the sum of the note’s lines.
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.
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.
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.
When the note’s failed card refund was marked as returned another
way (POST /), which
moved it to out_. Absent on every other note.
Prepaid commit credits this note retired, in the currency’s minor unit (cents for USD). Absent on other notes.
The invoice’s currency, uppercase.
When the note was issued. Absent until it is issued.
When the note was voided. Absent unless it is voided.
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 /, which looks for the
refund at Stripe first and then resends the same request with
the same idempotency key.
The Stripe refund (re_…) of the refund part. Absent until Stripe made one.
True when the card refund is a refund made in Stripe outside
Hardcount: recorded from Stripe’s refund webhook, linked with
stripe_ at create, or attached with
POST /. Hardcount made
no refund call for it; stripe_ names the refund.
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_ when set, otherwise display_.
object
The customer’s display name when the document was issued.
The billing profile’s legal name. Absent when none was set.
The customer’s email address. Absent when none was set.
First address line of the billing profile. Absent when none was set.
Second address line of the billing profile. Absent when none was set.
City of the billing profile. Absent when none was set.
State or region of the billing profile. Absent when none was set.
Postal code of the billing profile. Absent when none was set.
Country of the billing profile, as a two-letter ISO 3166 code. Absent when none was set.
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.
The kind of tax ID, as the billing profile stores it. Absent when none was set.
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
Your company name.
Your company’s contact email.
Your company’s phone number.
First line of your company address.
Second line of your company address.
City of your company address.
State or region of your company address.
Postal code of your company address.
Country of your company address.
Your company’s tax ID.
The tax provider’s reversal transaction, set when the note is issued against an invoice whose tax the provider recorded. Absent otherwise.
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.
Extra key-value data stored with the note. No API request sets it; it is absent when empty.
object
When the note was created.
The real-world time the note was created. Absent on notes created before releases recorded it.
When the note last changed.
Example
{ "id": "hc_cn_dbkrtc2q3gpgqfoq5c5h", "tenant_id": "hc_ten_dajqj02q3gpgqfoq5c00", "invoice_id": "hc_inv_dbj84b2q3gpgqfoq5c40", "customer_id": "hc_cus_dakhnk2q3gpgqfoq5c0g", "credit_note_number": "CN-000004", "status": "draft", "reason": "Service outage on Oct 14", "subtotal_cents": 1000, "tax_amount_cents": 0, "total_cents": 1000, "refund_amount_cents": 0, "credit_amount_cents": 1000, "out_of_band_amount_cents": 0, "currency": "USD", "refund_status": "none", "recorded_from_stripe": false, "tax_reversal_pending": false, "created_at": "2026-11-04T08:00:00Z", "recorded_at": "2026-11-04T08:00:00Z", "updated_at": "2026-11-04T08:00: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.
The body of an error answer. error. is the broad class,
error. is the exact reason for your code to branch on, and
error. is a sentence for a person. Quote
error. when you ask for help.
object
What went wrong.
object
One of invalid_, authentication_,
rate_ or api_. Every error the API
answers has this shape, including an unknown path (404,
code route_) and a method the path does not take
(405, code method_, with an Allow header).
The few exceptions are listed in
Errors.
The exact reason, such as validation_, not_,
already_, invalid_ or a more specific code
the operation lists. Branch on this, not on message.
What went wrong, written for a person to read.
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.
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.
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.
The body of an error answer. error. is the broad class,
error. is the exact reason for your code to branch on, and
error. is a sentence for a person. Quote
error. when you ask for help.
object
What went wrong.
object
One of invalid_, authentication_,
rate_ or api_. Every error the API
answers has this shape, including an unknown path (404,
code route_) and a method the path does not take
(405, code method_, with an Allow header).
The few exceptions are listed in
Errors.
The exact reason, such as validation_, not_,
already_, invalid_ or a more specific code
the operation lists. Branch on this, not on message.
What went wrong, written for a person to read.
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.
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.
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_) can only send usage, read a customer’s live
credit balance and call GET /; 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.
The body of an error answer. error. is the broad class,
error. is the exact reason for your code to branch on, and
error. is a sentence for a person. Quote
error. when you ask for help.
object
What went wrong.
object
One of invalid_, authentication_,
rate_ or api_. Every error the API
answers has this shape, including an unknown path (404,
code route_) and a method the path does not take
(405, code method_, with an Allow header).
The few exceptions are listed in
Errors.
The exact reason, such as validation_, not_,
already_, invalid_ or a more specific code
the operation lists. Branch on this, not on message.
What went wrong, written for a person to read.
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.
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.
Example
{ "error": { "type": "authentication_error", "code": "forbidden", "message": "insufficient permissions: this key type does not have customer:read access", "request_id": "req_dbjg652q3gpgqfoq5cd0" }}No invoice with this invoice_ in this account and mode. The message says credit_.
The body of an error answer. error. is the broad class,
error. is the exact reason for your code to branch on, and
error. is a sentence for a person. Quote
error. when you ask for help.
object
What went wrong.
object
One of invalid_, authentication_,
rate_ or api_. Every error the API
answers has this shape, including an unknown path (404,
code route_) and a method the path does not take
(405, code method_, with an Allow header).
The few exceptions are listed in
Errors.
The exact reason, such as validation_, not_,
already_, invalid_ or a more specific code
the operation lists. Branch on this, not on message.
What went wrong, written for a person to read.
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.
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.
Example
{ "error": { "type": "invalid_request_error", "code": "not_found", "message": "credit_note not found", "request_id": "req_dbjg652q3gpgqfoq5cd0" }}The invoice’s state refuses the note. Code invalid_: the
invoice is a draft, voided or written off, already fully
credited, or bought prepaid credit (use commit relief or
stripe_ when it is paid, void it when it is unpaid); a
relief on an unpaid or withdrawn top-up, one with no unused
credit, one whose payment is already returned in full, or one of
a customer with an issued invoice still to draw on the credit; or
a stripe_ that a credit note already records, or that
is still in flight at Stripe. Code stripe_: a
relief while a refund made in Stripe on the top-up is in flight
or flagged. Code payment_: a relief on a top-up whose
payment the customer’s bank disputes (a chargeback, an appeal
included). Code dispute_: a relief on a top-up
whose payment the bank took back in a dispute whose credit note is
not written yet; write it with
POST / first.
Code payment_: a charge on the invoice is unresolved.
Code concurrent_: with auto_, Postgres stopped the
issue because of another change to the same records (it broke a
deadlock, or ended a wait for a lock), and the note made was voided;
send the same request again, with the same Idempotency-Key, to
make and issue a new one.
The body of an error answer. error. is the broad class,
error. is the exact reason for your code to branch on, and
error. is a sentence for a person. Quote
error. when you ask for help.
object
What went wrong.
object
One of invalid_, authentication_,
rate_ or api_. Every error the API
answers has this shape, including an unknown path (404,
code route_) and a method the path does not take
(405, code method_, with an Allow header).
The few exceptions are listed in
Errors.
The exact reason, such as validation_, not_,
already_, invalid_ or a more specific code
the operation lists. Branch on this, not on message.
What went wrong, written for a person to read.
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.
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.
Example
{ "error": { "type": "invalid_request_error", "code": "invalid_state", "message": "cannot create credit notes for voided invoices", "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.
The body of an error answer. error. is the broad class,
error. is the exact reason for your code to branch on, and
error. is a sentence for a person. Quote
error. when you ask for help.
object
What went wrong.
object
One of invalid_, authentication_,
rate_ or api_. Every error the API
answers has this shape, including an unknown path (404,
code route_) and a method the path does not take
(405, code method_, with an Allow header).
The few exceptions are listed in
Errors.
The exact reason, such as validation_, not_,
already_, invalid_ or a more specific code
the operation lists. Branch on this, not on message.
What went wrong, written for a person to read.
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.
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.
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_, with param naming the field: a missing
reason or lines; a line with a quantity or amount below 1, or
naming another invoice’s line; a note above what the invoice can
still be credited; amounts that do not add up to the total; a
refund above what the card has left, after the refunds of earlier
notes and the refunds made in Stripe that no note holds; a refund
to the card of a payment the customer’s bank took back in a
dispute (param refund_: route it to
credit_ or out_); a
stripe_ that does not qualify; a relief on an invoice
that is not a top-up, one above the unused credit, one whose
retire_ pays for more cash than the payment has left, one
whose retire_ returns the last of the payment (send
retire_), one that rounds to no cash, or one whose card
refund is above what the card has left or follows a lost dispute;
or an unknown field (the body must use only the fields listed
here).
The body of an error answer. error. is the broad class,
error. is the exact reason for your code to branch on, and
error. is a sentence for a person. Quote
error. when you ask for help.
object
What went wrong.
object
One of invalid_, authentication_,
rate_ or api_. Every error the API
answers has this shape, including an unknown path (404,
code route_) and a method the path does not take
(405, code method_, with an Allow header).
The few exceptions are listed in
Errors.
The exact reason, such as validation_, not_,
already_, invalid_ or a more specific code
the operation lists. Branch on this, not on message.
What went wrong, written for a person to read.
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.
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.
Example
{ "error": { "type": "invalid_request_error", "code": "validation_error", "message": "refund_amount_cents ($10.00) + credit_amount_cents ($0.00) + out_of_band_amount_cents ($0.00) = $10.00, must equal credit note total $12.50", "request_id": "req_dbjg652q3gpgqfoq5cd0", "param": "allocation" }}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_), and 1,000 a second on the
usage routes (HARDCOUNT_). The dashboard
sessions of one account share one limit per mode. The routes under
/ and / (sign-in, password reset, invite
accept, setup) count per client address, by default 100 a minute
(HARDCOUNT_). The public invoice,
payment-update and cost-dashboard pages allow 60 a minute per client
address.
The body of an error answer. error. is the broad class,
error. is the exact reason for your code to branch on, and
error. is a sentence for a person. Quote
error. when you ask for help.
object
What went wrong.
object
One of invalid_, authentication_,
rate_ or api_. Every error the API
answers has this shape, including an unknown path (404,
code route_) and a method the path does not take
(405, code method_, with an Allow header).
The few exceptions are listed in
Errors.
The exact reason, such as validation_, not_,
already_, invalid_ or a more specific code
the operation lists. Branch on this, not on message.
What went wrong, written for a person to read.
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.
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.
Example
{ "error": { "type": "rate_limit_error", "code": "rate_limited", "message": "too many requests — please retry after the rate limit resets", "request_id": "req_dbjg652q3gpgqfoq5cd0" }}Headers
Section titled “Headers”Example
12Seconds to wait before the next request can pass, rounded up to a whole second and at least 1.
Example
1000How many requests the limit allows in its period (a minute, or a second on the usage routes).
Example
0How many requests are left in the current period.
Example
1793870460When the whole limit is available again, as Unix seconds. One
request may pass sooner; Retry-After says when.
Code provider_. Stripe could not be asked about the
stripe_, for example because Stripe is not connected
for this mode. Nothing was created.
The body of an error answer. error. is the broad class,
error. is the exact reason for your code to branch on, and
error. is a sentence for a person. Quote
error. when you ask for help.
object
What went wrong.
object
One of invalid_, authentication_,
rate_ or api_. Every error the API
answers has this shape, including an unknown path (404,
code route_) and a method the path does not take
(405, code method_, with an Allow header).
The few exceptions are listed in
Errors.
The exact reason, such as validation_, not_,
already_, invalid_ or a more specific code
the operation lists. Branch on this, not on message.
What went wrong, written for a person to read.
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.
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.
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" }}Code unbilled_, with stripe_ on a
top-up: Hardcount could not read the customer’s usage not
invoiced yet, which the note counts as credit already used, so
it wrote nothing. This answer
is not stored under the Idempotency-Key: send the same request
with the same key after Retry-After.
The body of an error answer. error. is the broad class,
error. is the exact reason for your code to branch on, and
error. is a sentence for a person. Quote
error. when you ask for help.
object
What went wrong.
object
One of invalid_, authentication_,
rate_ or api_. Every error the API
answers has this shape, including an unknown path (404,
code route_) and a method the path does not take
(405, code method_, with an Allow header).
The few exceptions are listed in
Errors.
The exact reason, such as validation_, not_,
already_, invalid_ or a more specific code
the operation lists. Branch on this, not on message.
What went wrong, written for a person to read.
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.
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.
Example
{ "error": { "type": "api_error", "code": "unbilled_usage_unavailable", "message": "Hardcount could not read the customer's usage not invoiced yet, so it wrote nothing; try again in a moment.", "request_id": "req_dbjg652q3gpgqfoq5cd0" }}Headers
Section titled “Headers”Seconds to wait before you send the request again.
Stuck, or found a bug? Ask in Discussions · Open an issue