---
title: "Start an autonomous run"
method: POST
path: "/v1/runs"
tags: ["runs"]
---

# Start an autonomous run

`POST /v1/runs`

Scope: `runs:write`. Drives `task` to completion on `machine_id`, running the screenshot→act→verify loop server-side. Managed defaults charge 5 credits per completed agent step on v3/v4/v5 and 8 on v1. With a live Coasty key, BYOK runs every role on YOUR provider key and debits zero Coasty platform credits for creation and every step, while persisting actual provider tokens; no wallet runway is required. Under test auth, a managed-mode run remains deterministic sandbox execution. Any BYOK header or provider metadata instead returns 422 LLM_PROVIDER_UNSUPPORTED before execution: BYOK is unavailable for synthetic test runs, workflows, and schedules. Use managed mode or a live Coasty API key. Test execution never decrypts or requires a stored provider key and does not call or bill Anthropic/OpenAI. Run steps do not inherit /v1/predict trajectory, HD-image, or combined-prompt surcharges. Idempotency-Key deduplicates top-level creation, not later GUI/terminal/file side effects. `webhook_secret` is returned only by create/replay; a live BYOK key snapshot is encrypted for crash recovery and scrubbed at terminal state.

## Headers

- `Idempotency-Key` string
- `X-LLM-Provider` 'anthropic' | 'openai'
- `X-LLM-Api-Key` string
- `X-LLM-Model` string

## Request body

- RunRequest
  - `machine_id` string, required — Target managed or connected external machine id (must be owned by the key's user).
  - `task` string, required — Natural-language task to drive to completion.
  - `cua_version` 'v1' | 'v3' | 'v4' | 'v5' — CUA engine version. Defaults to the latest (v5); available on all tiers.
  - `instructions` string, nullable — Appended to the base agent prompt.
  - `system_prompt` string, nullable — Custom preamble prepended to the task; it does not replace the built-in tool-aware agent system prompt. Shares the tier custom-prompt budget with instructions.
  - `model` string, nullable — Legacy top-level model selection (prefer llm.model for BYOK). Model ids are 1-256 characters, begin with a letter or number, and then use only letters, numbers, dot, underscore, colon, slash, plus, at-sign, or hyphen. Secret-shaped values such as sk-* keys, bearer credentials, authorization values, or API-key/secret assignments are rejected without reflection as 422 LLM_MODEL_INVALID; provider credentials belong only in X-LLM-Api-Key.
  - `max_steps` integer — Hard cap on agent steps (clamped to the server ceiling).
  - `action_policy` ActionPolicy — Opt-in, fail-closed post-model action enforcement. The complete normalized batch is checked atomically before actions are returned or dispatched. allowed_actions and blocked_actions cannot overlap. Prediction, Session, and Parse surfaces use prediction action names such as type_text; direct Machine routes use command names such as type. Task, Workflow, and Schedule policies are create-time controls inherited across execution and recovery.
    - `allowed_actions` string[], nullable — Optional action allowlist. Values are trimmed and lowercased before validation; duplicates after normalization are rejected. Terminal done/fail/awaiting_human signals remain allowed.
    - `blocked_actions` string[] — Action denylist. Values are trimmed and lowercased before validation; duplicates after normalization are rejected.
    - `blocked_keys` string[] — Keys forbidden in key_press, key_combo, and modifier-bearing actions. Values are trimmed and lowercased; duplicates after normalization are rejected; esc aliases escape.
    - `block_window_close` boolean — Block explicit close commands and common Alt+F4, Ctrl/Cmd+W, and Cmd+Q shortcuts.
    - `max_actions` integer, nullable — Maximum number of actions admitted in one prediction/session step, parsed action batch, or direct Machine batch.
    - `coordinate_bounds` CoordinateBounds — Inclusive coordinate rectangle in the request screenshot's pixel space.
      - `min_x` integer
      - `min_y` integer
      - `max_x` integer, required
      - `max_y` integer, required
  - `deadline_seconds` integer, nullable — Wall-clock budget in seconds (clamped).
  - `on_awaiting_human` 'pause' | 'fail' | 'cancel' — Behaviour when the agent needs a human.
  - `awaiting_human_timeout_seconds` integer, nullable
  - `webhook_url` string, nullable — HTTPS URL for HMAC-signed run-event deliveries.
  - `metadata` object, nullable — Opaque key/value map echoed back (≤50 keys).
  - `llm` LlmConfig — Opt-in BYOK model selection. provider 'managed' (or omitting llm) keeps the platform default. There is deliberately no api_key field (422 if attempted): keys ride the X-LLM-Api-Key header or the encrypted /v1/llm/keys store only. Once BYOK is requested there is NO silent fallback to Coasty's platform LLM keys.
    - `provider` 'managed' | 'anthropic' | 'openai' — Whose LLM account runs the harness. Anything else is 422 LLM_PROVIDER_UNSUPPORTED.
    - `model` string, nullable — Main worker model. Defaults: claude-sonnet-5 (anthropic), gpt-5.6-sol (openai). Model ids are 1-256 characters, begin with a letter or number, and then use only letters, numbers, dot, underscore, colon, slash, plus, at-sign, or hyphen; invalid ids return 422 LLM_MODEL_INVALID. The selected provider can still reject an unknown or inaccessible model. It must be vision-capable.
    - `grounding_model` string, nullable — Override for pixel-coordinate grounding. Defaults to model. Grounding quality is tuned on the platform model; expect best results with the defaults.
    - `compaction_model` string, nullable — Override for trajectory compaction. Defaults to model. A cheaper model here is the classic cost tune.
    - `code_agent_model` string, nullable — Override for the code agent. Defaults to model.

## Response `200`

Run created (status "queued").

- RunResponse
  - `id` string, required
  - `object` 'agent.run', required
  - `status` 'queued' | 'running' | 'awaiting_human' | 'succeeded' | 'failed' | 'cancelled' | 'timed_out', required
  - `machine_id` string, nullable
  - `machine` object, nullable
    - `mode` 'automatic'
    - `status` 'provisioning' | 'starting' | 'reconciling' | 'ready' | 'terminated' | 'cleanup_failed' — Lifecycle of the ephemeral machine Coasty created for this run. `starting` means the provider handle and billing record are durable but the desktop may still be booting; execution readiness is verified separately before the agent is allowed to start. `reconciling` means a provisioning outcome is being recovered from the provider journal, and the run keeps its lease while that resolves. `cleanup_failed` means the run reached a terminal outcome but teardown did not confirm.
    - `id` string, nullable
    - `cleanup` 'always'
    - `cleanup_status` 'pending' | 'terminating' | 'retrying' | 'terminated'
    - `error` object
  - `task` string
  - `cua_version` string
  - `instructions` string, nullable
  - `max_steps` integer
  - `deadline_seconds` integer — EFFECTIVE wall-clock budget after the server applied its ceiling. Echoed back so a clamp is never silent: request 86400 against a lower server ceiling and you see the value the run is actually held to, instead of discovering it as a surprise DEADLINE_EXCEEDED.
  - `awaiting_human_timeout_seconds` integer — EFFECTIVE awaiting-human timeout after the server applied its ceiling, echoed back for the same reason as deadline_seconds.
  - `on_awaiting_human` string
  - `steps_completed` integer
  - `credits_charged` integer
  - `cost_cents` integer
  - `result` object, nullable — Terminal outcome envelope: `passed` (boolean), `status`, `summary`, `usage`, and `verdict` only when a verifier pass ran. `summary` is the LAST 2000 characters of the trajectory, so it carries the agent's final answer; it is not the full trajectory and there is no `output` field. To read a complete trajectory, or a final answer you intend to parse, use GET /v1/runs/{run_id}/log.
  - `error` object, nullable
  - `awaiting_human_reason` string, nullable
  - `metadata` object, nullable
  - `llm` RunLlmInfo — Credential-free BYOK attribution returned by agent runs and workflow runs. Only these allowlisted fields are public.
    - `provider` 'anthropic' | 'openai', required
    - `model` string, required
    - `key_fingerprint` string, required
    - `key_source` 'header' | 'stored', required
    - `key_scrubbed` boolean, required
  - `webhook_url` string, nullable — Lifecycle callback destination. Agent Run terminal callbacks are transactionally queued in a durable outbox and delivered at least once, with at most 3 durably recorded delivery attempts. A crash after HTTP send but before durable acknowledgement can add duplicate physical sends. Stable Coasty-Delivery equals body id and logical delivered_at survives retries; receivers must deduplicate it. The non-terminal awaiting-human callback is best-effort in-process, can be missed on a worker failure, and uses (run.id, event, run.awaiting_human_since) for deduplication. GET the run for authoritative state.
  - `webhook_secret` string, nullable — Returned by create and its exact bounded Idempotency-Key replay; null on get/list. The pinned per-run secret is encrypted at rest through delivery/replay recovery and later scrubbed. Verify raw-body deliveries with HMAC-SHA256 before accepting the Coasty-Delivery deduplication key.
  - `created_at` string, nullable
  - `started_at` string, nullable
  - `awaiting_human_since` string, nullable
  - `finished_at` string, nullable
  - `request_id` string, nullable

## Other responses

- `400` — Invalid request body or parameters.
- `401` — Missing, invalid, or revoked API key. Pass `X-API-Key: sk-coasty-live-...` (or test).
- `402` — Insufficient balance for this operation. Direct metered API calls and managed-machine runtime use the prepaid Developer API wallet; scheduled execution is the documented consumer subscription-credit exception. Follow the operation's billing fields and top up the matching balance in the dashboard.
- `403` — API key lacks the required scope or tier-feature is unavailable on the caller's plan.
- `404` — Resource not found in this key's namespace.
- `409` — The resource state conflicts with this operation.
- `413` — The request body exceeds the endpoint limit.
- `422` — The JSON shape is valid but one or more values violate the endpoint contract.
- `429` — Rate or concurrency limit exceeded.
- `500` — Unexpected server error. Retry with exponential backoff.
- `502` — An upstream dependency returned an invalid response.
- `503` — A required service is temporarily unavailable.
- `504` — An upstream dependency timed out.

---

[API](https://skmtc.net/coasty/apis/coasty-public-api.md) · [All operations](https://skmtc.net/coasty/apis/coasty-public-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/coasty/coasty-public-api/revisions/f50d93b0d8a1/schema)
