Skip to content

Stripe: Bulk add invoice line items

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

← Invoices operations · Get started

Operation stripe.postinvoicesinvoiceaddlines

Provider route: POST /v1/invoices/{invoice}/add_lines. 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"]["postInvoicesInvoiceAddLines"]>[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.postInvoicesInvoiceAddLines(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_invoice_add_lines(arguments)
result = await call.wait()
return result.body_json()
FieldTypePresenceDescription and constraints
$objectRootAdditional keys: not allowed
pathobjectRequired within parentAdditional keys: not allowed
path.invoicestringRequired within parentMaximum length: 5000
headersobjectOptionalAdditional keys: not allowed
headers.Idempotency-KeystringOptionalMinimum length: 1
Maximum length: 255
bodyobjectRequired within parentAdditional keys: not allowed
body.expandarrayOptionalSpecifies which fields in the response should be expanded.
body.expand[]stringEach itemMaximum length: 5000
body.invoice_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.invoice_metadata (anyOf 1)objectAlternativeAdditional keys: see wildcard field
body.invoice_metadata (anyOf 1).*stringAdditional keys
body.invoice_metadata (anyOf 2)stringAlternativeOne of:
body.linesarrayRequired within parentThe line items to add.
body.lines[]objectEach item
body.lines[].amountintegerOptional
body.lines[].descriptionstringOptionalMaximum length: 5000
body.lines[].discountablebooleanOptional
body.lines[].discountsJSONOptional
body.lines[].discounts (anyOf 1)arrayAlternative
body.lines[].discounts (anyOf 1)[]objectEach item
body.lines[].discounts (anyOf 1)[].couponstringOptionalMaximum length: 5000
body.lines[].discounts (anyOf 1)[].discountstringOptionalMaximum length: 5000
body.lines[].discounts (anyOf 1)[].promotion_codestringOptionalMaximum length: 5000
body.lines[].discounts (anyOf 2)stringAlternativeOne of:
body.lines[].invoice_itemstringOptionalMaximum length: 5000
body.lines[].metadataJSONOptional
body.lines[].metadata (anyOf 1)objectAlternativeAdditional keys: see wildcard field
body.lines[].metadata (anyOf 1).*stringAdditional keys
body.lines[].metadata (anyOf 2)stringAlternativeOne of:
body.lines[].periodobjectOptional
body.lines[].period.endintegerRequired within parentFormat: unix-time
body.lines[].period.startintegerRequired within parentFormat: unix-time
body.lines[].price_dataModelOptionalExpand Bulk add invoice line items — request body — body lines item price data
body.lines[].pricingobjectOptional
body.lines[].pricing.pricestringOptionalMaximum length: 5000
body.lines[].quantityintegerOptional
body.lines[].quantity_decimalstringOptionalFormat: decimal
body.lines[].tax_amountsJSONOptional
body.lines[].tax_amounts (anyOf 1)arrayAlternative
body.lines[].tax_amounts (anyOf 1)[]ModelEach itemExpand Update an invoice’s line item — request body — body tax amounts array item
body.lines[].tax_amounts (anyOf 2)stringAlternativeOne of:
body.lines[].tax_ratesJSONOptional
body.lines[].tax_rates (anyOf 1)arrayAlternative
body.lines[].tax_rates (anyOf 1)[]stringEach itemMaximum length: 5000
body.lines[].tax_rates (anyOf 2)stringAlternativeOne of:

Referenced models: Bulk add invoice line items — request body — body lines item price data, Update an invoice’s line item — request body — body tax amounts array item

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

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

Bulk add invoice line items — request body — body lines item price data
FieldTypePresenceDescription and constraints
$objectRoot
currencystringRequired within parentFormat: currency
productstringOptionalMaximum length: 5000
product_dataModelOptionalExpand Update an invoice's line item — request body — body price data product data
tax_behaviorstringOptionalOne of: exclusive, inclusive, unspecified
unit_amountintegerOptional
unit_amount_decimalstringOptionalFormat: decimal

Referenced models: Update an invoice's line item — request body — body price data product data

Update an invoice's line item — request body — body tax amounts array item
FieldTypePresenceDescription and constraints
$objectRoot
amountintegerRequired within parent
tax_rate_dataModelRequired within parentExpand Update an invoice's line item — request body — body tax amounts array item tax rate data
taxability_reasonstringOptionalOne of: customer_exempt, not_collecting, not_subject_to_tax, not_supported, portion_product_exempt, portion_reduced_rated, portion_standard_rated, product_exempt, product_exempt_holiday, proportionally_rated, reduced_rated, reverse_charge, standard_rated, taxable_basis_reduced, zero_rated
taxable_amountintegerRequired within parent

Referenced models: Update an invoice's line item — request body — body tax amounts array item tax rate data

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
Pay an invoice — response body — automatic tax
FieldTypePresenceDescription and constraints
$objectRoot
disabled_reasonJSONOptional
disabled_reason (anyOf 1)stringAlternativeIf Stripe disabled automatic tax, this enum describes why.
Known values: finalization_requires_location_inputs, finalization_system_error
disabled_reason (anyOf 2)nullAlternative
enabledbooleanRequired within parentWhether Stripe automatically computes tax on this invoice. Note that incompatible invoice items (invoice items with manually specified [tax rates](https://docs.stripe.com/api/tax_rates), negative amounts, or `tax_behavior=unspecified`) cannot be added to automatic tax invoices.
liabilityJSONOptional
liability (anyOf 1)JSONAlternativeThe account that's liable for tax. If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. The tax transaction is returned in the report of the connected account.
liability (anyOf 1) (anyOf 1)ModelAlternativeExpand Pay an invoice — response body — issuer
liability (anyOf 2)nullAlternative
providerJSONOptional
provider (anyOf 1)stringAlternativeThe tax provider powering automatic tax.
Maximum length: 5000
provider (anyOf 2)nullAlternative
statusJSONOptional
status (anyOf 1)stringAlternativeThe status of the most recent automated tax calculation for this invoice.
Known values: complete, failed, requires_location_inputs
status (anyOf 2)nullAlternative

Referenced models: Pay an invoice — response body — issuer

Pay an invoice — response body — parent / The parent that generated this invoice / type: quote details, subscription details quote details value quote
FieldTypePresenceDescription and constraints
$objectRoot
quotestringRequired within parentThe quote that generated this invoice
Maximum length: 5000

SDK function policy ID: stripe.postinvoicesinvoiceaddlines. Catalog operation: PostInvoicesInvoiceAddLines. 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.