HTTP API
Public usage, delivery, query and Health routes, their credentials, request limits and failure classes.
Built from commit f569b4a on Nov 14, 2026
Use your instance’s HTTPS origin, https://YOUR_DOMAIN. The routes below are for collectors, integrations and monitoring. Browser pages are outside this reference.
| Route | Method | Credential | Purpose |
|---|---|---|---|
/healthz |
GET | None | Server status, program version and source revision. |
/v1/live |
GET or HEAD | None | Collector liveness probe. |
/v1/events |
POST | Personal ingest key | Canonical usage events. |
/v1/native-events |
POST | Personal ingest key | Sanitized native-receiver rows in an exact delivery batch. |
/v1/logs |
POST | Personal or organization ingest key | OpenTelemetry usage logs. |
/v1/metrics |
POST | Personal or organization ingest key | OpenTelemetry metric counts, not usage Facts. |
/v1/delivery |
POST | Personal ingest key | Original acknowledgements for that credential owner’s requested batches. |
/v1/query |
POST | Query key | One bounded Answer. |
/v1/health |
POST | Administrator’s query key | Operational Health document. |
Every /v1/ route also exists under /ingest/v1/ and /functions/v1/ingest/v1/ with the same behavior.
Credentials and encoding
Send ingest credentials as x-ingest-key and query credentials as x-query-key. A credential in the correct header but with the wrong scope is refused. Supplying only the other header leaves the required credential missing.
Use Content-Type: application/json. The server enforces this on Events, Native events, Query and Health. OpenTelemetry routes accept JSON encoding only. Protobuf fails JSON decoding. Delivery accepts a JSON body without requiring a content-type header.
An organization key works only on Logs and Metrics. Members’ query keys read their own usage. Administrators’ query keys read instance usage and Health.
Query and Health also accept a same-origin browser session. Do not combine that session with a query key, which produces 401 authentication. An absent or empty credential produces the same class.
See Users and Keys for issuing and revoking keys.
Liveness
GET /healthz returns fields status, program, version and revision. A running server reports status: "ok" and program: "tach-server". The server program’s version can differ from the package version. Compare revision with the verified package when checking an upgrade.
GET /v1/live returns:
{"status":"alive","service":"tach","maintenance":false}
Neither route proves that a collector has sent usage.
Canonical events
POST /v1/events accepts agent_usage.v1, at most 256 events and 1 MiB of encoded body. The following shows the shape. Replace the uppercase placeholders with a UUID, real RFC 3339 instant and your tool’s identifiers before sending:
{"schema":"agent_usage.v1","events":[{"event_id":"EVENT_UUID","event_time":"RFC3339_INSTANT","source":"pi","session_id":"SESSION_ID","provider":"anthropic","model":"MODEL_ID","usage":{"uncached_input_tokens":120,"output_tokens":40,"cache_read_tokens":0,"cache_write_tokens":0,"cache_write_1h_tokens":0,"reasoning_tokens":0}}]}
The collected-data reference lists every allowed event field and token constraint. Unknown fields, repeated event IDs within the request and invalid events refuse the batch.
A successful response partitions all submitted IDs into accepted and duplicates. Resending an already acknowledged event does not change it or count it again. Deduplication uses the credential owner and event ID.
Only acknowledged event IDs may be removed from a sender’s outbox. A failed, incomplete or ambiguous reply acknowledges nothing.
Exact delivery batches
Events can optionally carry both headers below. Native events require both.
| Header | Value |
|---|---|
x-tach-batch-id |
UUID identifying this frozen batch. |
x-tach-batch-sha256 |
SHA-256 of the exact request body bytes, as 64 lowercase hexadecimal characters. |
A missing partner, invalid value, repeated delivery header or body-digest mismatch produces 400 protocol. A previously committed batch ID with different bytes produces 409 protocol. Other routes refuse either delivery header.
The acknowledgement is tach.delivery-receipt.v1, with batch_id, body_sha256, the sorted event_ids, accepted, duplicates and committed_at. An exact retry returns the stored acknowledgement. Event receipts remain the deduplication authority.
Native receiver protocol
POST /v1/native-events accepts a closed envelope with schema: "tach.native-usage.v1" and events, at most 512 rows and 1 MiB. It consumes the native receiver’s mapped rows, rather than an OpenTelemetry envelope. For a new canonical integration, use /v1/events.
Every native row has exactly these fields:
| Fields | Constraint |
|---|---|
schema_version |
Exactly otlp.v1. |
event_time, source, provider, session_id |
Valid timestamp and bounded identifiers. Sources are claude_code, cowork, claude_code_desktop or codex, with the matching provider. |
event_id, event_hash |
UUID derived from a 64-character lowercase hexadecimal hash under the native receiver protocol. |
claimed_email |
Null or a bounded email claim. A personal key still attributes usage to its owner. |
model, machine_id, machine_label, source_version, agent_id, agent_name, call_kind |
Nullable metadata. A label requires a machine UUID. |
input_tokens, output_tokens, cache_read_tokens, cache_creation_tokens, cache_write_1h_tokens, reasoning_tokens |
Six whole-number counts with the canonical token limits. The native protocol’s input and cache-creation names map to uncached input and cache write. |
emitted_cost_usd |
Null or a finite nonnegative amount. |
Read an acknowledgement
POST /v1/delivery accepts at most 16 KiB and up to 256 requested batch UUIDs:
{"schema":"tach.delivery-query.v1","batch_ids":[]}
Add your known batch UUIDs to the array. The response is tach.delivery-readback.v1, with owner_email and batches. Each entry is the original receipt or an object containing that batch_id and state: "absent".
This route reads only the personal ingest credential owner’s requested batches. It cannot list another owner’s batches or read Answers. Query and organization keys are refused.
OpenTelemetry
POST /v1/logs maps finished Claude Code, Claude Desktop Code and Cowork api_request logs, and Codex response.completed events, into usage. Other records become bounded diagnostic counts. More than 512 mapped usage rows produces 413 protocol. The encoded body limit is 1 MiB.
POST /v1/metrics counts metrics by type and source. It does not turn metrics into usage Facts. Its body limit is also 1 MiB.
The success reply is:
{"partialSuccess":{}}
Configure the exporter’s final Logs URL as https://YOUR_DOMAIN/v1/logs, its Metrics URL as https://YOUR_DOMAIN/v1/metrics, and the key in x-ingest-key. Use http/json.
Query
POST /v1/query accepts at most 64 KiB. from and to are required real RFC 3339 instants. The start is inclusive and the end exclusive, with a positive span of at most 30 days.
| Field | Values and default |
|---|---|
group_by |
session, user, source, model, day, machine, provider, billing or tag:Category. May be an array of one or two distinct dimensions. Session cannot be paired. Default session. |
user, source, provider, model, machine, billing, session |
Optional filters. Machine is a UUID. Billing is usage_billed or subscription_notional. Session is a literal prefix and requires source. |
tags |
Optional object with at most eight current category-value filters. Category names have 1 to 32 characters and no colon or comma. Values have 1 to 64 characters. Not set selects an absent assignment. |
order_by |
tokens, cost, events or dim. Default tokens. |
limit |
1 to 1000. Default 50 for Session, otherwise 1000. |
offset |
Nonnegative safe integer. Default 0. |
include_inactive_people |
Boolean, default false. Despite the name, adds active registered people without usage. Requires scalar group_by: "user" and only user or tag filters. |
include_catalog_projection |
Boolean, default false. Adds a catalog-only comparison for the same matched events. Cannot combine with include_inactive_people. |
Unknown fields are refused. The response is tach.answer.v1, with normalized question fields, rows, full_count and evidence. Evidence covers every matching event before pagination. Each row includes six token counts, events, est_cost_usd, price_missing and cost_source.
Wire cost sources are emitted, estimated, mixed, missing, or none for a zero-event person row. A wholly unpriced usage row has est_cost_usd: null. A partially priced row retains its known amount and missing-price flag. Missing never means zero.
The query reader builds these requests for you.
Health
POST /v1/health requires an active administrator’s query key. The body is at most 1024 bytes. It accepts optional integer fields days and threshold, each from 1 to 30. Defaults are 7 and 3.
The response is tach.health.v1. Its status is ok, attention or critical. It includes stable problem IDs, readiness, people, computers, sources, dropped-event counts and price coverage. See Health for interpretation.
Failures
Failures use a JSON error class and the same value in x-tach-failure-class, without echoing submitted values.
| Status | Class | Meaning |
|---|---|---|
| 400 | protocol |
Invalid body, headers, encoding or request fields. |
| 401 | authentication |
Missing, unknown, revoked or deactivated credential, or an ambiguous query credential. |
| 403 | authorization |
Credential scope or role cannot use this route. |
| 405 | protocol |
Unsupported method. |
| 409 | protocol |
Reused batch ID with different bytes. |
| 413 | protocol |
Body or ingest row limit exceeded. |
| 413 | query_too_large |
Query exceeds its computation budget. |
| 422 | numeric_overflow |
Complete totals cannot be represented safely. |
| 429 | rate_limited |
Ledger rate limit reached. |
| 502 | protocol |
Stored or compiled reply fails validation. |
| 503 | dependency, storage, network or internal |
Capacity, storage, broken upload or worker failure. |
| 504 | timeout |
Upload or read deadline exceeded. |
Retry temporary failures with the same event identities and frozen batch bytes. Do not treat a failure as acknowledgement.