Skip to main content
Use this when an agent needs to run a computer-use task — software operated through its screen — through the hosted API or the stateset-computer-use MCP server: previewing, triggering, polling, retrieving results, using idempotency keys, or working with agent_type templates.

Environment

  • API base: https://api.computer.stateset.app/api/v1
  • Auth header on every call: X-API-Key: $STATESET_CUA_API_KEY
  • Never put an API key in a prompt, file, example, log or commit.

Preferred workflow

  1. Discover allowed task types with GET /templates, or MCP stateset_cua_list_templates.
  2. Preview any non-trivial task with POST /jobs/preview, or MCP stateset_cua_preview_task.
  3. Trigger with POST /trigger, or MCP stateset_cua_trigger_task.
  4. Send an Idempotency-Key on every trigger. Use a stable key for the same logical task, so a retry after a timeout does not run it twice.
  5. For a simple client, POST /jobs/{job_id}/wait with {"timeout_seconds": 30}. For a long-running task, poll GET /jobs/{job_id} or consume SSE until status is succeeded, failed or cancelled.
  6. Fetch GET /jobs/{job_id}/result for the summary and artifact pointers.

Trigger payload

Minimum:
Useful optional fields:
  • modelhaiku, sonnet, opus, or a canonical model id
  • effortlow, medium or high
  • max_cost_usd — a per-job budget ceiling
  • tags — up to 20 labels, e.g. ["tenant:acme", "flow:approval"]
  • output_schema — a JSON Schema the final answer is validated against, caller-side
  • webhook_url and webhook_secret — a one-shot completion callback

MCP tools

When the stateset-computer-use MCP server is available, prefer its tools over raw HTTP: stateset_cua_preview_task · stateset_cua_trigger_task · stateset_cua_trigger_batch · stateset_cua_get_job · stateset_cua_wait_for_result · stateset_cua_get_result · stateset_cua_list_jobs · stateset_cua_list_templates · stateset_cua_get_template

curl

Safety

  • Set max_cost_usd on exploratory or large tasks.
  • Preview before any batch submission.
  • Never retry without an idempotency key.
  • Treat artifact storage keys as pointers; use the dashboard or the authenticated artifact download endpoints to read them.

Further reading