# Fit-check API for agents

The human fit-check lives at <https://antonio.mk/fit-check/>. This document is
the machine-facing guide: it explains how an AI agent or another non-browser
client can run the same evidence-based role review through the HTTP API.

- Base URL: `https://antonio.mk/api`
- OpenAPI 3.1 contract: `https://antonio.mk/fit-check/openapi.json`
- This guide: `https://antonio.mk/fit-check/api.md`
- Human page: `https://antonio.mk/fit-check/`

`GET https://antonio.mk/fit-check/` returns this document when the request asks
for Markdown (`Accept: text/markdown` or `text/plain`) or comes from a recognized
agent or command-line user agent. Browser requests receive the normal HTML page.

## Ground rules

- Only submit a job description the user is allowed to share. The API stores the
  supplied JD and the clarifications added to the review.
- Never invent facts. Ask the user for missing salary, contract, location, work
  authorization, schedule, stack, or work-setup details.
- Do not submit a contact proposal unless the user explicitly asks you to
  contact Antonio. A proposal is a message from the user, not an automated
  application.
- The `credential` returned by `POST /reviews` is the only way to read or update
  that review. Store it securely and keep it out of URLs, logs, and share text.
- Share links are public. Anyone with the link can read the job description and
  clarifications in the snapshot. Create one only with the user's consent.
- Run one assessment at a time. Each create or update invokes a language model
  and can take up to about 90 seconds.
- The API is JSON-only and sends no CORS headers. Call it from a server, CLI, or
  agent runtime, not from a browser page on another origin.
- Do not use `POST /reviews/precheck/answer`. It is a legacy stub that returns
  `{"status":"proceed"}` and is intentionally excluded from the API contract.

## Recommended flow

1. If the user supplies a link or text with links, `POST /reviews/jd-source` and
   follow its result. When it returns `confirm`, ask the user to choose before
   continuing.
2. `POST /reviews/precheck` with the confirmed job description.
3. If the response contains `questions`, ask the user and collect answers.
4. `POST /reviews` with the job description and any gate data.
5. Present `view.report` and keep the credential for follow-ups.

### 0. Resolve text and links (optional)

When the user supplies a link instead of pasted text, convert it first. The
resolver also accepts text with links inside it:

```sh
curl -sS https://antonio.mk/api/reviews/jd-source \
  -H 'content-type: application/json' \
  -d '{"input":"Senior product engineer. Required: React and TypeScript. More detail: https://job-boards.greenhouse.io/apolloio/jobs/6150774004"}'
```

`input` is text, one or more links, or a mix of both, up to 20,000 characters.
Each link is http or https and at most 2,048 characters. The older
`{"url":"..."}` body is still accepted for clients written against the first
version of this endpoint. The source URL is never stored; only the resolved text
enters the review.

The response always contains `status`, `jd`, `sources`, `notices`, and
`confirmation`:

```json
{
  "status": "ready",
  "jd": "the confirmed posting text",
  "sources": [
    {
      "url": "https://job-boards.greenhouse.io/apolloio/jobs/6150774004",
      "host": "job-boards.greenhouse.io",
      "title": "Senior Software Engineer, Growth",
      "kind": "job",
      "message": "Matches your pasted description."
    }
  ],
  "notices": ["The linked posting matches your pasted description."],
  "confirmation": null
}
```

When `status` is `ready`, use `jd` for precheck. When `status` is `confirm`,
**ask the user** which source is the role they want. Each
`confirmation.options[]` entry has a short `label`, a `description`, and its own
complete `jd`. Do not combine options and do not pick one yourself. After the
user chooses, use that option's `jd` for precheck.

```json
{
  "status": "confirm",
  "jd": "the recommended option's text",
  "sources": [
    {
      "url": "https://example.com/jobs/42",
      "host": "example.com",
      "title": "Staff Product Engineer",
      "kind": "job",
      "message": "Looks like a different role."
    }
  ],
  "notices": [],
  "confirmation": {
    "prompt": "The linked posting describes a different role. Which description should this fit-check use?",
    "options": [
      {
        "id": "pasted",
        "label": "Use your pasted description",
        "description": "1,240 characters of pasted text",
        "jd": "the pasted description"
      },
      {
        "id": "source-s0",
        "label": "Use “Staff Product Engineer”",
        "description": "example.com · 8,100 characters",
        "jd": "the linked posting text"
      }
    ]
  }
}
```

One fit-check covers one role. `sources[].kind` explains how each link was
treated: `job` (the role description), `supporting` (role-relevant context such
as benefits), `unrelated`, or `unreadable`. Supporting context may already be
included in `jd` under an `Additional context from ...` heading when it adds
details. A failed link never discards usable pasted text; the reason is in
`notices` and `sources[].message`.

The importer reads up to four public links per request, in parallel. It uses
official Greenhouse, Lever, Ashby, and Workable APIs when available, then
schema.org `JobPosting` data, then the page text. It does not store the URLs,
sign in, or solve CAPTCHAs. If a site blocks automated reads, ask the user to
open the posting and paste the description. LinkedIn, Indeed, and Glassdoor
links normally need pasted text.

Declared failures (only when no usable text or link remains):

- `400 InvalidInput`: malformed text, an unsafe URL, or a link to a job board
  rather than an individual posting.
- `404 NotFound`: every supplied posting expired or was removed.
- `413 TooLarge`: a page resolved to more than 20,000 characters. Ask the user
  to paste the role and requirements section only.
- `422 InvalidRole`: the text or links did not contain a readable job
  description, or the only link was supporting information.
- `503 UpstreamUnavailable`: the site blocked the request, timed out, or was
  otherwise unreachable.

Resolution normally takes a few seconds and may take up to about 45 seconds
when several links need the managed fallback. Never submit a URL directly as
`jd` to precheck or create.

### 1. Precheck the job description

```sh
curl -sS https://antonio.mk/api/reviews/precheck \
  -H 'content-type: application/json' \
  -d '{"jd":"We are hiring a senior product engineer. Required: React and TypeScript. Remote within Europe. Salary: EUR 80,000-95,000 gross annual."}'
```

The request body is `{"jd": "..."}`. The `jd` is trimmed and must be 80-20,000
characters. To rerun a saved review, also send `clarifications`: the saved public
clarification history, at most 30 entries, 1-4,000 characters each and 65,000
characters in total. Saved clarifications are labelled context for the decision
model; they are never merged into the JD. The response is always HTTP 200 when
the check runs, with one of these shapes:

```json
{ "status": "unavailable" }
```

```json
{
  "status": "rejected",
  "reason": "This does not look like a job description."
}
```

```json
{
  "status": "questions",
  "round": 1,
  "questions": [
    {
      "id": "pay_range",
      "kind": "range",
      "prompt": "What is the annual gross salary range?",
      "options": [],
      "hint": "Include the currency and whether it is gross or net.",
      "topic": "compensation",
      "fields": ["pay_range", "pay_currency", "pay_period", "pay_basis"],
      "purpose": "clarification"
    }
  ],
  "signals": {
    "fieldDecisions": [],
    "factReadiness": [{ "topic": "compensation", "status": "missing" }],
    "isJobPosting": true,
    "isJobConfidence": 0.97,
    "missing": ["compensation"],
    "setup": "remote",
    "seniority": "senior"
  }
}
```

- `unavailable` means the description check could not run. Continue to create
  without gate data; the assessment still examines the JD.
- `rejected` means the text does not read as a job posting. Ask the user for the
  full role description instead of creating a review.
- `questions` means the check found consequential gaps. Ask the user each
  question, then send the answers to `POST /reviews`. A `questions` response with
  an empty `questions` array needs no answers.

Each question has a `kind`:

- `choice`: choose one of `options`, or record a free-form answer.
- `range`: ask for a range, for example `EUR 80,000-95,000 gross annual`.
- `text`: ask for a short free-form answer.

Never put words in the user's mouth. If the user cannot answer, record the
question as skipped or unknown in `questionContext` instead of inventing a value.

### 2. Create the review

```sh
curl -sS https://antonio.mk/api/reviews \
  -H 'content-type: application/json' \
  -d '{
    "jd": "We are hiring a senior product engineer. Required: React and TypeScript. Remote within Europe. Salary: EUR 80,000-95,000 gross annual.",
    "gateAnswers": [
      {
        "questionId": "pay_range",
        "question": "What is the annual gross salary range?",
        "answer": "EUR 80,000-95,000 gross annual"
      }
    ],
    "precheckFacts": [{ "topic": "compensation", "status": "resolved" }],
    "questionContext": {
      "decisions": [],
      "responses": [
        {
          "questionId": "pay_range",
          "topic": "compensation",
          "fields": ["pay_range", "pay_currency", "pay_period", "pay_basis"],
          "purpose": "clarification",
          "disposition": "answered"
        }
      ]
    }
  }'
```

The create body accepts:

- `jd` (required): the full posting, 80-20,000 characters after trimming.
- `gateAnswers` (optional, at most 9): one entry per answered question, with
  `questionId`, the original `question`, and the user's `answer` (1-2,000
  characters). Omit unanswered questions.
- `clarifications` (optional): saved public clarification history replayed when
  rerunning an existing review. At most 30 entries, 1-4,000 characters each and
  65,000 characters total, matching what updates can persist. The server stores
  these before the new `gateAnswers` and uses them as context for a fresh
  analysis with `previous: null`; the `jd` itself is stored unchanged. The
  combined saved history plus new `gateAnswers` must fit the review’s 30-entry /
  60,000-character storage bound; otherwise create returns HTTP 400
  `InvalidInput` before calling the model. Nothing is silently truncated.
- `precheckFacts` (optional): copy `signals.factReadiness` from the precheck
  response unchanged.
- `questionContext` (optional but recommended): copy `signals.fieldDecisions`
  (or `[]` when it is absent) into `decisions`. For every question with both
  `topic` and `fields`, add a response with the same `questionId`, `topic`,
  `fields`, and `purpose` (`clarification` by default), plus a `disposition`:
  - `answered` when the user answered;
  - `unknown` when the user explicitly could not answer;
  - `skipped` when the question was presented but not answered.

A successful create returns HTTP 201:

```json
{
  "credential": "a random bearer token",
  "view": {
    "id": "review id",
    "revisionId": "revision UUID",
    "jd": "the stored job description",
    "clarifications": ["question answer", "..."],
    "createdAt": 1760000000000,
    "report": {
      "title": "Senior product engineer",
      "company": null,
      "summary": "Short engineering summary.",
      "overall": {
        "score": 82,
        "experienceScore": 86,
        "conditionsScore": 75,
        "coverage": 90,
        "verdict": "strong",
        "strongestPointIds": ["react"],
        "concernPointIds": ["kubernetes"],
        "conditionPointIds": ["remote"]
      },
      "points": [
        {
          "id": "react",
          "title": "React",
          "category": "requirements",
          "importance": "required",
          "source": "React and TypeScript",
          "capability": {
            "status": "demonstrated",
            "explanation": "Direct production React experience.",
            "evidence": [
              {
                "id": "vidos",
                "title": "Vidos",
                "description": "Production React client.",
                "url": "https://antonio.mk/"
              }
            ]
          },
          "preference": null
        }
      ],
      "followUps": [],
      "assumptions": [],
      "unresolvedDetails": []
    }
  }
}
```

Treat `credential` as a secret. Persist `view.id`, `view.revisionId`, and the
credential together; the credential cannot be recovered if lost.

`view.report` is the same report rendered by the human page:

- `overall.score` is 0-100, with separate experience and conditions scores and a
  `verdict`: `strong`, `promising`, `limited`, `clarify`, `must_have_gap`, or
  `conflict`.
- `points` lists the extracted requirements, responsibilities, and working
  conditions. `importance` is `required`, `preferred`, or `unspecified`.
- `capability.status` is `demonstrated`, `partial`, `gap`, or `unknown`.
  `preference.status` is `aligned`, `discussion`, `conflict`, or `unknown`.
  Capability and preference are independent.
- `capability.evidence` contains the recorded work used to support a point. Do
  not claim experience that is not present in the evidence.
- `followUps`, `assumptions`, and `unresolvedDetails` describe what remains
  uncertain. Surface them instead of guessing.
- `evaluationVersions` appears on new reports; legacy reports may omit it and
  are reported as `unversioned` rather than failing to read.
- `run` (new reports only) is a public receipt of how the report was produced:
  `pipeline` (`staged` or `single`), `ai` (the kind of AI, e.g. `LLM`; never a
  model id), `totalMs`, `stages` (id, kind
  `llm` or `code`, start offset, duration, attempts and token counts), `checks`
  (quotes and evidence links verified, validator rules, repairs), the critic's
  `adjustments`, and `raw`, the validated structured output of each stage.
  Scores never come from the model; the server computes them.

### 2b. Create with live progress (optional)

`POST /api/reviews/stream` takes the same body and limits as `POST
/api/reviews` and answers with `text/event-stream`. Each event's `data` is a
JSON object with a `type`:

- `start` (`pipeline`, `ai`), then `stage` events (`id`, `label`, `status`:
  `running`, `done`, `repair` or `failed`, plus timings and token counts).
- `point`: a requirement as the extraction stage writes it; `verify`: a quote
  or evidence link passed the server checks.
- `match`: a lane's status and evidence ids for one requirement; `critic`: the
  audit's adjustments and whole-role axes; `score`: the server-computed score.
- `done` (`view`, `credential`), identical to the 201 body above, or `error`
  (`tag`, `message`) using the same tags as the JSON endpoint.

Invalid bodies are rejected before streaming with the usual JSON error. Use the
JSON endpoint when you do not need progress; the stream is not retried, and a
dropped connection does not cancel a review that has already started.

The authoritative field-level schema, including every optional property, is in
the OpenAPI document at <https://antonio.mk/fit-check/openapi.json>.

## Follow-ups and updates

### Read the current revision

```sh
curl -sS https://antonio.mk/api/reviews/REVIEW_ID/current \
  -H 'x-review-credential: CREDENTIAL'
```

The response is `{"view": { ... }, "freshness": { ... }}`. A missing, wrong, or
unknown credential returns HTTP 403; the API does not reveal whether the review
exists.

`freshness` describes the revision you just read:

```json
{
  "status": "outdated",
  "current": {
    "id": "ev1-…",
    "evaluator": "model=…;dialect=…;output=schema;effort=…;provider=…;decision=…;release=…",
    "evidence": "ev1-…",
    "preferences": "2026-10-08.4",
    "referenceData": "ecb-2026-10-07.1"
  },
  "evaluated": {
    "id": "ev1-…",
    "evaluator": "model=…;release=…",
    "evidence": "ev1-…",
    "preferences": "2026-10-08.4",
    "referenceData": "ecb-2026-10-07.1"
  },
  "changed": ["evaluator"]
}
```

- `current` is the manifest in use by the server now.
- `evaluated` is the manifest stored with this report, or `null` for a legacy
  report.
- `status` is `current` when every component matches, `outdated` when one or
  more differ, and `unversioned` when the report predates full version metadata.
- `changed` lists only the differing components: `evaluator`, `evidence`,
  `preferences`, or `referenceData`. For an unversioned report it may list
  legacy fields whose old versions are detected as different; an empty list
  still does not make the report current.

Run a rerun when `status` is not `current`. Reuse `view.jd` unchanged, pass the
saved `view.clarifications` to `POST /reviews/precheck`, then create a new
private review with the same `clarifications` and fresh `gateAnswers`. This is a
fresh evaluation, not an in-place update, so the original report and any share
snapshot stay intact.

### Ask a question or refine the review

```sh
curl -sS https://antonio.mk/api/reviews/REVIEW_ID/updates \
  -H 'content-type: application/json' \
  -H 'x-review-credential: CREDENTIAL' \
  -d '{"revisionId":"REVISION_UUID","message":"Do they offer visa sponsorship?"}'
```

Send exactly one of:

- `message` (1-4,000 characters): a clarification question or additional context.
- `jd` (80-20,000 characters): a replacement job description. When replacing the
  JD, run precheck first and include `gateAnswers` and `questionContext` in the
  same way as create. Replacing the JD clears earlier factual clarifications.

`revisionId` must be the current `view.revisionId`. A successful update returns
HTTP 200 with:

```json
{
  "view": { "...": "the new current view" },
  "changedIds": ["react"],
  "answer": "No sponsorship is mentioned in the posting.",
  "answerPointIds": ["eligibility"]
}
```

- `changedIds` lists report points whose assessment changed.
- `answer` is a direct short answer when the model could answer the message. It
  may be `null`.
- `answerPointIds` links that answer to report points.

If the update returns HTTP 409, the review changed in another session. Fetch
`GET /reviews/REVIEW_ID/current` again and retry with the new `revisionId`. Never
reuse a stale revision ID.

A review accepts at most 30 stored clarifications or 60,000 characters of
clarification text. A rerun create enforces the same bound over the saved
history plus fresh gate answers, so the new review can itself be rerun later.
When that limit is reached, start a new review with the complete JD and only the
clarifications that matter.

A clarification update reuses untouched points from the previous revision. It
therefore keeps that revision’s `evaluationVersions` (or its absence) instead of
claiming a complete current reevaluation; an answer-only update writes no
revision at all. Replacing the JD runs a full fresh analysis and stamps the
current manifest.

### Evaluation versions

New reports store `report.evaluationVersions`, a public manifest with four
component versions and a deterministic composite `id`:

- `evaluator` covers the configured model, dialect, output mode, reasoning
  effort, decision model, and the manual scoring/prompt release. Model ids
  appear only as hashes, so a change is detectable without naming the model.
- `evidence` fingerprints the exact candidate facts given to the model. Changing
  a model-facing fact invalidates old reports; changing only presentation such as
  URLs or PDF formatting does not.
- `preferences` is the private working-preference rules version.
- `referenceData` is the ECB exchange-rate snapshot version.

Model, endpoint, dialect, output-mode, effort, and decision-model changes are
detected automatically. Prompt, validation, scoring, or other behavior changes
need an explicit release bump (the server’s assessment version) so old results
are not silently presented as current. Preference-rule and exchange-rate changes
need their own version bumps.

The manifest deliberately contains no API keys, credentials, raw provider
endpoint, private preference rules, or compensation targets. Treat `current` and
`evaluated` as public metadata even though the report itself may be private.

## Sharing and copying

Create an immutable snapshot:

```sh
curl -sS https://antonio.mk/api/reviews/REVIEW_ID/shares \
  -H 'content-type: application/json' \
  -H 'x-review-credential: CREDENTIAL' \
  -d '{"revisionId":"REVISION_UUID"}'
```

The response is HTTP 201 with `{"shareId":"..."}`. The public URL is:

```text
https://antonio.mk/fit-check/?s=SHARE_ID
```

Later updates do not change an existing share. Anyone with the URL can read the
snapshot, including the JD and clarifications. Do not create a share link unless
the user asks for one.

Read a share without a credential:

```sh
curl -sS https://antonio.mk/api/review-shares/SHARE_ID
```

The response is `{"view": { ... }, "freshness": { ... }}` with the same
freshness shape as the current endpoint. Reading a share never updates the
snapshot; freshness is computed from the stored report for this response only.

Create an independent editable copy:

```sh
curl -sS -X POST https://antonio.mk/api/review-shares/SHARE_ID/copies
```

The copy returns HTTP 201 with a new `credential` and `view`. The copy is a
separate review; changes to it do not affect the original. Copying is not a
reevaluation: the copied report inherits the original report’s manifest, so
`GET /reviews/COPY_ID/current` keeps the same freshness until a full
reassessment (replacement JD) stamps the current manifest.

## Contact proposals

Only after the user explicitly asks to contact Antonio:

```sh
curl -sS https://antonio.mk/api/reviews/REVIEW_ID/proposals \
  -H 'content-type: application/json' \
  -H 'x-review-credential: CREDENTIAL' \
  -d '{
    "revisionId": "REVISION_UUID",
    "requestId": "A-FRESH-UUID",
    "message": "The role looks like a strong fit. Are you open to a conversation?",
    "email": "user@example.com",
    "name": "The user'"'"'s name",
    "company": "The user'"'"'s company"
  }'
```

- `message`: 10-4,000 characters.
- `email`: the user's reply address, at most 254 characters.
- `name` (optional, at most 120 characters) and `company` (optional, at most 180
  characters).
- `requestId`: a UUID chosen by you. Reuse the same value when retrying the same
  proposal; the API is idempotent on it.
- `revisionId`: the snapshot the proposal refers to. Use the current
  `view.revisionId`.

The response is HTTP 201 on the first save and HTTP 200 with the same
`proposalId` on a replay. No email is sent automatically; Antonio reads proposals
in the admin view.

## Limits, errors, and retries

- Total request body: at most 32,000 bytes, except `POST /reviews` and
  `POST /reviews/precheck`, which accept up to 1 MiB (1,048,576 bytes) so a full saved
  clarification history can be replayed with a complete JD and gate answers.
- `jd`: 80-20,000 characters after trimming.
- JD source `input`: 1-20,000 characters. Each link inside it: http or https,
  at most 2,048 characters, at most four links per request. Resolved `jd`:
  80-20,000 characters after trimming.
- `gateAnswers`: at most 9 entries, each answer 1-2,000 characters.
- Saved `clarifications`: at most 30 entries, each 1-4,000 characters, at most
  65,000 characters total. Precheck may use the full persisted history; create
  additionally requires the saved history plus fresh `gateAnswers` to fit the
  review storage bound of 30 entries or 60,000 characters, returning
  `400 InvalidInput` rather than truncating.
- Update `message`: 1-4,000 characters.
- Proposal `message`: 10-4,000 characters.
- `precheck` may take about 15 seconds; `jd-source` about 45 seconds; create and
  update may take up to about 90 seconds. Use a client timeout longer than 100
  seconds.

Declared errors use HTTP status codes and this JSON shape:

```json
{ "_tag": "InvalidRole", "message": "Paste a job description with the role's responsibilities and requirements." }
```

| Status | Meaning                                                         |
| ------ | --------------------------------------------------------------- |
| 400    | Invalid input, stale or malformed body (`InvalidInput`).        |
| 403    | Missing, wrong, or unknown credential (`Unauthorized`).         |
| 404    | Unknown share or revision, or an expired job posting (`NotFound`). |
| 409    | The revision is stale (`Conflict`).                             |
| 413    | Request, JD, or imported posting too large (`TooLarge`).        |
| 422    | The text does not read as a job description (`InvalidRole`).    |
| 502    | The model output failed validation (`ModelInvalid`).            |
| 503    | Provider, storage, or job page unavailable (`UpstreamUnavailable`, `StorageNotReady`). |

Schema decode failures may also return HTTP 400 with a different shape. Always
show the `message` field when it is present.

Retry guidance:

- 409: re-read the current review, then retry with the new revision ID.
- 502 or 503: wait and retry with exponential backoff (for example 1s, 4s),
  at most twice.
- `create` is not idempotent. If the request times out, do not retry
  automatically: a second create makes another review and can orphan the first
  credential. Ask the user before trying again.
- `share` is not idempotent; a retry creates another snapshot.
- `proposals` is idempotent on `requestId`.

There is no public rate-limit header or quota endpoint. Keep requests
sequential and avoid retrying non-idempotent calls.

## Discovery

- `GET /fit-check/` with `Accept: text/markdown` or `Accept: text/plain` returns
  this guide. Recognized AI agents and command-line clients get it without an
  explicit `Accept` header.
- `GET /fit-check/api.md` always returns this guide.
- `GET /fit-check/openapi.json` or `GET /api/openapi.json` returns the generated
  OpenAPI 3.1 document for the public review API. Admin routes are excluded.
- `GET /api/health` returns `{"ok":true}` when the API Worker is reachable.
