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

# Creating customers

> Create a Ledger customer for each user or organization in your app, keyed by your own ID.

A customer is whoever pays in your app: a user, or an organization for team billing. Its `customerId` is your own ID for them, so you never store a Ledger ID. Create the customer when they sign up, and attach their first plan:

```typescript TypeScript theme={"system"}
await billing.createOrGetCustomer({ customerId: user.id });
await billing.attach({ customerId: user.id, planId: "free" });
```

```python Python theme={"system"}
billing.create_or_get_customer(customer_id=user.id)
billing.attach(customer_id=user.id, plan_id="free")
```

* **It's safe to repeat.** `createOrGetCustomer` returns the existing customer if there is one, so you can also call it lazily, before a customer's first `check`.
* **Creating grants nothing.** Credits come from attaching a [plan](https://docs.integrateledger.com/configure-pricing/plans.md) or buying a [pack](https://docs.integrateledger.com/configure-pricing/credit-packs.md).
* **IDs are 1 to 255 characters**, and belong to one environment: the same `customerId` in Sandbox and Live is two separate customers. A Sandbox key asking for a Live customer gets `404 customer_not_found`.
* **Ledger creates the Stripe customer** when it first needs one. To reuse one you already have, for example when [migrating from Stripe](https://docs.integrateledger.com/migrate-from-stripe.md), link it first.

## Read a customer

`getCustomer` returns the balance and current plan. [Balances](https://docs.integrateledger.com/customers/balances.md) explains the fields.

## Delete a customer

[`DELETE /v1/customers`](https://docs.integrateledger.com/api-reference/customers/delete) removes a customer; the SDKs don't have it yet. In Sandbox it removes their usage events too, so you can start over cleanly. In Live the usage events stay as the record of what the customer used.


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