# Retrieve an upcoming invoice

At any time, you can preview the upcoming invoice for a customer. This will show you all the charges that are pending, including subscription renewal charges, invoice item charges, etc. It will also show you any discounts that are applicable to the invoice.

Note that when you are viewing an upcoming invoice, you are simply viewing a preview – the invoice has not yet been created. As such, the upcoming invoice will not show up in invoice listing calls, and you cannot use the API to pay or edit the invoice. If you want to change the amount that your customer will be billed, you can add, remove, or update pending invoice items, or update the customer’s discount.

You can preview the effects of updating a subscription, including a preview of what proration will take place. To ensure that the actual proration is calculated exactly the same as the previewed proration, you should pass the `subscription_details.proration_date` parameter when doing the actual subscription update. The recommended way to get only the prorations being previewed is to consider only proration line items where `period[start]` is equal to the `subscription_details.proration_date` value passed in the request.

Note: Currency conversion calculations use the latest exchange rates. Exchange rates may vary between the time of the preview and the time of the actual invoice creation. [Learn more](https://docs.stripe.com/currencies/conversions.md?api-version=2024-12-18.acacia)

## Prerequisites

Before you can run the following code snippet, you need to call these APIs with the provided parameters to set up the prerequisite API object(s).

1. createCustomer
POST /v1/customers {"name":"Jenny Rosen","email":"jennyrosen@example.com"}

## Request

```curl
curl -G https://api.stripe.com/v1/invoices/upcoming \
  -u "<<YOUR_SECRET_KEY>>" \
  -d customer={{CUSTOMER_ID}}
```

### Response

```json
{
  "object": "invoice",
  "account_country": "US",
  "account_name": "Stripe Docs",
  "account_tax_ids": null,
  "amount_due": 0,
  "amount_paid": 0,
  "amount_remaining": 0,
  "amount_shipping": 0,
  "application": null,
  "application_fee_amount": null,
  "attempt_count": 0,
  "attempted": false,
  "auto_advance": false,
  "automatic_tax": {
    "enabled": false,
    "liability": null,
    "status": null
  },
  "billing_reason": "manual",
  "charge": null,
  "collection_method": "charge_automatically",
  "created": 1680644467,
  "currency": "usd",
  "custom_fields": null,
  "customer": "cus_NeZwdNtLEOXuvB",
  "customer_address": null,
  "customer_email": "jennyrosen@example.com",
  "customer_name": "Jenny Rosen",
  "customer_phone": null,
  "customer_shipping": null,
  "customer_tax_exempt": "none",
  "customer_tax_ids": [],
  "default_payment_method": null,
  "default_source": null,
  "default_tax_rates": [],
  "description": null,
  "discount": null,
  "discounts": [],
  "due_date": null,
  "ending_balance": null,
  "footer": null,
  "from_invoice": null,
  "hosted_invoice_url": null,
  "invoice_pdf": null,
  "issuer": {
    "type": "self"
  },
  "last_finalization_error": null,
  "latest_revision": null,
  "lines": {
    "object": "list",
    "data": [],
    "has_more": false,
    "total_count": 0,
    "url": "/v1/invoices/in_1MtHbELkdIwHu7ixl4OzzPMv/lines"
  },
  "livemode": false,
  "metadata": {},
  "next_payment_attempt": null,
  "number": null,
  "on_behalf_of": null,
  "paid": false,
  "paid_out_of_band": false,
  "payment_intent": null,
  "payment_settings": {
    "default_mandate": null,
    "payment_method_options": null,
    "payment_method_types": null
  },
  "period_end": 1680644467,
  "period_start": 1680644467,
  "post_payment_credit_notes_amount": 0,
  "pre_payment_credit_notes_amount": 0,
  "quote": null,
  "receipt_number": null,
  "rendering_options": null,
  "shipping_cost": null,
  "shipping_details": null,
  "starting_balance": 0,
  "statement_descriptor": null,
  "status": "draft",
  "status_transitions": {
    "finalized_at": null,
    "marked_uncollectible_at": null,
    "paid_at": null,
    "voided_at": null
  },
  "subscription": null,
  "subtotal": 0,
  "subtotal_excluding_tax": 0,
  "tax": null,
  "test_clock": null,
  "total": 0,
  "total_discount_amounts": [],
  "total_excluding_tax": 0,
  "total_tax_amounts": [],
  "transfer_data": null,
  "webhooks_delivered_at": 1680644467
}
```

## Returns

Returns an invoice if valid customer information is provided. Raises [an error](https://docs.stripe.com/api/invoices/upcoming.md?api-version=2024-12-18.acacia#errors) otherwise.

## Parameters

- [`automatic_tax`](https://docs.stripe.com/api/invoices/upcoming.md?query=automatic_tax&api-version=2024-12-18.acacia) (object, optional)
  Settings for automatic tax lookup for this invoice preview.

- `coupon` (string, optional)
  The ID of the coupon to apply to this invoice. This field has been deprecated and will be removed in a future API version. Use `discounts` instead.

- `currency` (enum, optional)
  The currency to preview this invoice in. Defaults to that of `customer` if not specified.

- `customer` (string, optional)
  The identifier of the customer whose upcoming invoice you’d like to retrieve. If `automatic_tax` is enabled then one of `customer`, `customer_details`, `subscription`, or `schedule` must be set.

- [`customer_details`](https://docs.stripe.com/api/invoices/upcoming.md?query=customer_details&api-version=2024-12-18.acacia) (object, optional)
  Details about the customer you want to invoice or overrides for an existing customer. If `automatic_tax` is enabled then one of `customer`, `customer_details`, `subscription`, or `schedule` must be set.

- [`discounts`](https://docs.stripe.com/api/invoices/upcoming.md?query=discounts&api-version=2024-12-18.acacia) (array of objects, optional)
  The coupons to redeem into discounts for the invoice preview. If not specified, inherits the discount from the subscription or customer. This works for both coupons directly applied to an invoice and coupons applied to a subscription. Pass an empty string to avoid inheriting any discounts.

- [`invoice_items`](https://docs.stripe.com/api/invoices/upcoming.md?query=invoice_items&api-version=2024-12-18.acacia) (array of objects, optional)
  List of invoice items to add or update in the upcoming invoice preview (up to 250).

- [`issuer`](https://docs.stripe.com/api/invoices/upcoming.md?query=issuer&api-version=2024-12-18.acacia) (object, optional)
  The connected account that issues the invoice. The invoice is presented with the branding and support information of the specified account.

- `on_behalf_of` (string, optional)
  The 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/docs/billing/invoices/connect.md?api-version=2024-12-18.acacia) documentation for details.

- `preview_mode` (enum, optional)
  Customizes the types of values to include when calculating the invoice. Defaults to `next` if unspecified.
Possible enum values:
  - `next`
    Will calculate the next invoice for the customer or subscription, factoring in all one-time and recurring items.

  - `recurring`
    Will calculate an invoice that is an estimate of the subscription’s long-term recurring bill. The invoice lines will only include recurring subscription items, taxes, and coupons with `duration=repeating` or `duration=forever`.

    To calculate a recurring estimate, you must provide at least one of `subscription` or `subscription_details.items`. Prorations, subscription cancellations, and trials are not supported with recurring estimates.

- `schedule` (string, optional)
  The identifier of the schedule whose upcoming invoice you’d like to retrieve. Cannot be used with subscription or subscription fields.

- [`schedule_details`](https://docs.stripe.com/api/invoices/upcoming.md?query=schedule_details&api-version=2024-12-18.acacia) (object, optional)
  The schedule creation or modification params to apply as a preview. Cannot be used with `subscription` or `subscription_` prefixed fields.

- `subscription` (string, optional)
  The identifier of the subscription for which you’d like to retrieve the upcoming invoice. If not provided, but a `subscription_details.items` is provided, you will preview creating a subscription with those items. If neither `subscription` nor `subscription_details.items` is provided, you will retrieve the next upcoming invoice from among the customer’s subscriptions.

- `subscription_billing_cycle_anchor` (string | timestamp, optional)
  For new subscriptions, a future timestamp to anchor the subscription’s [billing cycle](https://docs.stripe.com/docs/subscriptions/billing-cycle.md?api-version=2024-12-18.acacia). This is used to determine the date of the first full invoice, and, for plans with `month` or `year` intervals, the day of the month for subsequent invoices. For existing subscriptions, the value can only be set to `now` or `unchanged`. This field has been deprecated and will be removed in a future API version. Use `subscription_details.billing_cycle_anchor` instead.

- `subscription_cancel_at` (timestamp, optional)
  A timestamp at which the subscription should cancel. If set to a date before the current period ends, this will cause a proration if prorations have been enabled using `proration_behavior`. If set during a future period, this will always cause a proration for that period. This field has been deprecated and will be removed in a future API version. Use `subscription_details.cancel_at` instead.

- `subscription_cancel_at_period_end` (boolean, optional)
  Indicate whether this subscription should cancel at the end of the current period (`current_period_end`). Defaults to `false`. This field has been deprecated and will be removed in a future API version. Use `subscription_details.cancel_at_period_end` instead.

- `subscription_cancel_now` (boolean, optional)
  This simulates the subscription being canceled or expired immediately. This field has been deprecated and will be removed in a future API version. Use `subscription_details.cancel_now` instead.

- `subscription_default_tax_rates` (array of strings, optional)
  If provided, the invoice returned will preview updating or creating a subscription with these default tax rates. The default tax rates will apply to any line item that does not have `tax_rates` set. This field has been deprecated and will be removed in a future API version. Use `subscription_details.default_tax_rates` instead.

- [`subscription_details`](https://docs.stripe.com/api/invoices/upcoming.md?query=subscription_details&api-version=2024-12-18.acacia) (object, optional)
  The subscription creation or modification params to apply as a preview. Cannot be used with `schedule` or `schedule_details` fields.

- [`subscription_items`](https://docs.stripe.com/api/invoices/upcoming.md?query=subscription_items&api-version=2024-12-18.acacia) (array of objects, optional)
  A list of up to 20 subscription items, each with an attached price. This field has been deprecated and will be removed in a future API version. Use `subscription_details.items` instead.

- `subscription_proration_behavior` (enum, optional)
  Determines how to handle [prorations](https://docs.stripe.com/docs/billing/subscriptions/prorations.md?api-version=2024-12-18.acacia) when the billing cycle changes (e.g., when switching plans, resetting `billing_cycle_anchor=now`, or starting a trial), or if an item’s `quantity` changes. The default value is `create_prorations`. This field has been deprecated and will be removed in a future API version. Use `subscription_details.proration_behavior` instead.
Possible enum values:
  - `always_invoice`
    Always invoice immediately for prorations.

  - `create_prorations`
    Will cause proration invoice items to be created when applicable. These proration items will only be invoiced immediately under [certain conditions](https://docs.stripe.com/docs/subscriptions/upgrading-downgrading.md?api-version=2024-12-18.acacia#immediate-payment).

  - `none`
    Disable creating prorations in this request.

- `subscription_proration_date` (timestamp, optional)
  If previewing an update to a subscription, and doing proration, `subscription_proration_date` forces the proration to be calculated as though the update was done at the specified time. The time given must be within the current subscription period and within the current phase of the schedule backing this subscription, if the schedule exists. If set, `subscription`, and one of `subscription_items`, or `subscription_trial_end` are required. Also, `subscription_proration_behavior` cannot be set to ‘none’. This field has been deprecated and will be removed in a future API version. Use `subscription_details.proration_date` instead.

- `subscription_resume_at` (string, optional)
  For paused subscriptions, setting `subscription_resume_at` to `now` will preview the invoice that will be generated if the subscription is resumed. This field has been deprecated and will be removed in a future API version. Use `subscription_details.resume_at` instead.

- `subscription_start_date` (timestamp, optional)
  Date a subscription is intended to start (can be future or past). This field has been deprecated and will be removed in a future API version. Use `subscription_details.start_date` instead.

- `subscription_trial_end` (string | timestamp, optional)
  If provided, the invoice returned will preview updating or creating a subscription with that trial end. If set, one of `subscription_items` or `subscription` is required. This field has been deprecated and will be removed in a future API version. Use `subscription_details.trial_end` instead.
