Sign in
An image of the Stripe logo
Create account
Sign in
Home
Payments
Business operations
Financial services
Developer tools
Security
All products
Home
Payments
Business operations
Home
Payments
Business operations
Financial services
Developer tools
Support
Overview
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
Customize 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
Multiple currencies
Testing
No-code options
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 this process, 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:

Terminal
# Available as a gem sudo gem install stripe
Gemfile
# If you use bundler, you can add this line to your Gemfile gem 'stripe'

Create a product

To create a product, enter its name:

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:

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:

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 preview an invoice.

See Create a customer for additional parameters.

Create an invoice

Before you invoice a customer, create an invoice item by passing in the customer id and product price. Creating an invoice automatically adds all pending invoice items for that customer. Only add invoice items to a single customer at a time to avoid adding them to the wrong one.

The maximum number of invoice items is 250. Creating an invoice will add up to 250 pending invoice items with the remainder to be added on the next invoice. To see your customer’s pending invoice items, see the Customer details page or set the pending attribute to true when you use the API to list all of the invoice items.

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

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.

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

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.

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.

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
  • Invoicing API
Was this page helpful?
Questions? Contact us.
View developer tutorials on YouTube.
Check out our product changelog.
Powered by Markdoc
You can unsubscribe at any time. Read our privacy policy.
On this page
Set up Stripe
Create a product
Create a price
Create a customer
Create an invoice
Send an invoice
Customize an invoice
Stripe Shell
Test mode
▗▄ ▄▟█ █▀▀ ▗▟████▙▖ ██████ ███▗▟█ ███ ███▗▟██▙▖ ▗▟█████▙▖ ███▖ ▀▀ ███ ███▀▀▀ ███ ███▀ ███ ███ ███ ▝▜████▙▖ ███ ███ ███ ███ ███ █████████ ▄▄ ▝███ ███ ▄ ███ ███ ███▄ ███ ███ ▄▄ ▝▜████▛▘ ▝▜███▛ ███ ███ ███▝▜██▛▘ ▝▜█████▛▘ ███ ▀▘
Welcome to the Stripe Shell! This is a graphical user interface of the Stripe CLI. You can use it to discover webhook events and manage your Stripe resources. By pressing ctrl + ` you can toggle it open from any page within the Stripe documentation. - View supported commands: - Listen for webhook events: - Trigger webhook events: - Call Stripe APIs: stripe [api resource] [api operation] (e.g. )
The Stripe Shell is best experienced on desktop.
$