Choose what you allow. Your choice applies on every tracken.ee address and you can change it any time with “Cookie settings” in the footer.

Remember your cookie choice, language and theme. Without them the site doesn't work the way you chose.

A cookie with your choice (6 months); language and theme in browser storage.


The services below learn that you visited this site, whether you came from their ad and whether you then created a Tracken account. That shows us which ads work, and these companies may show you Tracken ads later. They may link the data to your account with them. For Meta, Tracken ID's server reports the new account and also sends a hash of your e-mail address, your IP address and browser details.

ServiceCookiesKept for up to
Meta (Facebook, Instagram)_fbp, _fbc90 days

Tracken's own visit counter uses no cookies, stores no IP addresses and shares nothing with anyone. Privacy policy

Skip to content
Beta
BetaThe Tracken Accounts API is in beta: it may still change before v1, and every change is announced in the changelog.
API referenceDocuments of recordBilling

Create a billing run

live
POST/v1/billing-runs
Scope billing:writeMCP tool create_billing_runOperation id createBillingRun

Start billing a period. Answers 202 with the run; poll it until status is final. With dry_run=true the run is computed and returned, nothing stored: review its recipients and blockers, then start it with expected_fingerprint.

Details

A run already open for the plan and period is 409 BILLING_RUN_IN_PROGRESS with existing_id; starting a finished period again re-runs it (issued invoices are kept, drafts replaced).

Parameters

headers and query
Idempotency-Keyheader · stringat most 255 characters

Optional replay guard for a POST (DA-065). Send a key the CLIENT generates (a uuid per user-initiated request, reused across retries of that same request). The server performs the operation at most once per (organization, key) and answers a replay with the ORIGINAL response (status, headers and body), so a double-clicked Save or a retry after an ambiguous timeout never creates or posts anything twice.

Details

A request that FAILED frees its key, so retrying after a genuine error proceeds normally. Reusing a key with a DIFFERENT body is a client bug, not a retry, and returns 409 IDEMPOTENCY_KEY_REUSED rather than the earlier response. Keys are kept for 24 hours; a retry after that is a new request. Omitting the header keeps the previous behaviour exactly.

dry_runquery · booleandefault false

Validate and compute without storing anything: the answer is what the real request would answer (status, errors, computed totals, assigned numbers) but nothing is saved, posted or sent, and the response carries Tracken-Dry-Run: true.

Tracken-On-Behalf-Ofheader · stringat most 200 characters

For an app's installation token: the person the app acts for (its own user id and name, e.g. res_123 Mari Maasikas). Recorded in the audit log beside the app; never used for access, which the app enforces.

Request body

application/json · required
dataBillingRunInputrequired

Bill one period of a plan.

Attributes of data

plan_idstring (uuid)required

The plan; the run bills the revision in force for period.

periodstring (date)required

The period billed, the first day of its month.

finishstringdefault "draft"

Leave draft invoices, issue them, or issue and email them. Issuing also needs permission to write sales invoices (invoices:write).

One of draft, issue, issue_send

invoice_datestring (date) · nullable

Invoice date; today when absent.

posting_datestring (date) · nullable

Posting date, when not the invoice date.

due_datestring (date) · nullable

Override the plan's due-date rule.

variable_valuesarray of BillingRunVariableValue

Values for the plan's asked variables, and overrides of timed ones.

6 attributes of each item
keystringrequired1–63 characters

The variable's key in the plan.

valuestring · nullabledecimal string

The value, as a decimal string with at most 6 decimal places (a 7th is refused); it is stored and read back as sent, never rounded to fewer. Null with purchase_invoice_id: the variable's invoice formula over the chosen lines (invoice_formula on the plan variable; the lines' sum when it has none), computed by the server and kept to 6 places, half-even.

Details

A value sent with purchase_invoice_id must equal that result exactly.

purchase_invoice_idstring (uuid) · nullable

Or take it from lines of this purchase invoice.

purchase_invoice_line_idsarray of string (uuid)

The purchase invoice lines summed.

vatstring · nullable

Whether the purchase invoice lines are read with their VAT (included, the default) or without it: the line.amount of the invoice formula.

One of included, excluded

invoice_formulastring · nullableread-only

Read-only, on a run's values: the invoice formula a value taken from a purchase invoice was computed with, as the plan stood then. Null: the chosen lines' sum, or not taken from an invoice. Refused when sent.

exchange_ratestring · nullabledecimal stringpattern ^([1-9][0-9]{0,14}(\.[0-9]{1,10})?|0\.([1-9][0-9]{0,9}|0[1-9][0-9]{0,8}|00[1-9][0-9]{0,7}|000[1-9][0-9]{0,6}|0000[1-9][0-9]{0,5}|00000[1-9][0-9]{0,4}|000000[1-9][0-9]{0,3}|0000000[1-9][0-9]{0,2}|00000000[1-9][0-9]?|000000000[1-9]))$

For a plan in a currency the European Central Bank publishes no rate for: the rate every draft of the run is booked at, in ExchangeRate's direction, recorded as a manual rate and kept when the draft is issued.

Details

Used only when no ECB rate exists for the day the drafts convert on (the run's posting date); where one does, or for a plan in the book currency, the run is refused (EXCHANGE_RATE_OVERRIDE_INVALID). Omitted: the ECB's rate of that day.

external_refstring · nullable1–200 characters

Your own id for the run, unique per organization; on_conflict resolves a create against it.

on_conflictOnConflictdefault "error"

What a create does when a record of the same resource already holds the sent external_ref. error: 409 EXTERNAL_REF_EXISTS with existing_id. return: 200 with the existing record, unchanged.

One of error, return, update

Details

update: apply the sent fields to it as a PATCH would and answer 200; refused like a PATCH when the record is no longer editable.

expected_fingerprintstring · nullable

The fingerprint of the dry run you reviewed. If the result would differ now, the run is refused with BILLING_RUN_RESULT_CHANGED and creates nothing. Optional: a run sent without it is computed and started as the period stands.

Responses

errors use the error envelope
200BillingRun · dry_run=true: the run as it would be made, with its recipients, totals, blockers and fingerprint. Nothing is stored. Also an existing run with this external_ref (on_conflict return).
202BillingRun · Accepted; the run is queued and runs in the background.
400The request fails validation. This operation's own codes: BILLING_PLAN_VARIABLE_INVOICE_FORMULA_INVALID, BILLING_RUN_BLOCKED, BILLING_RUN_DUE_BEFORE_INVOICE_DATE, BILLING_RUN_INPUT_MISSING, BILLING_RUN_PERIOD_NOT_COVERED, BILLING_RUN_PLAN_NOT_APPROVED, BILLING_RUN_POSTING_PERIOD_CLOSED, BILLING_RUN_PURCHASE_FORMULA_NO_VALUE, BILLING_RUN_PURCHASE_INVOICE_INVALID, EXCHANGE_RATE_OVERRIDE_INVALID.
401No token, an expired token, or a token for another audience (UNAUTHENTICATED).
402The organization's subscription is not active (SUBSCRIPTION_INACTIVE): the trial ended without a plan, a payment is overdue, the subscription was cancelled, or the accounting firm that paid for it stopped. context.reason says which (trial_ended, not_paid, cancelled, payer_stopped; accept values you do not know) and context.export_until the last day (ISO date) the organization's data can still be exported. Every operation is refused, reads included, except reading the current user and the organization and the data export. A retry unchanged fails the same way: an owner reopens the subscription in the app.
403Not allowed. This operation's own codes: OPERATION_NOT_PUBLIC.
404Not found. This operation's own codes: BILLING_PLAN_NOT_FOUND.
409Conflicts with the resource's state. This operation's own codes: BILLING_RUN_IN_PROGRESS, BILLING_RUN_RESULT_CHANGED, EXTERNAL_REF_EXISTS, EXTRA_MONTH_CONFIRM_REQUIRED, WORK_MONTH_CONFIRM_REQUIRED. An API credential cannot confirm a month: a person confirms it in the app, then retry the request unchanged, with the same Idempotency-Key; context names the month, its price and currency.
429Rate limit exceeded (RATE_LIMITED). Wait Retry-After seconds.

Errors this operation can return

switch on code, never on message
CodeStatusWhen
BILLING_RUN_IN_PROGRESS409A run already open for the plan and period is 409 BILLING_RUN_IN_PROGRESS with existing_id; starting a finished period again re-runs it (issued invoices are kept, drafts replaced).
IDEMPOTENCY_KEY_REUSED409Idempotency-Key: Reusing a key with a DIFFERENT body is a client bug, not a retry, and returns 409 IDEMPOTENCY_KEY_REUSED rather than the earlier response.
BILLING_PLAN_VARIABLE_INVOICE_FORMULA_INVALID400Check the variable's formula over the invoice.
BILLING_RUN_BLOCKED400Invoices cannot be created until the problems are fixed.
BILLING_RUN_DUE_BEFORE_INVOICE_DATE400The due date cannot be before the invoice date.
BILLING_RUN_INPUT_MISSING400Enter every value the billing plan asks for when creating invoices.
BILLING_RUN_PERIOD_NOT_COVERED400The billing plan is not in force for this period.
BILLING_RUN_PLAN_NOT_APPROVED400Invoices can only be created from an approved billing plan.
10 more codes
BILLING_RUN_POSTING_PERIOD_CLOSED400The posting date is in a closed accounting period.
BILLING_RUN_PURCHASE_FORMULA_NO_VALUE400The formula gives no value from the chosen purchase invoice lines, e.g. a line's quantity is zero.
BILLING_RUN_PURCHASE_INVOICE_INVALID400The chosen purchase invoice lines do not give this amount.
OPERATION_NOT_PUBLIC403The operation is not part of the public API: the Tracken Accounts app may call it, API keys and scope-narrowed tokens may not.
BILLING_PLAN_NOT_FOUND404This billing plan could not be found.
BILLING_RUN_RESULT_CHANGED409expected_fingerprint: If the result would differ now, the run is refused with BILLING_RUN_RESULT_CHANGED and creates nothing.
EXTERNAL_REF_EXISTS409on_conflict: error: 409 EXTERNAL_REF_EXISTS with existing_id.
EXTRA_MONTH_CONFIRM_REQUIRED409This change falls outside the working month, so this month is billed separately.
WORK_MONTH_CONFIRM_REQUIRED409This change starts the plan year's working month, so the working month must be confirmed first.
EXCHANGE_RATE_OVERRIDE_INVALID400data.exchange_rate: Used only when no ECB rate exists for the day the drafts convert on (the run's posting date); where one does, or for a plan in the book currency, the run is refused (EXCHANGE_RATE_OVERRIDE_INVALID).

Plus the general codes every operation can answer (UNAUTHENTICATED, RATE_LIMITED …): handle them once.