> ## 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.

# Feature flags

> Put premium features like SSO or an audit log on the plans that pay for them, and gate them with one check.

> **Business:** SSO, audit log and priority support. Not on Free or Pro.

Put premium features like SSO and an audit log on the plans that pay for them, and gate access with one `check`. A `boolean` feature is on for every plan that lists it, with no count to track and no cost per use.

## The catalog

```ts ledger.config.ts theme={"system"}
import { defineCatalog, feature, plan } from "integrateledger-cli";

export default defineCatalog({
	features: [
		feature({ id: "sso", name: "SSO", type: "boolean" }),
		feature({ id: "audit_log", name: "Audit log", type: "boolean" }),
	],
	plans: [
		plan({ id: "pro", name: "Pro", monthlyCredits: 0, priceCents: 2000 }),
		plan({
			id: "business",
			name: "Business",
			monthlyCredits: 0,
			priceCents: 9900,
			items: [{ featureId: "sso" }, { featureId: "audit_log" }],
		}),
	],
	creditPacks: [],
});
```

```json ledger.catalog.json theme={"system"}
{
  "schemaVersion": 1,
  "features": [
    { "id": "sso", "name": "SSO", "type": "boolean" },
    { "id": "audit_log", "name": "Audit log", "type": "boolean" }
  ],
  "plans": [
    { "id": "pro", "name": "Pro", "monthlyCredits": 0, "priceCents": 2000 },
    { "id": "business", "name": "Business", "monthlyCredits": 0, "priceCents": 9900,
      "items": [{ "featureId": "sso" }, { "featureId": "audit_log" }] }
  ],
  "addOns": []
}
```

## What check returns

Check whenever you need to know, such as before showing the SSO settings page:

```typescript TypeScript theme={"system"}
const { allowed } = await billing.checkCredits({
	customerId: org.id,
	featureId: "sso",
});
if (!allowed) {
	return showUpgradeOffer("business");
}
```

```python Python theme={"system"}
decision = billing.check_credits(customer_id=org.id, feature_id="sso")
if not decision["allowed"]:
    return show_upgrade_offer("business")
```

```bash cURL theme={"system"}
curl https://api.integrateledger.com/v1/check \
  -H "Authorization: Bearer $LEDGER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"customerId": "org_123", "featureId": "sso"}'
```

A Business customer gets:

```json Response theme={"system"}
{
  "allowed": true,
  "availableCredits": 0,
  "creditCost": 0,
  "featureType": "boolean",
  "unlimited": false,
  "balance": null
}
```

A Pro customer gets `allowed: false`, your cue to show the upgrade, with `reason: "feature_not_in_plan"` and `plan: { "id": "pro", "name": "Pro", "status": "active" }`, and a customer with no plan gets `reason: "no_plan"`.

## Rules

* **A boolean item takes `featureId` alone,** with no `included` or `unlimited`.
* **Tracking is optional.** A `track` on a boolean feature records a [usage event](https://docs.integrateledger.com/concepts/usage-events.md) and charges nothing, so track only if you want usage history. It takes no `quantity`.
* **Follows the plan.** The flag is on for as long as the customer's current plan lists it. On an upgrade it turns on with the new plan; on a downgrade or cancellation it turns off when the plan ends.
* **Check without `reserve`.** A boolean feature answers `check` directly; `reserve` on it returns `400 reserve_not_supported`.
* **Listing it is a new version.** Adding or removing a boolean item publishes a new [plan version](https://docs.integrateledger.com/billing/plan-versions.md), so current subscribers keep the features they bought.

## Related

* [Limits](https://docs.integrateledger.com/pricing/limits.md): a count instead of on or off.
* [Metered allowances](https://docs.integrateledger.com/pricing/metered.md): a number of uses per period.
* [Check and track](https://docs.integrateledger.com/customers/check-and-track.md): the order of refusals.


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