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.

Checked 2026-11-22

·API reference·Models

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

RoutePurpose
GET /v1/exportsReturns 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/exportsCreates 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

FieldKindNotes
kindall, requiredwebhook, langfuse or otlp.
nameall1 to 80 characters.
key_idsallRestricts the export to those keys' traffic; null or absent covers every key.
include_bodiesallAdds request bodies for keys that retain them. Off by default.
urlwebhookA public https address.
public_keylangfuseThe Langfuse project's public key.
secret_keylangfuseThe project's secret key, encrypted and never displayed again.
hostlangfusehttps://cloud.langfuse.com by default; the US cloud host or a self-hosted https host also works.
endpointotlpThe OTLP/HTTP base URL; /v1/traces is appended if absent.
headersotlpUp 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 event is usage.batch, with destination_id, created_at and a data array of request events. Each POST is signed. One header carries a timestamp; another carries sha256= followed by a hex HMAC-SHA256 computed over the timestamp joined to the raw body by a period, using as its key the webhook_secret that 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_secret is 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:

csv
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,user

refund_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

bash
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.csv

The observability feature page shows the same exports from the console.

Questions and answers

In about a minute, as part of a batch. When a delivery meets a network error, a 408, a 429 or a 5xx, the gateway tries it again after 10 seconds, after 60 seconds and after 5 minutes before marking it failed.

After 50 consecutive failed deliveries the destination turns itself off and the organization's address gets a single email. Once the collector is back, PATCH enabled to true, which also zeroes the failure count.

Only on request. A body goes out when include_bodies is on and the request's key retains bodies; otherwise a destination sees metadata and token counts alone.
Join on Telegram
Help