# Twinfield — Accounting API: connection

> Canonical URL: https://developers.apideck.com/apis/accounting/twinfield/connection

# How to Connect to Twinfield

Twinfield (Wolters Kluwer) is connected through a standard OAuth authorization: you sign in to
Twinfield, approve access, and then tell Apideck which administration to work in. There is nothing
to install and no API key to generate.

There is no environment to choose in Vault: Apideck resolves the right Twinfield host for your
organisation automatically.

## Prerequisites

Before you start, you'll need:

- **A Twinfield login** (organisation user) with access to the administration you want to connect.
  The connection can only see what that user can see.
- **Your office code**: the code of the Twinfield administration to connect. See step 2 for where
  to find it.
- **A user you can dedicate to the integration.** The connection stays tied to whichever Twinfield
  user authorizes it, so a shared, non-personal user maintained for integrations keeps the
  connection alive when people change roles. See [Choosing the right Twinfield user](#choosing-the-right-twinfield-user).

## 1. Authorize Twinfield

1. Open the Twinfield connector in **Apideck Vault** and click **Authorize**.
2. You're redirected to Twinfield's sign-in page at `https://login.twinfield.com`. Sign in with the
   Twinfield user you want the connection to run as.
3. Review the access request and approve it.
4. Twinfield redirects you back to Vault, and the connection shows as **Connected**.

You don't need to pick a server, region, or API URL. Apideck resolves the correct Twinfield cluster
for your organisation automatically after you authorize.

## 2. Set your office code

Twinfield identifies administrations by **code**, not by name, and Apideck sends that code with
every request: it decides which administration your data is read from and written to.

1. In Twinfield, open the switch-administration menu. The administration code
   (*administratiecode*) is shown directly when you switch administrations. Take that code, not
   the environment code (*omgevingscode*) shown under **Gebruikersinstellingen** (the person icon
   in the top-right corner), which identifies your Twinfield environment rather than a single
   administration. Wolters Kluwer's article
   [Wat is mijn omgevingscode, administratiecode of gebruikerscode](https://wktaaeu.my.site.com/nlcommunity/articles/nl_NL/Knowledge/Wat-is-mijn-omgevingscode-administratiecode-of-gebruikerscode)
   explains the difference between the three codes.
2. Back in Vault, open the connection's **Settings** and enter it in **Office code** (for example,
   `1000`).
3. Save the connection.

The field is not marked required, but set it anyway: a connection operates against one office code,
and filling it in is what guarantees reads and writes land in the administration you intended.

## 3. Check your control accounts

Twinfield requires a control (system) account on every bill and payment, and its API offers no way
to look yours up. Apideck therefore uses Twinfield's standard chart of accounts by default:

| Setting | Default | Used for |
|---|---|---|
| **Accounts payable control account** | `1600` | Amounts owed to suppliers: bills and bill payments |
| **Accounts receivable control account** | `1300` | Amounts owed by customers: customer payments |

**If your administration uses Twinfield's standard chart of accounts, you can skip this step.**

If it doesn't, check the codes and enter them in Vault:

1. In Twinfield, go to **Settings → Administration settings → Administration settings**, then choose
   **System accounts** (*Systeemrekeningen*) in the left submenu.
2. Read the values of **Accounts receivable control account** (*Hoofdrekening debiteuren*) and
   **Accounts payable control account** (*Hoofdrekening crediteuren*). Wolters Kluwer documents this
   screen in
   [Crediteuren en debiteuren - Administratie-instellingen](https://wktaaeu.my.site.com/nlcommunity/articles/nl_NL/Knowledge/Crediteuren-en-debiteuren-Administratie-instellingen).
3. If either differs from the default above, enter it in the matching field in the connection's
   **Settings** in Vault and save.

## Choosing the right Twinfield user

The connection runs as the Twinfield organisation user who authorized it, so its lifetime follows
that user's. Twinfield revokes access immediately, with no advance warning, if the user is
deleted, disabled or locked, if their password expires, or if the organisation itself is
deactivated. The first sign is that the connection stops working and asks to be authorized again.

Two things keep this from surprising you:

- Authorize with a dedicated integration user rather than an individual employee's login, so staff
  changes don't take the connection down.
- Make sure that user's password policy and access to the administration are maintained the same way
  you'd maintain any other service account.

## Troubleshooting

**Authorization fails, or you see a redirect error after signing in.** The Twinfield OAuth
application is registered by whoever operates the integration, and its redirect URL has to match the
one Vault sends you back to. Report the exact error to your integration provider so they can check
the registration.

**You can sign in but the administration you expected isn't available.** Access mirrors the
Twinfield user's own rights. Ask your Twinfield administrator to grant that user access to the
administration, then reconnect.

**Data appears under the wrong administration, or writes don't show up where you expect.** The
office code in the connection settings points at a different administration, or the environment
code was entered instead of the administration code. Re-check it against step 2.

**A bill or payment is rejected with an unknown or invalid ledger account.** Your administration
likely uses a customized chart of accounts. Set the accounts payable and accounts receivable control
accounts as described in step 3.

**The connection suddenly asks to be authorized again.** The Twinfield user behind it was disabled,
locked, deleted, or its password expired. Restore that user in Twinfield, or authorize again with an
active user, ideally the dedicated integration user described above.

Still stuck? Reach out to [Apideck Support](https://help.apideck.com/en/articles/7774658).


[API reference](https://developers.apideck.com/apis/accounting/reference.md) · [Coverage matrix](https://developers.apideck.com/apis/accounting/coverage)
