---
title: "Log export API: relay finished requests to your log stack"
description: "Push every finished request to a webhook, Langfuse or an OTLP collector about a minute later, scope it per key, and download the usage log as a CSV."
canonical: https://pentestllm.ai/docs/exports
generated: 2026-11-27T06:25:48.868Z
source: https://pentestllm.ai/docs/exports
base_url: https://api.pentestllm.ai/v1
---

[Docs](https://pentestllm.ai/docs) / API reference

# Log export API

Updated 2026-11-22. Published by PentestLLM.

Route every finished request to the logging stack your security team already runs, and pull the same data as a spreadsheet whenever you need it; both live at `https://api.pentestllm.ai/v1`. Deliveries leave in batches roughly a minute after a request wraps up. One that fails on a dropped connection, a 408, a 429 or any 5xx is tried three further times, at 10 seconds, then 60 seconds, then 5 minutes; let 50 fail one after another and the destination is turned off with a single email to the account address.

## List destinations

`GET /v1/exports` returns `data`, one object per destination, each paired with a `summary` that states the host, an opening slice of a Langfuse public key, or which header names ride along. No stored secret appears in it.

## Add a destination

`POST /v1/exports` expects a `kind` plus the fields belonging to that kind, and answers `201`:

| Field | Type | Kind | Notes |
| --- | --- | --- | --- |
| `kind` | string, required | all | One of webhook, langfuse or otlp. |
| `name` | string | all | 1 to 80 characters. |
| `url` | string | webhook | A public https URL that takes the signed POST. |
| `public_key` | string | langfuse | The project's public key. |
| `secret_key` | string | langfuse | The project's secret key. Encrypted on save, never echoed again. |
| `host` | string | langfuse | The Langfuse host; its managed cloud host unless set. |
| `endpoint` | string | otlp | The OTLP-over-HTTP base URL; the traces path is appended where absent. |
| `headers` | object | otlp | As many as 10 headers on each delivery, for instance an API key. Encrypted, names only. |
| `key_ids` | array or null | all | Confine to these keys' requests; all keys unless set. |
| `include_bodies` | boolean | all | Carry request bodies for keys that keep them. Off unless set. |

A webhook destination takes a signed JSON POST whose body carries the event name, the destination, a timestamp and a `data` array of events; its signature is an HMAC-SHA256 computed across the timestamp joined to the body, keyed by a `webhook_secret` this create call returns one time only, and it travels in the delivery’s own headers. A Langfuse destination logs each request as a generation through Langfuse’s OpenTelemetry endpoint, bundled per session. An OTLP destination sends OTLP/HTTP JSON onward to the traces path carrying your headers, a session becoming one trace and every request a span. Nothing in an event identifies the infrastructure behind a call.

An account keeps up to 10 destinations at once; adding an 11th returns `409 limit_reached`. A `400 invalid_request` means the kind is unknown, the URL is not on public https, a required key is absent, or a key id belongs to a different account, and a console member who is not the owner gets `403 forbidden`.

## Change or remove a destination

`GET /v1/exports/{destination_id}` reads a destination together with its last 50 delivery attempts, `PATCH /v1/exports/{destination_id}` edits its fields (turning a paused one back on clears the failure tally), and `DELETE /v1/exports/{destination_id}` removes it, so no further batch is sent, including any already waiting in its queue. An unknown destination id gets `404 not_found`.

## Pull the usage log as CSV

`GET /v1/usage/export` yields one CSV row for each of the account’s requests inside the `from` to `to` window, oldest first, with these columns: `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` and `user`. Narrow it with `key_id`, `model`, `status` and `user`. Omit `from` and it opens 30 days before `to`, which stands at the present unless set; a single file reaches back no further than 92 days and stops at 200,000 rows, and a range whose `from` is not before `to`, or that spans more than 92 days, is rejected with `400 invalid_request`. The `charge_usd` column holds the settled amount with no figure typed here.

## Example

```bash
curl https://api.pentestllm.ai/v1/exports \
  -H "Authorization: Bearer sk-ptl-live-…" \
  -H "Content-Type: application/json" \
  -d '{"kind": "otlp", "name": "siem", "endpoint": "https://otel.example.org", "headers": {"x-api-key": "..."}}'
```

Each route on this page takes an admin key from the [console](https://app.pentestllm.ai/console).

## Questions

### How long until a request shows up at my destination?

A batch leaves within roughly a minute of the request finishing. Should a delivery fail on a connection fault, a 408, a 429 or a 5xx, it is repeated three further times, spaced about 10 seconds, a minute, and 5 minutes out.

### What if my receiver stays broken?

Fifty failures back to back turn the destination off and send one note to the account address, so a dead receiver neither loops without end nor backs up your other traffic; switch it on again and the tally starts over.

### Do prompts and completions leave the gateway?

Only when include_bodies is set, and even then only for keys told to keep bodies. Left off, a destination gets the metadata and token counts, not the message text.

## Read next

- [MCP servers](https://pentestllm.ai/docs/mcp-servers)
- [Invoices](https://pentestllm.ai/docs/invoices)
- [Billing details](https://pentestllm.ai/docs/billing-details)
- [Statement signing key](https://pentestllm.ai/docs/statements-public-key)
- [Keys and scopes](https://pentestllm.ai/docs/keys)
- [Usage and signed receipts](https://pentestllm.ai/docs/usage-and-receipts)
- [Spend limits and balance](https://pentestllm.ai/docs/spend-limits)
- [Redaction and guardrails](https://pentestllm.ai/docs/redaction-and-guardrails)
- [Sessions](https://pentestllm.ai/docs/sessions)
- [Embeddings, rerank and moderation](https://pentestllm.ai/docs/retrieval-and-moderation)
- [Batch files](https://pentestllm.ai/docs/files)
- [Batches](https://pentestllm.ai/docs/batches)
- [Status and proof feeds](https://pentestllm.ai/docs/status-and-proof)
- [Count tokens](https://pentestllm.ai/docs/count-tokens)
- [Usage by app](https://pentestllm.ai/docs/stats-apps)
- [App sign-in keys](https://pentestllm.ai/docs/auth-keys)
- [Webhook deliveries](https://pentestllm.ai/docs/webhooks-deliveries)
- [Docs: connect in two minutes](https://pentestllm.ai/docs)
- [Sessions, usage export and log streaming](https://pentestllm.ai/features/observability)
