Export Account Logs
GET /api/open/v1/logs/exportReturns every matching log row in a single response instead of paging. The filters are the same as Get account logs; the response is a file in CSV or JSONL format.
Request parameters
Section titled “Request parameters”| Parameter | In | Type | Required | Default | Description |
|---|---|---|---|---|---|
start_timestamp | query | integer | No | See below | Start time (inclusive), unix seconds |
end_timestamp | query | integer | No | See below | End time (inclusive), unix seconds |
type | query | integer | No | 2 | Log type: 2 for consumption (billed) requests, 7 for final failed requests (not billed). Repeat the parameter or separate values with commas (?type=2,7); other values return 400 |
model_name | query | string | No | — | Exact model name; repeat the parameter for multiple values (?model_name=a&model_name=b) or separate values with commas |
key_name | query | string | No | — | Exact Key name; repeat the parameter for multiple values. Commas are not supported because names may contain commas |
key_id | query | integer | No | — | Key ID, a positive integer; repeat the parameter or separate values with commas. IDs that belong to other users return no rows |
format | query | string | No | csv | Output format: csv or jsonl; other values return 400 |
Time range rules:
- Both omitted: the last 30 days.
- Only
start_timestamp: 30 days forward, capped at the current time. - Only
end_timestamp: 30 days backward. - The range can be at most 366 days.
Each multi-value parameter accepts at most 50 values; more returns 400 invalid_request. Timestamps must be non-negative integers, otherwise 400. This endpoint does not accept p or page_size.
Request example
Section titled “Request example”curl "https://www.routeapi.ai/api/open/v1/logs/export?start_timestamp=1726408000&end_timestamp=1729000000&key_name=bot&type=2,7&format=csv" \ -H "Authorization: Bearer $ROUTEAPI_MANAGEMENT_KEY" \ -o logs.csvResponse
Section titled “Response”The response body is the exported file, not the usual { success, message, data } JSON. Headers:
| Header | Description |
|---|---|
X-Export-Rows | Number of rows written to the file |
X-Export-Truncated | true when more rows matched than the per-request cap; false otherwise |
Cache-Control | Always no-store |
Content-Disposition | attachment; filename="logs-<UTC yyyyMMdd-HHmmss>.csv" or .jsonl |
Each request returns at most 50,000 rows. When more rows match, the newest 50,000 rows by log ID are returned and X-Export-Truncated is true; split the time range into smaller windows to fetch the rest. Unlike Get account logs, rows are sorted by log ID descending.
CSV format
Section titled “CSV format”format=csv returns Content-Type: text/csv; charset=utf-8 with a UTF-8 BOM, followed by a header row and one row per log. Columns are always in this order:
id,created_at,type,key_id,key_name,model_name,prompt_tokens,completion_tokens,total_tokens,amount,request_id,key,use_time,is_stream,first_response_ms,cache_read_tokens,cache_creation_tokens,reasoning_effort,request_path,web_search_calls,audio_input_tokens,audio_output_tokens,billing_source12345,1729000000,2,12,bot,gpt-4o,1200,300,1500,0.05,20261020120000123456789,sk-abcd**********wxyz,3,true,420,800,0,medium,/v1/chat/completions,0,0,0,walletThe fields match the items from Get account logs; created_at is unix seconds. Cells that start with =, +, @, a tab, or a carriage return, or that start with a non-numeric -, are prefixed with ' to prevent spreadsheet software from treating them as formulas.
JSONL format
Section titled “JSONL format”format=jsonl returns Content-Type: application/x-ndjson with one JSON object per line, using the same fields as the items from Get account logs:
{"id":12345,"created_at":1729000000,"type":2,"key_id":12,"key_name":"bot","key":"sk-abcd**********wxyz","model_name":"gpt-4o","prompt_tokens":1200,"completion_tokens":300,"total_tokens":1500,"amount":0.05,"use_time":3,"is_stream":true,"first_response_ms":420,"cache_read_tokens":800,"cache_creation_tokens":0,"reasoning_effort":"medium","request_path":"/v1/chat/completions","web_search_calls":0,"audio_input_tokens":0,"audio_output_tokens":0,"billing_source":"wallet","request_id":"20261020120000123456789"}Errors
Section titled “Errors”| HTTP | code | Scenario |
|---|---|---|
| 400 | invalid_request | A timestamp is not numeric or is negative, the range exceeds 366 days, start_timestamp is greater than end_timestamp, a multi-value parameter has more than 50 values, key_id is not a positive integer, type is not 2 or 7, or format is not csv or jsonl |
| 429 | — | Per-user query rate limit exceeded (default 30/minute); the body may be empty |
Errors are returned as the usual JSON error body, not a file. For other common error codes, see Platform API errors.
- By default only consumption (billing) logs are exported. Add
type=2,7to include final failed requests (not billed) as well. key_nameis the Key’s name at the time of the request; renaming a Key does not rewrite past records.keyis the masked value; it is an empty string when the Key has since been permanently deleted.- Token counts are raw counts, not millions. Amounts use the site display currency; see Get balance.
- This endpoint shares the per-user query rate limit (default 30/minute) with Account logs, Usage, Usage by model, and Usage by Key. See Rate limits.