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

# How to Set Up a Company for VAT Through the API

> Create a nexus, import or create VAT rates, add a company's VAT registration numbers, and turn on transaction currencies through the Public API.

A company can't post VAT until its VAT setup is complete. Through the Public API, you can do that setup without opening the app. The steps, in order, are:

1. Create a nexus for the country, with the company's tax agency and tax accounts.
2. Import the standard VAT rates.
3. Create any custom VAT rates you need, such as a non-deductible or reverse charge rate.
4. Set the company's VAT registration numbers.
5. Turn on the transaction currencies the company invoices or pays in.

When you finish, the company has a nexus with its tax accounts, the VAT rates it uses, its VAT registration numbers, and its transaction currencies, and it's ready for invoices, bills, and journal entries with VAT through the API.

The nexus, VAT rate, and currency endpoints are available on V2 and V3-alpha. The company update endpoint is also available on V1. For how VAT is calculated and posted in the app, see [Non-US Taxes](https://docs.dualentry.com/accountants/core-financials/tax-management/non-us-taxes.md).

## Prerequisites

Before you start the VAT setup through the API, confirm the following:

* **API key**: Your requests send your organization's API key in the `X-API-KEY` header. See [authenticating your requests](https://docs.dualentry.com/developers/guides/api/api-keys/how-to-authenticate-your-requests.md).
* **Permissions**: The API key's roles grant the permissions listed in [Permissions](#permissions).
* **Tax agency**: A vendor with `vendor_type` `tax_agency` exists for the country's tax authority, for example HM Revenue & Customs for the UK.
* **Tax accounts**: The company has a tax liability account (type `other_current_liability` or `long_term_liability`) and a tax asset account (type `other_current_asset` or `other_asset`). Output VAT posts to the liability account, and reclaimable input VAT posts to the asset account.
* **Company ID**: You have the `id` of the company. List companies with `GET /public/v2/companies/` to find it.

## Create a nexus for a company

A nexus is a country, or a country and a region, where your organization owes tax. Each nexus holds a list of company settings: one item for each company that owes tax there, with the company's tax agency and tax accounts. The following request creates a UK nexus for company 1:

```bash theme={null}
curl -X POST https://api.dualentry.com/public/v2/nexuses/ \
  -H "X-API-KEY: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "country": "GB",
    "description": "UK VAT",
    "company_settings": [
      {
        "company_id": 1,
        "tax_agency_id": 99,
        "tax_liability_account_id": 2210,
        "tax_asset_account_id": 1410
      }
    ]
  }'
```

The API returns `201` with the nexus. Each company setting gets its own `id`:

```json theme={null}
{
  "id": 12,
  "number": 3,
  "country": "GB",
  "region": null,
  "description": "UK VAT",
  "company_settings": [
    {
      "id": 31,
      "company_id": 1,
      "tax_agency_id": 99,
      "tax_liability_account_id": 2210,
      "tax_asset_account_id": 1410
    }
  ]
}
```

The request body fields are listed below.

| Field | Type | Required | Description |
| - | - | - | - |
| `country` | string | Yes | The ISO 3166-1 alpha-2 country code, such as `GB` or `DE`. |
| `region` | string or `null` | US only | A US state, or a Canadian province code. Required for a US nexus. Optional for Canada, where it must be a province code. |
| `description` | string or `null` | No | A label for the nexus. |
| `company_settings` | array | No | One item per company. Defaults to an empty list. |
| `company_settings[].company_id` | integer | Yes | The company that owes tax in this country. Each company can appear once. |
| `company_settings[].tax_agency_id` | integer | Yes | A vendor with `vendor_type` `tax_agency`. |
| `company_settings[].tax_liability_account_id` | integer | Yes | An `other_current_liability` or `long_term_liability` account. |
| `company_settings[].tax_asset_account_id` | integer or `null` | Outside the US | An `other_current_asset` or `other_asset` account. Required for a nexus outside the US. |

Each country and region can have one nexus. To add a second company to a country that already has a nexus, update the nexus instead of creating another one.

## Update a nexus

Update a nexus with `PATCH` to change its `description` or its company settings. You can't change `country` or `region`. A field you omit or send as `null` keeps its stored value.

When you send `company_settings`, the list replaces every company setting of the nexus. A company that isn't in the list loses its setting, and an empty list removes all of them. To add a company, read the nexus first and send back the existing items with the new one. The following request adds company 2 to the UK nexus and keeps company 1:

```bash theme={null}
curl -X PATCH https://api.dualentry.com/public/v2/nexuses/12/ \
  -H "X-API-KEY: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "company_settings": [
      {
        "id": 31,
        "company_id": 1,
        "tax_agency_id": 99,
        "tax_liability_account_id": 2210,
        "tax_asset_account_id": 1410
      },
      {
        "company_id": 2,
        "tax_agency_id": 99,
        "tax_liability_account_id": 2215,
        "tax_asset_account_id": 1415
      }
    ]
  }'
```

The nexus endpoints are listed below.

| Endpoint | Description |
| - | - |
| `GET /public/v2/nexuses/` | List nexuses. Filters: `country` (repeatable), `region`, `search` (matches the description, the number, or the location name), `limit`, `offset`. |
| `GET /public/v2/nexuses/{nexus_id}/` | Get one nexus. Returns `404` for a nexus in another organization. |
| `POST /public/v2/nexuses/` | Create a nexus. Returns `201`. |
| `PATCH /public/v2/nexuses/{nexus_id}/` | Update the description or the company settings. |

The API has no endpoint to archive a nexus. Archive it in the app under **Configuration → Tax Setup → Nexuses**.

## Import the standard VAT rates

DualEntry keeps a standard set of VAT rates for each VAT country: the standard and reduced rates, plus zero-rated, exempt, reverse charge, and out-of-scope rates. Importing adds these rates to your organization, the same as **Import VAT Rates** in the app. The request has no body:

```bash theme={null}
curl -X POST https://api.dualentry.com/public/v2/vat-rates/import/ \
  -H "X-API-KEY: YOUR_API_KEY"
```

The API returns `200` with a success response:

```json theme={null}
{
  "success": true,
  "errors": {},
  "message": null
}
```

The import adds each rate your organization doesn't have yet, with `is_system` and `is_active` set to `true`. It covers every VAT country at once, not one country. Your existing rates and custom rates stay as they are, and a second import adds nothing, so it's safe to call again.

The response doesn't include the imported rates. To get their IDs, list the VAT rates for the country:

```bash theme={null}
curl "https://api.dualentry.com/public/v2/vat-rates/?country_code=GB&is_active=true" \
  -H "X-API-KEY: YOUR_API_KEY"
```

Use a rate's `id` as `vat_rate_id` on invoice, bill, and journal entry lines. Filter the list with `country_code` (repeatable), `rate_type`, `tax_type`, and `is_active`. For how DualEntry applies the rate on a record, see [How to Calculate Tax Before Creating an Invoice or Bill](https://docs.dualentry.com/developers/guides/api/building-blocks/calculate-tax-before-invoicing.md).

## Create a custom VAT rate

Create a custom VAT rate when the imported set doesn't have the rate you need. A custom rate has `is_system` set to `false` and starts active. Write `rate` and `deductible` as a fraction from `0` to `1`, with up to four decimal places, so `0.2` is 20%.

### Create a non-deductible VAT rate

A non-deductible rate records VAT you were charged but can't reclaim, such as VAT on business entertaining in the UK. Set `is_non_deductible` to `true` and send `deductible`, the part of the VAT you can reclaim. To post the part you can't reclaim to a specific account, also send `non_deductible_cost_account_id`, an `expense`, `other_expense`, or `cost_of_goods_sold` account. The following request creates a 20% UK rate with no reclaimable VAT:

```bash theme={null}
curl -X POST https://api.dualentry.com/public/v2/vat-rates/ \
  -H "X-API-KEY: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "country_code": "GB",
    "name": "UK Standard 20% Entertaining",
    "rate": "0.2",
    "rate_type": "STANDARD",
    "tax_type": "INPUT_OUTPUT",
    "valid_from": "2026-01-01",
    "is_non_deductible": true,
    "deductible": "0",
    "non_deductible_cost_account_id": 6420
  }'
```

A zero-rated, exempt, or out-of-scope rate can't be non-deductible. When `is_non_deductible` is `false`, DualEntry ignores `deductible` and `non_deductible_cost_account_id`.

### Create a reverse charge VAT rate

A reverse charge rate makes the buyer account for the VAT instead of the supplier. Set `tax_type` to `REVERSE_CHARGE`:

```bash theme={null}
curl -X POST https://api.dualentry.com/public/v2/vat-rates/ \
  -H "X-API-KEY: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "country_code": "GB",
    "name": "Reverse Charge (Custom)",
    "rate": "0.2",
    "rate_type": "STANDARD",
    "tax_type": "REVERSE_CHARGE",
    "valid_from": "2026-01-01"
  }'
```

Both requests return `201` with the rate, including its `id`.

## VAT rate fields

The VAT rate create fields are listed below. The API returns `400` if a value breaks these rules, or if a rate with the same `country_code`, `name`, `rate`, and `valid_from` already exists.

| Field | Type | Required | Description |
| - | - | - | - |
| `country_code` | string | Yes | A VAT country code, such as `GB` or `DE`. |
| `name` | string | Yes | Up to 100 characters. |
| `rate` | decimal | Yes | A fraction from `0` to `1`, up to four decimal places. |
| `rate_type` | enum | Yes | `STANDARD`, `REDUCED`, `SUPER_REDUCED`, `PARKING`, `ZERO`, `EXEMPT`, or `OUT_OF_SCOPE`. |
| `tax_type` | enum | Yes | `INPUT_OUTPUT`, `ZERO_RATED`, `EXEMPT`, `REVERSE_CHARGE`, or `OUT_OF_SCOPE`. |
| `valid_from` | date | Yes | The first date the rate applies. |
| `valid_to` | date or `null` | No | The last date the rate applies. Can't be before `valid_from`. |
| `description` | string or `null` | No | Notes for your team. |
| `tax_asset_account_id` | integer or `null` | No | Overrides the nexus asset account. An active `other_current_asset` or `other_asset` account. |
| `tax_liability_account_id` | integer or `null` | No | Overrides the nexus liability account. An active `other_current_liability` or `long_term_liability` account. |
| `is_non_deductible` | boolean | No | Defaults to `false`. |
| `deductible` | decimal or `null` | When non-deductible | The reclaimable part of the VAT, from `0` to `1`. |
| `non_deductible_cost_account_id` | integer or `null` | No | The account for the part you can't reclaim. |
| `vatex_code` | string or `null` | No | The CEF VATEX code for an exempt rate, used for e-invoicing. |

A rate with no account overrides posts to the tax accounts on the company's nexus.

## Update or deactivate a VAT rate

Update a VAT rate with `PATCH /public/v2/vat-rates/{vat_rate_id}/`, sending only the fields you want to change. A field you omit keeps its stored value. The following request ends a custom rate on 12/31/2026:

```bash theme={null}
curl -X PATCH https://api.dualentry.com/public/v2/vat-rates/415/ \
  -H "X-API-KEY: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "valid_to": "2026-12-31" }'
```

The update rules are:

* **Locked fields**: You can't change `country_code`, `name`, `rate`, `rate_type`, `tax_type`, or `valid_from`. The update ignores them if you send them. To change one, create a new rate and set `is_active` to `false` on the old one.
* **Clearing a field**: Send `null` to clear `valid_to`, `tax_asset_account_id`, `tax_liability_account_id`, `deductible`, `non_deductible_cost_account_id`, or `vatex_code`. A `null` on `description`, `is_active`, or `is_non_deductible` changes nothing.
* **System rates**: On an imported rate (`is_system` is `true`), you can change `is_active`, `valid_to`, the tax accounts, and the non-deductible fields. A change to `description` or `vatex_code` returns `400`.
* **Accounts**: Each account you send must be active. An account you omit can stay inactive.

The VAT rate API has no delete endpoint. To stop using a rate, set `is_active` to `false`.

## Set a company's VAT registration numbers

A company's VAT registration numbers are part of the company record. Each number has a `country`, which is the country the company is registered in for VAT, and a `registration_number`. Set them with `PUT /public/v2/companies/{company_id}/`.

> [!WARNING]
>
> The company `PUT` is a full update, the same as saving the company form in the app. A field you leave out takes its default value: an omitted `address` is cleared, and an omitted `fiscal_year_end_month` resets to `12`. Read the company first and send back every field you want to keep.

First, read the company:

```bash theme={null}
curl https://api.dualentry.com/public/v2/companies/1/ \
  -H "X-API-KEY: YOUR_API_KEY"
```

Then send the company back with the VAT registration numbers. The required fields are `name`, `currency_iso_4217_code`, `is_active`, and `parent_company_id`. Also send the fields you read that you want to keep, such as `address`, `tin`, `tin_type`, `short_code`, `brand_color`, `fiscal_year_end_month`, and the default account IDs:

```bash theme={null}
curl -X PUT https://api.dualentry.com/public/v2/companies/1/ \
  -H "X-API-KEY: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Example Trading Ltd",
    "currency_iso_4217_code": "GBP",
    "is_active": true,
    "parent_company_id": null,
    "fiscal_year_end_month": 3,
    "address": {
      "street": "1 Example Street",
      "second_line": "",
      "city": "London",
      "state": "",
      "postal_code": "EC1A 1AA",
      "country": "GB"
    },
    "vat_registration_numbers": [
      { "country": "GB", "registration_number": "GB123456789" }
    ]
  }'
```

The `vat_registration_numbers` list works as follows:

* **List sent**: The list replaces every VAT registration number of the company. Include the numbers you want to keep.
* **Empty list**: Every VAT registration number is removed.
* **Field omitted**: The stored numbers stay as they are.

The `country` is an ISO 3166-1 alpha-2 code, and an unknown code returns `400`. The response is the updated company, with each number's `id`. `gst_registration_numbers` works the same way for GST. If your organization's approved record edit policy doesn't allow the change, the API returns `422`.

## Turn on a transaction currency

A transaction currency is a currency other than the company's base currency that records can use. The setting covers the whole organization, not one company. The currency endpoint is a toggle: each call turns the currency on if it's off, or off if it's on. Check the current state first:

```bash theme={null}
curl "https://api.dualentry.com/public/v2/currencies/?codes=USD" \
  -H "X-API-KEY: YOUR_API_KEY"
```

The response lists each matching currency and whether it's on:

```json theme={null}
{
  "items": [
    { "currency_iso_4217_code": "USD", "is_active": false }
  ],
  "count": 1
}
```

If `is_active` is `false`, toggle the currency to turn it on. The request has no body:

```bash theme={null}
curl -X PUT https://api.dualentry.com/public/v2/currencies/USD/toggle/ \
  -H "X-API-KEY: YOUR_API_KEY"
```

The API returns `200` with a success response, not the new state. List the currencies again to confirm it. Because the call flips the state, don't retry it blindly after a timeout: list the currency first.

You can't turn a currency off while it's the base currency of a company, while a record that isn't archived uses it, while an active account uses it, or while an item has a price in it. The API then returns `422` with a message that names each reason. The list endpoint takes the `is_active`, `codes` (repeatable), `search`, `limit`, and `offset` filters. For how transaction currencies work in the app, see [Multi-Currency Setup](https://docs.dualentry.com/accountants/platform-configuration/multi-currency-setup.md).

## Permissions

Each endpoint needs a permission on the API key's role. These are the same permissions the app checks for the matching screens.

| Endpoint | Permission |
| - | - |
| Nexuses (list, get) | Nexus: view |
| Nexuses (create) | Nexus: create |
| Nexuses (update) | Nexus: edit |
| VAT rates (list, get) | Tax calculation: view |
| VAT rates (create, import) | Tax calculation: create |
| VAT rates (update) | Tax calculation: edit |
| Companies (update) | Company: edit |
| Currencies (list) | Currency: view |
| Currencies (toggle) | Currency: edit |

A key without the permission gets `403`. A key limited to some companies can update only the companies it can read. For any other company, the company `PUT` returns `404`. If a call returns `403`, add a role with the missing permission to the key, or create a new key with the right roles. See [How to Give an Integration Access to DualEntry](https://docs.dualentry.com/developers/guides/api/api-keys/how-to-give-an-integration-access.md).

## Errors

The VAT setup endpoints return the standard error response. The status codes below are the ones specific to these endpoints.

| Status | Endpoint | Cause |
| - | - | - |
| `400` | Nexus create or update | A required field is missing, `region` is missing on a US nexus, a Canada `region` isn't a province code, or a `company_id` appears twice in `company_settings`. |
| `422` | Nexus create or update | The tax agency isn't a `tax_agency` vendor, an account has the wrong type, the asset account is missing outside the US, an ID belongs to another organization, or a nexus already exists for the country and region. |
| `400` | VAT rate create or update | A value breaks a rule in [VAT rate fields](#vat-rate-fields), the rate already exists, or the update changes `description` or `vatex_code` on a system rate. |
| `409` | VAT rate create | Another request created the same rate at the same time. List the rates to find its ID. To make your own create request safe to retry, send an `Idempotency-Key` on the original request and reuse it on retries. |
| `400` | Company update | A required field is missing, or a VAT registration `country` isn't a valid code. |
| `422` | Company update | The approved record edit policy blocks the change. |
| `422` | Currency toggle | The currency can't be turned off, or the currency code is unknown. |

For the error response format, see [Errors](https://docs.dualentry.com/developers/guides/api/core-concepts/errors.md). For the `Idempotency-Key` header that the create and update endpoints accept, see [Idempotency and Write Validation](https://docs.dualentry.com/developers/guides/api/core-concepts/idempotency-and-write-validation.md).

## Related pages

* [Non-US Taxes](https://docs.dualentry.com/accountants/core-financials/tax-management/non-us-taxes.md): how VAT rates, reverse charge, and non-reclaimable VAT work in the app
* [How to Calculate Tax Before Creating an Invoice or Bill](https://docs.dualentry.com/developers/guides/api/building-blocks/calculate-tax-before-invoicing.md): use the VAT rates on records
* [Pagination](https://docs.dualentry.com/developers/guides/api/core-concepts/pagination.md): `limit` and `offset` on list endpoints


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