API reference
Drift API
Check whether a code change actually implements the spec it was written from. A jury of models judges each requirement against the real diff and cites the lines that prove it.
/api/v1/drift/checkprs:readRuns a spec drift check against a pull request (or merge request) or a pair of branches. The spec is prose in your own words — the engine extracts the discrete requirements itself, then has several models independently judge each one against the diff, keeping only verdicts backed by a quote that mechanically matches the patch. Returns the finished report, or a run id to poll when the check outlasts wait_seconds.
Request body
| Name | Type | Required | Description |
|---|---|---|---|
repo | string | required | Repository full name, e.g. "acme/backend". |
spec_text | string | required | What the change was supposed to do, in prose. 20–40 000 characters. Meeting notes, a ticket description, or a paragraph you typed all work — no checklist formatting required. |
pr_number | integer | optional | Pull request number. Supply this or base_ref + head_ref. |
base_ref | string | optional | Branch to compare against, for checking an integration branch before its release PR exists. Requires head_ref. |
head_ref | string | optional | Branch carrying the change. Requires base_ref. |
requirements | string[] | optional | A checklist you have already agreed on, up to 20 items. When present, extraction is skipped and exactly these are judged. |
wait_seconds | integer | optional | How long to hold the request open waiting for the result, 0–240 (default 90). Prefer a small value and poll — a long-held request is at the mercy of every proxy in between. |
workspace_id | string | optional | Only needed when the API key spans an organization with more than one workspace. |
Request
curl -X POST https://api.scopedocs.ai/api/v1/drift/check \
-H "X-API-Key: sk-sd_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"repo": "acme/backend",
"pr_number": 412,
"spec_text": "Shoppers can apply a discount code at checkout. The code is validated against the discount table and applied to the order total before shipping is calculated.",
"wait_seconds": 20
}'Response
{
"run_id": "2edf5dee-63f2-4d87-b7e2-a0fa7bbf7958",
"status": "complete",
"repo": "acme/backend",
"target": {
"kind": "pr",
"pr_number": 412
},
"coverage_score": 0.7,
"summary": "The discount code is validated and applied to the order total, but expired codes are not rejected and the applied code is never stored on the order.",
"requirements": [
{
"text": "a valid discount code reduces the order total",
"verdict": "covered",
"confidence": 1,
"evidence": [
{
"file": "api/checkout.py",
"quote": "total = apply_discount(total, code.percent_off)"
}
]
},
{
"text": "an expired discount code shows an error",
"verdict": "missing",
"confidence": 1,
"evidence": []
}
],
"overspec": [
{
"summary": "A new /api/discounts/audit endpoint appears in the diff that no requirement explains."
}
],
"report_markdown": "## Drift check: 70% of the intent shipped\n…"
}/api/v1/drift/runs/{run_id}prs:readFetches a drift run's report: per-requirement verdicts with their evidence quotes, the coverage score, over-spec findings, and the stage-by-stage run log. Use this to poll a run that was still going when the check returned, or to re-read a finished one.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
run_id | string | required | The run id returned by POST /api/v1/drift/check. |
workspace_id | string | optional | Only needed when the API key spans an organization with more than one workspace. |
Request
curl https://api.scopedocs.ai/api/v1/drift/runs/2edf5dee-63f2-4d87-b7e2-a0fa7bbf7958 \
-H "X-API-Key: sk-sd_your_key_here"Response
{
"run_id": "2edf5dee-63f2-4d87-b7e2-a0fa7bbf7958",
"status": "complete",
"coverage_score": 0.7,
"requirements": [
{
"text": "a valid discount code reduces the order total",
"verdict": "covered",
"confidence": 1,
"reasoning": "The checkout path applies the discount to the running total before shipping is added.",
"evidence": [
{
"file": "api/checkout.py",
"quote": "total = apply_discount(total, code.percent_off)"
}
]
}
],
"overspec": [],
"report_markdown": "## Drift check: 70% of the intent shipped\n…",
"log": [
{
"stage": "verify",
"detail": "judged 5 requirements",
"ms": 41200
}
]
}