Skip to main content
POST
Create Task

Create Task

Create a new task and start background AI agent execution. The endpoint returns immediately with the task ID. Connect to the Stream endpoint to receive real-time updates.

Request

You can authenticate with either an API key (sigmic_...) or a JWT token (eyJ...) from Widget Authentication.

Form Fields

Environment Variables

Both env and secrets accept key-value string maps. They are injected into the sandbox as process.env variables and as MCP server context for {{mcp.KEY}} template resolution.
  • env — Non-sensitive config (tenant IDs, feature flags). Stored with the task and returned in GET responses for debugging.
  • secrets — Sensitive credentials (API tokens, database URLs). Never stored, never logged, never returned in any response.
  • Keys must be valid env var names: letters, digits, and underscores, starting with a letter or underscore.
  • If the same key appears in both, secrets takes precedence.
When using env or secrets, send the request as application/json instead of multipart/form-data. File uploads require multipart/form-data and cannot be combined with env/secrets in the same request.

File Upload Notes

  • ZIP files are automatically extracted into the workspace
  • Files are uploaded to the workspace uploads/ directory
  • File paths are included in the context sent to the agent
  • Maximum 20 files per request
  • Maximum 50MB per file

Response

Returns JSON with the task ID. Execution starts in the background.
After receiving the task ID, connect to GET /api/v1/tasks/:id/stream to receive real-time execution events including history replay and live streaming.

Examples

Basic Task

With File Upload

With Manual Tool Approval

Set autoExecute=false to review tool calls before they execute:
When a tool call requires approval, the stream will emit a tool_call event with status: awaiting_approval. You can also poll GET /api/v1/tasks/:id and check the pendingApprovals array. Use the Approve Tool Call endpoint to approve or reject it.

With Environment Variables

Inject credentials and configuration into the sandbox:
The agent’s sandbox will have TENANT_ID, REPORT_FORMAT, and DATABASE_URL available as process.env variables. MCP servers configured with {{mcp.DATABASE_URL}} in their headers will have the value resolved automatically.

With Custom System Prompt

Errors