Guides
Definitions: reusable agent templates in camelRun v2
Save reusable agent configurations at PUT /v2/definitions/:slug and instantiate agents, sub-agents, and channels from them.
A definition is a named, reusable agent configuration stored per tenant and addressed by its slug (such as support-triage or code-reviewer). Definitions let you share model settings, instructions, built-in suites, webhook tools, MCP servers, queue modes, dreaming settings, and spend limits across many agents, sub-agents, and inbound channels.
Create or update a definition
Use PUT /v2/definitions/:slug (or client.definitions.upsert(slug, config)):
const def = await client.definitions.upsert("support-triage", {
model: "azure/gpt-6.2-sol",
instructions: "Triage incoming customer tickets. Ask clarifying questions when needed.",
builtins: ["files", "web_search", "human"],
mcpServers: [
{
name: "crm",
url: "https://app.example.com/mcp",
auth: { type: "runtime" },
allowTools: ["lookup_customer", "list_tickets"],
},
],
queue: { mode: "each", windowMs: 0 },
spendLimitUsd: 5,
idleTtlSeconds: 604800,
dreaming: { enabled: true, idleSeconds: 3600 },
});Over REST
# Upsert a definition
curl -s -X PUT "https://run.camelai.com/v2/definitions/support-triage" \
-H "Authorization: Bearer $CAMELRUN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "azure/gpt-6.2-sol",
"instructions": "Triage incoming customer tickets.",
"builtins": ["files", "human"],
"spendLimitUsd": 5
}'
# List all definitions
curl -s "https://run.camelai.com/v2/definitions" \
-H "Authorization: Bearer $CAMELRUN_API_KEY"
# Read one definition
curl -s "https://run.camelai.com/v2/definitions/support-triage" \
-H "Authorization: Bearer $CAMELRUN_API_KEY"
# Delete a definition
curl -s -X DELETE "https://run.camelai.com/v2/definitions/support-triage" \
-H "Authorization: Bearer $CAMELRUN_API_KEY"Create agents from a definition
Pass definition: "<slug>" when upserting an agent. Any field you pass explicitly on the agent overrides the definition's value for that field; omitted fields inherit from the definition.
const agent = await client.agents.upsert(`support-${ticketId}`, {
definition: "support-triage",
toolIdentity: {
subject: user.id,
context: { ticketId },
},
// Optionally override a single field:
spendLimitUsd: 2,
});- When an agent uses a definition and calls a signed MCP server (
auth: { type: "runtime" }), the signed JWT automatically includes thedefinitionclaim with the slug name. - Definitions can also be referenced by delegated child agents (
delegate/spawn_agentwithdefinition: "<slug>") and by channels (POST /v2/channelswithdefinition: "<slug>"). - Updating a definition affects agents created or re-upserted afterward. To update an existing agent with a definition's latest config, call
PUT /v2/agents/:keywith{ definition: "<slug>" }.
All /v2/definitions endpoints require a tenant API key (cr_live_...).