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

> ## Agent Instructions
> Agents: start with https://docs.pre.dev/agents.md, which has complete recipes, plan access, polling rules, errors and limits.
> Authenticate with the workspace API key (pdk_…) from Integrations → Built-in, sent as Authorization: Bearer <key>.
> REST API: https://api.pre.dev (OpenAPI: https://docs.pre.dev/api-reference/openapi.json). AI Gateway: https://api.pre.dev/v1, OpenAI-compatible (OpenAPI: https://docs.pre.dev/api-reference/ai-gateway.openapi.json).
> pre.dev MCP server: npx -y @predotdev/mcp setup adds it to every local coding agent with every pre.dev tool plus the user's own Chrome; the hosted server is https://api.pre.dev/mcp. Search these docs over MCP at https://docs.pre.dev/mcp.

# Get run status and results

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

Use the `id` returned by [task submission](https://predev.mintlify.site/browser-agents/api/run-task.md). 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.

![Browser task states and charges: submission charges the per-task floor, PENDING and RUNNING add nothing, SUCCESS, BLOCKED, CAPTCHA\_FAILED, TIMEOUT, LOOP, and NO\_TARGET are metered at the floor or more, and ERROR and EXHAUSTED keep the floor and nothing more.](https://mintcdn.com/predev/rC7E2dpqWiYJ0E8K/images/diagrams/browser-task-states-light.svg?fit=max\&auto=format\&n=rC7E2dpqWiYJ0E8K\&q=85\&s=96fc0e3291437544a224a5cfba55d74f)

| Task status | Meaning | Charge |
| - | - | - |
| `PENDING` | Waiting to run | The floor, charged at submission |
| `RUNNING` | Execution has started | Nothing more; a retried attempt adds no charge |
| `SUCCESS` | The task succeeded | The floor, plus any usage above it |
| `BLOCKED` | The site blocked the task | The floor, plus any usage above it |
| `CAPTCHA_FAILED` | A challenge could not be completed | The floor, plus any usage above it |
| `TIMEOUT` | The execution budget expired | The floor, plus any usage above it |
| `LOOP` | Repeated actions prevented progress | The floor, plus any usage above it |
| `NO_TARGET` | The requested target or usable result was not found | The floor, plus any usage above it |
| `ERROR` | Another execution failure; read `error` | The floor and nothing more |
| `EXHAUSTED` | The run stopped responding before it finished, and no retry could finish it in time | The floor and nothing more |

Every browser task is charged a **0.1-credit floor** when you submit it, so you need available credits to start. When the task finishes, it is charged any usage above the floor, whether it succeeded or not. Only an `ERROR` or `EXHAUSTED` task keeps the floor and nothing more.

## 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](https://predev.mintlify.site/browser-agents/api/stream-task.md) provides a snapshot followed by live updates.

## Errors

| Status | When |
| - | - |
| `400` | `id` is not a valid run ID |
| `401` | Missing or invalid key |
| `404` | No run with this ID in your account |

Each status has an example body in the response examples. See [errors and retries](https://predev.mintlify.site/api-reference/errors.md).


## 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, 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: 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'
              example:
                error: invalid batch id
        '401':
          description: Missing, invalid, or ineligible authentication.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                missing_key:
                  summary: No key sent
                  value:
                    error: Missing API key
                    message: >-
                      Please provide an API key via Authorization: Bearer
                      <token> header or x-api-key header
                invalid_key:
                  summary: Unknown key
                  value:
                    error: Authentication failed
                    message: Invalid API key
        '404':
          description: Record unavailable.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: batch not found
        '500':
          description: Request failed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: Authentication failed
                message: Retry the request.
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
            - EXHAUSTED
        data:
          description: >-
            Extracted result; shape follows the requested or inferred schema.
            May be null or omitted.
        creditsUsed:
          type: number
          description: >-
            Settled task charge: every task keeps the 0.1-credit floor charged
            at submission; every status except ERROR and EXHAUSTED adds any
            usage above it.
        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: >-
        Your pre.dev workspace API key (pdk_...) from Integrations, Built-in
        tab: https://pre.dev/projects/integrations?tab=built-in
    xApiKey:
      type: apiKey
      in: header
      name: x-api-key
      description: 'Alternative to Authorization: Bearer.'

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.