# Candidates

> People on a job, from the apply link or by email; their statuses; the ranked list (no single score); and the one command they run.

Source: https://docs.b55.online/candidates

A candidate is one person on one job. They arrive through the job's apply link, or you add them by email and they open the same link. Each candidate gets a report when their scan lands.

## Add candidates by email

`POST /v0/jobs/{job_id}/candidates`

```bash
curl -s -X POST http://localhost:3100/api/v0/jobs/job_000001/candidates \
  -H "Authorization: Bearer $B55_API_KEY" -H 'content-type: application/json' \
  -d '{"email":"maya-frontend@example.com","client_id":"application-1042"}'
```

```json
{
  "object": "candidate",
  "id": "cand_000002",
  "job_id": "job_000001",
  "client_id": "application-1042",
  "email": "maya-frontend@example.com",
  "github": null,
  "source": "email",
  "status": "invited",
  "command": "pnpm b55 scan --candidate cand_000002 --demo",
  "report_id": null,
  "verdict": null,
  "relevance": null,
  "confidence": null,
  "timeline": [{ "status": "invited", "at": "2026-11-24T12:47:36.400Z" }],
  "created_at": "2026-11-24T12:47:36.400Z",
  "updated_at": "2026-11-24T12:47:36.400Z"
}
```

- The same email, or the same `client_id`, on the same job returns the existing candidate. **Sandbox:** no email is sent. **Production plan:** B55 emails them the job's apply link.
- `github` stays `null` until the candidate signs in. B55 never guesses a GitHub account from an email.
- A closed job returns `409 job_closed`.

## Statuses

| Status | Meaning | Event |
|---|---|---|
| `invited` | Added by email; has not opened the apply link yet. | `candidate.created` |
| `opened` | Opened the apply link and signed in with GitHub. People who apply through the link start here. | `candidate.opened` (and `candidate.created` for link applicants) |
| `consented` | Agreed to share. Waiting for them to run the command. | `candidate.consented` |
| `scanned` | The scan landed; the report is being built (a moment). | `scan.received` |
| `ready` | The report is ready. `verdict`, `relevance` and `confidence` are filled in. | `report.ready` |
| `insufficient_evidence` | Too little history to assess. The report says so; **it is not a low score**. | `report.insufficient_evidence` |

`ready` and `insufficient_evidence` are final. **Production plan:** `expired` (never finished) and withdrawal of consent (`consent.revoked`, the report is deleted).

## Ranking

`GET /v0/jobs/{job_id}/candidates` returns the job's candidates ranked:

1. **Verdict** first: `verified`, then `partially-verified`, then `self-reported`, then `insufficient-evidence`. Checked work comes before claims.
2. Then **role fit**: `strong`, `partial`, `weak`, `not-assessed`.
3. Then **confidence**: `high`, `medium`, `low`.
4. Then newest first, then by id (so the order never changes between calls).

Candidates without a report yet come after everyone with one. There is **no single overall score**, on purpose: self-reported numbers never rank anyone on their own.

```bash
curl -s "http://localhost:3100/api/v0/jobs/job_000001/candidates?sort=ranked&status=ready&verdict=verified" -H "Authorization: Bearer $B55_API_KEY"
```

| Query | Values |
|---|---|
| `sort` | `ranked` (default), `newest`, `oldest` |
| `status` | any status above |
| `verdict` | `verified`, `partially-verified`, `self-reported`, `insufficient-evidence` |

Anything else is `422 invalid_query`. `GET /v0/candidates/{candidate_id}` returns one candidate.

## The candidate's side

On the apply page the candidate signs in, sees what is shared and what never is, and consents. The page then shows their one command:

```bash
pnpm b55 scan --candidate cand_000002 --demo
```

- **Sandbox:** it runs the real CLI from this repo on sample data (`--demo`), shows in plain words exactly what it would send, and sends nothing unless they answer yes. To scan your own history instead, run `node <repo>/packages/cli/dist/index.js scan --candidate cand_… --sandbox-url http://localhost:3100/api` inside your project. The sandbox has no GitHub spot-check, so a real CLI scan is always `self-reported`. **Simulate scan** on the apply page plays the fictional developer instead.
- **Live:** one `npx` command with a signed, single-use token instead of the candidate id (next section).

These two candidate-facing calls take no API key: `POST /v0/jobs/{job_id}/apply` (the apply page) and `POST /v0/candidates/{candidate_id}/scan` (the CLI). A scan before consent is `409 consent_required`. They are not in the SDKs: your backend never calls them.

## Candidate tokens and the CLI command

In a live job the apply page, after the candidate has consented, shows one command:

```bash
npx -y github:Perfstaq/b55-cli scan --candidate b55ct_…
```

The `b55ct_…` value is a **candidate token**. It is what lets the CLI upload one scan, so treat it like a password:

| | |
|---|---|
| Single use | The first accepted upload spends it. A second try is refused. |
| Expires | 2 hours after it was issued. The candidate can generate a new one from the apply page in one click. |
| GitHub-bound | It belongs to the GitHub account the candidate signed in with, and the scan must be signed for exactly this command. Someone else cannot use it. |
| Scoped | It can upload one scan for one candidate on one job. It cannot read anything. |

The command installs the CLI from the public `Perfstaq/b55-cli` repository with `npx`, so the candidate needs Node and git. The CLI shows what it is about to send and sends nothing unless they answer yes. A token that is malformed, expired, used or for a different candidate is refused with a `token_*` code, and the fix is always to copy the current command from the apply page ([Errors](/errors#token_malformed)).

Your backend never sees or sends candidate tokens.

## Advance (sandbox only)

`POST /v0/candidates/{candidate_id}/advance` plays the candidate's next step: `invited → opened → consented → ready | insufficient_evidence`. A finished candidate returns `409 candidate_finished`. This endpoint does not exist in production.

## Sandbox candidates

The sandbox has eight fictional developers. On the apply page you pick one as the GitHub sign-in. For people added by email, the email's local part picks one when they sign in (`omar-backend@anything.com` gets that developer; any other email picks one deterministically).

| Developer | Evidence | Verdict you will see |
|---|---|---|
| `maya-frontend` | Signed commits, TypeScript and React | `verified` |
| `omar-backend` | GitHub-verified, Go and SQL | `verified` |
| `lin-mobile` | GitHub-verified, Swift, Kotlin and Dart | `verified` |
| `ravi-systems` | Signed commits, Rust and C++ | `verified` |
| `ada-agents` | GitHub-verified, Python with heavy AI-agent use | `verified` |
| `sam-private` | Mostly private work, 4 of 12 sampled commits matched | `partially-verified` |
| `kai-quiet` | No public commits matched, inactive | `self-reported` |
| `nia-new` | 8 commits on a new account | `insufficient-evidence` |

Confidence and role fit depend on the job's role. See [Reports](/reports).
