Invoices
The invoice object
An invoice bills a customer for line items, fee lines, tax and shipping, less discounts. It starts as a draft, becomes open when it is finalized, and ends paid or void; an uncollectible invoice can still be paid or voided. You create invoices directly; subscriptions and accepted quotes create them for you.
Attributes
idstringRequiredUnique identifier for the object.
objectstringRequiredString naming the object's type.
livemodebooleanRequiredtruewhen the object exists in live mode,falsein test mode.createdtimestampRequiredTime the object was created, in Unix seconds.
updatedtimestampRequiredTime the object last changed, in Unix seconds.
numberstringRequiredSequential invoice number assigned when the invoice is created, for example
INV2026020001. Empty in a preview.quote_idstringRequiredID of the quote whose acceptance created this invoice. Empty otherwise.
subscription_idstringRequiredID of the subscription that created the invoice. Empty for other invoices.
test_clock_idstringID of the test clock the invoice runs on. Only set in test mode, on invoices of a subscription attached to a test clock.
customer_idstringRequiredID of the customer the invoice is for. Empty on an invoice created without a customer until the payer enters their details at checkout; Paycose then records the payer as a customer and sets this field.
default_payment_method_idstringRequiredID of the saved payment method charged for this invoice. Empty when none is set; automatic collection then uses the subscription's default payment method, then the customer's.
payment_method_typestringPayment method type set as the invoice's default with
default_payment_method.type, for examplecardorpromptpay. Omitted when none was set.collection_methodenumRequiredHow the invoice is collected:
charge_automaticallycharges a saved payment method,send_invoicelets the customer pay it themselves.charge_automaticallyPaycose charges the invoice's default payment method, else the subscription's or the customer's, when the invoice is finalized, and retries on failure.
send_invoiceThe customer pays the invoice themselves, by its due date when one is set.
capture_methodstringRequiredHow card payments for the invoice are captured:
automaticcaptures at once,manualholds the authorization until you capture it.automaticThe payment is captured as soon as it is authorized.
manualThe authorization is held and the payment is captured only when you capture it.
amount_capturableintegerRequiredAmount authorized but not yet captured on the invoice's
manualcapture payments, in the smallest currency unit. Only computed when you retrieve a single invoice;0in lists and in the responses of other operations.auto_advancebooleanRequiredtruewhen the invoice finalizes itself. A draft withauto_advanceis finalized as soon as it is created or the flag is turned on; if that fails, Paycose retries the finalization later.due_datetimestampNullableWhen payment is due, in Unix seconds. Set on
send_invoiceinvoices: the date you set, the finalization time plus the invoice'sdays_until_due, or for a subscription's invoice the finalization time plus the subscription'sdays_until_due. Omitted when none is set.days_until_dueintegerRequiredNullableNumber of days after it is finalized that a
send_invoiceinvoice falls due, as you set it on create or update. Null when not set, and always null oncharge_automaticallyinvoices.descriptionstringRequiredMemo shown on the invoice. Empty unless you set it with an update.
customer_namestringRequiredName of the customer, copied onto the invoice when it was created.
customer_emailstringRequiredEmail address of the customer, copied onto the invoice when it was created.
customer_phonestringRequiredPhone number of the customer, copied onto the invoice when it was created.
customer_tax_idsarray of objectsRequiredThe customer's tax IDs as the invoice was issued: each
type,valueand, for a Thai tax ID, itsbranch. Copied from the customer (or the tax ID the payer entered at checkout) while the invoice is a draft and frozen when it is finalized, as Stripe's are; a provider-hosted invoice takes its provider's.[]when the customer has none, and on an invoice made before tax IDs were recorded, which the invoice PDF and dashboard fill from the customer as it is now.Show child attributes
customer_tax_ids.typestringRequiredType of the tax ID, as a tax ID type code from
GET /tax_id_types.customer_tax_ids.valuestringRequiredThe tax ID number.
customer_tax_ids.branchstringBranch number of a Thai tax ID, such as
00000for the head office. Omitted when the tax ID has none.
addressobjectNullableThe customer's billing address, copied onto the invoice when it was created and again when it is finalized: the customer's
billingaddress (or its first address), else the billing details the payer entered at checkout. A provider-hosted invoice takes its provider'scustomer_address. Omitted when none is known.Show child attributes
address.idstringUnique identifier for the object.
address.address_typestringRequiredKind of address:
billingorshippingas recorded on the customer or the request. A shipping address you send without a type is stored asshipping.address.namestringRequiredName of the person or business at the address.
address.phonestringRequiredPhone number for the address.
address.line1stringRequiredFirst address line, such as the street and house number.
address.line2stringRequiredSecond address line, such as the building, floor or unit.
address.citystringRequiredCity, district or town.
address.statestringRequiredState, province or region.
address.postal_codestringRequiredPostal or ZIP code.
address.countrystringRequiredCountry, as it was entered.
line_itemsarray of objectsRequiredThe invoice's lines, product lines first and fee lines after them.
Show child attributes
line_items.idstringRequiredUnique identifier for the object.
line_items.objectstringRequiredString naming the object's type.
line_items.product_idstringRequiredID of the product the line bills. On a fee line it holds the provider's product reference for the fee when a provider hosts the invoice, and is empty otherwise.
line_items.product_price_idstringRequiredID of the price the line bills. On a fee line it holds the provider's price reference for the fee when a provider hosts the invoice, and is empty otherwise.
line_items.sort_orderintegerRequiredPosition of the line among the invoice's lines, when one was assigned;
0otherwise.line_items.typestringRequiredproductfor a line that bills a price,feefor a fee line. Can be empty on lines generated for a subscription period.productA line that bills a price of a product.
feeA line that bills one of your fees, listed after the product lines.
line_items.descriptionstringRequiredText describing the line, normally the product or fee name.
line_items.product_namestringRequiredName of the product (or fee) at the time the line was created.
line_items.product_descriptionstringRequiredDescription of the product (or fee) at the time the line was created.
line_items.product_imagestringRequiredURL of the product's image at the time the line was created. Empty when the product has none.
line_items.product_typestringRequiredKind of price the line bills:
onetime,recurringorusage-based, orfeeon a fee line. Can be empty on lines generated for a subscription period.onetimeThe line bills a one-time price.
recurringThe line bills a recurring price of a subscription.
usage-basedThe line bills a metered price, charged for reported usage.
feeThe line bills a fee.
line_items.unit_amountintegerRequiredPrice of one unit, in the smallest currency unit. On a fee line it is the fee amount, fixed or computed as a percentage of the product lines.
line_items.quantityintegerRequiredNumber of units billed. Always
1on fee lines.line_items.amount_discountintegerRequiredThis line's share of the invoice's discount, in the smallest currency unit.
0on fee lines.line_items.amount_subtotalintegerRequiredunit_amounttimesquantity, before discount and before tax added on top, in the smallest currency unit.line_items.amount_taxintegerRequiredTax on the line, in the smallest currency unit, including tax already contained in a tax-inclusive price.
line_items.amount_totalintegerRequiredLine amount after its discount share plus tax added on top, in the smallest currency unit (for example,
49900is 499.00 THB).line_items.currencystringRequiredThree-letter ISO 4217 currency code, in lowercase.
line_items.discountablebooleanRequiredtruewhen the invoice's coupon can discount this line. Fee lines are never discountable.line_items.withholding_taxbooleanRequiredWhether the customer withholds Thai tax on this line; such a line counts in the document's
amount_withholding.line_items.prorationbooleanRequiredtruewhen the line is a proration created by a change to a subscription mid-period.line_items.period_starttimestampRequiredNullableStart of the period the line bills, in Unix seconds. For a one-off product line it is the time the line was priced.
nullon fee lines.line_items.period_endtimestampRequiredNullableEnd of the period the line bills, in Unix seconds. For a subscription line it is the end of the billing period; for a one-off product line it equals
period_start.nullon fee lines.line_items.reference_idstringRequiredThe hosting provider's ID for the line when a provider hosts the invoice; otherwise an internal reference.
line_items.metadataobjectRequiredKey-value pairs stored on the line. On a fee line it holds
application_fee_id, the ID of the fee the line bills.line_items.taxesarray of objectsRequiredTaxes applied to the line, one entry per tax rate.
Show child attributes
line_items.taxes.idstringRequiredUnique identifier for the object.
line_items.taxes.tax_rate_idstringRequiredID of the tax rate applied.
line_items.taxes.taxable_amountintegerRequiredPart of the line amount the rate taxes, in the smallest currency unit. For an inclusive rate it is the line amount without the tax it contains.
line_items.taxes.tax_amountintegerRequiredTax this rate charges on the line, in the smallest currency unit.
line_items.taxes.inclusivebooleanRequiredtruewhen the rate is tax-inclusive: the tax is already contained in the line amount and is not added on top.
discountsarray of objectsRequiredDiscounts applied to the invoice, one per coupon.
Show child attributes
discounts.idstringRequiredUnique identifier for the object.
discounts.coupon_idstringRequiredID of the coupon that gives the discount.
discounts.promotion_code_idstringRequiredID of the promotion code the coupon was applied through. Empty when the coupon was applied directly.
discounts.namestringRequiredName of the coupon.
discounts.amountintegerRequiredAmount the discount takes off the invoice, in the smallest currency unit.
shipping_detailsobjectNullableShipping address and shipping rate of the invoice. Omitted when the invoice has neither.
Show child attributes
shipping_details.addressobjectNullableAddress the order ships to. Omitted when the invoice has no shipping address.
Show child attributes
shipping_details.address.idstringUnique identifier for the object.
shipping_details.address.address_typestringRequiredKind of address:
billingorshippingas recorded on the customer or the request. A shipping address you send without a type is stored asshipping.shipping_details.address.namestringRequiredName of the person or business at the address.
shipping_details.address.phonestringRequiredPhone number for the address.
shipping_details.address.line1stringRequiredFirst address line, such as the street and house number.
shipping_details.address.line2stringRequiredSecond address line, such as the building, floor or unit.
shipping_details.address.citystringRequiredCity, district or town.
shipping_details.address.statestringRequiredState, province or region.
shipping_details.address.postal_codestringRequiredPostal or ZIP code.
shipping_details.address.countrystringRequiredCountry, as it was entered.
shipping_details.rateobjectNullableShipping rate charged on the invoice. Omitted when no shipping rate applies.
Show child attributes
shipping_details.rate.idstringRequiredUnique identifier for the object.
shipping_details.rate.display_namestringRequiredName of the shipping rate shown to the customer.
shipping_details.rate.typestringRequiredKind of shipping rate. Always
fixed_amount.fixed_amountA fixed shipping amount per invoice.
shipping_details.rate.currencystringRequiredThree-letter ISO 4217 currency code, in lowercase.
shipping_details.rate.amountintegerRequiredShipping amount the rate charges, in the smallest currency unit.
subtotalintegerRequiredSum of the line amounts, fee lines included, before discounts and before tax added on top of prices, in the smallest currency unit.
taxintegerRequiredTotal tax on the invoice, in the smallest currency unit. It includes tax already contained in tax-inclusive prices, which is not added to
totalagain.totalintegerRequiredAmount of the invoice after discounts, tax added on top and shipping, in the smallest currency unit (for example,
49900is 499.00 THB).amount_shippingintegerRequiredShipping charged on the invoice, in the smallest currency unit.
0without shipping.amount_discountintegerRequiredTotal discount applied to the invoice, in the smallest currency unit.
withholding_taxobjectRequiredNullableThai withholding tax the customer deducts, as
{"rate": 3};nullwhen it withholds nothing.Show child attributes
withholding_tax.rateintegerRequiredWithholding percent: 1, 2, 3 or 5.
amount_withholdingintegerRequiredWithholding tax in the smallest currency unit:
withholding_tax.ratepercent of the withheld lines' amount before VAT and after discounts, rounded half up once on their sum. Fees and shipping are never withheld. The customer paysamount_due=total−amount_withholding, and a paid invoice readsamount_paid+amount_withholding=total.amount_dueintegerRequiredAmount the customer owes for the invoice, in the smallest currency unit. It equals
totallessamount_withholdingonce the invoice is priced; for a provider-hosted invoice it is the provider's figure.amount_paidintegerRequiredAmount paid so far, in the smallest currency unit. Paying the invoice sets it to
totallessamount_withholding; refunding a payment lowers it again. An invoice marked paid out of band (paid_out_of_band) collected nothing here and reads0, as at Stripe.amount_remainingintegerRequiredAmount still to be paid, in the smallest currency unit. It is
0once the invoice is paid, except for an invoice marked paid out of band (paid_out_of_band), which keeps itsamount_duehere, as at Stripe. A credit note issued before payment lowers it, and a refund raises it.starting_balanceintegerRequiredAlways
0. Paycose does not apply a customer credit balance to invoices.pre_payment_credit_notes_amountintegerRequiredTotal of every credit note on the invoice that is not voided, in the smallest currency unit: the part that lowered what the customer owed before paying. Filled when you retrieve or list invoices;
0in the responses of other operations.post_payment_credit_notes_amountintegerRequiredTotal of every credit note on the invoice that is not voided, in the smallest currency unit: the part paid back to the customer (refunded, settled out of band or credited to their balance) after the invoice was paid. Filled when you retrieve or list invoices;
0in the responses of other operations.currencystringRequiredThree-letter ISO 4217 currency code, in lowercase.
scaling_factorintegerRequiredNumber of smallest currency units in one unit of
currency(10 to the power of the currency's decimal places), for example100for THB. Divide an amount by it to get the value in major units.transfer_dataobjectRequiredNullableWhere the invoice's payment settles: the account it is for and the balance credited. An invoice you create without
transfer_datasettles to your own account.nullwhen nothing was recorded.Show child attributes
transfer_data.destinationstringRequiredID of the connected account (
acct_…) the document is for.transfer_data.balance_idstringRequiredID of the balance the document's payments are booked to.
transfer_data.connectedbooleanRequiredTrue when the destination is a connected account paid under Connect: what you owe it and your application fee are recorded on your ledger. False for a legacy destination.
on_behalf_ofstringID of the connected account (
acct_…) the invoice is issued on behalf of, when you set it. It always equalstransfer_data.destination. Omitted otherwise.statusenumRequiredWhere the invoice is in its lifecycle.
draftBeing prepared. Its lines and pricing can change, and it can be deleted. It cannot be paid yet.
openFinalized and waiting for payment. Only presentational fields can change; it can be paid, voided, marked paid or become uncollectible.
paidPaid in full, through Paycose or out of band. Final; use a credit note to reduce it.
voidCanceled after finalization. Final; it can no longer be paid.
uncollectibleWritten off after automatic payment attempts ran out, or marked so by the hosting provider. It can still be marked paid or voided.
paidbooleanRequiredtruewhenstatusispaid.paid_out_of_bandbooleanRequiredtruewhen the invoice was marked paid for a payment made outside Paycose, such as cash or a bank transfer. Such an invoice readsamount_paid0,amount_remainingequal toamount_dueand nopayment_intent.attemptedbooleanRequiredtrueonce an automatic payment attempt has been made on the invoice, whether it succeeded or failed.attempt_countintegerRequiredNumber of automatic payment attempts made on the invoice so far.
next_payment_attempttimestampNullableWhen the next automatic payment attempt is scheduled, in Unix seconds. Omitted when no retry is pending.
payment_intentstringID of the payment intent used by the most recent automatic payment attempt. Omitted when none was made. Every payment made against the invoice is listed by
GET /invoices/{id}/payments.last_finalization_errorobjectWhy the last attempt to finalize this draft failed, as Stripe shapes it:
code(the Paycose error code, such asE4202),type(such asinvalid_request_errororapi_error) andmessage. Finalizing the invoice clears it. A failed payment never sets it; that reason is on the payment intent. Omitted when finalization has not failed.status_transitionsobjectRequiredWhen the invoice was finalized, paid, voided or marked uncollectible.
Show child attributes
status_transitions.finalized_atintegerRequiredNullableWhen the invoice was finalized and became
open. Marking a draft paid also sets it.status_transitions.paid_atintegerRequiredNullableWhen the invoice became
paid.status_transitions.voided_atintegerRequiredNullableWhen the invoice was voided.
status_transitions.marked_uncollectible_atintegerRequiredNullableWhen the invoice became
uncollectible.
providerstringRequiredName of the payment provider the invoice is billed and collected through, for example
stripeoromise: the first ofpayment_method_providersyour account routes, else the provider the default payment method is saved on, else your card provider; a subscription's invoice has the subscription's. When that provider bills on its own side it hosts the invoice; otherwise Paycose bills it and collects through that provider.reference_idstringRequiredThe hosting provider's own ID for the invoice. Empty for invoices Paycose bills.
paymentsarray of objects (invoice_payment)Payments made against the invoice. Only included when you retrieve a single invoice.
hosted_invoice_urlstringLink to a page where the customer can view and pay the invoice: the provider's page for a provider-hosted invoice, or Paycose's hosted page for an invoice Paycose bills. Set when the invoice is finalized; omitted for a draft.
invoice_pdfstringURL of the invoice PDF made by the hosting provider. Omitted for invoices Paycose bills.
provider_numberstringThe hosting provider's own number for the invoice;
numberstays Paycose's. Omitted for invoices Paycose bills.billing_reasonstringWhy the invoice was created. Subscription invoices say which billing event made them; a provider-hosted invoice can carry the provider's own reason. Omitted on invoices you create with
POST /invoices.subscription_createFirst invoice of a new subscription.
subscription_cycleRenewal invoice for a new billing period of a subscription.
subscription_updateInvoice for a change to a subscription, such as prorations.
subscription_thresholdInvoice raised early because a subscription's usage reached its billing threshold.
manualReported by the hosting provider for an invoice created directly rather than by a subscription.
receipt_idstringID of the receipt issued when the invoice was paid. Omitted until then.
metadataobjectRequiredKey-value pairs you attach to the object for your own use. Paycose never reads or changes them.
default_tax_ratesarray of stringsRequiredIDs of the tax rates the invoice applies by default, read from its lines: the rates on its fee lines or, when it has no fee lines, the rates all its product lines share.
account_tax_idsarray of stringsRequiredTax IDs of your business recorded on the invoice, as you sent them. When a provider hosts the invoice they are passed to it unchanged.
payment_method_typesarray of stringsRequiredPayment method types the payer may use for this invoice. Empty means any type available to your account.
payment_method_providersarray of stringsRequiredProviders the payer may pay through, by name. Empty means any provider that serves the payment method.
The full customer object when you pass
expand[]=customer; otherwise omitted. Usecustomer_id.billing_detailsobjectNullableBilling and tax details the payer entered on the hosted checkout page for this invoice. Omitted when none were collected.
Show child attributes
billing_details.namestringPayer's name, up to 255 characters. Omitted when not given.
Max length 255
billing_details.emailstringPayer's email address. Omitted when not given.
Max length 254 · Format
emailbilling_details.phonestringPayer's phone number, up to 64 characters. Omitted when not given.
Max length 64
billing_details.addressobjectNullablePayer's billing address. Omitted when not given.
Show child attributes
billing_details.address.line1stringFirst line of the address, such as street and house number. Up to 255 characters.
Max length 255
billing_details.address.line2stringSecond line of the address, such as building or unit. Up to 255 characters.
Max length 255
billing_details.address.citystringCity or district. Up to 255 characters.
Max length 255
billing_details.address.statestringState, province or region. Up to 255 characters.
Max length 255
billing_details.address.postal_codestringPostal code. Up to 32 characters.
Max length 32
billing_details.address.countrystringTwo-letter ISO 3166-1 country code, in uppercase.
Pattern
^[A-Z]{2}$
billing_details.business_namestringName of the payer's business, up to 255 characters. Omitted when not given.
Max length 255
billing_details.tax_idobjectNullablePayer's tax ID. Omitted when not given.
Show child attributes
billing_details.tax_id.typestringRequiredType of the tax ID, as a tax ID type code from
GET /tax_id_types. Up to 64 characters.Max length 64
billing_details.tax_id.valuestringRequiredThe tax ID number. Up to 255 characters; checked against the type's format.
Max length 255
The full payment method object when you pass
expand[]=default_payment_method; otherwise omitted. Usedefault_payment_method_id.The full quote object when you pass
expand[]=quote; otherwise omitted. Usequote_id.The full subscription object when you pass
expand[]=subscription; otherwise omitted. Usesubscription_id.