> ## Documentation Index
> Fetch the complete documentation index at: https://docs.runlayer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# API

> Programmatically manage your Runlayer platform

## Management API

The Runlayer platform provides a RESTful API for programmatic management of your organization's MCP infrastructure.

**Key Capabilities**:

* **Server Management**: Create, update, and delete MCP servers
* **User Operations**: Read user information and permissions
* **Audit Logs**: Query activity history and security events
* **Analytics**: Access usage metrics and insights

## Coverage by Data Type

Use this table to decide which public surface to start from:

| Data or configuration | Public surface |
| - | - |
| **Connectors / MCP servers** | Management API, dashboard, [Runlayer MCP](https://docs.runlayer.com/runlayer-mcp.md) |
| **Audit logs and security events** | API/CLI, [Runlayer MCP](https://docs.runlayer.com/runlayer-mcp.md), [S3 SIEM export](https://docs.runlayer.com/platform-audit-logs.md#siem-export-s3) |
| **Analytics / usage / cost dashboards** | Dashboard and Runlayer MCP CSV exports; exact API schemas are available at `/docs` on your tenant |
| **Agent runs: start, status, cancel, continue** | [Agent runs API](#agent-runs) |
| **Agents: creator, consumers, sharing, token usage** | [Agent Usage Feed](#agent-usage-feed) API; [warehouse recipes](https://docs.runlayer.com/cookbook-agent-usage-feed.md); [Runlayer MCP](https://docs.runlayer.com/runlayer-mcp.md) `get_agent_usage_report` |
| **Searching agents, skills and connectors** (catalog or "discover first" pages) | [Search API](#search-agents-skills-and-connectors); [Runlayer MCP](https://docs.runlayer.com/runlayer-mcp.md) `list_agents`, `list_skills`, `list_servers` |
| **Policies and roles** | Dashboard; API coverage depends on tenant version and is documented in `/docs` |
| **Sessions and incidents** | Dashboard-first in public docs; full session content via [session SIEM export](https://docs.runlayer.com/platform-sessions.md#siem-export); audit events for policy/security decisions are exportable through audit-log paths |
| **Webhooks / OTEL exports** | OTLP ingestion is documented for [Claude Code](https://docs.runlayer.com/claude-code-otlp-monitoring.md) and [Claude Cowork](https://docs.runlayer.com/claude-cowork-monitoring.md), and Glean traces are also accepted; public docs do not document a general outbound webhook export for sessions or incidents |

> [!NOTE]
>
> For interactive request/response schemas and a built-in API explorer, visit `/docs` on your hosted Runlayer instance. It lists the connector (server) and current-user endpoints. The agent endpoints are documented on this page.

***

## Authentication

For personal or organization API keys, send the key in the `x-runlayer-api-key` header. Do not send API keys as bearer tokens. The base URL is your Runlayer instance with the `/api/v1` prefix.

```bash theme={null}
export RUNLAYER_API_KEY="rl_..."
export RUNLAYER_BASE_URL="https://<your-tenant>.runlayer.com"

# List the servers you can access
curl "$RUNLAYER_BASE_URL/api/v1/servers" \
  -H "x-runlayer-api-key: $RUNLAYER_API_KEY"
```

Responses are JSON. Standard HTTP status codes apply — `401` for a missing or invalid key, `403` when the key's role lacks access to the endpoint.

***

## Agent runs

Start an agent run from your own code, poll it, cancel it, and continue the conversation. Use a personal API key. The run executes as the key's owner, with that person's access and connected accounts, and needs an agent they can run. Organization API keys and agent account keys aren't accepted here.

```bash theme={null}
# Start a run. Returns 202 right away with {"run": {...}}; keep run.id
curl -X POST "$RUNLAYER_BASE_URL/api/v1/agents/$AGENT_ID/runs" \
  -H "x-runlayer-api-key: $RUNLAYER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"input": "Review pull request 42 in acme/repo-a"}'

# Status and result
curl "$RUNLAYER_BASE_URL/api/v1/agents/$AGENT_ID/runs/$RUN_ID" \
  -H "x-runlayer-api-key: $RUNLAYER_API_KEY"

# Cancel (no body)
curl -X POST "$RUNLAYER_BASE_URL/api/v1/agents/$AGENT_ID/runs/$RUN_ID/cancel" \
  -H "x-runlayer-api-key: $RUNLAYER_API_KEY"
```

| Endpoint | What it does |
| - | - |
| `POST /api/v1/agents/{agent_id}/runs` | Starts a run. Body: `input` (required). Optional: `runId` to continue a finished run, `messages` (earlier `user`/`assistant` turns as context). Returns `202` with `run` |
| `GET /api/v1/agents/{agent_id}/runs/{run_id}` | The run: `status`, `output`, `error`, `failure_reason`, `started_at`, `finished_at`, `duration_ms`, token counts, `total_cost_usd`, `can_cancel`, and the step-by-step trace in `grouped_steps` |
| `POST /api/v1/agents/{agent_id}/runs/{run_id}/cancel` | Stops a running run and returns it |
| `GET /api/v1/agents/{agent_id}/runs` | Lists runs, newest first. `skip`, `limit` (up to 100), `start_date`, `end_date`, `own_only`. Returns `data` and `count` |
| `POST /api/v1/agents/{agent_id}/runs/{run_id}/retry` | Starts a new run with a failed run's input. Returns `202` with `run` |

* **Agent ID:** the UUID in the app URL (`/agents/<agent-id>`), or search with `GET /api/v1/agents?query=`.
* **Status:** `running` until it ends as `succeeded`, `failed` or `cancelled`. Poll every 10 to 15 seconds. `succeeded` means the agent finished its turn; read `output` for what it said.
* **Continue a conversation:** pass the `id` of a finished run you started as `runId` (camelCase). The new run picks up the same conversation.
* **Cancel:** works while `can_cancel` is `true`. Otherwise you get `400` ("This run's runtime does not support cancellation"). A run that already ended comes back unchanged. `409` means the cancel didn't settle; read the run again before retrying.
* **Who can read a run:** you can read runs you started. The agent's owner and editors can read everyone's. With workspace content redaction on, other people's runs come back with `input`, `output` and `error` empty and `is_redacted: true` unless you've unlocked them. Their `grouped_steps` keep each step's kind, tool, tokens and timing, with `***REDACTED***` in place of its text and error and no raw events or attachments.
* **Errors when starting:** `400` empty `input`; `403` the agent isn't shared with you or you can only view it; `404` no such agent; `429` the agent hit its [run limit or cost budget](https://docs.runlayer.com/platform-agents.md#usage-limits).
* **No OTLP export of runs:** agent runs aren't sent to your OpenTelemetry collector. To get them into your own tooling, use the [audit-log SIEM export](https://docs.runlayer.com/platform-audit-logs.md#siem-export-s3) (`agent_run`, `agent_run_success` and `agent_run_failure` events, plus `tool_call*` events that carry the run's `agent_id` and `run_id`), the [session SIEM export](https://docs.runlayer.com/platform-sessions.md#siem-export) for full transcripts, or read each run from this API (duration, token counts, `total_cost_usd`, `grouped_steps`) and convert it yourself.
* **No callbacks yet:** Runlayer doesn't push completion events or heartbeats to your system, so poll. For progress updates, tell the agent to call your endpoint itself over HTTPS and allow that host in its [network access policy](https://docs.runlayer.com/platform-agents.md#network-access-policy).

To start runs from a system that shouldn't hold a person's key, use an agent [webhook](https://docs.runlayer.com/platform-agents.md#set-up-an-agent) instead.

***

## Agent Usage Feed

`GET /api/v1/agents/metrics/usage` returns every agent in your organization, newest first, with its creator, its consumers, who it is shared with, and its token usage over a date range. Use it to feed agent data into a BI tool or data warehouse; [Pull Agent Usage into Your Warehouse](https://docs.runlayer.com/cookbook-agent-usage-feed.md) has copy-paste recipes.

The caller needs both the **View company metrics** and **Export usage data** permissions. Admins, Security Admins, and Analytics Admins have both. Use a personal API key from a user who holds them.

```bash theme={null}
curl "$RUNLAYER_BASE_URL/api/v1/agents/metrics/usage?start_date=2026-09-01T00:00:00Z&end_date=2026-10-01T00:00:00Z&limit=100" \
  -H "x-runlayer-api-key: $RUNLAYER_API_KEY"
```

| Parameter | Default | Notes |
| - | - | - |
| `start_date`, `end_date` | Last 30 days | ISO 8601. Usage counts runs started in this range. The range must sit inside the retention window your tenant keeps queryable |
| `limit` | `100` | 1–100 agents per page |
| `cursor` | — | Pass the previous response's `next_cursor` to get the next page. Stop when `next_cursor` is `null`. Agents created while you page don't shift later pages |
| `consumer_limit` | `10` | 1–50 top consumers returned per agent |

The response has `count` (total agents), `next_cursor`, and `data`. Each item in `data` carries:

* `id`, `name`, `description`, `is_disabled`, `created_at`
* `creator`: `id`, `email`, `full_name` of the agent's current owner. That's the user who created it, unless ownership was transferred (for example when the creator was offboarded)
* `usage`: `run_count`, `cost_usd`, and token counts over the range, counting every run, including eval and test runs (they spend tokens too). `input_tokens` is uncached prompt tokens; `cache_read_tokens` and `cache_creation_tokens` are counted separately; `reasoning_tokens` is 0 where the model bills reasoning inside `output_tokens`. The buckets don't overlap, and `total_tokens` is their sum
* `consumer_count`: how many users started a run of the agent in the range
* `consumers`: the top `consumer_limit` of those users by run count, each with the same `usage` breakdown for their own runs. Automated runs (schedules, webhooks, triggers) count toward the user each run is attributed to on the agent's Runs tab
* `share_scope`: `private` (owner only), `specific` (shared with chosen users or groups), or `organization` (everyone in the org). An agent made visible to the whole workspace reads `organization` even without an `organization` entry in `shared_with`
* `shared_with_count` and `shared_with`: who can use the agent, one entry per grant, listing up to 50 (`shared_with_count` is the full total; page every grant with `GET /api/v1/agents/{agent_id}/shares`). Grants to deleted users, groups, or teams are left out of both fields and of `share_scope`. Each has `principal_type` (`user`, `group`, `role`, `team`, or `organization`), `principal_id`, `name`, `email` (users only), and `permission` (`can_use` or `can_edit`). Groups and teams are listed as one entry, not expanded to their members

`consumers` is who actually used the agent in the range. `shared_with` is who has access, whether they used it or not.

Agents with no runs in the range are still listed, with zero usage.

What the feed leaves out, so you can reconcile it:

* **Deleted agents and Runlayer's built-in agents** (Runlayer Assistant, Researcher) aren't listed, even for runs inside the range, so totals won't match billing.
* **Deleting an agent removes its history from the feed.** With the cookbook's "replace the last two days" sync, a deleted agent's last two days of usage also disappear from your warehouse.
* **`name`, `creator`, `share_scope`, and `shared_with` are current state at pull time**, not as of the date range. Only `usage` and `consumers` are scoped to the range.

Usage comes from each agent run's own accounting, the same numbers as an agent's cost card and Monitor tab. The **Enterprise AI Usage** tab on the Usage page counts session-level spend across all AI clients, so its totals won't match this feed.

Runs still in progress report their tokens once they finish, so the most recent day can still change. When loading into a warehouse, re-pull the last two days on each sync instead of only appending new ones.

### All consumers of one agent

When `consumer_count` is larger than `consumers`, page the full list with `GET /api/v1/agents/{agent_id}/metrics/consumers`. It takes the same `start_date`, `end_date`, and `cursor` parameters, plus `limit` (1–500, default 100), and returns `next_cursor` and `data` (each entry has `user` and `usage`).

### Large ranges

Both endpoints sum individual runs and return `422` rather than a slow or partial answer when there are more than 100,000 in the range:

* **Agent usage feed:** counts the runs of every agent on the page. Narrow the date range or lower `limit` and retry.
* **Consumers of one agent:** counts that agent's runs only, so `limit` doesn't help. Narrow the date range.

***

## Search agents, skills and connectors

Use these endpoints to build your own catalog or "discover first" page, so people find an existing agent, skill or connector before building a new one. Each one returns only what the caller can access. Call them with a personal API key or a user token, so results match the person searching.

```bash theme={null}
# Agents for a job, most-used first
curl "$RUNLAYER_BASE_URL/api/v1/agents?query=release%20notes&sort_by=user_count&sort_order=desc&limit=20" \
  -H "x-runlayer-api-key: $RUNLAYER_API_KEY"

# Skills
curl "$RUNLAYER_BASE_URL/api/v1/skills?query=release%20notes&limit=20" \
  -H "x-runlayer-api-key: $RUNLAYER_API_KEY"

# Active connectors the caller can use
curl "$RUNLAYER_BASE_URL/api/v1/servers?scope=accessible&query=github&limit=20" \
  -H "x-runlayer-api-key: $RUNLAYER_API_KEY"
```

* `query` matches the name or description. For agents, every word must match in any order, so `release notes` also finds "Notes for each release".
* Agents: `filter=org_wide` lists only agents shared with the whole workspace. `sort_by` takes `created_at`, `name`, `last_used_at`, `run_count` or `user_count` (distinct people who ran it). Each agent includes `description`, `created_by_name`, `run_count`, `user_count`, `last_used_at` and its connector and skill counts.
* Page with `skip` and `limit` (up to 100 per page; 500 for connectors). Each response has `data` and `count`.

The same searches are available to AI clients as the Runlayer MCP tools `list_agents`, `list_skills` and `list_servers`. See [Find an existing agent before you build](https://docs.runlayer.com/platform-agents.md#discover-first).

***

## Artifacts and public links

List artifacts, read their content, and turn public links off from your own tools, for example to feed a DLP scanner. Use a personal API key. Results follow the key owner's access: a user with **Manage Agents** can reach every artifact in the workspace.

```bash theme={null}
# Every artifact in the workspace (Manage Agents), newest first
curl "$RUNLAYER_BASE_URL/api/v1/artifacts?filter=full_access_by_me&limit=100&skip=0" \
  -H "x-runlayer-api-key: $RUNLAYER_API_KEY"

# One artifact, then its current content
curl "$RUNLAYER_BASE_URL/api/v1/artifacts/$ARTIFACT_ID" \
  -H "x-runlayer-api-key: $RUNLAYER_API_KEY"
curl -L "$RUNLAYER_BASE_URL/api/v1/artifacts/$ARTIFACT_ID/content" \
  -H "x-runlayer-api-key: $RUNLAYER_API_KEY" -o artifact.bin

# Turn a public link off
curl -X PUT "$RUNLAYER_BASE_URL/api/v1/artifacts/$ARTIFACT_ID/public-access" \
  -H "x-runlayer-api-key: $RUNLAYER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"is_public": false}'
```

* `filter` takes `created_by_me` (default), `shared_with_me`, `all`, `editable_by_me` or `full_access_by_me`. With **Manage Agents**, `full_access_by_me` returns every artifact in the workspace, including ones nobody shared with the caller.
* Each artifact includes `is_public` and `public_requires_email`. Callers with full access also get `public_url`, `public_expires_at` and `public_opens_left`. A link counts as public only while it's live: it ends 30 days after it was turned on or after 5 opens. See [Public links](https://docs.runlayer.com/artifacts/sharing.md#public-links).
* Page with `skip` and `limit` (up to 100 per page). The response has `data` and `count`.
* With full access to the artifact, you can always turn its link off. Turning one on through the API needs the same organization setting as the app.
* There is no webhook before a link goes public. To react when one is turned on, watch the audit log for `agent_artifact_public_access_changed` (with `is_public` and `requires_email`), through [SIEM Export](https://docs.runlayer.com/platform-audit-logs.md#siem-export-s3) or the Runlayer MCP `export_audit_logs` tool. Admins can also turn public links off for the whole workspace in **Settings** → **Artifacts**.

***

## API Keys

Create API keys in **Settings → Personal API keys** or **Settings → Organization API keys**. (For a map of all admin settings pages, see [Where to Find Key Settings](https://docs.runlayer.com/platform-roles.md#where-to-find-key-settings).)

* **Personal API keys** authenticate as the user who created them and work for user-scoped management API calls.
* **Organization API keys** authenticate as the workspace and are scoped by role. Use them for workload-specific automation that should not depend on a user's session.
* **Agent account API keys** authenticate as an agent account on the MCP gateway only, not on the management API. Create them from the agent account page (**⋯ → Manage API keys**). See [Using an API key](https://docs.runlayer.com/platform-agent-accounts.md#using-an-api-key).

Organization API key roles include:

| Role | Use case |
| - | - |
| Deploy | CI/CD workflows that initialize, validate, deploy, pull, and destroy Runlayer Deploy deployments |
| Shadow AI Scan | AI Watch scan, hook, and OTLP submissions. Minted automatically by a configuration in **Settings → MDM configuration**; not selectable when creating a key by hand |
| Security Scan | Security scanner API submissions |
| Cursor Cloud Hooks | Write-only, monitor-only [Cursor Cloud Agent session ingestion](https://docs.runlayer.com/shadow-ai/cursor-cloud-agents.md) |
| Grok Bot Hooks | Write-only, monitor-only [Grok Bot session ingestion](https://docs.runlayer.com/shadow-ai/grok-bot.md) |
| OTLP Telemetry | Write-only, monitor-only OpenTelemetry ingestion (logs, metrics, traces) from AI clients such as [Claude Code](https://docs.runlayer.com/claude-code-otlp-monitoring.md), [Claude Cowork](https://docs.runlayer.com/claude-cowork-monitoring.md), and Glean |

> [!NOTE]
>
> For deploy pipelines, see [CI/CD with organization API keys](https://docs.runlayer.com/platform-deploy.md#cicd-with-organization-api-keys).

***

## Related Resources

> [card] [Analytics](https://docs.runlayer.com/platform-analytics.md)
>
> View usage metrics

> [card] [Audit Logs](https://docs.runlayer.com/platform-audit-logs.md)
>
> Activity history


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.