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
The context to fix tests that failed in CI: errors, steps and files of the failed tests of a run, a spec file or a single test — the same content as Fix in the Currents dashboard. To hand it to someone without Currents credentials, create a link with POST /share and purpose: fix.
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. A crnts_pat_ personal access token is accepted as a Bearer while its owner remains an eligible administrator in its active organization. Each operation requires the corresponding scope stored on that token.
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. Five 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), an OAuth token on an endpoint that accepts an API key and nothing else (api_key_required), and an API key on an endpoint that answers for a user (user_credential_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"
}
}
}
}Creates a public link to test results for a run, a spec file (instance) or a single test, for someone or something with no Currents credentials: a coding agent, a reviewer, a CI comment. Anyone with the link can open it, without authentication, until it expires. Treat the link as a secret.
purpose picks the document:
fix: the failure context, the same markdownGET /context?format=mdreturns, for an agent that will fix the tests. Flaky tests are included and markedflaky, so the reader decides whether they matter. Defaults to 1 day.report: every test of the target with each attempt, its status, duration and file links, for a person. Defaults to 7 days.
The document is rendered once, when the link is created, and does not reflect later changes to the run.
Without expiresInDays, a fix request for the same target returns the existing link while more than an hour of it remains. With it, and for every report, a new link is created.
An organization can turn public sharing off entirely; see the 403 response.
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. A crnts_pat_ personal access token is accepted as a Bearer while its owner remains an eligible administrator in its active organization. Each operation requires the corresponding scope stored on that token.
A single test. attempt is accepted only here, and runId is ignored.
One instance of a run.
A whole run.
The public link
OKInvalid request parameters
Authentication failed
Either the credential cannot create links (an OAuth token without shares:write, or a read-only API key), or public sharing is turned off for this organization. An organization admin can turn it back on; links created earlier keep working until they expire.
Resource not found
fix only: nothing failed in the target, or the selected attempt recorded no error.
Rate limit exceeded
POST /v1/share HTTP/1.1
Host: api.currents.dev
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 98
{
"purpose": "fix",
"runId": "text",
"instanceId": "text",
"testId": "text",
"attempt": 1,
"expiresInDays": 1
}{
"status": "OK",
"data": {
"purpose": "fix",
"url": "https://s.crts.sh/ai/x7Kp2mQ9vLbEr4Tz.md",
"pageUrl": "https://s.crts.sh/ai/x7Kp2mQ9vLbEr4Tz",
"expiresAt": "2026-01-01T00:00:00.000Z"
}
}Last updated
Was this helpful?