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

# Get run status and results

> Retrieve a browser run, individual task outcomes, retry counts, and optional execution timelines.

export const LifecycleExplorer = ({kind = "spec"}) => {
  const [selected, setSelected] = useState(0);
  const specExamples = [{
    label: "pending",
    tone: "active",
    badge: "Keep polling",
    title: "The request is saved.",
    body: "The submission returns specId. Save it before starting your polling loop.",
    next: "Request GET /spec-status/{specId} every few seconds, with a deadline.",
    endpoint: "POST /fast-spec · async: true",
    response: {
      specId: "507f1f77bcf86cd799439011",
      status: "pending"
    }
  }, {
    label: "processing",
    tone: "active",
    badge: "Keep polling",
    title: "The specification is being generated.",
    body: "Progress fields help you display activity. Full artifacts may still be absent or null.",
    next: "Keep polling the same ID. Do not submit another specification to check progress.",
    endpoint: "GET /spec-status/{specId}",
    response: {
      status: "processing",
      progress: 45,
      progressMessage: "Generating architecture..."
    }
  }, {
    label: "completed",
    tone: "success",
    badge: "Stop polling",
    title: "Read the generated artifacts.",
    body: "Use the Markdown or structured JSON for your reader. Check optional graphs and download URLs before using them.",
    next: "Review the specification against your requirements before building.",
    endpoint: "GET /spec-status/{specId}",
    response: {
      status: "completed",
      codingAgentSpecMarkdown: "# Team task manager\n...",
      creditsUsed: 7.2
    }
  }, {
    label: "failed",
    tone: "warning",
    badge: "Stop polling",
    title: "Generation did not complete.",
    body: "Read errorMessage and decide how to recover. A request may fail while pending or processing.",
    next: "An HTTP 200 status response does not mean generation succeeded.",
    endpoint: "GET /spec-status/{specId}",
    response: {
      status: "failed",
      errorMessage: "Specification generation failed."
    }
  }];
  const browserExamples = [{
    label: "Queued",
    tone: "active",
    badge: "Keep polling",
    title: "The run exists; a task is waiting.",
    body: "The run status is processing, even when its tasks are still PENDING. Use the saved run id to retrieve progress.",
    next: "Poll the run or attach to its existing-run stream.",
    response: {
      status: "processing",
      results: [{
        status: "PENDING",
        queuePosition: 2
      }]
    }
  }, {
    label: "Running",
    tone: "active",
    badge: "Keep polling",
    title: "Check status, not the counters.",
    body: "Result slots can already be counted in completed while tasks are still RUNNING. The run is not finished until its status is terminal.",
    next: "Treat missing data and null result slots as in-progress possibilities.",
    response: {
      status: "processing",
      total: 1,
      completed: 1,
      results: [{
        status: "RUNNING",
        queuePosition: 0
      }]
    }
  }, {
    label: "Completed",
    tone: "success",
    badge: "Stop polling; inspect tasks",
    title: "Finished does not mean every task succeeded.",
    body: "This completed run contains a SUCCESS and a BLOCKED task. Read each task’s status before using its data.",
    next: "Use successful results. Inspect error on unsuccessful tasks before deciding to retry.",
    response: {
      status: "completed",
      results: [{
        status: "SUCCESS",
        data: {
          heading: "Example Domain"
        }
      }, {
        status: "BLOCKED",
        error: "The site blocked this task."
      }]
    }
  }, {
    label: "Failed",
    tone: "warning",
    badge: "Stop polling",
    title: "The run reached a failure state.",
    body: "Inspect the run error and any available task outcomes. Partial results may still be present.",
    next: "Keep the run ID when investigating or recovering from a failure.",
    response: {
      status: "failed",
      error: "Run execution failed.",
      results: []
    }
  }];
  const isBrowser = kind === "browser";
  const examples = isBrowser ? browserExamples : specExamples;
  const example = examples[selected];
  const panelId = isBrowser ? "browser-lifecycle-response" : "spec-lifecycle-response";
  return <figure className="pd-visual not-prose" aria-label={isBrowser ? "Explore browser run and task states" : "Explore specification states"}>
      <div className="pd-panel">
        <div className="pd-bar"><strong>{isBrowser ? "One run. Individual task outcomes." : "From saved request to specification."}</strong><span>Interactive example</span></div>
        <div className="pd-state-controls" role="group" aria-label="Choose an example state">
          {examples.map((item, index) => <button key={item.label} type="button" className="pd-state-button" aria-pressed={selected === index} aria-controls={panelId} onClick={() => setSelected(index)}>{item.label}</button>)}
        </div>
        <div id={panelId} aria-live="polite" aria-atomic="true">
          <div className="pd-bar"><code>{isBrowser ? "GET /browser-agent/{id}" : example.endpoint}</code><span>Response excerpt</span></div>
          <div className="pd-response">
            <div className="pd-response-code"><pre><code>{JSON.stringify(example.response, null, 2)}</code></pre></div>
            <div className="pd-response-explanation">
              <span className="pd-chip" data-tone={example.tone}>{example.badge}</span>
              <strong className="pd-figure-title">{example.title}</strong>
              <p>{example.body}</p>
              <p className="pd-response-next">{example.next}</p>
            </div>
          </div>
        </div>
      </div>
      <figcaption>Select a state to see example response fields and what to do next.</figcaption>
    </figure>;
};

Use the `id` returned by [task submission](/browser-agents/api/run-task). A run is also called a batch in the API and SDK types.

```bash theme={null}
curl --fail-with-body "https://api.pre.dev/browser-agent/$BATCH_ID" \
  -H "Authorization: Bearer $PREDEV_API_KEY"
```

## Batch and task states

Batch `status` is `processing`, `completed`, or `failed`. Stop polling on either terminal state. A completed batch may contain unsuccessful tasks.

<LifecycleExplorer kind="browser" />

| Task status      | Meaning                                             |
| ---------------- | --------------------------------------------------- |
| `PENDING`        | Waiting to run                                      |
| `RUNNING`        | Execution has started                               |
| `SUCCESS`        | The task succeeded                                  |
| `BLOCKED`        | The site blocked the task                           |
| `CAPTCHA_FAILED` | A challenge could not be completed                  |
| `TIMEOUT`        | The execution budget expired                        |
| `LOOP`           | Repeated actions prevented progress                 |
| `NO_TARGET`      | The requested target or usable result was not found |
| `ERROR`          | Another execution failure; read `error`             |

## In-progress results

`results` is aligned to task order. An entry can be a terminal result, a `PENDING`/`RUNNING` stub, or null when task details are unavailable. Pending entries need not include `data`, `durationMs`, or `creditsUsed`.

The detail response counts result slots in `completed`, including synthesized entries. **Use `status`, not `completed === total` or array length, to decide whether the run is finished.**

Additional fields can include:

| Field                                       | Meaning                                                                           |
| ------------------------------------------- | --------------------------------------------------------------------------------- |
| `name` / `taskNames`                        | Generated display names, when available                                           |
| `results[i].attempts`                       | Execution attempts; greater than one indicates a retry                            |
| `results[i].queuePosition`                  | Advisory position for pending work; zero for running work, or null if unavailable |
| `results[i].instruction`, `input`, `output` | Original task inputs when available                                               |
| `totalCreditsUsed`                          | Sum of reported task credit usage                                                 |

Inspect task `status` before using `data`. Treat display names, queue position, and timestamps as optional.

## Event timeline

Set `includeEvents=true` when you need execution evidence:

```bash theme={null}
curl --fail-with-body "https://api.pre.dev/browser-agent/$BATCH_ID?includeEvents=true" \
  -H "Authorization: Bearer $PREDEV_API_KEY"
```

`results[i].events` contains available task events. `liveEvents[i]` can contain events for unfinished tasks; completed slots can be empty arrays. These fields can remain present after batch completion.

An event uses `{ type, timestamp, iteration?, data }`, where `timestamp` is Unix time in milliseconds. Types include `navigation`, `plan`, `action`, `screenshot`, `validation`, `done`, `error`, and lifecycle events. Accept unfamiliar event types and inspect their payloads instead of assuming a closed list.

Screenshot payloads can contain inline image data rather than a URL. Events vary by execution path and are not guaranteed for every step. Timelines can be large, so omit them from routine status checks. The [existing-run stream](/browser-agents/api/stream-task) provides a snapshot followed by live updates.

A malformed ID returns `400`. An unknown or inaccessible run returns `404`.


## OpenAPI

````yaml api-reference/openapi.json GET /browser-agent/{id}
openapi: 3.1.0
info:
  title: pre.dev API
  description: >-
    Public REST API for software specifications, browser automation, proposal
    assessment, and credit balance. Base URL: https://api.pre.dev. MCP is
    documented separately at https://docs.pre.dev/mcp/tools.
  version: 1.1.0
  contact:
    name: pre.dev Support
    url: https://pre.dev
    email: support@pre.dev
  license:
    name: Proprietary
    url: https://pre.dev/terms
servers:
  - url: https://api.pre.dev
    description: Production API Server
security:
  - apiKeyAuth: []
  - xApiKey: []
tags:
  - name: Specifications
  - name: Browser Agents
  - name: Proposals
  - name: Account
paths:
  /browser-agent/{id}:
    get:
      tags:
        - Browser Agents
      summary: Get browser task status
      description: >-
        Use batch status for completion, then each task status for success. The
        completed counter includes placeholder slots.
      operationId: getRun
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            description: 24-character record ID.
            pattern: ^[a-fA-F0-9]{24}$
        - name: includeEvents
          in: query
          required: false
          schema:
            type: boolean
            default: false
      responses:
        '200':
          description: Batch with available results and optional events.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BatchResult'
              examples:
                processing:
                  summary: Processing with placeholders
                  value:
                    id: 507f1f77bcf86cd799439011
                    total: 1
                    completed: 1
                    results:
                      - url: https://example.com
                        status: RUNNING
                        queuePosition: 0
                        attempts: 1
                    totalCreditsUsed: 0
                    status: processing
                completed:
                  summary: Completed run (illustrative)
                  value:
                    id: 507f1f77bcf86cd799439011
                    total: 1
                    completed: 1
                    results:
                      - url: https://example.com
                        status: SUCCESS
                        data:
                          heading: Example Domain
                        creditsUsed: 0.1
                    totalCreditsUsed: 0.1
                    status: completed
        '400':
          description: Invalid request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Missing, invalid, or ineligible authentication.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Record unavailable.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Request failed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    BatchResult:
      type: object
      required:
        - id
        - status
        - results
      properties:
        id:
          type: string
          description: 24-character record ID.
          pattern: ^[a-fA-F0-9]{24}$
        name:
          anyOf:
            - type: string
            - type: 'null'
        taskNames:
          type: array
          items:
            type: string
        total:
          type: integer
        completed:
          type: integer
          description: >-
            Counts result slots, including pending/running placeholders or
            nulls. Do not use this as the completion signal.
        results:
          type: array
          items:
            anyOf:
              - $ref: '#/components/schemas/TaskResult'
              - type: 'null'
          description: >-
            Ordered by task index. Slots can be null or partial until a result
            arrives.
        totalCreditsUsed:
          type: number
        status:
          type: string
          enum:
            - processing
            - completed
            - failed
        createdAt:
          type: string
          format: date-time
        completedAt:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
        liveEvents:
          type: array
          items:
            type: array
            items:
              $ref: '#/components/schemas/RunnerEvent'
          description: >-
            Per-task events when includeEvents=true and live events are
            available.
        error:
          anyOf:
            - type: string
            - type: 'null'
      additionalProperties: true
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: string
        message:
          type: string
          description: Optional detail; not returned by every endpoint.
        code:
          type: string
          description: Machine-readable code when available.
        actionUrl:
          type: string
          format: uri
        requiresSubscription:
          type: boolean
        trialsUsed:
          type: integer
        maxTrials:
          type: integer
      additionalProperties: true
    TaskResult:
      type: object
      properties:
        url:
          type: string
        name:
          type: string
        instruction:
          type: string
        input:
          type: object
          properties: {}
          additionalProperties: true
        output:
          type: object
          properties: {}
          additionalProperties: true
        status:
          type: string
          description: >-
            PENDING and RUNNING are status placeholders; all other listed values
            are terminal task outcomes.
          enum:
            - PENDING
            - RUNNING
            - SUCCESS
            - ERROR
            - TIMEOUT
            - BLOCKED
            - CAPTCHA_FAILED
            - LOOP
            - NO_TARGET
        data:
          description: >-
            Extracted result; shape follows the requested or inferred schema.
            May be null or omitted.
        creditsUsed:
          type: number
          description: >-
            Settled task charge: SUCCESS has a 0.1-credit floor; non-SUCCESS
            tasks have zero charge. Submission may reserve credits before
            settlement.
        durationMs:
          type: integer
          description: Wall-clock task duration in milliseconds.
        error:
          anyOf:
            - type: string
            - type: 'null'
        attempts:
          type: integer
        queuePosition:
          anyOf:
            - type: integer
              description: Queue estimate; 0 when running.
            - type: 'null'
        events:
          type: array
          items:
            $ref: '#/components/schemas/RunnerEvent'
          description: Available timeline when includeEvents=true.
      additionalProperties: true
    RunnerEvent:
      type: object
      required:
        - type
        - timestamp
      properties:
        type:
          type: string
          description: >-
            Extensible event type, for example navigation, screenshot, plan,
            action, validation, waiting, done, or error.
        timestamp:
          type: number
          description: Unix timestamp in milliseconds.
        iteration:
          type: integer
        data:
          description: >-
            Event-specific payload. Screenshot data is not guaranteed to be a
            URL.
      additionalProperties: true
  securitySchemes:
    apiKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: API key
      description: Use a pre.dev API key from https://pre.dev/projects/key.
    xApiKey:
      type: apiKey
      in: header
      name: x-api-key
      description: 'Alternative to Authorization: Bearer.'

````