agency-time
POST /v1/agency/time/billing-runs
Bill now — turn unbilled time into a draft invoice.
Authentication
Send an API key as a bearer token. This endpoint does not state a specific permission in the specification, so give your key the least it needs and check the response rather than assuming.
Where your organisation id goes
This endpoint takes org_id as a field in the JSON body.
Your organisation id is on the API keys screen in your dashboard, beside the key itself. It is the same id in every call you make.
Try it
Replace anything in angle brackets with your own values, and the key placeholder with a key from your dashboard.
curl -X POST https://api.zinndigital.com/v1/agency/time/billing-runs \
-H "Authorization: Bearer zdk_live_…" \
-H "Content-Type: application/json" \
-d '{ "client_id": <string>, "currency": <string> }'Signed in? The API console in your dashboard fills in your real organisation id and your own key, and runs the request against the live API so you can see the actual response. Open this endpoint in the API console
Details
The owner's *"as well as sending on demand invoices"*. Claims the client's unbilled, priced work, hands it to the agency invoicing suite as a **draft**, and records what came back. ⛔ The entries are claimed in a committed transaction **before** the invoicing suite is called, so no other trigger can select them while the call is in flight. The idempotency key handed to the suite is derived from the sorted entry ids rather than minted, so a retry after a crash is given back the invoice that already exists instead of raising a second one for the same hours. `reconcile_state` is `ok` only when the invoice's total for these lines equals our own exact arithmetic. `mismatch` means do not send it.
Request body
| Name | Type | Required | What it is |
|---|---|---|---|
client_id | string | Yes | — |
currency | string | Yes | — |
until | string | No | Bill work up to and including this date — "everything to the end of last month". |
notes | string | No | — |
org_id | string | No | — |
Response
| Name | Type | Required | What it is |
|---|---|---|---|
id | string | Yes | — |
client_id | string | No | — |
currency | string | Yes | — |
period_start | string | No | — |
period_end | string | No | — |
trigger | string<manual, on_log, day_of_month, threshold> | Yes | — |
status | string<claimed, invoiced, failed, released> | Yes | `claimed` is the state between claiming the time and the invoicing suite's reply — a process that dies there leaves one, and the recovery pass finishes it with the same derived… |
subtotal_minor | integer | Yes | Our own exact arithmetic, before tax. What the invoice is reconciled against. |
minutes_total | integer | Yes | — |
duration_label | string | No | — |
entry_count | integer | No | — |
fixed_line_count | integer | No | — |
invoice_id | string | No | — |
invoice_number | string | No | — |
invoice_created | boolean | No | FALSE means the invoicing suite's idempotency key fired and handed back an invoice an earlier attempt had already raised. Surfaced rather than hidden: it is the observable that… |
reconcile_state | string<pending, ok, mismatch, unavailable> | No | Whether the invoice's total for these lines equals our own arithmetic **exactly**. There is no "close enough": both sides compute from the same two integers, so any difference i… |
reconcile_detail | string | No | — |
invoiced_at | string | No | — |
released_at | string | No | — |
last_error | string | No | — |
created_at | string | Yes | — |
actual | object | No | What this run actually consumed, derived from the time entries rather than read off the run's stored columns — so a divergence is visible on the screen. |
Errors this endpoint can return
401 · 403 · 422