> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agentmark.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Launch a worker run

> Launches a terminal coding agent against the app's connected repo on managed compute: it clones the code, does the task, and delivers a branch + pull request. Poll `GET /v1/workers/runs/{runId}` for the outcome, or hand a human the returned `url` — the dashboard's live chat thread for the run.

Requires the key's environment (or the app default) to carry the agent's credential env var (e.g. `ANTHROPIC_API_KEY`).



## OpenAPI

````yaml /openapi.yaml post /v1/workers/runs
openapi: 3.0.3
info:
  contact:
    email: hello@agentmark.co
    url: https://docs.agentmark.co
  description: >-
    The AgentMark Gateway API lets you ingest traces, create scores, and
    retrieve prompt templates programmatically.


    Most developers should use the [AgentMark SDK](/introduction/overview) for
    integration.

    The REST API is for cases where you need direct HTTP access or are building
    a custom integration.


    Versioning: every endpoint is prefixed with `/v1/`. Breaking changes ship
    under a new version prefix (`/v2/`, etc.) with a 90-day-minimum deprecation
    window — see [API versioning & stability](/api-reference/versioning) for the
    full policy on what constitutes a breaking vs. additive change.
  title: AgentMark Gateway API
  version: '1.0'
servers:
  - description: Production (AgentMark Cloud)
    url: https://api.agentmark.co
  - description: Local dev server (`npx @agentmark-ai/cli dev`)
    url: http://localhost:9418
security:
  - AppId: []
    BearerAuth: []
tags:
  - description: Ingest, query, and export OpenTelemetry trace data.
    name: Traces
  - description: >-
      Coding-agent session ingest (outerlayer sync) and content-addressed
      session images.
    name: Agents
  - description: Query individual spans across traces.
    name: Spans
  - description: Create, retrieve, list, and delete score records for spans and traces.
    name: Scoring
  - description: Structured-filter search across observability resources.
    name: Search
  - description: Retrieve the effective synced project configuration.
    name: Config
  - description: List and retrieve datasets.
    name: Datasets
  - description: Query server feature availability.
    name: Capabilities
  - description: Per-model LLM pricing data. Public, unauthenticated.
    name: Pricing
  - description: >-
      Create, list, and revoke tenant API keys. Plaintext returned exactly once
      at creation.
    name: API Keys
  - description: >-
      List and retrieve score configuration definitions from the synced project
      config.
    name: Score Configs
  - description: >-
      Trigger and inspect managed deployments. POST returns 202; deployments run
      asynchronously and progress is observed via GET.
    name: Deployments
  - description: >-
      Per-app named environments (e.g. `dev`, `prod`). CRUD for env lifecycle;
      promote/rollback routes land alongside in this group as feature 054 lands
      the saga.
    name: Environments
  - description: >-
      App CRUD — the top-level tenant entity every other resource hangs off.
      Lets a headless agent provision an app without the dashboard.
    name: Apps
  - description: >-
      Cloud workers — terminal coding agents on managed compute. Launch one-shot
      runs or persistent multi-turn sessions against the app's connected repo;
      every response carries the dashboard deep link to the live thread.
    name: Workers
  - description: Service health checks.
    name: Health
paths:
  /v1/workers/runs:
    post:
      tags:
        - Workers
      summary: Launch a worker run
      description: >-
        Launches a terminal coding agent against the app's connected repo on
        managed compute: it clones the code, does the task, and delivers a
        branch + pull request. Poll `GET /v1/workers/runs/{runId}` for the
        outcome, or hand a human the returned `url` — the dashboard's live chat
        thread for the run.


        Requires the key's environment (or the app default) to carry the agent's
        credential env var (e.g. `ANTHROPIC_API_KEY`).
      operationId: launch-worker-run
      requestBody:
        content:
          application/json:
            schema:
              properties:
                agent:
                  description: >-
                    Agent id (default claude-code). One of: claude-code, codex,
                    cursor, opencode
                  type: string
                base_branch:
                  description: Base branch (defaults to the app's tracked branch).
                  type: string
                task_prompt:
                  description: What the agent should do.
                  minLength: 1
                  type: string
                wall_clock_cap_s:
                  description: Wall-clock cap in seconds (default 1800).
                  maximum: 3600
                  minimum: 60
                  type: integer
              required:
                - task_prompt
              type: object
      responses:
        '200':
          content:
            application/json:
              schema:
                properties:
                  data:
                    properties:
                      run_id:
                        type: string
                      status:
                        type: string
                      url:
                        description: Dashboard deep link to the live run thread.
                        nullable: true
                        type: string
                    required:
                      - run_id
                      - status
                      - url
                    type: object
                required:
                  - data
                type: object
          description: Run dispatched.
        '400':
          content:
            application/json:
              schema:
                properties:
                  error:
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                    required:
                      - code
                      - message
                    type: object
                required:
                  - error
                type: object
          description: Invalid request body or unknown agent.
        '401':
          content:
            application/json:
              schema:
                properties:
                  error:
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                    required:
                      - code
                      - message
                    type: object
                required:
                  - error
                type: object
          description: Missing or invalid API key.
        '402':
          content:
            application/json:
              schema:
                properties:
                  error:
                    properties:
                      code:
                        enum:
                          - entitlement_required
                        type: string
                      current:
                        type: number
                      entitlement:
                        type: string
                      limit:
                        type: number
                      message:
                        type: string
                    required:
                      - code
                      - message
                      - entitlement
                    type: object
                required:
                  - error
                type: object
          description: >-
            Workers not enabled for the tenant's tier, or a concurrency /
            monthly-minutes quota is exhausted.
        '403':
          content:
            application/json:
              schema:
                properties:
                  error:
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                    required:
                      - code
                      - message
                    type: object
                required:
                  - error
                type: object
          description: Caller lacks 'worker_run.insert' permission.
        '502':
          content:
            application/json:
              schema:
                properties:
                  error:
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                    required:
                      - code
                      - message
                    type: object
                required:
                  - error
                type: object
          description: Dispatch failed; the run is recorded as failed.
        '503':
          content:
            application/json:
              schema:
                properties:
                  error:
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                    required:
                      - code
                      - message
                    type: object
                required:
                  - error
                type: object
          description: Worker compute is not configured on this deployment.
components:
  securitySchemes:
    AppId:
      description: >-
        Application ID for tenant scoping. X-Outerlayer-App-Id is accepted as an
        equivalent header.
      in: header
      name: X-Agentmark-App-Id
      type: apiKey
    BearerAuth:
      description: API key (sk_agentmark_*)
      scheme: bearer
      type: http

````