Skip to navigation

Create Invoice

View as Markdown

Create a new invoice.

Supports two invoice types:

  • “one_off”: Manual invoice, items must be provided explicitly, no subscription_id allowed
  • “recurring”: Subscription-attached invoice; items must be provided explicitly (empty items 422s). Floating items are swept in only at subscription renewal, not at create time.

An optional processor_route_id pins a route to the invoice’s card charges. A route that cannot be used is not pinned and the invoice is still created; routing in the response says why.

Works for both User and API Key authentication. Account access is automatically validated via endpoint dependency.

Authentication

AuthorizationBearer

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

Path parameters

account_idstringRequired

Headers

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

Request

This endpoint expects an object.
customer_idstringRequired
invoice_typeenumOptional
Allowed values:
statusenumOptional
collection_methodenumOptional
Allowed values:
billing_reasonenum or nullOptional

Why an invoice exists. Re-exported from invoices_schemas for backwards compatibility — new code should import it from here.

Lives in this dependency-free module, rather than in invoices_schemas, because the payments side needs it too: payment_intents snapshots the producing invoice’s reason (see PaymentIntentEntity.invoice_billing_reason) and importing invoices_schemas from intents_model would drag half of billing into the payments import graph. Same reasoning that moved the PaymentIntent enums into intents_enums.

currencyenum or nullOptional
Invoice currency. If not provided, inferred from the first item's price currency.
issued_atdatetime or nullOptional
Invoice issue date. Defaults to the current time if not provided.
due_datedatetime or nullOptional
descriptionstring or nullOptional
metadatamap from strings to any or nullOptional
custom_fieldsmap from strings to any or nullOptional
Custom field values to set on this invoice. Keys must match defined field keys for the invoice entity type. Set a key to null to delete that field's value.
notestring or nullOptional

Optional free-text note to attach to the invoice. Merchant-private: unlike description it never appears on the invoice PDF. Use PATCH /invoices/{id} to edit or clear it later.

coupon_idstring or nullOptional
ID of a coupon to attach as a discount to this invoice.
net_dinteger or nullOptional

Number of days after the invoice’s creation date that it is due. Overrides due_date if provided. When neither net_d nor due_date is set, a send_invoice invoice is due 30 days after its creation date and a charge_automatically invoice on issued_at. The creation date is when the API creates the invoice, not issued_at.

default_payment_method_idstring or nullOptional
ID of the default payment method for this invoice.
processor_route_idstring or nullOptional

Processor route to pin to this invoice. While the account’s routing engine is enabled and the route applies, it overrides the subscription’s pinned route (for an invoice of a subscription), routing rules and the account default for every card charge of this invoice: POST /invoices/{id}/collect, a payment from the customer portal and dunning retries. It applies only to card payment methods. Each of those collections first checks the route against the cards it would try, in order: when it would charge none of them through the route (for example, none is saved on an active processor the route names that supports the invoice currency, or a card it reaches first cannot be charged at all under the route), the route does not apply to that collection, whose charges route as if no route had been named, and the collect response’s routing gives fallback_reason route_cannot_charge_card and fallback_detail. When it would reach a card the route can charge, the route applies. A route whose effect depends on the payment (conditions, a weighted split over routes) is not checked. Except in a collection the route does not apply to, engine on or off, the invoice’s card charges never fall back to a network-token charge on a processor outside the route. Set only here: it cannot be changed or removed later. Setting it needs the routing_rule:edit permission (dashboard users; API keys always may). A route that cannot be used is not pinned, and the invoice is still created: its charges route as if no route had been named (the subscription’s pinned route, if any, then the account’s routing rules, then the account default), and the response’s routing object gives fallback_reason and fallback_detail. That happens when the route is not an active route of this account (route_not_found, route_inactive) or when it stops every payment (route_stops_every_payment). Create does not check the route against the customer’s payment methods, because collect can charge another one (payment_method_id). POST /invoices/preview ignores it.

itemslist of objects or nullOptional

Response

Successful Response
idstring
customer_idstring
statusenum
currencyenum
ISO 4217 currency codes.
subtotal_amount_atominteger or null
tax_amount_atominteger or null
total_amount_atominteger or null
due_amount_atominteger or null
paid_amount_atominteger or null
remaining_amount_atominteger or null
issued_atdatetime
due_datedatetime or null
descriptionstring or null
metadatamap from strings to any or null
created_atdatetime
updated_atdatetime
applied_balance_amount_atominteger or nullOptional
total_discount_amount_atominteger or nullOptional
period_startdatetime or nullOptional
period_enddatetime or nullOptional
collection_methodenumOptional
Allowed values:
custom_fieldsmap from strings to any or nullOptional

Custom field values. Only included when expand=custom_fields is specified.

notestring or nullOptional

Free-text note attached to this invoice, from the notes side-table. Merchant-private — unlike description, it never appears on the invoice PDF or any customer-facing surface.

itemslist of objectsOptional
invoice_numberinteger or nullOptional
billing_reasonenum or nullOptional

Why an invoice exists. Re-exported from invoices_schemas for backwards compatibility — new code should import it from here.

Lives in this dependency-free module, rather than in invoices_schemas, because the payments side needs it too: payment_intents snapshots the producing invoice’s reason (see PaymentIntentEntity.invoice_billing_reason) and importing invoices_schemas from intents_model would drag half of billing into the payments import graph. Same reasoning that moved the PaymentIntent enums into intents_enums.

subscription_idstring or nullOptional
payment_method_idstring or nullOptional
invoice_pdf_urlstring or nullOptional
receipt_pdf_urlstring or nullOptional
hosted_invoice_urlstring or nullOptional
apply_customer_balancebooleanOptionalDefaults to true

False when the checkout session that created this invoice opted out of the customer’s credit balance (no credit applied; a debt is still settled).

processor_route_idstring or nullOptional

The processor route pinned to this invoice at create (processor_route_id on POST /invoices), or null when none is. While the account’s routing engine is on and the route is active, the invoice’s card charges go through it, ahead of the subscription’s pinned route, routing rules and the account default. A collection that would charge none of its cards through it routes as if the invoice had no route.

routingobject or nullOptional

What became of the requested processor_route_id: pinned, or not pinned and why (the invoice’s charges then route as if no route had been named). Create charges nothing, so charge_route_id is null. Present only when the request named a route.

Errors

422
Unprocessable Entity Error