Skip to main content
POST
/
v1
/
billing.preview_attach
Typescript (SDK)
import { Autumn } from 'autumn-js'

const autumn = new Autumn()

const result = await autumn.billing.previewAttach({
  customerId: "cus_123",
  planId: "pro_plan",
});
{
  "customerId": "charles",
  "lineItems": [
    {
      "title": "Pro seed",
      "description": "Pro seed - Base Price (from 18 Feb 2026 to 18 Mar 2026)",
      "amount": 20,
      "discounts": []
    }
  ],
  "total": 20,
  "currency": "usd"
}

Body Parameters

Response

{
  "customerId": "charles",
  "lineItems": [
    {
      "title": "Pro seed",
      "description": "Pro seed - Base Price (from 18 Feb 2026 to 18 Mar 2026)",
      "amount": 20,
      "discounts": []
    }
  ],
  "total": 20,
  "currency": "usd"
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Headers

x-api-version
string
default:2.1
required

Body

application/json
customer_id
string
required

The ID of the customer to attach the plan to.

plan_id
string
required

The ID of the plan.

entity_id
string

The ID of the entity to attach the plan to.

feature_quantities
FeatureQuantity · object[]

If this plan contains prepaid features, use this field to specify the quantity of each prepaid feature. This quantity includes the included amount and billing units defined when setting up the plan.

version
number

The version of the plan to attach.

customize
object

Customize the plan to attach. Can override the price, items, free trial, or a combination.

invoice_mode
object

Invoice mode creates a draft or open invoice and sends it to the customer, instead of charging their card immediately. This uses Stripe's send_invoice collection method.

proration_behavior
enum<string>

How to handle proration when updating an existing subscription. 'prorate_immediately' charges/credits prorated amounts now, 'none' skips creating any charges.

Available options:
prorate_immediately,
none
discounts
AttachDiscount · object[]

List of discounts to apply. Each discount can be an Autumn reward ID, Stripe coupon ID, or Stripe promotion code.

success_url
string

URL to redirect to after successful checkout.

new_billing_subscription
boolean

Only applicable when the customer has an existing Stripe subscription. If true, creates a new separate subscription instead of merging into the existing one.

plan_schedule
enum<string>

When the plan change should take effect. 'immediate' applies now, 'end_of_cycle' schedules for the end of the current billing cycle. By default, upgrades are immediate and downgrades are scheduled.

Available options:
immediate,
end_of_cycle

Response

200 - application/json

OK

customer_id
string
required

The ID of the customer.

line_items
object[]
required

List of line items for the current billing period.

total
number
required

The total amount in cents for the current billing period.

currency
string
required

The three-letter ISO currency code (e.g., 'usd').

next_cycle
object

Preview of the next billing cycle, if applicable. This shows what the customer will be charged in subsequent cycles.