---
title: "Get test failure context"
method: GET
path: "/context"
tags: ["Context"]
---

# Get test failure context

`GET /context`

Retrieve structured test failure context for AI debugging. One of three query shapes is used:

- **Run-level:** `run_id` only (omit `instance_id` and `test_id`). Paginate failed tests with `limit` and `page`.
- **Instance-level:** `run_id` and `instance_id` (omit `test_id`). Paginate with `limit` and `page`.
- **Test-level:** `instance_id` and `test_id`. The run is resolved server-side from the instance; optional `run_id` is ignored for lookup. Optional `attempt` selects a specific attempt; omit for the latest.

Responses can be large (for example, tests with many steps). There is a 1MB response limit. Include `Accept-Encoding: gzip` in your request when possible. You can also use `detail=compact` or `detail=summary`, or (for `format=md`) `max_length`, to reduce response size.

## Query parameters

- `run_id` string
- `instance_id` string
- `test_id` string
- `attempt` integer
- `format` 'json' | 'md'
- `detail` 'default' | 'compact' | 'summary'
- `limit` integer
- `page` integer
- `max_length` integer

## Response `200`

Context data

- ContextResponse
  - `status` 'OK', required
  - `data` union, required
    - ContextTestData
      - `level` 'test', required
      - `spec` string, required — Spec file path
      - `test` object, required
        - `title` string[] — Test title hierarchy
        - `status` string
        - `attempt` integer
        - `totalAttempts` integer
        - `duration` integer — Duration in milliseconds
      - `error` ContextError, nullable, required — Error details including message, stack, location, and code snippet
        - `message` string, nullable
        - `stack` string, nullable
        - `location` ContextErrorLocation, nullable — Source code location of an error
          - `file` string
          - `line` integer
          - `column` integer
        - `snippet` string, nullable — Code snippet around the error location
      - `otherAttempts` object[] — Summary of other attempts for cross-attempt comparison
        - `attempt` integer
        - `status` string
        - `sameError` boolean — Whether this attempt had the same error as the displayed attempt
        - `error` object, nullable — Simplified error summary (no stack/snippet)
          - `message` string, nullable
          - `location` ContextErrorLocation, nullable — Source code location of an error
            - `file` string
            - `line` integer
            - `column` integer
      - `errorContext` ContextAsset — A signed URL reference to a stored artifact (trace, screenshot, video, attachment, or instance stdout).
        - `name` string
        - `url` string — Signed, time-limited URL to fetch the object from storage. The uploader may store the object with gzip compression; the GET response can include `Content-Encoding: gzip`. Decompress when that header is present or when the body starts with gzip magic bytes `0x1f 0x8b`. Browsers and most HTTP libraries decompress automatically when they send `Accept-Encoding: gzip`; other clients may need explicit decompression.
      - `traceErrorAnalysis` object, nullable — Console entries and network requests from the error timeframe
        - `consoleEntries` object[]
          - `time` number
          - `messageType` string
          - `text` string
          - `location` object, nullable
            - `url` string
            - `lineNumber` integer
            - `columnNumber` integer
        - `networkRequests` object[]
          - `time` number
          - `url` string
          - `status` integer
          - `method` string
      - `failureContext` ContextFailureContext, nullable — Context around the failed step
        - `failedStepIndex` integer — Index of the failed step in the flattened steps array (0-indexed)
        - `stepBefore` ContextStep — A test execution step (recursive structure)
          - `title` string — Step title/description
          - `category` string — Step category (e.g., pw:api)
          - `duration` integer — Duration in milliseconds
          - `error` ContextError, nullable — Error details including message, stack, location, and code snippet
            - `message` string, nullable
            - `stack` string, nullable
            - `location` ContextErrorLocation, nullable — Source code location of an error
              - …
            - `snippet` string, nullable — Code snippet around the error location
          - `steps` ContextStep[] — Nested child steps
        - `failedStep` ContextStep — A test execution step (recursive structure)
          - `title` string — Step title/description
          - `category` string — Step category (e.g., pw:api)
          - `duration` integer — Duration in milliseconds
          - `error` ContextError, nullable — Error details including message, stack, location, and code snippet
            - `message` string, nullable
            - `stack` string, nullable
            - `location` ContextErrorLocation, nullable — Source code location of an error
              - …
            - `snippet` string, nullable — Code snippet around the error location
          - `steps` ContextStep[] — Nested child steps
        - `stepAfter` ContextStep — A test execution step (recursive structure)
          - `title` string — Step title/description
          - `category` string — Step category (e.g., pw:api)
          - `duration` integer — Duration in milliseconds
          - `error` ContextError, nullable — Error details including message, stack, location, and code snippet
            - `message` string, nullable
            - `stack` string, nullable
            - `location` ContextErrorLocation, nullable — Source code location of an error
              - …
            - `snippet` string, nullable — Code snippet around the error location
          - `steps` ContextStep[] — Nested child steps
      - `steps` ContextStep[] — Test execution steps (omitted when detail=summary)
        - `title` string — Step title/description
        - `category` string — Step category (e.g., pw:api)
        - `duration` integer — Duration in milliseconds
        - `error` ContextError, nullable — Error details including message, stack, location, and code snippet
          - `message` string, nullable
          - `stack` string, nullable
          - `location` ContextErrorLocation, nullable — Source code location of an error
            - `file` string
            - `line` integer
            - `column` integer
          - `snippet` string, nullable — Code snippet around the error location
        - `steps` ContextStep[] — Nested child steps
      - `stdout` string[] — Standard output lines from the test
      - `stderr` string[] — Standard error lines from the test
      - `assets` object — Signed URLs for traces, screenshots, videos, and attachments
        - `traces` ContextAsset[]
          - `name` string
          - `url` string — Signed, time-limited URL to fetch the object from storage. The uploader may store the object with gzip compression; the GET response can include `Content-Encoding: gzip`. Decompress when that header is present or when the body starts with gzip magic bytes `0x1f 0x8b`. Browsers and most HTTP libraries decompress automatically when they send `Accept-Encoding: gzip`; other clients may need explicit decompression.
        - `screenshots` ContextAsset[]
          - `name` string
          - `url` string — Signed, time-limited URL to fetch the object from storage. The uploader may store the object with gzip compression; the GET response can include `Content-Encoding: gzip`. Decompress when that header is present or when the body starts with gzip magic bytes `0x1f 0x8b`. Browsers and most HTTP libraries decompress automatically when they send `Accept-Encoding: gzip`; other clients may need explicit decompression.
        - `videos` ContextAsset[]
          - `name` string
          - `url` string — Signed, time-limited URL to fetch the object from storage. The uploader may store the object with gzip compression; the GET response can include `Content-Encoding: gzip`. Decompress when that header is present or when the body starts with gzip magic bytes `0x1f 0x8b`. Browsers and most HTTP libraries decompress automatically when they send `Accept-Encoding: gzip`; other clients may need explicit decompression.
        - `attachments` object[]
          - `name` string
          - `filename` string
          - `contentType` string
          - `url` string — Signed URL to the attachment
        - `totals` object, nullable — Total counts for each asset category. Only present when assets are limited (detail=compact or detail=summary)
          - `traces` integer — Total number of traces before limiting
          - `screenshots` integer — Total number of screenshots before limiting
          - `videos` integer — Total number of videos before limiting
          - `attachments` integer — Total number of attachments before limiting
      - `meta` object, required
        - `projectId` string
        - `runId` string
        - `instanceId` string
        - `testId` string
        - `signature` string
        - `attempt` integer
      - `environment` object, required
        - `framework` ContextFramework, nullable — Test framework information
          - `type` string — Framework type (e.g., playwright, cypress)
          - `version` string, nullable
        - `platform` ContextPlatform, nullable — Platform/browser information
          - `osName` string
          - `osVersion` string
          - `browserName` string
          - `browserVersion` string
        - `project` string, nullable
    - ContextInstanceData
      - `level` 'instance', required
      - `spec` string, required
      - `instanceStatus` string, required — Instance lifecycle status (FAILED, TIMED_OUT, CANCELLED, etc.)
      - `instanceAssets` object, required — Instance-level assets
        - `stdout` ContextAsset — A signed URL reference to a stored artifact (trace, screenshot, video, attachment, or instance stdout).
          - `name` string
          - `url` string — Signed, time-limited URL to fetch the object from storage. The uploader may store the object with gzip compression; the GET response can include `Content-Encoding: gzip`. Decompress when that header is present or when the body starts with gzip magic bytes `0x1f 0x8b`. Browsers and most HTTP libraries decompress automatically when they send `Accept-Encoding: gzip`; other clients may need explicit decompression.
      - `list` object[], required — Failed tests on this page
        - `testId` string
        - `title` string[] — Test title hierarchy
        - `status` string
        - `attempt` integer
        - `duration` integer — Duration in milliseconds
        - `error` ContextError, nullable — Error details including message, stack, location, and code snippet
          - `message` string, nullable
          - `stack` string, nullable
          - `location` ContextErrorLocation, nullable — Source code location of an error
            - `file` string
            - `line` integer
            - `column` integer
          - `snippet` string, nullable — Code snippet around the error location
        - `errorContext` ContextAsset — A signed URL reference to a stored artifact (trace, screenshot, video, attachment, or instance stdout).
          - `name` string
          - `url` string — Signed, time-limited URL to fetch the object from storage. The uploader may store the object with gzip compression; the GET response can include `Content-Encoding: gzip`. Decompress when that header is present or when the body starts with gzip magic bytes `0x1f 0x8b`. Browsers and most HTTP libraries decompress automatically when they send `Accept-Encoding: gzip`; other clients may need explicit decompression.
        - `failureContext` ContextFailureContext, nullable — Context around the failed step
          - `failedStepIndex` integer — Index of the failed step in the flattened steps array (0-indexed)
          - `stepBefore` ContextStep — A test execution step (recursive structure)
            - `title` string — Step title/description
            - `category` string — Step category (e.g., pw:api)
            - `duration` integer — Duration in milliseconds
            - `error` ContextError, nullable — Error details including message, stack, location, and code snippet
              - …
            - `steps` ContextStep[] — Nested child steps
          - `failedStep` ContextStep — A test execution step (recursive structure)
            - `title` string — Step title/description
            - `category` string — Step category (e.g., pw:api)
            - `duration` integer — Duration in milliseconds
            - `error` ContextError, nullable — Error details including message, stack, location, and code snippet
              - …
            - `steps` ContextStep[] — Nested child steps
          - `stepAfter` ContextStep — A test execution step (recursive structure)
            - `title` string — Step title/description
            - `category` string — Step category (e.g., pw:api)
            - `duration` integer — Duration in milliseconds
            - `error` ContextError, nullable — Error details including message, stack, location, and code snippet
              - …
            - `steps` ContextStep[] — Nested child steps
        - `detailUrl` string — Absolute URL for full test-level context
        - `totalAttempts` integer
      - `count` integer, required — Number of items in `list` for this page
      - `total` integer, required — Total number of failed tests for the instance
      - `nextPage` union, required — Next page index (0-based), or false if no more pages
        - integer
        - false
      - `meta` object, required
        - `projectId` string
        - `runId` string
        - `instanceId` string
      - `environment` object, required
        - `framework` ContextFramework, nullable — Test framework information
          - `type` string — Framework type (e.g., playwright, cypress)
          - `version` string, nullable
        - `platform` ContextPlatform, nullable — Platform/browser information
          - `osName` string
          - `osVersion` string
          - `browserName` string
          - `browserVersion` string
        - `project` string, nullable
    - ContextRunData
      - `level` 'run', required
      - `runId` string, required
      - `runStatus` string, required
      - `instances` object[], required — All non-passed instances in the run
        - `instanceId` string
        - `spec` string
        - `status` string
        - `durationMs` integer, nullable
        - `groupId` string, nullable
      - `list` object[], required — Paginated unique failing tests (deduplicated by signature + error)
        - `testId` string
        - `title` string[] — Test title hierarchy
        - `status` string
        - `attempt` integer
        - `duration` integer — Duration in milliseconds
        - `error` ContextError, nullable — Error details including message, stack, location, and code snippet
          - `message` string, nullable
          - `stack` string, nullable
          - `location` ContextErrorLocation, nullable — Source code location of an error
            - `file` string
            - `line` integer
            - `column` integer
          - `snippet` string, nullable — Code snippet around the error location
        - `errorContext` ContextAsset — A signed URL reference to a stored artifact (trace, screenshot, video, attachment, or instance stdout).
          - `name` string
          - `url` string — Signed, time-limited URL to fetch the object from storage. The uploader may store the object with gzip compression; the GET response can include `Content-Encoding: gzip`. Decompress when that header is present or when the body starts with gzip magic bytes `0x1f 0x8b`. Browsers and most HTTP libraries decompress automatically when they send `Accept-Encoding: gzip`; other clients may need explicit decompression.
        - `failureContext` ContextFailureContext, nullable — Context around the failed step
          - `failedStepIndex` integer — Index of the failed step in the flattened steps array (0-indexed)
          - `stepBefore` ContextStep — A test execution step (recursive structure)
            - `title` string — Step title/description
            - `category` string — Step category (e.g., pw:api)
            - `duration` integer — Duration in milliseconds
            - `error` ContextError, nullable — Error details including message, stack, location, and code snippet
              - …
            - `steps` ContextStep[] — Nested child steps
          - `failedStep` ContextStep — A test execution step (recursive structure)
            - `title` string — Step title/description
            - `category` string — Step category (e.g., pw:api)
            - `duration` integer — Duration in milliseconds
            - `error` ContextError, nullable — Error details including message, stack, location, and code snippet
              - …
            - `steps` ContextStep[] — Nested child steps
          - `stepAfter` ContextStep — A test execution step (recursive structure)
            - `title` string — Step title/description
            - `category` string — Step category (e.g., pw:api)
            - `duration` integer — Duration in milliseconds
            - `error` ContextError, nullable — Error details including message, stack, location, and code snippet
              - …
            - `steps` ContextStep[] — Nested child steps
        - `detailUrl` string — Absolute URL for full test-level context
        - `instanceId` string
        - `spec` string
        - `groupId` string, nullable
        - `alsoFailedIn` object[] — Other tests with the same error (cross-group deduplication)
          - `testId` string
          - `instanceId` string
          - `groupId` string
          - `title` string[] — Test title for context
      - `count` integer, required — Number of items in `list` for this page
      - `total` integer, required — Unique failing tests after deduplication (may be subset on large runs)
      - `nextPage` union, required — Next page index (0-based), or false if no more pages
        - integer
        - false
      - `meta` object, required
        - `projectId` string
        - `runId` string
      - `environment` object, required
        - `framework` ContextFramework, nullable — Test framework information
          - `type` string — Framework type (e.g., playwright, cypress)
          - `version` string, nullable

## Other responses

- `400` — Invalid request parameters
- `401` — Authentication failed
- `404` — Resource not found
- `413` — Payload Too Large - Response size exceeds limits. Use Accept-Encoding: gzip header, or reduce size with detail=compact, detail=summary, or max_length (markdown only).

---

[API](https://skmtc.dev/currents/apis/currents-rest-api.md) · [All operations](https://skmtc.dev/currents/apis/currents-rest-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/currents/currents-rest-api/revisions/d0e2ed0e7e6a/schema)
