Context
Retrieve structured test failure context for AI debugging.
The Context endpoint provides test failure data in JSON or Markdown format, suitable for feeding into AI tools and MCP integrations. It supports three detail levels:
Run-level: Summary of all failures across a run
Instance-level: Failures within a single spec file
Test-level: Full detail for a single test attempt
Retrieve structured test failure context for AI debugging. One of three query shapes is used:
Run-level:
run_idonly (omitinstance_idandtest_id). Paginate failed tests withlimitandpage. Addinclude_flaky=trueto also list flaky tests after the failed ones.Instance-level:
run_idandinstance_id(omittest_id). Paginate withlimitandpage.Test-level:
instance_idandtest_id. The run is resolved server-side from the instance; optionalrun_idis ignored for lookup. Optionalattemptselects a specific attempt; omit for the last attempt with an error (else 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.
An organization API key, sent as Authorization: Bearer <key>. A key carries one scope for the whole API: a read key reaches the GET endpoints, a write key reaches all of them.
Run identifier. Required for run-level (run_id only) and instance-level (run_id + instance_id, no test_id). For test-level (instance_id + test_id), ignored; the server resolves the run from the instance.
Instance identifier. Required for instance-level and test-level. Omit for run-level (use run_id only).
Test identifier. When set, selects test-level detail and requires instance_id.
Attempt number (0-indexed); defaults to the last attempt with an error, or the latest attempt when none reported one. Test-level only: sending it without both instance_id and test_id is rejected with 400 rather than ignored.
Response format. Falls back to Accept header when absent.
jsonPossible values: Controls output verbosity to limit token count. 'default' returns all available data. 'compact' reduces output size by omitting the full steps array and limiting assets to 3 per category while preserving failure context and analysis. 'summary' minimizes output by including only error info and metadata.
defaultPossible values: Maximum number of failed tests per page (run-level and instance-level only)
10Page number for failed tests pagination, 0-indexed (run-level and instance-level only)
0Truncate markdown response to this character limit (only applies when format=md). Useful for fitting context into AI prompts.
Run-level only. When true, flaky tests are listed after the failed ones (each with the error from its last failed attempt) and totalFlakyTests is set.
falseContext data
Invalid request parameters
Authentication failed
The credential authenticated but is not permitted to use this endpoint. Four refusals share the status: a read API key on an endpoint that writes, an OAuth token that was not granted the scope the endpoint needs (insufficient_scope), an OAuth token that was granted it but whose holder no longer has a role permitting it (insufficient_role), and an OAuth token on an endpoint that accepts an API key and nothing else (api_key_required). Discriminate on code rather than on the message, which is free-form. The first refusal predates the codes and sets none. Only insufficient_scope carries the challenge header, because it is the only one a client can act on by re-authorizing.
Resource not found
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).
GET /v1/context HTTP/1.1
Host: api.currents.dev
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
{
"status": "OK",
"data": {
"level": "test",
"spec": "text",
"test": {
"title": [
"text"
],
"status": "text",
"attempt": 1,
"totalAttempts": 1,
"duration": 1
},
"error": {
"message": "text",
"stack": "text",
"location": {
"file": "text",
"line": 1,
"column": 1
},
"snippet": "text"
},
"otherAttempts": [
{
"attempt": 1,
"status": "text",
"sameError": true,
"error": {
"message": "text",
"location": {
"file": "text",
"line": 1,
"column": 1
}
}
}
],
"errorContext": {
"name": "text",
"url": "text"
},
"traceErrorAnalysis": {
"consoleEntries": [
{
"time": 1,
"messageType": "text",
"text": "text",
"location": {
"url": "text",
"lineNumber": 1,
"columnNumber": 1
}
}
],
"networkRequests": [
{
"time": 1,
"url": "text",
"status": 1,
"method": "text"
}
]
},
"failureContext": {
"failedStepIndex": 1,
"stepBefore": {
"title": "text",
"category": "text",
"duration": 1,
"error": {
"message": "text",
"stack": "text",
"location": {
"file": "text",
"line": 1,
"column": 1
},
"snippet": "text"
},
"steps": "[Circular Reference]"
},
"failedStep": {
"title": "text",
"category": "text",
"duration": 1,
"error": {
"message": "text",
"stack": "text",
"location": {
"file": "text",
"line": 1,
"column": 1
},
"snippet": "text"
},
"steps": [
"[Circular Reference]"
]
},
"stepAfter": {
"title": "text",
"category": "text",
"duration": 1,
"error": {
"message": "text",
"stack": "text",
"location": {
"file": "text",
"line": 1,
"column": 1
},
"snippet": "text"
},
"steps": "[Circular Reference]"
}
},
"steps": [
{
"title": "text",
"category": "text",
"duration": 1,
"error": {
"message": "text",
"stack": "text",
"location": {
"file": "text",
"line": 1,
"column": 1
},
"snippet": "text"
},
"steps": [
"[Circular Reference]"
]
}
],
"stdout": [
"text"
],
"stderr": [
"text"
],
"assets": {
"traces": [
{
"name": "text",
"url": "text"
}
],
"screenshots": [
{
"name": "text",
"url": "text"
}
],
"videos": [
{
"name": "text",
"url": "text"
}
],
"attachments": [
{
"name": "text",
"filename": "text",
"contentType": "text",
"url": "text"
}
],
"totals": {
"traces": 1,
"screenshots": 1,
"videos": 1,
"attachments": 1
}
},
"meta": {
"projectId": "text",
"runId": "text",
"instanceId": "text",
"testId": "text",
"signature": "text",
"attempt": 1
},
"environment": {
"framework": {
"type": "text",
"version": "text"
},
"platform": {
"osName": "text",
"osVersion": "text",
"browserName": "text",
"browserVersion": "text"
},
"project": "text"
},
"git": {
"repository": "text",
"branch": "text",
"sha": "text",
"pullRequest": {
"number": "text",
"url": "text",
"baseBranch": "text"
}
}
}
}Last updated
Was this helpful?