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

# Count runs per product

GET https://api.runtype.com/v1/runs/stats/products

Total and failed runs for several products in one read, over the same window and `traffic` filter as `GET /v1/runs/stats`. A product counts its agent capabilities' runs by `agentId` and its other capabilities' runs by `flowId`, each family read the way `/v1/runs/stats` reads it, and the two summed. Name at most 100 products; one the caller does not own is left out, as is one that does not exist. An API key needs PRODUCTS:READ, plus AGENTS:READ or FLOWS:READ for each family the named products run.

Reference: https://docs.runtype.com/api-reference/runtype-api/runs/count-runs-per-product

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

- `traffic` (enum, optional) — live keeps runs real users and integrations started; test keeps runs started from the dashboard (Test, step tests, Ask); eval keeps eval-batch runs; sim keeps simulation turns; all, or omitted, keeps every run. A simulation turn is sim even when a schedule started it, a schedule run is live, and an eval batch run is eval whoever started it.
  - Allowed values: `live`, `test`, `eval`, `sim`, `all`
- `from` (string, optional) — Window start (ISO 8601). Defaults to 24 hours ago.
- `to` (string, optional) — Window end (ISO 8601). Defaults to now.
- `productIds` (string, required) — Comma-separated product ids, at most 100. A product the caller does not own is left out of the answer.

## Response

### 200

Run counts per product returned

- `data` (RunProductStats, required)
- `window` (V1RunsStatsProductsGetResponsesContentApplicationJsonSchemaWindow, required) — The started_at window the query resolved to, after defaults.

## Errors

### 400 Bad Request Error

Invalid request, including a filter whose value could not 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.

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

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

Run store temporarily unavailable; nothing could be read. Retry after the `Retry-After` interval (seconds).

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

## Types

### RunProductStats

- `byProductId` (map from string to RunProductStatsByProductId, required) — One entry per named product the caller owns, a product with no flow or agent reading zero. Each sums `/v1/runs/stats` for its flows and for its agents, read one family at a time.

### V1RunsStatsProductsGetResponsesContentApplicationJsonSchemaWindow

The started_at window the query resolved to, after defaults.

- `from` (string, required)
- `to` (string, 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, …).

### RunStoreUnavailableErrorDetailsItems

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

### RunProductStatsByProductId

- `failed` (integer, required) — Of those, the runs that read as failed in `/v1/runs` (the same predicate as `status=failed`).
- `total` (integer, required) — Runs of the product's flows plus runs of its agents.

## Examples

**Response**

```json
{
  "data": {
    "byProductId": {}
  },
  "window": {
    "from": "string",
    "to": "string"
  }
}
```

**SDK Code**

```python
import requests

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

querystring = {"productIds":"productIds"}

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

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

print(response.json())
```

```javascript
const url = 'https://api.runtype.com/v1/runs/stats/products?productIds=productIds';
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/runs/stats/products?productIds=productIds"

	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/runs/stats/products?productIds=productIds")

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/runs/stats/products?productIds=productIds")
  .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/runs/stats/products?productIds=productIds', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.runtype.com/v1/runs/stats/products?productIds=productIds");
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/runs/stats/products?productIds=productIds")! 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()
```