Skip to content
All guides

Usage webhook

For AI usage Trakkwise can't read on its own: an internal app that calls a model API with its own key, an AI tool with no admin API, or a cost your finance team tracks elsewhere. Your system posts each day's totals to Trakkwise, signed with a secret only it and Trakkwise know. They count in spend and usage like any connector's: in the cost ledger and the reports built on it.

Connect

In the console, Settings → Integrations → Usage webhook → Connect. Trakkwise makes a signing secret and shows it once, with the endpoint:

https://ingest.trakkwise.com/v1/webhooks/int_…

Keep the secret where your sender reads its secrets (a vault, or the CI or scheduler's secret store). Make a new secret replaces it at once: the old one stops working, so update the sender first if you can't afford a gap. Pause refuses deliveries (409) without losing anything already sent. Disconnect deletes the secret and everything sent with it.

Send

POST the endpoint with a JSON body and two headers:

Header Value
Content-Type application/json
X-Trakkwise-Timestamp the current time, in Unix seconds
X-Trakkwise-Signature v1= and the hex HMAC-SHA256 of <timestamp>.<body>, keyed with the secret

Sign the exact bytes you send. A timestamp more than 5 minutes from Trakkwise's clock is refused, so a captured delivery can't be replayed later.

{
  "records": [
    { "day": "2026-11-26", "tool": "support-bot", "model": "gpt-5", "person": "dana@acme.com", "metric": "cost_billed_usd", "quantity": 4.2 },
    { "day": "2026-11-26", "tool": "support-bot", "model": "gpt-5", "person": "dana@acme.com", "metric": "requests", "quantity": 120 }
  ]
}
Field Required
day yes YYYY-MM-DD, UTC, within the last 400 days
tool yes A Trakkwise catalog id (chatgpt, claude-code, openai-api) or your own (lowercase letters, digits, ., _, -)
metric yes One of the metrics below
quantity yes A number. Costs may be negative (a refund or credit); counts may not
model no The model, as you name it
item no A line item or product, as you name it
person no The person's work email. Leave it out for organization-level usage: a bill with no person is split by each person's share of that tool's use

Metrics: cost_billed_usd (what was billed), cost_estimated_usd (your estimate), seat, credits, requests, sessions, prompts, input_tokens, output_tokens, cache_read_tokens, cache_write_tokens, active_seconds, lines_added, lines_removed, commits, pull_requests.

At most 5,000 records per delivery, and 2 MB.

Each record is that day's total for its day, tool, model, item, person and metric. Sending it again sets the same number, so retries never count twice, and a later delivery can correct a day (send 0 to clear one). Send yesterday's final totals once a day, or today's running totals as often as you like.

Answers

Status Meaning
202 Accepted: {"accepted": <records>}
400 The body isn't valid; error says which record and field
401 Unknown endpoint, bad signature, or a timestamp more than 5 minutes off
409 The integration is paused
429 Too many deliveries; wait the Retry-After seconds

Repeated 401s from one address are throttled like failed sign-ins.

Example (Node.js 18 or later)

// send.mjs
import { createHmac } from "node:crypto";

const url = "https://ingest.trakkwise.com/v1/webhooks/int_…";
const secret = process.env.TRAKKWISE_WEBHOOK_SECRET;
const body = JSON.stringify({ records: [
  { day: "2026-11-26", tool: "support-bot", model: "gpt-5", person: "dana@acme.com", metric: "cost_billed_usd", quantity: 4.2 },
] });
const ts = Math.floor(Date.now() / 1000);
const sig = createHmac("sha256", secret).update(`${ts}.${body}`).digest("hex");
const r = await fetch(url, { method: "POST", body, headers: {
  "content-type": "application/json", "x-trakkwise-timestamp": String(ts), "x-trakkwise-signature": `v1=${sig}`,
} });
console.log(r.status, await r.text());

What Trakkwise keeps

The records as sent, as usage records (see the data inventory), for 730 days. Nothing else from the request: no addresses, headers or raw bodies are stored. Erasing a person removes the records that name them.