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 →

Retry tax calculation on a draft invoice

POST
/v1/invoices/{id}/retry-tax
curl --request POST \
--url http://localhost:8080/v1/invoices/hc_inv_dbj84b2q3gpgqfoq5c40/retry-tax \
--header 'Authorization: Bearer <token>' \
--header 'Idempotency-Key: 5f0c8a2e-7b1d-4c3e-9a6f-2d8b4e1c7a90'

Calculates tax again on a draft invoice whose tax_status is pending, after you fixed the cause (for example the customer’s address). It also refreshes a draft whose Stripe Tax calculation expires within 1 hour or has expired, and was never recorded, which finalize refuses. The route takes no body.

Each call rewrites the tax on the lines and the invoice. A retry of pending tax adds one to tax_retry_count; refreshing an expired calculation does not. A retry that succeeds clears tax_pending_reason and tax_error_code. A retry that still fails records the new error code and answers 200 with the updated invoice, so check its attention.

When the tax resolves on an invoice the billing engine made, the call also finalizes it, in the same transaction as the tax. If nothing is then due, the invoice is marked paid at once; otherwise the automatic charge collects it on its next run. An invoice you created stays a draft for you to finalize. If the finalize fails, the call returns 500 or 409 and the tax is not saved: the invoice stays a draft with its tax pending and keeps its notice. The try is counted (toward the automatic retries, for an error Hardcount retries). A 409 names the finalize failure; for a 500 the server log says why.

id
required
string

The draft invoice’s id (hc_inv_…).

Example

hc_inv_dbj84b2q3gpgqfoq5c40
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

Invoice updated; check attention for the new state.

Media typeapplication/json

A bill for one customer, in one currency. The billing engine creates one at the end of each subscription period (and for a subscription’s start when a fee is billed in advance, or a cancel); you can also create one-off invoices with POST /v1/invoices. The engine creates its invoices already finalized, or as a draft while their tax is pending. An invoice you create starts as a draft until you finalize it. A finalized invoice ends paid, voided or uncollectible. Every amount is a whole number in the currency’s minor unit (cents for USD). The invoice routes and the invoice.* and payment.* webhook events return it.

object
id
required

Unique identifier of the invoice, starting hc_inv_.

string
tenant_id

The account the invoice belongs to. Your API key already decides the account, so you rarely need it.

string
customer_id
required

The customer the invoice bills.

string
subscription_id
required

The subscription the invoice bills. An empty string when the invoice bills no subscription. An invoice you create with POST /v1/invoices carries the subscription_id you sent.

string
invoice_number
required

The number printed on the invoice: the account’s invoice prefix (default HC), a hyphen and a sequence padded to six digits, for example HC-000042. Test mode and live mode count separately. Set when the invoice is created, drafts included, except on a top-up (billing_reason topup): empty until its payment numbers it, and still empty once an unpaid one is voided.

string
status
required

Where the invoice is in its life.

  • draft: not issued yet. Lines can still be added, and nothing is charged.
  • finalized: issued and owed. Hardcount collects it.
  • paid: settled, by card, credit, an offline payment or a credit note that left nothing due.
  • voided: cancelled. Nothing is owed. Voiding is final.
  • uncollectible: written off as bad debt, by you (POST /v1/invoices/{id}/mark-uncollectible) or by a dunning policy’s final action. Hardcount stops collecting it, but it stays on the books and can still be paid.
string
Allowed values: draft finalized paid voided uncollectible
payment_status
required

The state of the invoice’s payment.

  • pending: nothing has been charged yet, or a charge is about to be sent. Also the status after Stripe refused the amount as below its minimum charge (see amount_below_minimum).
  • processing: Stripe is still working on a charge.
  • succeeded: the invoice is paid.
  • failed: the last charge was declined or refused. Dunning, when a policy is on, retries it.
  • unknown: a Stripe charge is being confirmed, or its answer was unclear. Every card charge shows it for the moment the charge takes: Hardcount records the Stripe payment on the invoice (stripe_payment_intent_id) before any money moves, then confirms it. If the answer is unclear (a 5xx, a timeout or a dropped connection), the invoice stays unknown, and Hardcount cannot yet tell whether Stripe took the money. A few minutes later it reads that payment from Stripe and records what happened: paid, declined, or nothing charged. After “nothing charged” the invoice goes back to pending (failed after a dunning retry) and is charged again as usual.
string
Allowed values: pending processing succeeded failed unknown
currency
required

The invoice’s currency, as an uppercase ISO 4217 code. Every amount on the invoice and its lines is in this currency’s minor unit.

string
subtotal_cents
required

The sum of the line amounts, before discount and tax, in the currency’s minor unit (cents for USD). With tax-inclusive prices, it is the net amount after the tax is taken out.

integer format: int64
discount_cents
required

Discount taken off the subtotal, in the currency’s minor unit (cents for USD). 0 when there is none.

integer format: int64
tax_amount_cents
required

Tax on the invoice, in the currency’s minor unit (cents for USD). On an invoice you create with POST /v1/invoices, it is 0 until finalize calculates the tax.

integer format: int64
tax_rate
required

Tax rate as a percent, up to four decimal places (18.5 means 18.5%).

number format: double
tax_inclusive
required

Whether the invoice’s prices include tax, fixed when the invoice is created: a subscription invoice takes the account’s tax-inclusive setting at the time its lines were priced, a one-off invoice the setting when it was created. The invoice’s tax is always worked out in these terms, so a later change to the setting does not change it. Invoices from before this field take the account’s setting at the upgrade.

boolean
tax_name

The tax’s label, such as VAT or Sales Tax. Absent when there is none.

string
tax_country

The country the tax was calculated for. Absent when none was recorded.

string
tax_id

The customer’s tax ID the tax was calculated with. Absent when there was none.

string
tax_provider

The tax engine that calculated the tax: stripe_tax, manual (a flat rate from the account settings) or none. A draft’s tax can be calculated again (retry-tax, or finalize of a one-off draft); once the invoice is finalized it no longer changes. Absent until tax is calculated.

string
tax_calculation_id

The tax provider’s calculation reference (Stripe Tax only). A Stripe Tax calculation expires 90 days after it is made; Hardcount keeps the reference so a finalized invoice can still be traced. Absent for the manual and none providers.

string
tax_transaction_id

The tax provider’s committed transaction (Stripe Tax only). On an invoice the billing engine creates, it is recorded when the invoice is built; on one you create, at finalize. When that first commit fails, a background retry records it later. Hardcount reverses it when the invoice is voided or a credit note is issued. Absent until committed, and for providers that keep no record.

string
tax_reverse_charge

True when reverse charge applies: no tax is charged and the customer accounts for it. Absent when false.

boolean
tax_exempt_reason

Why the customer is exempt from tax, as recorded on the customer. Absent when they are not exempt.

string
tax_status

Whether tax has been calculated. ok: it has (a zero tax counts). pending: the calculation failed, and tax_error_code says why and whether Hardcount retries it. A pending invoice stays a draft and cannot be finalized, so a wrong tax amount is never sent.

string
Allowed values: ok pending
tax_deferred_at

When the tax calculation failed and the invoice was held as a draft. A later successful calculation clears it. Absent unless tax is deferred.

string format: date-time
tax_retry_count

How many times tax was calculated again while it was pending: each POST /v1/invoices/{id}/retry-tax on pending tax, each automatic retry, and each finalize of a one-off draft whose earlier calculation failed. Absent when 0.

integer
tax_pending_reason

Why tax could not be calculated, while tax_status is pending: the provider’s error, or Hardcount’s own text when the provider was never called (tax_error_code provider_not_configured). Cut to 500 bytes. Absent otherwise.

string
tax_error_code

Why tax could not be calculated, as a code. Set while tax_status is pending; tax_pending_reason has the detail.

string
Allowed values: customer_data_invalid jurisdiction_unsupported provider_outage provider_auth provider_not_configured unknown
tax_next_retry_at

The earliest time the background retry may calculate tax again, after a failed attempt. Absent when a retry may run now, and when none is scheduled: an error code Hardcount does not retry, or the automatic retries are used up. After the invoice is finalized, it is the earliest time Hardcount retries a tax commit or tax reversal that failed. It can hold a past time with nothing left to retry, when the Stripe Tax calculation expired while a commit was waiting.

string format: date-time
tax_reversed_at

When the provider’s tax transaction was reversed after a void, or found to need no reversal. Absent while the reversal is not confirmed.

string format: date-time
payment_anomaly_kind

Set when a payment arrived that the invoice did not expect. The webhook event name of the cause: payment.duplicate_charge, payment.amount_mismatch, payment.currency_mismatch or payment.received_on_voided_invoice. Only the latest one is kept. Absent when there is none.

string
payment_anomaly_payment_intent_id

The Stripe PaymentIntent of that unexpected payment. Absent when there is none.

string
payment_anomaly_captured_cents

The amount Stripe took in that unexpected payment, in the currency’s minor unit (cents for USD). Absent when there is none.

integer format: int64
payment_card_brand

Brand of the saved card that paid the invoice, as Stripe names it (for example visa). Absent when the card is unknown.

string
payment_card_last4

Last four digits of the saved card that paid the invoice. Absent when the card is unknown.

string
attention

Why an invoice needs your attention now, and what to do about it. Hardcount works it out each time the invoice is read, from the invoice’s tax and payment state and related facts (the customer’s card, the dunning run, disputes, refunds made in Stripe); it is never stored. The invoice leaves it out when nothing needs attention. GET /v1/invoices, GET /v1/invoices/{id} and the finalize, retry-tax and rotate-public-token responses carry it; the other invoice responses and the webhook events do not.

object
severity
required

How urgent an Attention notice is, most urgent first: critical, warning, info. Sort or filter on it; the dashboard shows one colour per level.

string
Allowed values: info warning critical
reason
required

Why an invoice needs your attention, as a closed code. A code is never reused for another meaning; a retired code stays reserved. Attention.code carries the open, provider-specific sub-code.

  • tax_calculation_failed: the tax provider could not calculate tax. The cause is in code.
  • tax_location_required: the customer’s billing address or tax ID is missing or not valid for the tax provider. Edit the billing profile.
  • payment_failed: the last charge failed. code is payment.declined for a decline, payment.card_refused when the bank refused the card for good, or payment.authentication_required when the bank wants the customer to confirm the payment. Stripe’s own message is in provider_response.
  • payment_unconfirmed: a charge got an unclear answer from Stripe. Hardcount asks Stripe what happened.
  • payment_anomaly: money does not reconcile: a double charge, a captured amount that differs from the amount booked, a payment in another currency, or a payment on a voided invoice. Shown even on paid and voided invoices.
  • payment_processing: a payment may be in progress. Stripe is still processing a charge (it settles on its own), the customer has the hosted payment page open (code payment.page_open), or a charge is in progress on a written-off invoice (code payment.recovery_processing).
  • payment_scheduled: the invoice is queued, and the automatic charge collects it on its next run.
  • awaiting_payment: the invoice is unpaid and not queued for an automatic charge, so the automatic charge skips it. Collect it with Charge now (POST /v1/invoices/{id}/collect), or email the customer a payment link. Every invoice is queued when it is finalized, so only an invoice taken out of the queue reaches this state: one an older release wrote, or one held by paused collection when the upgrade that removed it ran.
  • topup_awaiting_payment: a top-up nobody has paid yet, with nothing charged. Nothing collects it on its own. The actions are what can work on this server and mode: copy_payment_link and send_reminder only when its payment page can take a card, the latter only when the server can send email, and record_payment in every case. It shows only while nothing is charged and no payment page is open: while the customer has the page open, the top-up gets payment_processing with code payment.page_open and no action. code is topup.awaiting_payment, or names why the page can’t take a card: topup.below_minimum, topup.payment_page_off, topup.payment_link_missing or topup.stripe_not_connected.
  • no_payment_method: the customer has no card ready to charge. The invoice stays queued, and the automatic charge collects it on its first run after a card is added. When Stripe is not connected for the invoice’s mode, no card can be added online and the invoice is emailed instead. message says which applies.
  • dunning_exhausted: the customer still has no card and automatic recovery has ended without collecting; the policy’s final action ran.
  • dispute_lost: the customer disputed a payment on the invoice with their bank, and the dispute closed as lost, so the bank took the money back. The invoice stays paid. On an ordinary invoice you record the loss. On a top-up whose own payment was disputed, Hardcount records it as a credit note that takes back the unused credit the money paid for, and the notice is a warning with the figures; it is critical while that note is not written yet (POST /v1/invoices/{id}/disputes/{dispute_id}/record-loss writes it). Shown even on paid invoices, which is where disputes land. When the invoice also has payment_anomaly, that reason stays and its message asks you to check Stripe before any refund. The disputes are at GET /v1/invoices/{id}/disputes.
  • dispute_open: the customer’s bank holds a chargeback on a top-up’s payment (an inquiry raises none), and the customer can still spend the credit it bought. Critical: the message says what Stripe took, the date to respond by and the unused credit. Pause the customer’s key at your gateway while it is open. It clears when the dispute closes.
  • dispute_won_after_loss: Stripe recorded a top-up’s lost dispute as won after Hardcount wrote the loss’s credit note. Info: the money is back in your Stripe balance and the credit note stands, so sell the credit again as a top-up and record its payment as paid outside Hardcount.
  • refunded_in_stripe: a refund of the invoice’s payment was made in Stripe outside Hardcount, and Hardcount did not record it as a credit note: the invoice was not paid yet, the currency differs, Hardcount first saw the refund more than a day after it was made, a credit note on the invoice has a failed card refund this refund may replace, the refund is more than the invoice had left to refund or credit, or the credit it paid for on a top-up could not be worked out (critical, since that credit can still be spent). code is payment.refunded_in_stripe. followed by that review reason. Record it with a credit note that names the refund (stripe_refund_id on POST /v1/credit-notes), attach it to the credit note whose refund failed (POST /v1/credit-notes/{id}/attach-stripe-refund), or dismiss it (POST /v1/invoices/{id}/stripe-refunds/{stripe_refund_id}/dismiss). Shown even on paid invoices, which is where refunds land.
  • amount_below_minimum: Stripe refused to charge the invoice, or refused a payment page for it, because the amount is below Stripe’s minimum charge. The minimum depends on the currency the Stripe account settles in; Stripe’s reply, in provider_response, names it. Nothing was charged, the invoice stays finalized with payment_status pending, it is not charged again automatically, dunning does not start (a run already open ends), and the customer is not emailed. Void it or record a payment. POST /v1/invoices/{id}/collect applies the customer’s credit balance and marks the invoice paid if that covers it, and otherwise asks Stripe again. Stripe’s answer can change (for a converted charge the minimum is the settlement currency’s), and a different answer ends this reason.
string
Allowed values: tax_calculation_failed tax_location_required payment_failed payment_unconfirmed payment_anomaly payment_processing payment_scheduled awaiting_payment topup_awaiting_payment no_payment_method dunning_exhausted dispute_lost dispute_open dispute_won_after_loss refunded_in_stripe amount_below_minimum
message
required

Text that is safe to show as it is: one plain sentence saying what happens and what to do. Facts that must show up front follow on more lines, separated by a newline (\n), one sentence each and up to two lines in all, such as the setup-link email on no_payment_method (and on dunning_exhausted when no link can be emailed). The wording can change between releases; switch on reason and code, not on this text.

string
actions

Recommended next steps. The first is the main one; the rest are secondary. Absent when there is nothing to do but wait.

Array<object>

One recommended next step on an Attention notice.

object
code
required

A recommended next step, as a closed code. Each code maps to an API route or a dashboard page.

  • edit_billing_profile: fix the customer’s billing address or tax ID.
  • retry_tax: POST /v1/invoices/{id}/retry-tax.
  • retry_payment and charge_now: POST /v1/invoices/{id}/collect.
  • wait_provider: nothing to do; the provider is expected to answer.
  • rotate_api_key: replace the Stripe key under Settings.
  • reconcile_payment: open the payment in Stripe and refund or correct it there. Offered on payment_anomaly.
  • review_registration: check your tax registrations with the tax provider.
  • send_reminder: email the customer. On no_payment_method and dunning_exhausted that is the setup link (POST /v1/invoices/{id}/resend-setup-link); otherwise it is the invoice with its payment link (POST /v1/invoices/{id}/send).
  • add_payment_method: add a card for the customer.
  • update_payment_method: send the customer a link to replace a card that was declined.
  • connect_tax_provider: connect the tax provider under Settings.
  • void_invoice: POST /v1/invoices/{id}/void. Offered only on amount_below_minimum.
  • record_dispute_loss: POST /v1/invoices/{id}/disputes/{dispute_id}/record-loss, with the action’s target_id as the dispute. Offered on a top-up’s dispute_lost notice while the loss’s credit note is not written.
  • record_stripe_refund: POST /v1/credit-notes with stripe_refund_id set to the action’s target_id. Offered on a refunded_in_stripe notice the refund can be recorded from.
  • copy_payment_link: copy the invoice’s payment page address, the hosted invoice page at /invoice/{public_token}. Offered on topup_awaiting_payment.
  • record_payment: POST /v1/invoices/{id}/record-payment, for a payment received outside Hardcount. Offered on topup_awaiting_payment.
string
Allowed values: edit_billing_profile retry_tax retry_payment wait_provider rotate_api_key reconcile_payment review_registration charge_now send_reminder add_payment_method update_payment_method connect_tax_provider void_invoice record_dispute_loss record_stripe_refund copy_payment_link record_payment
label

A default button label. You can show your own, translated text instead. Absent when there is none.

string
target_id

What the action acts on when the invoice alone does not say: the dispute’s id (hc_dsp_…) for record_dispute_loss, the refund’s Stripe id (re_…) for record_stripe_refund. Absent otherwise.

string
code

Open, dotted code naming the exact cause, for example tax.customer_data_invalid or payment.declined. New codes can appear in any release, as with Stripe’s error codes.

string
doc_url

A link to documentation about this reason. No such pages are published yet, so this release always leaves it out.

string
param

Dotted path to the field to edit to fix the cause. Today only tax_location_required sets it, always to customer.address.postal_code, even when the tax ID is what is wrong. Absent otherwise.

string
detail

Hardcount’s own explanation behind message: why the state holds, what Hardcount does on its own, and ids support may ask for (for example the payment intent ids of a payment anomaly). Plain text; may contain blank-line paragraph breaks. Never a provider payload: that is provider_response.

string
provider_response

The provider’s response as Hardcount recorded it: the Stripe Tax error (cleaned of its JSON envelope and cut to 500 bytes), or the invoice’s last_payment_error. Absent when Hardcount did not call the provider or recorded no response.

string
since

When the condition started, so you can sort by age. For a tax reason it is when tax was deferred, for amount_below_minimum when Stripe refused the amount, for dispute_lost when the dispute closed, for dispute_open when Stripe opened it, and for refunded_in_stripe when the refund was made. Otherwise it is when the invoice last changed. Absent when it is not known.

string format: date-time
next_attempt_at

When Hardcount will next retry on its own. Today only a tax retry sets it. Absent when no automatic retry is scheduled.

string format: date-time
due_by

The invoice’s payment deadline (its due_at), or for dispute_open the date to respond to the dispute by. Hardcount does not act on this date; it is shown so you know it. Absent when the reason does not show a deadline or there is none.

string format: date-time
recovery_warning

What you should know before you record an offline payment on a written-off invoice: a consequence that will not reconcile on its own, never a refusal. Sent only on uncollectible invoices, by the same responses that carry attention. Absent when there is nothing to say.

object
blocked
required

Always false. This object only warns; it never refuses.

boolean
code

What will not reconcile. tax_reversed_unrecoverable: the invoice’s Stripe Tax transaction was reversed, and recording the payment does not report it again, so the tax collected will not appear in your tax provider’s records.

string
Allowed values: tax_reversed_unrecoverable
message

One sentence for the operator naming the consequence and what to do about it.

string
total_amount_cents
required

The invoice total: subtotal_cents minus discount_cents plus tax_amount_cents, in the currency’s minor unit (cents for USD). It is what the invoice charges before credit and payments, and it does not change when the invoice is paid.

integer format: int64
amount_due_cents
required

What the customer still owes, in the currency’s minor unit (cents for USD): the total, less customer credit applied (credits_applied_cents), credit notes issued before payment, and payments. It becomes 0 when the invoice is paid. A voided or written-off invoice keeps the amount that was due.

integer format: int64
amount_paid_cents
required

What was paid by card or recorded as an offline payment, in the currency’s minor unit (cents for USD). Set when the invoice is paid, to the amount that was due then; 0 before. Credit applied is counted in credits_applied_cents, not here.

integer format: int64
credits_applied_cents
required

How much of the customer’s credit balance paid this invoice, in the currency’s minor unit (cents for USD). Credit is applied when the invoice is collected (after finalize, or by POST /v1/invoices/{id}/collect). A void gives it back to the customer’s balance, and a credit note issued before payment can give part of it back, lowering this figure.

integer format: int64
billing_period_start
required

Start of the period the invoice bills (included). On a one-off invoice created without a period, the time it was created.

string format: date-time
billing_period_end
required

End of the period the invoice bills (not included): the next period’s start. On a one-off invoice created without a period, the time it was created.

string format: date-time
billing_period_display

The period as people read it, with its last day included, in billing_timezone: for example “Oct 1, 2026 – Oct 31, 2026”. billing_period_start and billing_period_end stay the exact boundaries. Worked out when the invoice is read, so it comes with the same responses as attention. Absent when the period starts and ends at the same instant.

string
billing_timezone

The IANA time zone the period boundaries are in: the account’s billing time zone, copied onto the invoice when it was created. billing_period_display, the PDF and the hosted page show dates in it, so an issued invoice’s dates stay the same if the account later changes its time zone. Absent only on invoices created before releases recorded it.

string
bill_to_snapshot

The buyer details this invoice was issued with, copied when it was finalized (or created already finalized). The PDF, the hosted page and the dashboard show an issued invoice from this copy, so a later edit to the customer or billing profile does not change it. Absent on drafts and on invoices issued before this field existed; those show the current customer details.

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

Your company details this invoice was issued with, copied when it was finalized (or created already finalized). Absent on drafts and on invoices issued before this field existed. Branding (logo, brand color) is not part of it.

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
issued_at

When the invoice was issued. Every invoice gets one when it is created, drafts included. An invoice you create with POST /v1/invoices gets a new one when it is finalized.

string format: date-time
due_at

When payment is due: issued_at plus net_payment_term_days calendar days, counted in billing_timezone. Set with issued_at. Hardcount does not charge on this date: it collects right after finalize and retries on the dunning schedule. The overdue filter of GET /v1/invoices uses it. Absent on a top-up, which has no due date.

string format: date-time
paid_at

When the invoice was paid. Absent until it is paid.

string format: date-time
voided_at

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

string format: date-time
uncollectible_at

When the invoice was written off as uncollectible. Absent unless it was.

string format: date-time
stripe_payment_intent_id

The Stripe PaymentIntent of the card charge that paid the invoice, or of its last charge that is in progress or failed. It can be absent after a charge was sent: for example when the invoice was then paid without a card (by credits, with nothing due, or outside Hardcount: paid_out_of_band), or when Stripe refused the last charge as below its minimum.

string
paid_out_of_band
required

True when the payment was recorded as made outside Hardcount, such as a bank transfer or cheque (POST /v1/invoices/{id}/record-payment, or a dunning run resolved as payment_recovered). Such an invoice has no stripe_payment_intent_id, so there is no card to refund.

boolean
last_payment_error

The error text recorded with the invoice’s last charge attempt that did not succeed. Usually Stripe’s message, which is written for the cardholder, with card numbers and email addresses masked. It can also be Hardcount’s own text, such as customer has no payment method on file. Absent when there is none.

string
auto_charge_pending

True while the invoice is queued for the automatic charge, which applies credit and charges the saved card. Absent when false.

boolean
no_pm_notified_at

When Hardcount automatically queued an email to the customer with a link to add a payment method for this invoice. It is queued once, when Stripe is connected, the customer has an email address and the server’s PAYMENT_UPDATE_URL is set; it reaches the customer only when the server can send email. POST /v1/invoices/{id}/resend-setup-link sends it again and does not change this time. Absent until the automatic email is queued.

string format: date-time
invoice_emailed_at

When Hardcount itself emailed the customer this invoice, because Stripe is not connected for the invoice’s mode. The email is sent once. An invoice you email with POST /v1/invoices/{id}/send does not set it. Absent until then.

string format: date-time
provider_payment_status

Stripe’s PaymentIntent status the last time Hardcount checked it, word for word. For information only: payment_status is the invoice’s payment state. Absent until Hardcount has checked. An invoice checked by the Stripe Search sweep of earlier releases may still show search_not_found, search_terminal_only or search_error.

string
provider_synced_at

When Hardcount last asked Stripe about this invoice’s payment, whether or not Stripe answered: a read of provider_payment_status, or a check of a charge whose result was lost. Absent until then.

string format: date-time
public_token

The token in the hosted invoice page’s link, like Stripe’s hosted_invoice_url; GET /v1/public/invoices/{token} serves the page’s data. Anyone with it can view and pay the invoice, so share it only with the customer. Created when the invoice is finalized, or created already finalized; absent on drafts. Replace it with POST /v1/invoices/{id}/rotate-public-token.

string
net_payment_term_days
required

Days from issued_at to due_at. 0 means due on receipt.

integer
memo

A note you set when creating the invoice, printed on the PDF and the hosted page. Absent when empty.

string
footer

The account’s invoice footer as it was when this invoice was issued. Printed on the PDF and the hosted invoice page. Absent on a draft and when no footer was set.

string
metadata

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

object
key
additional properties
any
created_at
required

When the invoice was created.

string format: date-time
updated_at
required

When the invoice last changed.

string format: date-time
billing_reason

Why the invoice was made, like Stripe’s invoice.billing_reason. Set when the invoice is created and never changed.

  • subscription_cycle: the invoice for a subscription period that ended (a renewal).
  • subscription_create: the first invoice when a subscription starts, for the fees its plans bill in advance. A subscription billed only in arrears has none.
  • subscription_cancel: the final invoice when a subscription is canceled at once in the middle of a period.
  • subscription_update: an invoice an earlier release made when a subscription’s items changed in the middle of a period. No new invoice has it.
  • manual: an invoice you created with POST /v1/invoices.
  • threshold: an invoice an earlier release made when a spend threshold was crossed in the middle of a period. No new invoice has it.
  • topup: a top-up, which sells prepaid credit: an invoice you created with POST /v1/invoices and one commit_granted_cents line, alone. It stays a draft with no invoice_number until it is paid; the payment numbers it, issues it and grants the credit.
string
Allowed values: subscription_cycle subscription_create subscription_cancel subscription_update manual threshold topup

Example

{
"id": "hc_inv_dbj84b2q3gpgqfoq5c42",
"tenant_id": "hc_ten_dajqj02q3gpgqfoq5c00",
"customer_id": "hc_cus_dakhnk2q3gpgqfoq5c0g",
"subscription_id": "hc_sub_dauq502q3gpgqfoq5c2g",
"invoice_number": "HC-000044",
"status": "finalized",
"payment_status": "pending",
"currency": "USD",
"subtotal_cents": 8650,
"discount_cents": 0,
"tax_amount_cents": 735,
"tax_rate": 8.5,
"tax_name": "Sales Tax",
"tax_country": "US",
"tax_provider": "stripe_tax",
"tax_calculation_id": "taxcalc_1QHkAbLkdIwHu7ixZ1y2x3w4",
"tax_transaction_id": "tax_1QHkAcLkdIwHu7ixV5u6t7s8",
"tax_status": "ok",
"tax_inclusive": false,
"tax_retry_count": 1,
"attention": {
"severity": "info",
"reason": "payment_scheduled",
"message": "The card on file is charged automatically, usually within an hour; use Charge now to collect it right away.",
"actions": [
{
"code": "charge_now",
"label": "Charge now"
}
],
"code": "payment.scheduled",
"detail": "Automatic charges run on a schedule, hourly by default.",
"since": "2026-12-01T09:30:00Z",
"due_by": "2026-12-31T00:05:00Z"
},
"total_amount_cents": 9385,
"amount_due_cents": 9385,
"amount_paid_cents": 0,
"credits_applied_cents": 0,
"billing_period_start": "2026-11-01T00:00:00Z",
"billing_period_end": "2026-12-01T00:00:00Z",
"billing_period_display": "Nov 1, 2026 – Nov 30, 2026",
"billing_timezone": "UTC",
"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"
},
"issued_at": "2026-12-01T00:05:00Z",
"due_at": "2026-12-31T00:05:00Z",
"paid_out_of_band": false,
"auto_charge_pending": true,
"public_token": "hc_pinv_c4d5e6f708192a3b4c5d6e7f8091a2b3c4d5e6f7019f2c4e1a7b3d5f6081a2b3",
"net_payment_term_days": 30,
"created_at": "2026-12-01T00:05:00Z",
"updated_at": "2026-12-01T09:30:00Z",
"billing_reason": "subscription_cycle"
}

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 invoice 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": "invoice not found",
"request_id": "req_dbjg652q3gpgqfoq5cd0"
}
}

Code invalid_state. The invoice is not a draft, or its tax is not pending and its calculation is not an expired one. Also returned when the invoice was finalized while its tax was being calculated, or when the invoice’s state stopped the finalize; the tax was not saved. Code invoice_lines_changed: a line was added to the invoice while its tax was being calculated, and nothing was saved; retry.

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": "tax retry only valid on draft invoices (current: finalized)",
"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"
}
}

The request has a body with a field. This route takes no body (param names the 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": "unknown field \"force\"",
"request_id": "req_dbjg652q3gpgqfoq5cd0",
"param": "force"
}
}

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.

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