> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.runtype.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.runtype.com/_mcp/server.

# Get aggregated log stats

GET https://api.runtype.com/v1/logs/stats

Returns aggregated log statistics including histogram, counts by level, and counts by category.

Reference: https://docs.runtype.com/api-reference/runtype-api/logs/get-aggregated-log-stats

## Authentication

- `Authorization` header (bearer token, required) — API key or Clerk session token

## Servers

- `https://api.runtype.com` (Production, default)
- `https://api.runtype-staging.com` (Staging)

## Request

### Query parameters

- `from` (string, optional) — Start timestamp (ISO 8601). Defaults to 24 hours ago.
- `to` (string, optional) — End timestamp (ISO 8601). Defaults to now.
- `startTime` (string, optional) — Alias for from. Ignored when from is also given.
- `endTime` (string, optional) — Alias for to. Ignored when to is also given.
- `level` (string, optional) — Comma-separated log levels (debug,info,warn,error). An unknown value is rejected with 400.
- `category` (string, optional) — Comma-separated categories (execution,agent,tool,model,system,error,schedule,batch,audit). An unknown value is rejected with 400.
- `flowId` (string, optional) — Filter by flow ID
- `agentId` (string, optional) — Filter by agent ID
- `executionId` (string, optional) — Filter by runtime execution_id / executionSessionId (for example exec_... or otel-...), not the aex_... agent-execution row ID
- `surfaceId` (string, optional) — Filter by surface ID
- `conversationId` (string, optional) — Filter by conversation ID
- `search` (string, optional) — Case-insensitive substring search over a span's message, name, operation, tool name or error class; a live-tier row matches on its message.
- `status` (string, optional) — Comma-separated statuses (running,completed,failed,queued,cancelled,unknown). An unknown value is rejected with 400. A row is unknown while its activity has not finished, else failed at level error and completed otherwise; running, queued and cancelled match no row today.
- `type` (string, optional) — Comma-separated entry types (flow,step,tool,batch,system,agent,model,schedule,audit). An unknown value is rejected with 400. Matches the type each row is rendered with, so step selects step spans only and flow selects flow runs without their steps. Combined with category by AND.
- `limit` (string, optional) — Max results per page (default 500, max 1000)
- `cursor` (string, optional) — Pagination cursor
- `order` (string, optional) — Sort order: asc or desc

## Response

### 200

Log stats returned

- `data` (V1LogsStatsGetResponsesContentApplicationJsonSchemaData, required)
- `success` (boolean, required)
- `window` (V1LogsStatsGetResponsesContentApplicationJsonSchemaWindow, required) — The time window the query resolved to, after defaults and from/to aliases.
- `cachedAt` (string, optional, nullable) — When the response was served from cache, the cache write time. Null for fresh responses.

## Errors

### 400 Bad Request Error

Invalid request

- `error` (string, required)
- `code` (string, optional) — Stable error code. `insufficient_scope` marks an API key that lacks a scope this request needs.
- `details` (list of ErrorDetailsItems, optional)
- `requiredScopes` (list of string, optional) — On `insufficient_scope`: every API key scope this request needs.

### 401 Unauthorized Error

Unauthorized

- `error` (string, required)
- `code` (string, optional) — Stable error code. `insufficient_scope` marks an API key that lacks a scope this request needs.
- `details` (list of ErrorDetailsItems, optional)
- `requiredScopes` (list of string, optional) — On `insufficient_scope`: every API key scope this request needs.

### 402 Payment Required Error

Audit trail not available on the current plan (category=audit requested)

- `code` (string, required)
- `error` (string, required)
- `message` (string, required)

### 403 Forbidden Error

API key lacks a read scope (FLOWS:READ, AGENTS:READ or ANALYTICS:READ)

- `error` (string, required)
- `code` (string, optional) — Stable error code. `insufficient_scope` marks an API key that lacks a scope this request needs.
- `details` (list of ErrorDetailsItems, optional)
- `requiredScopes` (list of string, optional) — On `insufficient_scope`: every API key scope this request needs.

### 500 Internal Server Error

Internal server error

- `error` (string, required)
- `code` (string, optional) — Stable error code. `insufficient_scope` marks an API key that lacks a scope this request needs.
- `details` (list of ErrorDetailsItems, optional)
- `requiredScopes` (list of string, optional) — On `insufficient_scope`: every API key scope this request needs.

### 503 Service Unavailable Error

Log store temporarily unavailable; no entries or counts could be read

- `error` (string, required)
- `code` (string, optional) — Stable error code. `insufficient_scope` marks an API key that lacks a scope this request needs.
- `details` (list of ErrorDetailsItems, optional)
- `requiredScopes` (list of string, optional) — On `insufficient_scope`: every API key scope this request needs.

## Types

### V1LogsStatsGetResponsesContentApplicationJsonSchemaData

- `byCategory` (map from string to double, required)
- `byLevel` (map from string to double, required)
- `byStatus` (map from string to double, required)
- `byType` (map from string to double, required)
- `histogram` (list of V1LogsStatsGetResponsesContentApplicationJsonSchemaDataHistogramItems, required)
- `total` (double, required)
- `coveredFrom` (string, optional, nullable) — The span plane’s earliest certified hour for this organization (ISO 8601). Counts before it are not in the store. Null when no hour is certified yet.
- `degraded` (boolean, optional) — True when the live overlay or the audit plane could not be read, so counts are partial. Absent on healthy responses, which are the only ones cached.
- `statsSource` (enum, optional) — Which tier answered these counts. Always store today; the field exists so a granularity discontinuity is a labeled one rather than an unexplained drop in total.
  - Allowed values: `store`, `legacy`, `mixed`

### V1LogsStatsGetResponsesContentApplicationJsonSchemaWindow

The time window the query resolved to, after defaults and from/to aliases.

- `from` (string, required) — Resolved start timestamp the query actually used
- `to` (string, required) — Resolved end timestamp the query actually used

### ErrorDetailsItems

- `message` (string, required)
- `code` (string, optional) — Stable Runtype validation code (e.g. MISSING_REQUIRED_FIELD, INVALID_ENUM).
- `path` (string, optional) — Dotted JSON path to the offending field.
- `suggestion` (string, optional) — Actionable hint (allowed values, accepted range, …).

### V1LogsStatsGetResponsesContentApplicationJsonSchemaDataHistogramItems

- `bucket` (string, required)
- `count` (double, required)
- `errors` (double, required)

## Examples

**Response**

```json
{
  "data": {
    "byCategory": {},
    "byLevel": {},
    "byStatus": {},
    "byType": {},
    "histogram": [
      {
        "bucket": "string",
        "count": 1.1,
        "errors": 1.1
      }
    ],
    "total": 1.1,
    "coveredFrom": "string",
    "degraded": true,
    "statsSource": "store"
  },
  "success": true,
  "window": {
    "from": "string",
    "to": "string"
  },
  "cachedAt": "string"
}
```

**SDK Code**

```python
import requests

url = "https://api.runtype.com/v1/logs/stats"

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.runtype.com/v1/logs/stats';
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.runtype.com/v1/logs/stats"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.runtype.com/v1/logs/stats")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.runtype.com/v1/logs/stats")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.runtype.com/v1/logs/stats', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.runtype.com/v1/logs/stats");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.runtype.com/v1/logs/stats")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```