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

# Taxes

> Create tax rates and assign them to your billing configuration.

A [tax](https://getlago.com/docs/v2/api-reference/taxes/retrieve.md) defines a percentage rate, such as 20% VAT. Create the tax, then assign it to a Rate Card, Plan, customer or billing entity. Creating a tax does not apply it to invoices automatically.

## Create a tax

> [tab] Dashboard
>
> 1. Open **Settings**.
> 2. Open **Taxes**.
> 3. Click **Add**.
> 4. Enter a name.
> 5. Enter a unique code.
> 6. Optionally, add a description.
> 7. Enter the tax rate.
> 8. Save.

> [tab] API
>
> > [accordion] Tax fields
> >
> > | Field | Meaning |
> > | - | - |
> > | `code` | Unique within the organization, including deleted taxes. Used in every `tax_codes` array. |
> > | `name` | Display name, such as `VAT`. |
> > | `rate` | Percentage. `20` means 20%. Accepts a number or a decimal string, returned as a number. |
> > | `description` | Internal description. `null` clears it. |
> > | `deleted_at` | `null` until the tax is deleted. |
>
> `name`, `code` and `rate` are required. A code already used by another tax, including a deleted one, returns `422`.
>
> ```bash Create a 20% VAT theme={"dark"}
> LAGO_URL="https://api.getlago.com"
> API_KEY="__YOUR_API_KEY__"
>
> curl --location --request POST "$LAGO_URL/api/v2/taxes" \
>   --header "Authorization: Bearer $API_KEY" \
>   --header 'Content-Type: application/json' \
>   --data-raw '{
>     "tax": {
>       "name": "VAT",
>       "code": "standard_vat",
>       "rate": 20,
>       "description": "Standard VAT"
>     }
>   }'
> ```
>
> > [accordion] API compatibility
> >
> > The `applied_to_organization` parameter from v1 is ignored and not returned.

## Assign taxes

Every object below takes a `tax_codes` array. An empty array clears the assignments.

| Assign to | Field |
| - | - |
| [Rate Card](https://getlago.com/docs/v2/guide/rate-cards/overview.md) | `tax_codes` |
| [Plan](https://getlago.com/docs/v2/guide/plans/overview.md) | `tax_codes` |
| [Customer](https://getlago.com/docs/v2/guide/customers/customer-management.md) | `tax_codes` |
| [Billing entity](https://getlago.com/docs/v2/guide/billing-entities.md) | `tax_codes` |

### Which taxes apply

For a Product fee, Lago uses the first nonempty tax assignment in this order:

1. Rate Card.
2. Plan.
3. Customer.
4. Billing entity.

Lago applies all taxes in the selected set. It does not combine assignments from different levels. Clearing an assignment allows the next level to apply.

### Assign a tax to a Rate Card

Tax assignments remain editable after the Rate Card has Rates.

> [tab] Dashboard
>
> 1. Open **Rate cards**.
> 2. Select a Rate Card.
> 3. Click **Edit**.
> 4. In the tax section, add the tax.
> 5. Save.

> [tab] API
>
> ```bash Assign VAT to the API-call rate card theme={"dark"}
> LAGO_URL="https://api.getlago.com"
> API_KEY="__YOUR_API_KEY__"
>
> curl --location --request PUT "$LAGO_URL/api/v2/rate_cards/api_calls_usd" \
>   --header "Authorization: Bearer $API_KEY" \
>   --header 'Content-Type: application/json' \
>   --data-raw '{
>     "rate_card": {
>       "tax_codes": ["standard_vat"]
>     }
>   }'
> ```
>
> ```bash Read the taxes of a rate card theme={"dark"}
> LAGO_URL="https://api.getlago.com"
> API_KEY="__YOUR_API_KEY__"
>
> curl --globoff --location --request GET "$LAGO_URL/api/v2/rate_cards/api_calls_usd?expands[]=taxes" \
>   --header "Authorization: Bearer $API_KEY"
> ```

### Assign a tax to a Plan, customer or billing entity

You can update a Plan’s tax codes after a Contract uses it.

```bash Plan theme={"dark"}
LAGO_URL="https://api.getlago.com"
API_KEY="__YOUR_API_KEY__"

curl --location --request PUT "$LAGO_URL/api/v2/plans/api_monthly" \
  --header "Authorization: Bearer $API_KEY" \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "plan": {
      "tax_codes": ["standard_vat"]
    }
  }'
```

```bash Customer theme={"dark"}
LAGO_URL="https://api.getlago.com"
API_KEY="__YOUR_API_KEY__"

curl --location --request PUT "$LAGO_URL/api/v2/customers/customer_example" \
  --header "Authorization: Bearer $API_KEY" \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "customer": {
      "tax_codes": ["standard_vat"]
    }
  }'
```

```bash Billing entity theme={"dark"}
LAGO_URL="https://api.getlago.com"
API_KEY="__YOUR_API_KEY__"

curl --location --request PUT "$LAGO_URL/api/v2/billing_entities/acme_corp" \
  --header "Authorization: Bearer $API_KEY" \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "billing_entity": {
      "tax_codes": ["standard_vat"]
    }
  }'
```

Plans expose `taxes` with `expands[]=taxes` on retrieval. Billing entities expose assigned taxes the same way.

## Read taxes on an invoice

This illustrative example covers one full monthly billing period in USD, with no proration, discounts or credits. A monthly service costs USD 100, and 2,000 API calls at USD 0.01 cost USD 20. Both fees have `standard_vat` (20%) assigned through their Rate Cards.

```
monthly_service      1 x $100.00          $100.00   VAT 20%   $20.00
api_calls_product    2,000 x $0.01         $20.00   VAT 20%    $4.00
--------------------------------------------------------------------
Subtotal (excl. tax)                      $120.00
Tax                                        $24.00
--------------------------------------------------------------------
Total                                     $144.00
```

Each fee returns its own `taxes_amount_cents`, and `expands[]=applied_taxes` lists the `tax_code`, `tax_rate` and `amount_cents` applied. On the invoice, `taxes_amount_cents` is `2400` and `total_amount_cents` is `14400`.

## Update or delete a tax

`PUT` and `PATCH` both accept partial updates. `code` can be renamed if no other tax, including a deleted one, uses the new code.

`DELETE /taxes/{code}` returns the tax with a non-null `deleted_at`. Deleted taxes are no longer listed or retrievable.

> [!WARNING]
>
> Changing a rate or deleting a tax can affect how future fees are taxed for every object that carries it. Review the tax assignments before changing the rate or deleting the tax.

```bash Update a tax rate theme={"dark"}
LAGO_URL="https://api.getlago.com"
API_KEY="__YOUR_API_KEY__"

curl --location --request PUT "$LAGO_URL/api/v2/taxes/standard_vat" \
  --header "Authorization: Bearer $API_KEY" \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "tax": {
      "rate": "21"
    }
  }'
```

```bash Delete a tax theme={"dark"}
LAGO_URL="https://api.getlago.com"
API_KEY="__YOUR_API_KEY__"

curl --location --request DELETE "$LAGO_URL/api/v2/taxes/standard_vat" \
  --header "Authorization: Bearer $API_KEY"
```

## Use a tax provider

To let a tax provider compute taxes, use a tax integration: [Anrok](https://getlago.com/docs/v2/integrations/taxes/anrok.md), [Avalara](https://getlago.com/docs/v2/integrations/taxes/avalara.md) or [Lago EU taxes](https://getlago.com/docs/v2/integrations/taxes/lago-eu-taxes.md). When provider tax processing fails, [retry taxes](https://getlago.com/docs/v2/api-reference/invoices/retry-taxes.md) on the invoice.

## Next steps

> [card] [Rate cards](https://getlago.com/docs/v2/guide/rate-cards/overview.md)
>
> Assign taxes to Rate Cards.

> [card] [Invoices](https://getlago.com/docs/v2/guide/invoicing/overview.md)
>
> How taxes appear on invoice totals.

> [card] [Create a tax (API)](https://getlago.com/docs/v2/api-reference/taxes/create.md)
>
> Request and response schema.

> [card] [Update a rate card (API)](https://getlago.com/docs/v2/api-reference/rate-cards/update.md)
>
> Assign `tax_codes` to a rate card.


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