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

# Roll up recent runs of an agent

GET https://api.runtype.com/v1/agents/{id}/run-insights

Aggregates the agent's most recent runs into per-version and per-tool counts, average tokens and cost, and the attached tools that were never called in the window. Backs the run-detail advice strip; the counts are evidence about a version, not billing figures.

Reference: https://docs.runtype.com/api-reference/runtype-api/agents/roll-up-recent-runs-of-an-agent

## 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

### Path parameters

- `id` (string, required)

### Query parameters

- `limit` (string, optional) — How many recent runs to roll up (default 50, max 200)

## Response

### 200

Run insights for the agent

- `data` (V1AgentsIdRunInsightsGetResponsesContentApplicationJsonSchemaData, required)
- `success` (boolean, required)

## 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.

### 403 Forbidden Error

Insufficient permissions

- `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.

### 404 Not Found Error

Agent not found

- `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.

## Types

### V1AgentsIdRunInsightsGetResponsesContentApplicationJsonSchemaData

- `attachedTools` (list of string, required)
- `attachedToolsRuns` (integer, required) — Runs in the window on that version, the only runs neverCalledTools is judged over
- `attachedToolsVersionId` (string, required, nullable) — The version attachedTools was read from; null when the agent has no published version
- `cost` (V1AgentsIdRunInsightsGetResponsesContentApplicationJsonSchemaDataCost, required, nullable)
- `neverCalledTools` (list of string, required)
- `tokens` (V1AgentsIdRunInsightsGetResponsesContentApplicationJsonSchemaDataTokens, required, nullable)
- `tools` (list of V1AgentsIdRunInsightsGetResponsesContentApplicationJsonSchemaDataToolsItems, required)
- `versions` (list of V1AgentsIdRunInsightsGetResponsesContentApplicationJsonSchemaDataVersionsItems, required)
- `window` (V1AgentsIdRunInsightsGetResponsesContentApplicationJsonSchemaDataWindow, required)

### 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, …).

### V1AgentsIdRunInsightsGetResponsesContentApplicationJsonSchemaDataCost

- `avgPerRun` (double, required)

### V1AgentsIdRunInsightsGetResponsesContentApplicationJsonSchemaDataTokens

- `avgInputPerRun` (double, required)
- `avgPerRun` (double, required)

### V1AgentsIdRunInsightsGetResponsesContentApplicationJsonSchemaDataToolsItems

- `calls` (integer, required)
- `failedCalls` (integer, required)
- `runsUsing` (integer, required)
- `toolName` (string, required)

### V1AgentsIdRunInsightsGetResponsesContentApplicationJsonSchemaDataVersionsItems

- `agentVersionId` (string, required, nullable)
- `failed` (integer, required)
- `label` (string, required, nullable)
- `runs` (integer, required)
- `versionNumber` (integer, required, nullable) — The immutable version number, for ordering; labels are user-set

### V1AgentsIdRunInsightsGetResponsesContentApplicationJsonSchemaDataWindow

- `from` (string, required, nullable)
- `runs` (integer, required)
- `to` (string, required, nullable)

## Examples

**Response**

```json
{
  "data": {
    "attachedTools": [
      "string"
    ],
    "attachedToolsRuns": 1,
    "attachedToolsVersionId": "string",
    "cost": {
      "avgPerRun": 1.1
    },
    "neverCalledTools": [
      "string"
    ],
    "tokens": {
      "avgInputPerRun": 1.1,
      "avgPerRun": 1.1
    },
    "tools": [
      {
        "calls": 1,
        "failedCalls": 1,
        "runsUsing": 1,
        "toolName": "string"
      }
    ],
    "versions": [
      {
        "agentVersionId": "string",
        "failed": 1,
        "label": "string",
        "runs": 1,
        "versionNumber": 1
      }
    ],
    "window": {
      "from": "string",
      "runs": 1,
      "to": "string"
    }
  },
  "success": true
}
```

**SDK Code**

```python
import requests

url = "https://api.runtype.com/v1/agents/id/run-insights"

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

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

print(response.json())
```

```javascript
const url = 'https://api.runtype.com/v1/agents/id/run-insights';
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/agents/id/run-insights"

	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/agents/id/run-insights")

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/agents/id/run-insights")
  .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/agents/id/run-insights', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.runtype.com/v1/agents/id/run-insights");
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/agents/id/run-insights")! 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()
```