Getting started
From nothing to your first API answer: a credential, a token, a call. Then the command line and an assistant in Claude Code on the same API.
Two ways in
A program
API credentialAn integration, a script, a nightly sync. It uses an OAuth client of one organization, with the scopes you gave it. Steps 1 to 3 below are this path.
Why
No person signs in, and the credential's scopes are all it may do.
A person
Tracken ID sign-inWorks through the CLI or an MCP client, signed in to Tracken ID with their own account, and names the organization in every request (X-Organization-ID; the CLI does it for you).
Why
They act with their role in the organization, narrowed to the scopes they signed in with.
Before you start
- A company in Tracken Accounts (
https://accounts.tracken.ee). Build in a sandbox copy; a demo company has no API access. - The owner or administrator role in that company: only they can create an API credential.
- For the CLI only: Node.js 22 or later, then
npm i -g @tracken/cli.
Create an API credential
- Sign in to Tracken Accounts (
https://accounts.tracken.ee) and open the company the program will work in. Use a sandbox copy while you build. - Go to Settings → API access and choose New API credential.
- Name it after the program (“Web shop”) and pick the scopes it needs.
- Copy the client ID and the client secret. The secret is shown once.
Who can create one, expiry, and signing in without a secret
Only the company's owners and administrators can create one, and only with rights their own role has.
When you create it you can optionally set an expiry date and how long it may stay unused before it is disabled.
Keep the secret in your secret store, never in code. A credential can instead register a public key and sign in with private_key_jwt (RFC 7523), so no secret is shared at all.
TRACKEN_CLIENT_ID=…
TRACKEN_CLIENT_SECRET=… # shown onceGet an access token
Exchange the credential for a 10-minute access token at Tracken ID, then send it as Authorization: Bearer <token>. When it expires, ask for a new one the same way.
The CLI and the SDK do this exchange for you and renew the token as it nears expiry.
How the exchange works
OAuth 2.0 client credentials, the client authenticating with HTTP Basic. resource names the integration audience of the environment; scope asks for some or all of the credential's scopes, and leaving it out asks for all of them.
There is no refresh token for a credential.
curl https://id.tracken.ee/token \
-u "$TRACKEN_CLIENT_ID:$TRACKEN_CLIENT_SECRET" \
-d grant_type=client_credentials \
-d resource=https://accounts-api.tracken.ee/integration \
-d scope="invoices:read contacts:read"# The CLI runs as a program with an API credential instead of a person
export TRACKEN_CLIENT_ID=…
export TRACKEN_CLIENT_SECRET=…
tracken sales-invoices list --since 1dimport { Tracken } from "@tracken/sdk";
// Exchanged at Tracken ID and renewed as it nears expiry
const tracken = new Tracken({
auth: { clientId: process.env.TRACKEN_CLIENT_ID!, clientSecret: process.env.TRACKEN_CLIENT_SECRET! },
});{
"access_token": "eyJhbGciOi…",
"token_type": "Bearer",
"expires_in": 600,
"scope": "invoices:read contacts:read"
}Make a call
List the last five sales invoices. A machine token belongs to one organization, so it sends no X-Organization-ID.
"1240.00") and a date is YYYY-MM-DD.Read the conventions next: they hold for every operation.
curl "https://accounts-api.tracken.ee/v1/sales-invoices?limit=5" \
-H "Authorization: Bearer $TOKEN"tracken sales-invoices list --limit 5const page = await tracken.salesInvoices.list({ query: { limit: 5 } });
console.log(page.body.data[0].total); // "1240.00"{
"data": [
{
"id": "0b8f0c2e-5f3c-4a52-9d7e-1c2b3a4d5e6f",
"number": "2026-0142",
"date": "2026-10-12",
"currency": "EUR",
"net_total": "1000.00",
"tax_total": "240.00",
"total": "1240.00"
}
],
"meta": { "pagination": { "limit": 5, "next_cursor": "c2VxOjQy…", "has_more": true } }
}Next
Scopes
A scope admits a group of operations; each operation in the reference lists the scopes it needs. A call outside the token's scopes answers 403 with INSUFFICIENT_SCOPE, and WWW-Authenticate names the missing scope.
All 29 scopes
| Scope | Admits |
|---|---|
read | Read everything the credential's organization holds (shorthand for all *:read scopes). |
organizations:read | Organization, fiscal years, periods. |
ledger:read | Chart of accounts, tax codes, dimensions, transactions. |
ledger:write | Post and change manual transactions; manage accounts and dimensions. |
contacts:read | Contacts. |
contacts:write | Create and change contacts. |
items:read | Items. |
items:write | Create and change items. |
invoices:read | Sales invoices, quotes, purchase invoices. |
invoices:write | Create, change, issue, void and send invoices and quotes. |
payments:read | Payments and their allocations. |
payments:write | Record and remove payments. |
bank:read | Bank accounts, statements and lines. |
bank:write | Import statements; reconcile lines; manage bank accounts. Reconciling a line as: posting books it to any of the organization's accounts without ledger:write, as the app's own post to the ledger from a bank line does. |
documents:read | Document vault, downloads, extractions. |
documents:write | Upload, link, digitize and delete documents. |
assets:read | Fixed assets and depreciation. |
assets:write | Manage and dispose of fixed assets. |
reports:read | Run reports; read report definitions. |
reports:write | Create, change and delete custom report definitions; open a month's VAT return as a draft (filing stays in the app). |
vat:read | VAT returns and their files. |
audit:read | Audit log. |
exports:write | Create and download full data exports (after v1). after v1 |
webhooks:manage | Manage webhook endpoints (after v1). after v1 |
billing:read | Billing plans, runs and the formula catalog. |
billing:write | Create, change, approve and archive billing plans; start billing runs (issuing their invoices also needs invoices:write). |
objects:read | Object types, objects, meter types, meters and readings. |
objects:write | Create and change object types, objects, meter types and meters. |
readings:write | Record, correct and delete meter readings. |
A sandbox company
Build against a copy, not the real books. In Tracken Accounts add the company you already have once more (the same registry code): Accounts offers to make a copy. Create the credential in the copy; it belongs to that company only.
What a copy does, and why to use one on development too
Accounts asks why (“Trying a different setup” fits) and copies either the setup and master data, or everything with its history. A copy is a sandbox: it sends no e-mail to anyone outside the company, gets no deadline reminders and runs no VIES checks, so an integration can issue and send invoices without reaching a real customer.
On the development environment every company is test data, shared with other testers; still, issuing or sending from a real-looking company e-mails the addresses on it, so use a copy there too.
The command line: tracken
Every v1 operation is a command, generated from the same API document: tracken <resource> <verb>, for example tracken sales-invoices issue <id> or tracken reports run balance-sheet.
Install it from npm: npm i -g @tracken/cli (0.2.0, MIT, beta; Node.js 22 or later).
Install, sign-in and sessions
Install it with npm i -g @tracken/cli (tracken --version names the API document it was built for), then sign in with your own Tracken ID.
tracken login uses the OAuth device flow: it prints a link and a code such as BCDF-GHJK; confirm it in any browser. A read-only session stays signed in 7 days unused (30 days at most); one with --write or any write scope 24 hours unused (7 days at most). Tokens live in the operating system's keychain.
Every POST carries an automatic Idempotency-Key, --all follows the cursor, --dry-run asks the API to check a write without storing it, and table output shows money and dates as 1 234,50 and 12.10.2026.
The CLI also runs as a program, with an API credential instead of a person: set TRACKEN_CLIENT_ID and TRACKEN_CLIENT_SECRET (see step 2, CLI tab).
tracken login # read-only; add --write to change data
tracken org list # * marks the organization commands act in
tracken org use <organization-id>
tracken sales-invoices list --since 7d -o tableAn assistant in Claude Code (MCP)
tracken mcp is a local Model Context Protocol server: Claude Code (or Claude Desktop, Cursor, VS Code) works in Tracken Accounts as you, through the same public API, sign-in and organization as the CLI. It runs on your computer and stores nothing.
- Its tools are the operations marked for assistants, named like the operation in snake_case (
list_sales_invoices,create_purchase_invoice,run_report); the reference shows each one's tool name. - Read-only by default. With a plain
tracken logina tool that changes data answers “runtracken login --write” without calling the API. - Every write tool takes
dry_run, and its description asks the model to show you the result and get your confirmation before it writes for real. tracken org usein a terminal switches the organization for the next tool call, with no restart.
Why read-only by default
Give an assistant a write session only while you need it, and tracken logout when done.
tracken login
claude mcp add tracken -- tracken mcp
# or save its configuration in a project:
tracken mcp --print-config claude # prints the .mcp.json