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.

POST/api/v1/drift/checkprs:read

Runs 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

NameTypeRequiredDescription
repostringrequiredRepository full name, e.g. "acme/backend".
spec_textstringrequiredWhat 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_numberintegeroptionalPull request number. Supply this or base_ref + head_ref.
base_refstringoptionalBranch to compare against, for checking an integration branch before its release PR exists. Requires head_ref.
head_refstringoptionalBranch carrying the change. Requires base_ref.
requirementsstring[]optionalA checklist you have already agreed on, up to 20 items. When present, extraction is skipped and exactly these are judged.
wait_secondsintegeroptionalHow 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_idstringoptionalOnly 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

JSON
{
  "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…"
}
GET/api/v1/drift/runs/{run_id}prs:read

Fetches 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

NameTypeRequiredDescription
run_idstringrequiredThe run id returned by POST /api/v1/drift/check.
workspace_idstringoptionalOnly 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

JSON
{
  "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
    }
  ]
}