# Edit invoices Learn how to edit invoices after finalization. You can’t revise invoices that are attached to *subscriptions* (A Subscription represents the product details associated with the plan that your customer subscribes to. Allows you to charge the customer on a recurring basis) after finalization. For these types of invoices, the **Edit invoice** button is disabled. Stripe lets you revise a finalized invoice in `open` or `uncollectible` status. You can’t, however, revise an invoice in `void` or `paid` status. You might want to revise an invoice if you need to: - Edit the invoice description. - Edit the customer to update contact information. - Add, remove, or edit a line item. - Add a discount or apply taxes. You can also [customize invoices](https://docs.stripe.com/invoicing/customize.md) if you need to change their content or branding. > The invoice compliance process can vary across countries. For example, if you’re based in the European Union, you might want to void an invoice and issue a credit note instead of revising the original invoice. Stripe recommends that you consult with your legal counsel for advice specific to your business. # API You can use the [API](https://docs.stripe.com/api/invoices.md) to edit an invoice after finalization. ## Revise an invoice To begin the post-finalization revision process, use the [Create](https://docs.stripe.com/api/invoices/create.md) endpoint with the `from_invoice` parameter. This request creates a new draft invoice that’s linked back to the original as a revision. It also duplicates all of the invoice line items associated with the invoice. It doesn’t, however, duplicate any invoice credit notes, which could result in a change to the amount due. Also, this request doesn’t pull in pending invoice items the way invoice creation does. > You can’t use the [Update](https://docs.stripe.com/api/invoices/update.md) endpoint to edit most fields on an invoice after it has been finalized, including monetary amounts, discounts, or customer information. ```python # Don't put any keys in code. See https://docs.stripe.com/keys-best-practices. # Find your keys at https://dashboard.stripe.com/apikeys. client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. invoice = client.v1.invoices.create({ "from_invoice": {"invoice": "{{ORIGINAL_INVOICE_ID}}", "action": "revision"}, }) ``` After you submit a request to create an invoice using the `from_invoice` parameter, Stripe responds with the following: ```json { "id": "{{FIRST_REVISION_INVOICE_ID}}", "status": "draft", "from_invoice": { "invoice": "{{ORIGINAL_INVOICE_ID}}", "action": "revision", }, } ``` This new draft invoice has mostly identical fields to the original invoice, with a few exceptions: - If you updated the invoice’s customer after finalizing the original invoice, the new invoice uses the updated customer information. If you use [automatic tax](https://docs.stripe.com/tax/invoicing.md), this might cause a recalculation of the tax amount. - If the original invoice had `auto_advance == true`, the revision invoice has it set to false. - The revision invoice’s `starting_balance` and `amount_due` reflects any [customer balance](https://docs.stripe.com/invoicing/customer/balance.md) applied to the original invoice plus any additional balance that is available on the customer object. From here, you can make additional changes to the invoice like you would any draft. The following example updates the description of the invoice: ```python # Don't put any keys in code. See https://docs.stripe.com/keys-best-practices. # Find your keys at https://dashboard.stripe.com/apikeys. client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. invoice = client.v1.invoices.update( "{{FIRST_REVISION_INVOICE_ID}}", {"description": "Updated maintenance contract"}, ) ``` To add a new line item to the revised invoice: ```python # Don't put any keys in code. See https://docs.stripe.com/keys-best-practices. # Find your keys at https://dashboard.stripe.com/apikeys. client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. invoice_item = client.v1.invoice_items.create({ "customer": "{{CUSTOMER_ID}}", "invoice": "{{FIRST_REVISION_INVOICE_ID}}", "pricing": {"price": "{{PRICE_ID}}"}, "quantity": 100, "description": "Additional Stripe swag!", }) ``` Invoice revisions allow you to update customer information and have it reflected in the PDFs and on the Hosted Invoice Pages of finalized invoices: ```python # Don't put any keys in code. See https://docs.stripe.com/keys-best-practices. # Find your keys at https://dashboard.stripe.com/apikeys. client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. customer = client.v1.customers.update( "{{CUSTOMER_ID}}", {"name": "John Doe"}, ) ``` After you make all of your desired changes, finalize the revised invoice: ```python # Don't put any keys in code. See https://docs.stripe.com/keys-best-practices. # Find your keys at https://dashboard.stripe.com/apikeys. client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. invoice = client.v1.invoices.finalize_invoice("{{FIRST_REVISION_INVOICE_ID}}") ``` Finalizing the revised invoice changes its state to `open`, and sets the `finalized_at` parameter to the current time stamp (rather than the `finalized_at` time stamp for the original invoice ). When you finalize an invoice, Stripe does the following: - Voids the original invoice. - Adds a `latest_revision` parameter to the original invoice. ## Multiple invoice revisions In some cases, you might need to make several revisions to an invoice. The process here is the same one used for the first revision except that Stripe updates the `latest_revision` parameter on all previous revisions. We only update the `latest_revision` parameter on finalization, not when you create the revised invoice. ```python # Don't put any keys in code. See https://docs.stripe.com/keys-best-practices. # Find your keys at https://dashboard.stripe.com/apikeys. client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. invoice = client.v1.invoices.create({ "from_invoice": {"invoice": "{{FIRST_REVISION_INVOICE_ID}}", "action": "revision"}, }) ``` After you submit a request using the `from_invoice` parameter, you receive a response similar to the following: ```json { "id": "{{LATEST_REVISION_INVOICE_ID}}", "status": "draft", "from_invoice": { "invoice": "{{FIRST_REVISION_INVOICE_ID}}", "action": "revision", }, # ... more fields } ``` Finalize the new invoice to complete the revision: ```python # Don't put any keys in code. See https://docs.stripe.com/keys-best-practices. # Find your keys at https://dashboard.stripe.com/apikeys. client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. invoice = client.v1.invoices.finalize_invoice("{{LATEST_REVISION_INVOICE_ID}}") ``` If you attempt to fetch the original invoice, you receive a response indicating that it’s void. Stripe voids the original invoice as soon as the first revision finalizes. ```json { "id": "{{ORIGINAL_INVOICE_ID}}", "status": "void", "latest_revision": "{{LATEST_REVISION_INVOICE_ID}}", # This has changed from "{{FIRST_REVISION_INVOICE_ID}". } ``` ## Invoice revision constraints Stripe enforces several constraints on invoice revisions: - **Invoices can have at most one draft revision**—If you `POST` to the `/v1/invoices` endpoint when another `draft` invoice exists with the same `from_invoice[invoice]` parameter, Stripe responds with a 400 status code. - **You can only create a revision for invoices with open or uncollectible statuses**—If you `POST` to the `/v1/invoices` endpoint, and `from_invoice[invoice]` corresponds to an invoice with any state other than `open` or `uncollectible`, we respond with a 400 status code. - **If an invoice is open or uncollectible but has a payment intent in the processing state, you can’t create or finalize revisions**—If a customer is using a payment method where the invoice status doesn’t update to `paid` when a payment attempt is initiated (like `us_bank_account`), we respond with a 400 status code. - **If an open or uncollectible invoice enters a paid or void status or has a processing payment intent while it has a draft revision, you can’t finalize the revision**—Stripe enforces this through a 400 status code on any endpoint that could result in invoice finalization, including `/v1/invoices/:id/finalize`, `/v1/invoices/:id/pay`, and `/v1/invoices/:id/send`. - **You can’t revise invoices that are attached to a subscription**—After finalization, you can’t edit invoices that have a subscription ID after finalization. For these types of invoices, Stripe sends an `invoice.created` webhook [1 hour before finalization](https://docs.stripe.com/billing/subscriptions/webhooks.md#understand) for all invoices after the first. Additionally, you can’t edit any standalone invoices with subscription line items. These standalone invoices are usually created by pulling in pending proration line items. - **You can’t revise invoices that have credit notes**—You can’t create a revision for an invoice that has a [credit note](https://docs.stripe.com/api/credit_notes.md). ## See also - [Use the Dashboard](https://docs.stripe.com/invoicing/dashboard.md) - [Integrate with the API](https://docs.stripe.com/invoicing/integration.md) - [Hosted Invoice Page](https://docs.stripe.com/invoicing/hosted-invoice-page.md)