Skip to content

Stripe: Create an invoice

Stripe invoices.postInvoices: arguments, response, policy and SDK examples.

← Invoices operations · Get started

Operation stripe.postinvoices

Provider route: POST /v1/invoices. Alter supplies the connection’s credentials and routing.

Install @alter-ai/sdk @alter-ai/stripe with npm, or alter-sdk-stripe with pip. Supply your connected customer’s grant ID and the arguments described below.

import { App } from "@alter-ai/sdk";
import { StripeIntegration } from "@alter-ai/stripe";
async function execute(input: Parameters<StripeIntegration["invoices"]["postInvoices"]>[0]) {
const app = new App({ apiKey: process.env.ALTER_API_KEY! });
try {
const provider = new StripeIntegration(app, { grantId: process.env.PROVIDER_GRANT_ID! });
const call = await provider.invoices.postInvoices(input);
const result = await call.wait();
return result.bodyJson();
} finally {
await app.close();
}
}
import os
from alter_sdk import App
from alter_sdk_stripe import StripeIntegration
async def execute(arguments):
async with App(api_key=os.environ["ALTER_API_KEY"]) as app:
provider = StripeIntegration(app, {"grant_id": os.environ["PROVIDER_GRANT_ID"]})
call = await provider.invoices.post_invoices(arguments)
result = await call.wait()
return result.body_json()
FieldTypePresenceDescription and constraints
$objectRootAdditional keys: not allowed
headersobjectOptionalAdditional keys: not allowed
headers.Idempotency-KeystringOptionalMinimum length: 1
Maximum length: 255
bodyobjectOptionalAdditional keys: not allowed
body.account_tax_idsJSONOptionalThe account tax IDs associated with the invoice. Only editable when the invoice is a draft.
body.account_tax_ids (anyOf 1)arrayAlternative
body.account_tax_ids (anyOf 1)[]stringEach itemMaximum length: 5000
body.account_tax_ids (anyOf 2)stringAlternativeOne of:
body.application_fee_amountintegerOptionalA fee in cents (or local equivalent) that will be applied to the invoice and transferred to the application owner’s Stripe account. The request must be made with an OAuth key or the Stripe-Account header in order to take an application fee. For more information, see the application fees [documentation](https://docs.stripe.com/billing/invoices/connect#collecting-fees).
body.auto_advancebooleanOptionalControls whether Stripe performs [automatic collection](https://docs.stripe.com/invoicing/integration/automatic-advancement-collection) of the invoice. If `false`, the invoice’s state doesn’t automatically advance without an explicit action. Defaults to false.
body.automatic_taxobjectOptionalSettings for automatic tax lookup for this invoice.
body.automatic_tax.enabledbooleanRequired within parent
body.automatic_tax.liabilityobjectOptional
body.automatic_tax.liability.accountstringOptional
body.automatic_tax.liability.typestringRequired within parentOne of: account, self
body.automatically_finalizes_atintegerOptionalThe time when this invoice should be scheduled to finalize (up to 5 years in the future). The invoice is finalized at this time if it’s still in draft state.
Format: unix-time
body.collection_methodstringOptionalEither `charge_automatically`, or `send_invoice`. When charging automatically, Stripe will attempt to pay this invoice using the default source attached to the customer. When sending an invoice, Stripe will email this invoice to the customer with payment instructions. Defaults to `charge_automatically`.
One of: charge_automatically, send_invoice
body.currencystringOptionalThe currency to create this invoice in. Defaults to that of `customer` if not specified.
Format: currency
body.custom_fieldsJSONOptionalA list of up to 4 custom fields to be displayed on the invoice.
body.custom_fields (anyOf 1)arrayAlternative
body.custom_fields (anyOf 1)[]objectEach item
body.custom_fields (anyOf 1)[].namestringRequired within parentMaximum length: 40
body.custom_fields (anyOf 1)[].valuestringRequired within parentMaximum length: 140
body.custom_fields (anyOf 2)stringAlternativeOne of:
body.customerstringOptionalThe ID of the customer to bill.
Maximum length: 5000
body.customer_accountstringOptionalThe ID of the account to bill.
Maximum length: 5000
body.days_until_dueintegerOptionalThe number of days from when the invoice is created until it is due. Valid only for invoices where `collection_method=send_invoice`.
body.default_payment_methodstringOptionalID of the default payment method for the invoice. It must belong to the customer associated with the invoice. If not set, defaults to the subscription’s default payment method, if any, or to the default payment method in the customer’s invoice settings.
Maximum length: 5000
body.default_sourcestringOptionalID of the default payment source for the invoice. It must belong to the customer associated with the invoice and be in a chargeable state. If not set, defaults to the subscription’s default source, if any, or to the customer’s default source.
Maximum length: 5000
body.default_tax_ratesarrayOptionalThe tax rates that will apply to any line item that does not have `tax_rates` set.
body.default_tax_rates[]stringEach itemMaximum length: 5000
body.descriptionstringOptionalAn arbitrary string attached to the object. Often useful for displaying to users. Referenced as ‘memo’ in the Dashboard.
Maximum length: 1500
body.discountsJSONOptionalThe coupons and promotion codes to redeem into discounts for the invoice. If not specified, inherits the discount from the invoice’s customer. Pass an empty string to avoid inheriting any discounts.
body.discounts (anyOf 1)arrayAlternative
body.discounts (anyOf 1)[]objectEach item
body.discounts (anyOf 1)[].couponstringOptionalMaximum length: 5000
body.discounts (anyOf 1)[].discountstringOptionalMaximum length: 5000
body.discounts (anyOf 1)[].promotion_codestringOptionalMaximum length: 5000
body.discounts (anyOf 2)stringAlternativeOne of:
body.due_dateintegerOptionalThe date on which payment for this invoice is due. Valid only for invoices where `collection_method=send_invoice`.
Format: unix-time
body.effective_atintegerOptionalThe date when this invoice is in effect. Same as `finalized_at` unless overwritten. When defined, this value replaces the system-generated ‘Date of issue’ printed on the invoice PDF and receipt.
Format: unix-time
body.expandarrayOptionalSpecifies which fields in the response should be expanded.
body.expand[]stringEach itemMaximum length: 5000
body.footerstringOptionalFooter to be displayed on the invoice.
Maximum length: 5000
body.from_invoiceobjectOptionalRevise an existing invoice. The new invoice will be created in `status=draft`. See the [revision documentation](https://docs.stripe.com/invoicing/invoice-revisions) for more details.
body.from_invoice.actionstringRequired within parentOne of: revision
Maximum length: 5000
body.from_invoice.invoicestringRequired within parentMaximum length: 5000
body.issuerobjectOptionalThe connected account that issues the invoice. The invoice is presented with the branding and support information of the specified account.
body.issuer.accountstringOptional
body.issuer.typestringRequired within parentOne of: account, self
body.metadataJSONOptionalSet of [key-value pairs](https://docs.stripe.com/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`.
body.metadata (anyOf 1)objectAlternativeAdditional keys: see wildcard field
body.metadata (anyOf 1).*stringAdditional keys
body.metadata (anyOf 2)stringAlternativeOne of:
body.numberstringOptionalSet the number for this invoice. If no number is present then a number will be assigned automatically when the invoice is finalized. In many markets, regulations require invoices to be unique, sequential and / or gapless. You are responsible for ensuring this is true across all your different invoicing systems in the event that you edit the invoice number using our API. If you use only Stripe for your invoices and do not change invoice numbers, Stripe handles this aspect of compliance for you automatically.
Maximum length: 26
body.on_behalf_ofstringOptionalThe account (if any) for which the funds of the invoice payment are intended. If set, the invoice will be presented with the branding and support information of the specified account. See the [Invoices with Connect](https://docs.stripe.com/billing/invoices/connect) documentation for details.
body.payment_settingsModelOptionalExpand Create an invoice — request body — body payment settings
body.pending_invoice_items_behaviorstringOptionalHow to handle pending invoice items on invoice creation. Defaults to `exclude` if the parameter is omitted.
One of: exclude, include
body.renderingModelOptionalExpand Create an invoice — request body — body rendering
body.shipping_costobjectOptionalSettings for the cost of shipping for this invoice.
body.shipping_cost.shipping_ratestringOptionalMaximum length: 5000
body.shipping_cost.shipping_rate_dataModelOptionalExpand Create an invoice — request body — body shipping cost shipping rate data
body.shipping_detailsobjectOptionalShipping details for the invoice. The Invoice PDF will use the `shipping_details` value if it is set, otherwise the PDF will render the shipping address from the customer.
body.shipping_details.addressobjectRequired within parent
body.shipping_details.address.citystringOptionalMaximum length: 5000
body.shipping_details.address.countrystringOptionalMaximum length: 5000
body.shipping_details.address.line1stringOptionalMaximum length: 5000
body.shipping_details.address.line2stringOptionalMaximum length: 5000
body.shipping_details.address.postal_codestringOptionalMaximum length: 5000
body.shipping_details.address.statestringOptionalMaximum length: 5000
body.shipping_details.namestringRequired within parentMaximum length: 5000
body.shipping_details.phoneJSONOptional
body.shipping_details.phone (anyOf 1)stringAlternativeMaximum length: 5000
body.shipping_details.phone (anyOf 2)stringAlternativeOne of:
body.statement_descriptorstringOptionalExtra information about a charge for the customer’s credit card statement. It must contain at least one letter. If not specified and this invoice is part of a subscription, the default `statement_descriptor` will be set to the first subscription item’s product’s `statement_descriptor`.
Maximum length: 22
body.subscriptionstringOptionalThe ID of the subscription to invoice, if any. If set, the created invoice will only include pending invoice items for that subscription. The subscription’s billing cycle and regular subscription events won’t be affected.
Maximum length: 5000
body.transfer_dataobjectOptionalIf specified, the funds from the invoice will be transferred to the destination and the ID of the resulting transfer will be found on the invoice’s charge.
body.transfer_data.amountintegerOptional
body.transfer_data.destinationstringRequired within parent

Referenced models: Create an invoice — request body — body payment settings, Create an invoice — request body — body rendering, Create an invoice — request body — body shipping cost shipping rate data

Response media type: application/json. The table describes the pinned successful response. Referenced models link to their complete fields.

FieldTypePresenceDescription and constraints
$ModelRootExpand Pay an invoice — response body

Referenced models: Pay an invoice — response body

710 more schemas are linked from the tables above, on the schema pages.

Create an invoice — request body — body payment settings
FieldTypePresenceDescription and constraints
$objectRootConfiguration settings for the PaymentIntent that is generated when the invoice is finalized.
default_mandateJSONOptional
default_mandate (anyOf 1)stringAlternativeMaximum length: 5000
default_mandate (anyOf 2)stringAlternativeOne of:
payment_method_optionsModelOptionalExpand Create an invoice — request body — body payment settings payment method options
payment_method_typesJSONOptional
payment_method_types (anyOf 1)arrayAlternative
payment_method_types (anyOf 1)[]stringEach itemOne of: ach_credit_transfer, ach_debit, acss_debit, affirm, alipay, amazon_pay, au_becs_debit, bacs_debit, bancontact, billie, blik, boleto, card, cashapp, crypto, custom, customer_balance, eps, fpx, giropay, grabpay, ideal, jp_credit_transfer, kakao_pay, klarna, konbini, kr_card, link, mb_way, multibanco, naver_pay, nz_bank_account, p24, pay_by_bank, payco, paynow, paypal, payto, pix, promptpay, revolut_pay, satispay, sepa_credit_transfer, sepa_debit, sofort, swish, twint, upi, us_bank_account, wechat_pay
payment_method_types (anyOf 2)stringAlternativeOne of:

Referenced models: Create an invoice — request body — body payment settings payment method options

Create an invoice — request body — body rendering
FieldTypePresenceDescription and constraints
$objectRootThe rendering-related settings that control how invoices render in customer-facing interfaces such as the PDF or hosted invoice page.
amount_tax_displaystringOptionalOne of: , exclude_tax, include_inclusive_tax
pdfobjectOptional
pdf.page_sizestringOptionalOne of: a4, auto, letter
templatestringOptionalMaximum length: 5000
template_versionJSONOptional
template_version (anyOf 1)integerAlternative
template_version (anyOf 2)stringAlternativeOne of:
Create an invoice — request body — body shipping cost shipping rate data
FieldTypePresenceDescription and constraints
$objectRoot
delivery_estimateobjectOptional
delivery_estimate.maximumobjectOptional
delivery_estimate.maximum.unitstringRequired within parentOne of: business_day, day, hour, month, week
delivery_estimate.maximum.valueintegerRequired within parent
delivery_estimate.minimumobjectOptional
delivery_estimate.minimum.unitstringRequired within parentOne of: business_day, day, hour, month, week
delivery_estimate.minimum.valueintegerRequired within parent
display_namestringRequired within parentMaximum length: 100
fixed_amountobjectOptional
fixed_amount.amountintegerRequired within parent
fixed_amount.currencystringRequired within parentFormat: currency
fixed_amount.currency_optionsobjectOptionalAdditional keys: see wildcard field
fixed_amount.currency_options.*objectAdditional keys
fixed_amount.currency_options.*.amountintegerRequired within parent
fixed_amount.currency_options.*.tax_behaviorstringOptionalOne of: exclusive, inclusive, unspecified
metadataobjectOptionalAdditional keys: see wildcard field
metadata.*stringAdditional keys
tax_behaviorstringOptionalOne of: exclusive, inclusive, unspecified
tax_codestringOptional
typestringOptionalOne of: fixed_amount
Create a Location — response body — address
FieldTypePresenceDescription and constraints
$objectRoot
cityJSONOptional
city (anyOf 1)stringAlternativeCity, district, suburb, town, or village.
Maximum length: 5000
city (anyOf 2)nullAlternative
countryJSONOptional
country (anyOf 1)stringAlternativeTwo-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)).
Maximum length: 5000
country (anyOf 2)nullAlternative
line1JSONOptional
line1 (anyOf 1)stringAlternativeAddress line 1, such as the street, PO Box, or company name.
Maximum length: 5000
line1 (anyOf 2)nullAlternative
line2JSONOptional
line2 (anyOf 1)stringAlternativeAddress line 2, such as the apartment, suite, unit, or building.
Maximum length: 5000
line2 (anyOf 2)nullAlternative
postal_codeJSONOptional
postal_code (anyOf 1)stringAlternativeZIP or postal code.
Maximum length: 5000
postal_code (anyOf 2)nullAlternative
stateJSONOptional
state (anyOf 1)stringAlternativeState, county, province, or region ([ISO 3166-2](https://en.wikipedia.org/wiki/ISO_3166-2)).
Maximum length: 5000
state (anyOf 2)nullAlternative
Cancel a SetupIntent — response body — last_setup_error / value / type: api error, card error, idempotency error, invalid request error
FieldTypePresenceDescription and constraints
$objectRoot
advice_codestringOptionalFor card errors resulting from a card issuer decline, a short string indicating [how to proceed with an error](https://docs.stripe.com/declines/card#retrying-issuer-declines) if they provide one.
Maximum length: 5000
chargestringOptionalFor card errors, the ID of the failed charge.
Maximum length: 5000
codestringOptionalFor some errors that could be handled programmatically, a short string indicating the [error code](https://docs.stripe.com/error-codes) reported.
Maximum length: 5000
decline_codestringOptionalFor card errors resulting from a card issuer decline, a short string indicating the [card issuer's reason for the decline](https://docs.stripe.com/declines#issuer-declines) if they provide one.
Maximum length: 5000
doc_urlstringOptionalA URL to more information about the [error code](https://docs.stripe.com/error-codes) reported.
Maximum length: 5000
messagestringOptionalA human-readable message providing more details about the error. For card errors, these messages can be shown to your users.
Maximum length: 40000
network_advice_codestringOptionalFor card errors resulting from a card issuer decline, a 2 digit code which indicates the advice given to merchant by the card network on how to proceed with an error.
Maximum length: 5000
network_decline_codestringOptionalFor payments declined by the network, an alphanumeric code which indicates the reason the payment failed.
Maximum length: 5000
paramstringOptionalIf the error is parameter-specific, the parameter related to the error. For example, you can use this to display a message near the correct form field.
Maximum length: 5000
payment_intentModelOptionalExpand Cancel a Payment Intent — response body
payment_methodModelOptionalExpand Create a Payment Method — response body
payment_method_typestringOptionalIf the error is specific to the type of payment method, the payment method type that had a problem. This field is only populated for invoice-related errors.
Maximum length: 5000
request_log_urlstringOptionalA URL to the request log entry in your dashboard.
Maximum length: 5000
setup_intentModelOptionalExpand Cancel a Setup Intent — response body
sourceJSONOptionalThe [source object](https://docs.stripe.com/api/sources/object) for errors returned on a request involving a source.
source (anyOf 1)ModelAlternativeExpand Retrieve a bank account — response body
source (anyOf 2)ModelAlternativeExpand Retrieve a card — customers get Customers Customer Cards Id — response body
source (anyOf 3)ModelAlternativeExpand Create a source — response body
typestringRequired within parentThe type of error returned. One of `api_error`, `card_error`, `idempotency_error`, or `invalid_request_error`
Known values: api_error, card_error, idempotency_error, invalid_request_error

Referenced models: Retrieve a bank account — response body, Retrieve a card — customers get Customers Customer Cards Id — response body, Cancel a Payment Intent — response body, Create a Payment Method — response body, Cancel a Setup Intent — response body, Create a source — response body

PostApplicationFeesIdRefund — response body — application / object: application
FieldTypePresenceDescription and constraints
$objectRoot
idstringRequired within parentUnique identifier for the object.
Maximum length: 5000
nameJSONOptional
name (anyOf 1)stringAlternativeThe name of the application.
Maximum length: 5000
name (anyOf 2)nullAlternative
objectstringRequired within parentString representing the object's type. Objects of the same type share the same value.
Known values: application

SDK function policy ID: stripe.postinvoices. Catalog operation: PostInvoices. Rules can name either ID; function rules distinguish managed calls and conservatively cover raw calls sharing the route. Existing grant permissions and policy rules apply. wait() returns an immediate result or waits for a required approval; it never approves the request itself. Persist the approval ID to resume after a restart.

Provider errors retain their response; JSON decoding raises ProviderAPIError for provider failures. ManagedOperationError identifies contract/input/retention errors. See error handling and provider-specific behavior. Sensitive input may be refused before approval storage. A decoding error never resubmits a write.

Pinned headers: {"Stripe-Version": "2026-09-30.endive"}

Official provider source

Report an issue with this page

Necessary

Required for sign-in, security, authorization, and remembering your choices.

Always active

Analytics

Helps us understand which product and documentation features are useful.

Performance diagnostics

Uses performance tracing and privacy-masked session replay to diagnose problems.

You can change these choices at any time from Cookie settings.