Docs · Understand
API reference
Organization-scoped REST. People authenticate with a session cookie, integrations with an org API token, and the API serves its own OpenAPI 3.1 document.
Authentication
Session cookie
Better Auth sets an HTTP-only session cookie when you sign in. Browsers send it on their own; other clients pass it with each request. Better Auth checks the Origin header of POST requests to its routes against TRUSTED_ORIGINS, so from a non-browser client send your web app's address as Origin, as the CLI does.
Organizations
The org-scoped routes need an active organization. A session without one gets 401 unauthorized. After you sign in:
POST /api/auth/organization/createwith{ "name", "slug" }creates an organization. You become its owner.POST /api/auth/organization/set-activewith{ "organizationId" }makes it active. Later calls are scoped to it.
The CLI calls the same two routes when it creates an organization.
curl -X POST http://localhost:4000/api/auth/sign-in/email \
-H "content-type: application/json" \
-H "Origin: http://localhost:3000" \
-d '{"email":"you@example.com","password":"..."}' -c cookies.txt
curl -X POST http://localhost:4000/api/auth/organization/set-active \
-H "content-type: application/json" \
-H "Origin: http://localhost:3000" \
-d '{"organizationId":"<org id>"}' -b cookies.txt -c cookies.txt
curl http://localhost:4000/api/jobs -b cookies.txtOrg API tokens
The ATS webhook (POST /api/webhooks/ats) and public parse (POST /api/public/parse) take an org API token instead of a cookie: Authorization: Bearer hl_…. A token acts as its organization. Owners create and revoke tokens in Settings, on the Integrations — API tokens card. You see the token once, when you create it, and a revoked token stops working on the next call. See ATS integration.
Public parse is rate-limited per token: 60 requests a minute by default, set by CANDIDLENS_PARSE_RATE_LIMIT. Each server instance keeps its own count. Over the limit you get 429 rate_limited with a Retry-After header.
The contract
The API serves its OpenAPI 3.1 document at GET /api/openapi.json, with no sign-in. Any OpenAPI viewer, such as Swagger UI, Redoc, Insomnia or Bruno, can load it from a running instance.
Its error schema is out of date. For errors, follow the error envelope at the end of this page.
Routes
| Method | Path | What it does |
|---|---|---|
GET | / | Public health check |
POST | / | Register (Better Auth) |
POST | / | Log in |
GET| | / | Jobs CRUD (org-scoped) |
GET| | / | Rubric versions |
POST | / | LLM JD → criteria |
POST | / | Upload a resume (PDF/DOCX/TXT/MD) |
POST | / | Batch-upload a ZIP of resumes |
POST | / | Score every candidate; waits for the run and returns its summary |
GET | / | Scoring run history |
GET | / | Run detail: per-candidate scores + evidence spans |
GET | / | Candidate list (metadata only — no resume text) |
GET | / | Candidate detail: parsed profile, document text, decisions |
GET | / | Ranked review table: latest overall per candidate + stage |
POST | / | Record a decision (stage + required reason; audit-chained) |
PATCH | / | Manual score override (author + reason recorded) |
PUT | / | Candidate's opt-in demographics self-report |
POST | / | Adverse-impact report (four-fifths rule; audited) |
GET | / | Search candidates across every job in the organization |
POST | / | Parse one resume without storing it (API token) |
GET | / | The live OpenAPI 3.1 contract |
Public parse
POST /api/public/parse parses one resume and doesn't store it. Send either a multipart body with a file part, or JSON { "text": "..." } of up to 200,000 characters. Any other content type gets 415 unsupported_media_type.
curl -X POST https://your-host/api/public/parse \
-H "Authorization: Bearer hl_…" \
-F file=@resume.pdfThe response includes:
parsed: the parsed profile.contentHash: a hash of the resume text.formatCheck:verdict(pass,warnorfail), a 0–100score, andfindings, each with acode,labelanddetail.kind,pageCount,extractedCharsandwarningsabout the document.
Talent pool
GET /api/talent-pool searches candidates across every job in your organization. It looks at the newest 2,000 candidates. Query parameters:
q: matches the uploaded filename, email or phone.skills: comma-separated skill names. A candidate matches if their skills include any of them.stage: the stage of the latest decision:new,shortlisted,advancedorrejected.minScore: the lowest overall score (0–100) on the candidate's latest completed run.pageandpageSize:pageSizedefaults to 25, at most 100.blind=1: hides filenames, email and phone, and ignoresq.
The response has candidates, total, page, pageSize and facets (stage and skill counts).
Scoring
POST /api/jobs/:id/score scores every candidate on the job against its latest rubric. The request waits until the run finishes, then returns { "ok": true, "summary": { ... } }. The summary holds the runId, the rubric version, and how many candidates were scored and failed.
curl -X POST http://localhost:4000/api/jobs/$JOB/score -b cookies.txt
curl http://localhost:4000/api/jobs/$JOB/runs/$RUN -b cookies.txtPass the runId to GET /api/jobs/:id/runs/:runId for each candidate's overall score, criterion scores and quoted evidence. To score only the candidates that failed, call POST /api/jobs/:id/runs/:runId/retry-failed; it starts a new run.
Roles
Each member has one role in an organization. Routes ask for one of three levels: view (viewer), edit (recruiter) or admin (owner). A higher role can do everything a lower one can, and a call below the level gets 403 forbidden.
| Role | What it can do |
|---|---|
viewer | Read jobs, rubrics, candidates, runs, the review table, search and the talent pool. Run a bias audit and record a demographics self-report. |
hiring_manager | The same as viewer. No route asks for this role, so a hiring manager can't record decisions or override scores. |
recruiter | Everything a viewer can, plus create and edit jobs and rubrics, upload and remove candidates, score, record decisions, override scores and create share links. |
owner | Everything a recruiter can, plus delete jobs, manage API tokens and change the model settings. |
Error envelope
An error has ok: false and a short error code. Many routes return only those two fields. Some add a message you can show to a person.
{ "ok": false, "error": "not_found" }
{ "ok": false, "error": "llm_not_configured", "message": "No LLM provider is configured ..." }Build against the HTTP status and the error code, not the message text. Routes under /api/auth/* are answered by Better Auth and use its own error format.
| Status | Code | When |
|---|---|---|
| 400 | invalid_body | The body failed validation. Some routes add the validation issues |
| 401 | unauthorized | No session, or no active organization. The ATS webhook also uses it for a bad token |
| 401 | invalid_token | Public parse got no valid API token |
| 403 | forbidden | Your role is too low; needRole names the minimum |
| 404 | not_found | No such route, or no such record in your organization |
| 409 | no_rubric | You scored a job that has no rubric yet |
| 413 | payload_too_large | The request body is over the size limit |
| 422 | unreadable_document | No text could be read from the file |
| 429 | rate_limited | Public parse went over the token's limit |
| 500 | internal_error | Something failed on the server. Quote the errorId when you report it |
| 503 | llm_not_configured | No model is configured on the server |