# Workers ## Create a worker **post** `/api/workers` Create a new agent worker and start it with the supplied instruction. ### Body Parameters - `input: string` - `budget: optional "low" or "standard" or "high" or "unlimited"` - `"low"` - `"standard"` - `"high"` - `"unlimited"` - `stream: optional boolean` ### Returns - `Worker object { id, created_at, error, 12 more }` - `id: string` - `created_at: number` - `error: unknown` - `files: array of object { filename, mediaType, url }` - `filename: string` - `mediaType: string` - `url: string` - `incomplete_details: unknown` - `messages: array of unknown` - `metadata: map[unknown]` - `object: "worker"` - `"worker"` - `output: array of object { id, content, role, 2 more }` - `id: string` - `content: array of object { text, type }` - `text: string` - `type: "output_text"` - `"output_text"` - `role: "assistant"` - `"assistant"` - `status: "completed"` - `"completed"` - `type: "message"` - `"message"` - `output_text: string` - `running: boolean` - `sources: array of object { id, title, type, url }` - `id: string` - `title: string` - `type: "url"` - `"url"` - `url: string` - `status: "running" or "completed" or "pending"` - `"running"` - `"completed"` - `"pending"` - `costs: optional object { internalCostUsd, modelCostUsd, sandboxCostUsd, toolCostUsd }` - `internalCostUsd: number` - `modelCostUsd: number` - `sandboxCostUsd: number` - `toolCostUsd: number` - `usage: optional object { cacheReadTokens, cacheWriteTokens, costUsd, 6 more }` - `cacheReadTokens: number` - `cacheWriteTokens: number` - `costUsd: number` - `inputTokens: number` - `outputTokens: number` - `reasoningTokens: number` - `steps: number` - `totalTokens: number` - `credits: optional number` ### Example ```http curl https://v3.handinger.com/api/workers \ -H 'Content-Type: application/json' \ -H "Authorization: Bearer $HANDINGER_API_KEY" \ -d '{ "input": "x" }' ``` #### Response ```json { "id": "id", "created_at": 0, "error": null, "files": [ { "filename": "filename", "mediaType": "mediaType", "url": "url" } ], "incomplete_details": null, "messages": [ {} ], "metadata": { "foo": "bar" }, "object": "worker", "output": [ { "id": "id", "content": [ { "text": "text", "type": "output_text" } ], "role": "assistant", "status": "completed", "type": "message" } ], "output_text": "output_text", "running": true, "sources": [ { "id": "id", "title": "title", "type": "url", "url": "url" } ], "status": "running", "costs": { "internalCostUsd": 0, "modelCostUsd": 0, "sandboxCostUsd": 0, "toolCostUsd": 0 }, "usage": { "cacheReadTokens": 0, "cacheWriteTokens": 0, "costUsd": 0, "inputTokens": 0, "outputTokens": 0, "reasoningTokens": 0, "steps": 0, "totalTokens": 0, "credits": 0 } } ``` ## Retrieve a worker **get** `/api/workers/{workerId}` Retrieve the current worker state. Pass stream=true or request text/event-stream to subscribe to updates. ### Path Parameters - `workerId: string` ### Query Parameters - `stream: optional boolean` Return a server-sent event stream instead of JSON. ### Returns - `Worker object { id, created_at, error, 12 more }` - `id: string` - `created_at: number` - `error: unknown` - `files: array of object { filename, mediaType, url }` - `filename: string` - `mediaType: string` - `url: string` - `incomplete_details: unknown` - `messages: array of unknown` - `metadata: map[unknown]` - `object: "worker"` - `"worker"` - `output: array of object { id, content, role, 2 more }` - `id: string` - `content: array of object { text, type }` - `text: string` - `type: "output_text"` - `"output_text"` - `role: "assistant"` - `"assistant"` - `status: "completed"` - `"completed"` - `type: "message"` - `"message"` - `output_text: string` - `running: boolean` - `sources: array of object { id, title, type, url }` - `id: string` - `title: string` - `type: "url"` - `"url"` - `url: string` - `status: "running" or "completed" or "pending"` - `"running"` - `"completed"` - `"pending"` - `costs: optional object { internalCostUsd, modelCostUsd, sandboxCostUsd, toolCostUsd }` - `internalCostUsd: number` - `modelCostUsd: number` - `sandboxCostUsd: number` - `toolCostUsd: number` - `usage: optional object { cacheReadTokens, cacheWriteTokens, costUsd, 6 more }` - `cacheReadTokens: number` - `cacheWriteTokens: number` - `costUsd: number` - `inputTokens: number` - `outputTokens: number` - `reasoningTokens: number` - `steps: number` - `totalTokens: number` - `credits: optional number` ### Example ```http curl https://v3.handinger.com/api/workers/$WORKER_ID \ -H "Authorization: Bearer $HANDINGER_API_KEY" ``` #### Response ```json { "id": "id", "created_at": 0, "error": null, "files": [ { "filename": "filename", "mediaType": "mediaType", "url": "url" } ], "incomplete_details": null, "messages": [ {} ], "metadata": { "foo": "bar" }, "object": "worker", "output": [ { "id": "id", "content": [ { "text": "text", "type": "output_text" } ], "role": "assistant", "status": "completed", "type": "message" } ], "output_text": "output_text", "running": true, "sources": [ { "id": "id", "title": "title", "type": "url", "url": "url" } ], "status": "running", "costs": { "internalCostUsd": 0, "modelCostUsd": 0, "sandboxCostUsd": 0, "toolCostUsd": 0 }, "usage": { "cacheReadTokens": 0, "cacheWriteTokens": 0, "costUsd": 0, "inputTokens": 0, "outputTokens": 0, "reasoningTokens": 0, "steps": 0, "totalTokens": 0, "credits": 0 } } ``` ## Continue a worker **post** `/api/workers/{workerId}` Send another instruction to an existing worker. ### Path Parameters - `workerId: string` ### Body Parameters - `input: string` - `budget: optional "low" or "standard" or "high" or "unlimited"` - `"low"` - `"standard"` - `"high"` - `"unlimited"` - `stream: optional boolean` ### Returns - `Worker object { id, created_at, error, 12 more }` - `id: string` - `created_at: number` - `error: unknown` - `files: array of object { filename, mediaType, url }` - `filename: string` - `mediaType: string` - `url: string` - `incomplete_details: unknown` - `messages: array of unknown` - `metadata: map[unknown]` - `object: "worker"` - `"worker"` - `output: array of object { id, content, role, 2 more }` - `id: string` - `content: array of object { text, type }` - `text: string` - `type: "output_text"` - `"output_text"` - `role: "assistant"` - `"assistant"` - `status: "completed"` - `"completed"` - `type: "message"` - `"message"` - `output_text: string` - `running: boolean` - `sources: array of object { id, title, type, url }` - `id: string` - `title: string` - `type: "url"` - `"url"` - `url: string` - `status: "running" or "completed" or "pending"` - `"running"` - `"completed"` - `"pending"` - `costs: optional object { internalCostUsd, modelCostUsd, sandboxCostUsd, toolCostUsd }` - `internalCostUsd: number` - `modelCostUsd: number` - `sandboxCostUsd: number` - `toolCostUsd: number` - `usage: optional object { cacheReadTokens, cacheWriteTokens, costUsd, 6 more }` - `cacheReadTokens: number` - `cacheWriteTokens: number` - `costUsd: number` - `inputTokens: number` - `outputTokens: number` - `reasoningTokens: number` - `steps: number` - `totalTokens: number` - `credits: optional number` ### Example ```http curl https://v3.handinger.com/api/workers/$WORKER_ID \ -H 'Content-Type: application/json' \ -H "Authorization: Bearer $HANDINGER_API_KEY" \ -d '{ "input": "x" }' ``` #### Response ```json { "id": "id", "created_at": 0, "error": null, "files": [ { "filename": "filename", "mediaType": "mediaType", "url": "url" } ], "incomplete_details": null, "messages": [ {} ], "metadata": { "foo": "bar" }, "object": "worker", "output": [ { "id": "id", "content": [ { "text": "text", "type": "output_text" } ], "role": "assistant", "status": "completed", "type": "message" } ], "output_text": "output_text", "running": true, "sources": [ { "id": "id", "title": "title", "type": "url", "url": "url" } ], "status": "running", "costs": { "internalCostUsd": 0, "modelCostUsd": 0, "sandboxCostUsd": 0, "toolCostUsd": 0 }, "usage": { "cacheReadTokens": 0, "cacheWriteTokens": 0, "costUsd": 0, "inputTokens": 0, "outputTokens": 0, "reasoningTokens": 0, "steps": 0, "totalTokens": 0, "credits": 0 } } ``` ## Stream worker updates **get** `/api/workers/{workerId}/stream` Subscribe to a worker using server-sent events. ### Path Parameters - `workerId: string` ### Example ```http curl https://v3.handinger.com/api/workers/$WORKER_ID/stream \ -H "Authorization: Bearer $HANDINGER_API_KEY" ``` ## Retrieve a worker email address **get** `/api/workers/{workerId}/email` Retrieve the inbound email address for a worker. ### Path Parameters - `workerId: string` ### Example ```http curl https://v3.handinger.com/api/workers/$WORKER_ID/email \ -H "Authorization: Bearer $HANDINGER_API_KEY" ``` #### Response ```json "string" ``` ## Retrieve a worker file **get** `/api/workers/{workerId}/files/{filePath}` Retrieve a file published from a worker workspace. The runtime route accepts nested paths after /files/. ### Path Parameters - `workerId: string` - `filePath: string` ### Example ```http curl https://v3.handinger.com/api/workers/$WORKER_ID/files/$FILE_PATH \ -H "Authorization: Bearer $HANDINGER_API_KEY" ``` ## Domain Types ### Create Worker - `CreateWorker object { input, budget, stream }` - `input: string` - `budget: optional "low" or "standard" or "high" or "unlimited"` - `"low"` - `"standard"` - `"high"` - `"unlimited"` - `stream: optional boolean` ### Worker - `Worker object { id, created_at, error, 12 more }` - `id: string` - `created_at: number` - `error: unknown` - `files: array of object { filename, mediaType, url }` - `filename: string` - `mediaType: string` - `url: string` - `incomplete_details: unknown` - `messages: array of unknown` - `metadata: map[unknown]` - `object: "worker"` - `"worker"` - `output: array of object { id, content, role, 2 more }` - `id: string` - `content: array of object { text, type }` - `text: string` - `type: "output_text"` - `"output_text"` - `role: "assistant"` - `"assistant"` - `status: "completed"` - `"completed"` - `type: "message"` - `"message"` - `output_text: string` - `running: boolean` - `sources: array of object { id, title, type, url }` - `id: string` - `title: string` - `type: "url"` - `"url"` - `url: string` - `status: "running" or "completed" or "pending"` - `"running"` - `"completed"` - `"pending"` - `costs: optional object { internalCostUsd, modelCostUsd, sandboxCostUsd, toolCostUsd }` - `internalCostUsd: number` - `modelCostUsd: number` - `sandboxCostUsd: number` - `toolCostUsd: number` - `usage: optional object { cacheReadTokens, cacheWriteTokens, costUsd, 6 more }` - `cacheReadTokens: number` - `cacheWriteTokens: number` - `costUsd: number` - `inputTokens: number` - `outputTokens: number` - `reasoningTokens: number` - `steps: number` - `totalTokens: number` - `credits: optional number` ### Worker Stream Updates Response - `WorkerStreamUpdatesResponse = string` ### Worker Retrieve Email Response - `WorkerRetrieveEmailResponse = string` # Schedules ## List worker schedules **get** `/api/workers/{workerId}/schedules` List scheduled tasks for a worker. ### Path Parameters - `workerId: string` ### Returns - `schedules: array of WorkerSchedule` - `object { id, budget, input, 2 more }` - `id: string` - `budget: "low" or "standard" or "high" or "unlimited"` - `"low"` - `"standard"` - `"high"` - `"unlimited"` - `input: string` - `nextRunAt: string` - `type: "scheduled"` - `"scheduled"` - `object { id, budget, delayInSeconds, 3 more }` - `id: string` - `budget: "low" or "standard" or "high" or "unlimited"` - `"low"` - `"standard"` - `"high"` - `"unlimited"` - `delayInSeconds: number` - `input: string` - `nextRunAt: string` - `type: "delayed"` - `"delayed"` - `object { id, budget, cron, 3 more }` - `id: string` - `budget: "low" or "standard" or "high" or "unlimited"` - `"low"` - `"standard"` - `"high"` - `"unlimited"` - `cron: string` - `input: string` - `nextRunAt: string` - `type: "cron"` - `"cron"` - `object { id, budget, input, 3 more }` - `id: string` - `budget: "low" or "standard" or "high" or "unlimited"` - `"low"` - `"standard"` - `"high"` - `"unlimited"` - `input: string` - `intervalSeconds: number` - `nextRunAt: string` - `type: "interval"` - `"interval"` - `workerId: string` ### Example ```http curl https://v3.handinger.com/api/workers/$WORKER_ID/schedules \ -H "Authorization: Bearer $HANDINGER_API_KEY" ``` #### Response ```json { "schedules": [ { "id": "id", "budget": "low", "input": "input", "nextRunAt": "2019-12-27T18:11:19.117Z", "type": "scheduled" } ], "workerId": "workerId" } ``` ## Create a worker schedule **post** `/api/workers/{workerId}/schedules` Schedule a worker instruction for a future or recurring run. ### Path Parameters - `workerId: string` ### Body Parameters - `input: string` - `when: object { date, type } or object { delayInSeconds, type } or object { cron, type } or object { intervalSeconds, type }` - `object { date, type }` - `date: string` - `type: "scheduled"` - `"scheduled"` - `object { delayInSeconds, type }` - `delayInSeconds: number` - `type: "delayed"` - `"delayed"` - `object { cron, type }` - `cron: string` - `type: "cron"` - `"cron"` - `object { intervalSeconds, type }` - `intervalSeconds: number` - `type: "interval"` - `"interval"` - `budget: optional "low" or "standard" or "high" or "unlimited"` - `"low"` - `"standard"` - `"high"` - `"unlimited"` ### Returns - `WorkerSchedule = object { id, budget, input, 2 more } or object { id, budget, delayInSeconds, 3 more } or object { id, budget, cron, 3 more } or object { id, budget, input, 3 more }` - `object { id, budget, input, 2 more }` - `id: string` - `budget: "low" or "standard" or "high" or "unlimited"` - `"low"` - `"standard"` - `"high"` - `"unlimited"` - `input: string` - `nextRunAt: string` - `type: "scheduled"` - `"scheduled"` - `object { id, budget, delayInSeconds, 3 more }` - `id: string` - `budget: "low" or "standard" or "high" or "unlimited"` - `"low"` - `"standard"` - `"high"` - `"unlimited"` - `delayInSeconds: number` - `input: string` - `nextRunAt: string` - `type: "delayed"` - `"delayed"` - `object { id, budget, cron, 3 more }` - `id: string` - `budget: "low" or "standard" or "high" or "unlimited"` - `"low"` - `"standard"` - `"high"` - `"unlimited"` - `cron: string` - `input: string` - `nextRunAt: string` - `type: "cron"` - `"cron"` - `object { id, budget, input, 3 more }` - `id: string` - `budget: "low" or "standard" or "high" or "unlimited"` - `"low"` - `"standard"` - `"high"` - `"unlimited"` - `input: string` - `intervalSeconds: number` - `nextRunAt: string` - `type: "interval"` - `"interval"` ### Example ```http curl https://v3.handinger.com/api/workers/$WORKER_ID/schedules \ -H 'Content-Type: application/json' \ -H "Authorization: Bearer $HANDINGER_API_KEY" \ -d '{ "input": "x", "when": { "date": "2019-12-27T18:11:19.117Z", "type": "scheduled" } }' ``` #### Response ```json { "id": "id", "budget": "low", "input": "input", "nextRunAt": "2019-12-27T18:11:19.117Z", "type": "scheduled" } ``` ## Cancel a worker schedule **delete** `/api/workers/{workerId}/schedules/{scheduleId}` Cancel a scheduled task for a worker. ### Path Parameters - `workerId: string` - `scheduleId: string` ### Returns - `cancelled: boolean` ### Example ```http curl https://v3.handinger.com/api/workers/$WORKER_ID/schedules/$SCHEDULE_ID \ -X DELETE \ -H "Authorization: Bearer $HANDINGER_API_KEY" ``` #### Response ```json { "cancelled": true } ``` ## Domain Types ### Worker Schedule - `WorkerSchedule = object { id, budget, input, 2 more } or object { id, budget, delayInSeconds, 3 more } or object { id, budget, cron, 3 more } or object { id, budget, input, 3 more }` - `object { id, budget, input, 2 more }` - `id: string` - `budget: "low" or "standard" or "high" or "unlimited"` - `"low"` - `"standard"` - `"high"` - `"unlimited"` - `input: string` - `nextRunAt: string` - `type: "scheduled"` - `"scheduled"` - `object { id, budget, delayInSeconds, 3 more }` - `id: string` - `budget: "low" or "standard" or "high" or "unlimited"` - `"low"` - `"standard"` - `"high"` - `"unlimited"` - `delayInSeconds: number` - `input: string` - `nextRunAt: string` - `type: "delayed"` - `"delayed"` - `object { id, budget, cron, 3 more }` - `id: string` - `budget: "low" or "standard" or "high" or "unlimited"` - `"low"` - `"standard"` - `"high"` - `"unlimited"` - `cron: string` - `input: string` - `nextRunAt: string` - `type: "cron"` - `"cron"` - `object { id, budget, input, 3 more }` - `id: string` - `budget: "low" or "standard" or "high" or "unlimited"` - `"low"` - `"standard"` - `"high"` - `"unlimited"` - `input: string` - `intervalSeconds: number` - `nextRunAt: string` - `type: "interval"` - `"interval"` ### Schedule List Response - `ScheduleListResponse object { schedules, workerId }` - `schedules: array of WorkerSchedule` - `object { id, budget, input, 2 more }` - `id: string` - `budget: "low" or "standard" or "high" or "unlimited"` - `"low"` - `"standard"` - `"high"` - `"unlimited"` - `input: string` - `nextRunAt: string` - `type: "scheduled"` - `"scheduled"` - `object { id, budget, delayInSeconds, 3 more }` - `id: string` - `budget: "low" or "standard" or "high" or "unlimited"` - `"low"` - `"standard"` - `"high"` - `"unlimited"` - `delayInSeconds: number` - `input: string` - `nextRunAt: string` - `type: "delayed"` - `"delayed"` - `object { id, budget, cron, 3 more }` - `id: string` - `budget: "low" or "standard" or "high" or "unlimited"` - `"low"` - `"standard"` - `"high"` - `"unlimited"` - `cron: string` - `input: string` - `nextRunAt: string` - `type: "cron"` - `"cron"` - `object { id, budget, input, 3 more }` - `id: string` - `budget: "low" or "standard" or "high" or "unlimited"` - `"low"` - `"standard"` - `"high"` - `"unlimited"` - `input: string` - `intervalSeconds: number` - `nextRunAt: string` - `type: "interval"` - `"interval"` - `workerId: string` ### Schedule Cancel Response - `ScheduleCancelResponse object { cancelled }` - `cancelled: boolean`