> ## Documentation Index
> Fetch the complete documentation index at: https://docs.integrateledger.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Custom plans per customer

> Close a sales-led deal in one call, with one customer's own price, credits, items or overage over a plan, billed under the plan's name.

> **Acme on Enterprise:** \$2,500 a month, 200,000 credits, 100,000 messages and then 1 cent each, no audit logs.

Custom plans turn a negotiated deal into billing in one call. Attach a plan with `customize`, and Ledger makes that customer's own version of it, with their price, credits, items or overage, and starts it. Check, track, reservations, renewals and invoices treat it as any version of the plan, and the customer sees the plan's name on Checkout and every invoice.

## Attach with custom terms

```typescript TypeScript theme={"system"}
const result = await billing.attach({
	customerId: "acme",
	planId: "enterprise",
	customize: {
		monthlyPriceCents: 250000,
		monthlyCredits: 200000,
		items: [{ featureId: "messages", included: 100000, overageUnitAmountCents: 1 }],
		removeItems: ["audit_logs"],
	},
});
```

```python Python theme={"system"}
result = billing.attach(
    customer_id="acme",
    plan_id="enterprise",
    customize={
        "monthlyPriceCents": 250000,
        "monthlyCredits": 200000,
        "items": [{"featureId": "messages", "included": 100000, "overageUnitAmountCents": 1}],
        "removeItems": ["audit_logs"],
    },
)
```

```bash cURL theme={"system"}
curl https://api.integrateledger.com/v1/billing/attach \
  -H "Authorization: Bearer $LEDGER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"customerId": "acme", "planId": "enterprise", "customize": {"monthlyPriceCents": 250000, "monthlyCredits": 200000, "items": [{"featureId": "messages", "included": 100000, "overageUnitAmountCents": 1}], "removeItems": ["audit_logs"]}}'
```

The reply is an ordinary [attach](https://docs.integrateledger.com/billing/checkout-and-attach.md): a Checkout URL, or `active` when Ledger charged the saved card.

| Field | |
| - | - |
| `monthlyPriceCents` or `priceCents` | The price for the plan's billing interval: a year's price on an annual plan. |
| `monthlyCredits` | Credits each allowance period. |
| `overageUnitAmountCents`, `overageBillingUnits`, `overageCapCents`, `overageTiers`, `overageTiersMode` | The plan's credit [overage](https://docs.integrateledger.com/pricing/overage.md), as on a plan. |
| `rollover`, `autoTopUp`, `trial` | As on a plan. |
| `items` | Each item replaces the plan's item for the same feature, or adds a feature the plan doesn't have. Same shape as a plan's items. |
| `removeItems` | Features the plan includes that this customer's plan leaves out. |

Everything else is the plan's: its name, interval, the items you don't name, its [group](https://docs.integrateledger.com/pricing/plan-groups.md) and its controls.

## How it behaves

* **Billed and granted their terms**, every period, under the plan's name: Checkout and invoices show "Enterprise".
* **One version per deal.** The same `customize` for the same customer reuses their custom version.
* **Stripe stays tidy.** A `customize` that keeps the plan's price reuses the plan's Stripe Price, so a credits-only deal creates nothing in Stripe. A new price gets a Stripe Price of its own under the plan's Product.
* **Visible on the customer.** [`GET /v1/customers`](https://docs.integrateledger.com/api-reference/customers/get) shows `currentPlan.custom: true` and `basePlan`, the catalog version it was made from.
* **Private.** It stays out of the catalog, `GET /v1/plans` and the plan's versions, and [migrations](https://docs.integrateledger.com/billing/plan-versions.md) of the plan leave it alone.

## Plans only for custom deals

Give a plan `customOnly: true` for an Enterprise plan that only sales sells: attaching it needs `customize`, and a plain attach answers `422 plan_requires_customize` before anything reaches Stripe. It applies to every version of the plan, in place.

```json ledger.catalog.json theme={"system"}
{ "id": "enterprise", "name": "Enterprise", "monthlyCredits": 100000, "priceCents": 200000,
  "customOnly": true, "items": [{ "featureId": "messages", "included": 50000 }] }
```

## Change a customer's terms

Renegotiate in place with [`POST /v1/customers/subscriptions/{id}/plan`](https://docs.integrateledger.com/api-reference/customers/plan-terms): the new `customize` is patched over the subscription's current terms.

```typescript TypeScript theme={"system"}
await billing.changeSubscriptionPlanTerms({
	customerId: "acme",
	subscriptionId: 4812,
	body: { customize: { monthlyCredits: 300000 }, timing: "at_renewal" },
});
```

```python Python theme={"system"}
billing.change_subscription_plan_terms(
    customer_id="acme",
    subscription_id=4812,
    customize={"monthlyCredits": 300000},
    timing="at_renewal",
)
```

```bash cURL theme={"system"}
curl "https://api.integrateledger.com/v1/customers/subscriptions/4812/plan?customerId=acme" \
  -H "Authorization: Bearer $LEDGER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"customize": {"monthlyCredits": 300000}, "timing": "at_renewal"}'
```

```json Response theme={"system"}
{ "subscriptionId": 4812, "timing": "at_renewal", "status": "scheduled", "planId": "enterprise" }
```

* **`timing: "at_renewal"`**: nothing changes now, and the next period bills and grants the new terms (`status: "scheduled"`).
* **`timing: "now"`**: the new terms start at once, with no proration and no charge (`status: "applied"`). The period's allowance is the new one less what it already used, and the renewal bills the new price.

Take the subscription's `id` from [List customer subscriptions](https://docs.integrateledger.com/api-reference/customers/subscriptions.md).

## Rules

* **Plan rules apply.** The custom terms must pass the same rules as a plan in the catalog: `400 invalid_customize`, with each problem under `customize.` in `issues`.
* **Take a feature away with `removeItems`**, not with `included: 0`.
* **One change at a time.** A subscription with another plan change open answers `409 pending_change`; one that's trialing, waiting on a payment or billed another way answers `409 subscription_not_movable`.
* **`customOnly` is policy.** It applies to every version in place, with no new version.

## Related

* [Overrides](https://docs.integrateledger.com/customers/overrides.md): one customer's overage cap, rate or controls on the plan they already have.
* [Plan versions](https://docs.integrateledger.com/billing/plan-versions.md): change a plan for everyone on it.
* [Checkout and attach](https://docs.integrateledger.com/billing/checkout-and-attach.md): how a plan starts.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.