Sign in
An image of the Stripe logo
Create account
Sign in
Home
Payments
Business operations
Financial services
Developer tools
No-code
All products
Home
Payments
Business operations
Home
Payments
Business operations
Financial services
Developer tools
Support
Overview
Online payments
Products and prices
Invoicing
    Overview
    How invoicing works
    Get started
    No-code quickstart guide
    Payment methods
    Invoicing resources
    Customers
    Products and prices
    Taxes
    Manage invoices
    Use the Dashboard
    Integrate with the API
      Quickstart
      Automatic invoice advancement
      Status transitions and finalization
      Generate credit notes
      Virtual bank account numbers
      Test your integration
    Customize invoices
    Edit invoices
    Send customer emails
    Hosted Invoice Page
    Invoicing and Connect
    Automated collections
    Automatic reconciliation
    Automatic collection
    Automatic charging
    Global invoicing
    Set up invoices in Europe
    Set up invoices in Japan
    Multi-currency customers
    India e-Mandates
    Customize the IBAN country
Subscriptions
Quotes
In-person payments
Multiparty payments
After the payment
Add payment methods
Payment Links
Stripe Checkout
Stripe Elements
About the APIs
Regulation support
Implementation guides
Testing
Invoicing
·
HomePaymentsInvoicing

Integrate with the Invoicing API

Learn how to create and send an invoice with code.

The Dashboard is the most common way to create invoices. If you’d like to automate invoice creation, you can integrate with the API. Build a full, working Invoicing integration using our sample integration.

You don’t need to integrate with the Payments API to integrate with the Invoicing API.

Set up Stripe

Use our official libraries for access to the Stripe API:

Command Line
# For detailed setup, see our quickstarts at https://stripe.com/docs/development/quickstart bundle add stripe

Create a product

To create a product, enter its name:

Command Line
curl https://api.stripe.com/v1/products \ -u
sk_test_4eC39HqLyjWDarjtT1zdp7dc
: \ -d name="Gold Special"

Create a price

Prices define how much and how often to charge for products. This includes how much the product costs, what currency to use, and the billing interval (when the price is for a subscription). Like products, if you only have a few prices, it’s preferable to manage them in the Dashboard. Use the unit amount to express prices in the lowest unit of the currency—in this case, cents (10 USD is 1,000 cents, so the unit amount is 1000).

As an alternative, if you don’t need to create a price for your product, you can use the amount parameter during invoice item creation.

To create a price and assign it to the product, pass the product ID, unit amount, and currency. In the following example, the price for the “Gold Special” product is 10 USD:

Command Line
curl https://api.stripe.com/v1/prices \ -u
sk_test_4eC39HqLyjWDarjtT1zdp7dc
: \ -d product=
{{PRODUCT_ID}}
\ -d unit_amount=1000 \ -d currency=usd

Create a customer

The Customer object represents the customer purchasing your product. It’s required for creating an invoice. To create a customer with a name, email, and description, add the following code replacing the values with your own:

Command Line
curl https://api.stripe.com/v1/customers \ -u
sk_test_4eC39HqLyjWDarjtT1zdp7dc
: \ -d name="Jenny Rosen" \ -d email="jenny.rosen@example.com" \ -d description="My first customer"

After you create the customer, store the customer id in your database so that you can use it later. The next step, for example, uses the customer ID to create an invoice.

See Create a customer for additional parameters.

Create an invoice

Set the collection_method attribute to send_invoice. For Stripe to mark an invoice as past due, you must add the days_until_due parameter. When you send an invoice, Stripe emails the invoice to the customer with payment instructions.

Command Line
curl https://api.stripe.com/v1/invoices \ -u
sk_test_4eC39HqLyjWDarjtT1zdp7dc
: \ -d customer=
{{CUSTOMER_ID}}
\ -d collection_method=send_invoice \ -d days_until_due=30

Then, create an invoice item by passing in the customer id, product price, and invoice ID invoice.

The maximum number of invoice items is 250.

Command Line
curl https://api.stripe.com/v1/invoiceitems \ -u
sk_test_4eC39HqLyjWDarjtT1zdp7dc
: \ -d customer=
{{CUSTOMER_ID}}
\ -d price=
{{PRICE_ID}}
\ -d invoice=
{{INVOICE_ID}}

If you set auto_advance to false, you can continue to modify the invoice until you finalize it. To finalize a draft invoice, use the Dashboard, send it to the customer, or pay it. You can also use the Finalize API:

If you created the invoice in error, void it. You can also mark an invoice as uncollectible.

Command Line
curl -X POST https://api.stripe.com/v1/invoices/
{{INVOICE_ID}}
/finalize
\ -u
sk_test_4eC39HqLyjWDarjtT1zdp7dc
:

Send an invoice

Send the invoice to the email address associated with the customer. As soon as the an invoice is sent, Stripe finalizes it. Many jurisdictions consider finalized invoices a legal document making certain fields unalterable. If you send invoices that have already been paid, there’s no reference to the payment in the email.

When you send invoices that have already been paid, the email doesn’t reference the payment. Stripe sends invoices to the email address associated with the customer.

Command Line
curl -X POST https://api.stripe.com/v1/invoices/
{{INVOICE_ID}}
/send
\ -u
sk_test_4eC39HqLyjWDarjtT1zdp7dc
:

OptionalCustomize an invoice

See also

  • Post-finalization
  • Use incoming webhooks to get real-time updates
Was this page helpful?
Questions? Contact us.
Watch our developer tutorials.
Check out our product changelog.
Powered by Markdoc
You can unsubscribe at any time. Read our privacy policy.
Code quickstart
On this page
Set up Stripe
Create a product
Create a price
Create a customer
Create an invoice
Send an invoice
Customize an invoice
See also
Related Guides
How Invoicing Works
Invoicing API
Hosted Invoice Page
Stripe Shell
Test mode
Welcome to the Stripe Shell! Stripe Shell is a browser-based shell with the Stripe CLI pre-installed. Login to your Stripe account and press Control + Backtick on your keyboard to start managing your Stripe resources in test mode. - View supported Stripe commands: - Find webhook events: - Listen for webhook events: - Call Stripe APIs: stripe [api resource] [operation] (e.g. )
The Stripe Shell is best experienced on desktop.
$