Creating Agents Programmatically
Spawn and configure agents from your own code or from another agent — set the model, instructions, tools, and network settings in one call.
You can create a new agent programmatically — from your own code using the API, or from another agent using the Createst MCP (manage_agent). The new agent is a full tab with its own project context, agent, model, and tools, ready to work immediately.
Create an agent
Send a POST to the agents endpoint (or use manage_agent with action: "create" from the MCP):
curl https://createst.ai/api/v1/agents \
-H "Authorization: Bearer <your-api-key>" \
-H "Content-Type: application/json" \
-d '{
"projectKey": "<your-project-key>",
"name": "Research assistant",
"framework": "CLAUDE",
"model": "claude-sonnet-4-20250514",
"systemPrompt": "You are a research assistant.",
"initialPrompt": "Summarize the latest PRs.",
"autorun": true
}'The response includes the new tabId and whether the agent started working (started: true).
Choose the agent and model
Set framework to the agent you want (CLAUDE, OPENCODE, CODEX, or QWEN) and model to any model you have access to in the model catalog.
Set instructions
You can configure how the agent's instructions work:
systemPromptMode | Behavior |
|---|---|
"custom" (default when you provide a prompt) | Your systemPrompt replaces the built-in instructions entirely. |
"append" | Your systemPrompt is added on top of the built-in instructions — the agent keeps its base behavior plus your additions. |
"default" | The agent uses only its built-in instructions. Any systemPrompt you pass is stored but not active. |
Attach tools and skills
Pass mcpServerIds and skillIds to enable specific MCP servers and skills on the new agent. Discover available ids with list_resources({type: "mcp_server"}) or list_resources({type: "skill"}) from the MCP.
Start the agent immediately
When you include initialPrompt, the agent starts working on that prompt right away (this is the default; set autorun: false to create the tab idle instead). Poll the agent's status with get_resource({type: "agent", id: tabId}) and read its output with read_agent_output.
Make the agent callable
By default, a newly created agent is not reachable as an API endpoint. To make it callable — by other agents or your own integrations — set apiEnabled: true when you create it:
{
"apiEnabled": true,
"apiVisibility": "OWNER_ONLY"
}| Parameter | Description |
|---|---|
apiEnabled | Set to true to enable the agent's API endpoint. Default: false. |
apiVisibility | "OWNER_ONLY" (default) — only your own API key can call it. "PUBLIC" — any valid key with access to the project can call it. |
writeActionsEnabled | Whether the caller can trigger write actions (file edits, source control). Default: false. |
Choose where tools run
If you use a runner, you can direct the agent's file and terminal operations to run on your connected device:
| Parameter | Description |
|---|---|
runnerId | The runner to use. Discover runners from the MCP. |
runTargetMode | "none" (cloud, default), "selected" (the specified runner), or "all" (your full fleet). |
Route internet access
You can route the agent's outbound internet traffic through your runner or through a SOCKS5 proxy:
| Parameter | Description |
|---|---|
egressProxyMode | "runner" (tunnel through your runner) or "socks5" (external proxy). |
egressProxyRunnerId | The runner to tunnel through (when mode is "runner"). |
For SOCKS5, you can also set egressProxySocksHost, egressProxySocksPort, egressProxySocksUsername, and egressProxySocksPassword.
Sub-agents inherit their parent's settings
When you create a sub-agent (lifecycle: "ephemeral" with a parentTabId), it automatically inherits its parent's runner, internet-access, and API-endpoint settings — so the sub-agent uses the same network path and is callable in the same way. If you pass any of these parameters explicitly, your values take priority over the inherited ones.
Persistent agents (the default) do not inherit from a parent — they use your project and profile defaults.
Team-scoped agents
Pass teamId to create the agent in a team context, so it runs in that team's scope and has access to team projects. You must be a member of the team.
Choose which account to use
You can pin the agent to a specific connected account or account group:
anthropicAccountId/anthropicGroupId— for Claude-based agentsopenaiAccountId/openaiGroupId— for OpenAI-based agentsanthropicAutoRotate/openaiAutoRotate— cycle through accounts in a group automatically
Discover your connected accounts and groups with list_resources({type: "subscription_account"}) or list_resources({type: "account_group"}).