Log export API: send finished requests to your stack
Stream each finished request into a webhook, Langfuse or OTLP collector, limit it to chosen keys, and download the usage log as CSV, all on an admin key.
Every finished request on your organization can be forwarded to a destination you run, and the routes under https://api.uplinkswitch.com/v1/exports manage those destinations. Batches leave roughly a minute after each request. A delivery that hits a network error, a 408, a 429 or any 5xx is attempted three more times, 10 seconds, 60 seconds and 5 minutes later. Fifty failures in a row switch the destination off and send one email to the organization's address. Ten destinations is the most one organization can keep.
These routes take an admin key or a signed-in console session. From the console, only the owner may change a destination; another member gets 403.
Routes
| Route | Purpose |
|---|---|
GET /v1/exports | Returns the destinations in data. Each carries a summary: the host, plus a Langfuse destination's public-key prefix or an OTLP destination's header names. Secrets never appear. |
POST /v1/exports | Creates a destination and answers 201. |
GET /v1/exports/{destination_id} | One destination together with its 50 latest deliveries. |
PATCH /v1/exports/{destination_id} | Any subset of name, enabled, key_ids, include_bodies and the kind's own settings. Re-enabling a switched-off destination resets its failure count. |
DELETE /v1/exports/{destination_id} | Deletes it, and batches still queued for it are dropped. |
Destination ids are exp_ followed by 16 hex characters.
Fields for POST
| Field | Kind | Notes |
|---|---|---|
kind | all, required | webhook, langfuse or otlp. |
name | all | 1 to 80 characters. |
key_ids | all | Restricts the export to those keys' traffic; null or absent covers every key. |
include_bodies | all | Adds request bodies for keys that retain them. Off by default. |
url | webhook | A public https address. |
public_key | langfuse | The Langfuse project's public key. |
secret_key | langfuse | The project's secret key, encrypted and never displayed again. |
host | langfuse | https://cloud.langfuse.com by default; the US cloud host or a self-hosted https host also works. |
endpoint | otlp | The OTLP/HTTP base URL; /v1/traces is appended if absent. |
headers | otlp | Up to 10 headers sent on every delivery, such as a vendor API key. Encrypted; reads list names only. |
What each kind receives
- webhook: a JSON POST whose
eventisusage.batch, withdestination_id,created_atand adataarray of request events. Each POST is signed. One header carries a timestamp; another carriessha256=followed by a hex HMAC-SHA256 computed over the timestamp joined to the raw body by a period, using as its key thewebhook_secretthat appears only in the 201 response. - langfuse: each request lands as a generation through the Langfuse OpenTelemetry endpoint, grouped by session.
- otlp: OTLP/HTTP JSON posted to the traces path with your headers. A session becomes one trace and each request a span with
gen_ai.*attributes, which Datadog, Honeycomb, Grafana and similar backends read.
No event names the infrastructure that served the request.
Status codes
- 201: created; a webhook's
webhook_secretis shown in this response and nowhere else. - 400
invalid_request: an unknown kind, an address that is not public https, a missing Langfuse key, or a key id belonging to another organization. - 403
forbidden: a signed-in member who is not the owner attempted a change. - 404
not_found: the destination id is not yours. - 409
limit_reached: all 10 destination slots are taken.
The usage log as CSV
GET /v1/usage/export, also on an admin key, returns your requests as CSV, oldest first, one row per request, under this header line:
request_id,created_at,key_id,session_id,model,outcome,status,input_tokens,cache_read_tokens,cache_write_tokens,output_tokens,charge_usd,latency_ms,refund_reason,userrefund_reason is filled when a request was refunded. from and to accept a UTC date as YYYY-MM-DD (a to date counts its whole day) or Unix milliseconds. Without to the range ends now, and without from it starts 30 days before to. A file stops at 92 days and 200,000 rows; a from that is not earlier than to, or a span longer than 92 days, returns 400 invalid_request. Narrow it with key_id, model, user or status, where status=failed selects upstream_error and upstream_rejected rows together. charge_usd is each request's settled charge, taken from your own records rather than from any rate quoted here.
Example
curl https://api.uplinkswitch.com/v1/exports \
-H "Authorization: Bearer sk-uplink-live-..." \
-H "Content-Type: application/json" \
-d '{"kind": "otlp", "name": "traces", "endpoint": "https://otlp.example.com", "headers": {"api-key": "..."}}'
curl "https://api.uplinkswitch.com/v1/usage/export?from=2026-11-01&to=2026-11-21" \
-H "Authorization: Bearer sk-uplink-live-..." -o usage.csvThe observability feature page shows the same exports from the console.