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

# Billing details

> Save a customer's address, tax IDs, tax exemption and invoice fields once, and Stripe Tax and every invoice use them.

Save a customer's address, tax IDs, tax exemption and invoice fields with one call, and Stripe Tax and every invoice Stripe makes for them use them. Ledger writes them to the customer's Stripe customer and reads them back. Save them when a customer fills in your billing form, before they first pay on a saved card.

```typescript TypeScript theme={"system"}
const result = await billing.setCustomerBillingDetails({
	customerId: "acme",
	body: {
		name: "Acme GmbH",
		address: { line1: "1 Main St", city: "Berlin", postalCode: "10115", country: "DE" },
		taxIds: { add: [{ type: "eu_vat", value: "DE123456789" }] },
		taxExempt: "reverse",
		invoiceCustomFields: [{ name: "PO Number", value: "PO-10042" }],
	},
});
```

```python Python theme={"system"}
result = billing.set_customer_billing_details(
    customer_id="acme",
    name="Acme GmbH",
    address={"line1": "1 Main St", "city": "Berlin", "postalCode": "10115", "country": "DE"},
    tax_ids={"add": [{"type": "eu_vat", "value": "DE123456789"}]},
    tax_exempt="reverse",
    invoice_custom_fields=[{"name": "PO Number", "value": "PO-10042"}],
)
```

```bash cURL theme={"system"}
curl "https://api.integrateledger.com/v1/customers/billing-details?customerId=acme" \
  -H "Authorization: Bearer $LEDGER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Acme GmbH",
    "address": {"line1": "1 Main St", "city": "Berlin", "postalCode": "10115", "country": "DE"},
    "taxIds": {"add": [{"type": "eu_vat", "value": "DE123456789"}]},
    "taxExempt": "reverse",
    "invoiceCustomFields": [{"name": "PO Number", "value": "PO-10042"}]
  }'
```

The response is the details as Stripe now holds them:

```json Response theme={"system"}
{
  "customerId": "acme",
  "billingDetails": {
    "stripeCustomerId": "cus_TbXyZ",
    "name": "Acme GmbH",
    "email": null,
    "address": { "line1": "1 Main St", "line2": null, "city": "Berlin", "state": null, "postalCode": "10115", "country": "DE" },
    "taxIds": [{ "type": "eu_vat", "value": "DE123456789", "verification": { "status": "pending", "verifiedName": null } }],
    "taxExempt": "reverse",
    "taxLocation": "not_collecting",
    "invoiceCustomFields": [{ "name": "PO Number", "value": "PO-10042" }],
    "invoiceFooter": null
  }
}
```

## What each field does

| Field | Effect |
| - | - |
| `name`, `email` | Shown on invoices and receipts. Stripe emails receipts to `email` when your Stripe account sends them; Ledger never emails invoices. |
| `address` | Where [automatic tax](https://docs.integrateledger.com/billing/tax.md) locates the customer. A saved-card attach, upgrade or final overage invoice is taxed once `taxLocation` is `supported`. |
| `taxIds` | VAT numbers and other tax IDs, printed on invoices. Stripe checks the format for each `type` and verifies some with the tax authority (`verification`). |
| `taxExempt` | `none` (taxed as usual), `exempt` (never taxed) or `reverse` (reverse charge, noted on the invoice). |
| `invoiceCustomFields` | Up to 4 name and value pairs, such as a PO number, printed on every invoice: renewals, upgrades and the final overage invoice. |
| `invoiceFooter` | Text at the foot of every invoice. |

You can also send `billingDetails` when you [create the customer](https://docs.integrateledger.com/api-reference/customers/create.md); the customer is created even if Stripe refuses them.

## Read them back

```typescript TypeScript theme={"system"}
const { billingDetails } = await billing.getCustomerBillingDetails({ customerId: "acme" });
```

```python Python theme={"system"}
details = billing.get_customer_billing_details(customer_id="acme")
```

```bash cURL theme={"system"}
curl "https://api.integrateledger.com/v1/customers/billing-details?customerId=acme" \
  -H "Authorization: Bearer $LEDGER_API_KEY"
```

The response has the same fields as above. `taxLocation` is Stripe Tax's view of the customer: `supported` (Stripe Tax can tax them), `not_collecting` (located where you aren't registered), `unrecognized_location` (the address isn't enough) or `failed`. `billingDetails` is `null` for a customer with no Stripe customer.

## Related

* [Tax](https://docs.integrateledger.com/billing/tax.md): when Ledger adds tax, and what a location changes.
* [Creating customers](https://docs.integrateledger.com/customers/creating-customers.md): create the customer first.
* [Set billing details](https://docs.integrateledger.com/api-reference/customers/billing-details.md) and [Get billing details](https://docs.integrateledger.com/api-reference/customers/get-billing-details.md): the API reference.

## Rules

* **Only the fields you send change.** `null` clears a field.
* **`address` and `invoiceCustomFields` replace the whole value.** Send every part of the address you want kept.
* **Tax IDs are added and removed one by one.** `taxIds.add` and `taxIds.remove` touch only the IDs they list, and adding an ID the customer already has leaves it as it is. To correct an ID, remove it and add the new value in the same call.
* **Saves are all or nothing.** Ledger adds new tax IDs first, then the other fields, then removes tax IDs. If Stripe refuses a tax ID (`422 invalid_tax_id`) or can't locate the address for tax (`422 invalid_address`), nothing is saved, and any tax ID the same call added is deleted again. Stripe checks the address at once when automatic tax is on in that environment.
* **Saving creates the Stripe customer** when there is none: the same Stripe customer Ledger creates at the first attach, with Ledger's metadata.
* **Checkout collects its own.** With automatic tax on, Checkout asks for a billing address and tax ID and saves them over what you set.


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