Agents API
Create, configure and run agents from your own software. Every agent lives in a workspace and a team, so its policies, budgets and permissions follow the same rules as an agent created in the dashboard.
Base path: /api/v1/agents. Permissions: agents:read to read, agents:write to change, agents:execute to run, agents:delete to delete.
List agents
GET /api/v1/agents
| Parameter | Type | Description |
|---|---|---|
page | integer | Page number (default 1) |
limit | integer | Results per page (default 100) |
appId | string | Only agents in this workspace |
teamId | string | Only agents in this team |
skill | string | Only agents that have this skill (by slug) |
{
"agents": [
{
"id": "agent_abc123",
"name": "Lead Qualifier",
"model": "claude-sonnet-latest",
"status": "active",
"appId": "app_456",
"teamId": "team_789"
}
],
"meta": { "total": 12, "page": 1, "limit": 100, "hasMore": false }
}
You only see agents in workspaces you can access.
Create an agent
POST /api/v1/agents
| Field | Type | Required | Description |
|---|---|---|---|
appId | string | Yes | Workspace the agent belongs to |
teamId | string | One of the two | Existing team to add the agent to |
createTeam | boolean | One of the two | true creates a new team for this agent |
newTeamName | string | No | Name of that new team (defaults to the agent's name) |
name | string | Yes | 2-100 characters |
description | string | No | Up to 1,000 characters |
model | string | No | Model id or alias. Default: claude-sonnet-latest |
systemPrompt | string | No | Role, personality and method, up to 10,000 characters |
contextPrompt | string | No | Company or customer context, up to 10,000 characters |
parentAgentId | string | No | The agent this one reports to |
templateId | string | No | Start from an agent template |
Pass exactly one of teamId or createTeam. Without either, the API answers 400 with "code": "TEAM_REQUIRED". A retired model is refused with "error": "model_retired" and the recommended replacement; a model being phased out is accepted with an X-Model-Warning header.
curl -X POST https://api.meetloyd.com/api/v1/agents \
-H "Authorization: Bearer $MEETLOYD_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"appId": "app_456",
"teamId": "team_789",
"name": "FAQ Assistant",
"systemPrompt": "You answer questions about our return policy."
}'
The response (201) is the new agent.
Read, update, delete
GET /api/v1/agents/:id
PATCH /api/v1/agents/:id
DELETE /api/v1/agents/:id
PATCH changes only the fields you send: name, description, model, systemPrompt, contextPrompt, status (active or paused) and more. Every change to an agent's behaviour is recorded in its change history, so it can be compared and rolled back from the dashboard.
Run an agent
POST /api/v1/agents/:id/execute
| Field | Type | Required | Description |
|---|---|---|---|
message | string | Yes | What you ask the agent, up to 100,000 characters |
conversationId | string | No | Continue an existing conversation |
options.maxTokens | integer | No | Cap the length of the answer |
options.temperature | number | No | 0-2 |
options.tools | string[] | No | Restrict the tools the agent may use for this run |
The call waits for the agent to finish and returns the run:
{
"id": "run_789",
"agentId": "agent_abc123",
"status": "completed",
"output": "Our return window is 30 days from delivery…",
"toolCalls": [],
"tokenUsage": { "input": 1250, "output": 340, "total": 1590 },
"cost": 0.0034,
"duration": 2340
}
A failed run answers 500 with the run and its error. 402 means your organisation's model key ran out of credit; 423 means an administrator halted the agent or its team.
For a streamed, token-by-token answer, start a conversation and send messages to it.
Pause and resume
POST /api/v1/agents/:id/pause
POST /api/v1/agents/:id/resume
A paused agent refuses new runs (400, "error": "agentInactive") until it is resumed. Its conversations and history are kept.
Run history
GET /api/v1/agents/:id/runs?page=1&limit=50
Each run carries its input, output, tool calls, token usage, cost, duration and status.
Duplicate an agent
POST /api/v1/agents/:id/duplicate
Optional body: { "name": "…" }. The copy keeps the prompts, model and configuration under a new id.
Just ask Loyd
In the dashboard you can ask Loyd to "pause the outreach agent" or "give the support agent the ticket-triage skill". To add agents, ask Loyd to design the team you need: it drafts a team blueprint and deploys it with you.