CandidLens

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:

  1. POST /api/auth/organization/create with { "name", "slug" } creates an organization. You become its owner.
  2. POST /api/auth/organization/set-active with { "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.txt

Org 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

MethodPathWhat it does
GET/api/healthPublic health check
POST/api/auth/sign-up/emailRegister (Better Auth)
POST/api/auth/sign-in/emailLog in
GET|POST|PATCH/api/jobsJobs CRUD (org-scoped)
GET|POST/api/jobs/:id/rubricsRubric versions
POST/api/jobs/:id/rubrics/deriveLLM JD → criteria
POST/api/jobs/:id/candidatesUpload a resume (PDF/DOCX/TXT/MD)
POST/api/jobs/:id/candidates/zipBatch-upload a ZIP of resumes
POST/api/jobs/:id/scoreScore every candidate; waits for the run and returns its summary
GET/api/jobs/:id/runsScoring run history
GET/api/jobs/:id/runs/:runIdRun detail: per-candidate scores + evidence spans
GET/api/jobs/:id/candidatesCandidate list (metadata only — no resume text)
GET/api/jobs/:id/candidates/:cidCandidate detail: parsed profile, document text, decisions
GET/api/jobs/:id/reviewRanked review table: latest overall per candidate + stage
POST/api/jobs/:id/decisionsRecord a decision (stage + required reason; audit-chained)
PATCH/api/jobs/:id/scores/:scoreIdManual score override (author + reason recorded)
PUT/api/jobs/:id/candidates/:cid/demographicsCandidate's opt-in demographics self-report
POST/api/jobs/:id/bias-auditAdverse-impact report (four-fifths rule; audited)
GET/api/talent-poolSearch candidates across every job in the organization
POST/api/public/parseParse one resume without storing it (API token)
GET/api/openapi.jsonThe 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.pdf

The response includes:

  • parsed: the parsed profile.
  • contentHash: a hash of the resume text.
  • formatCheck: verdict (pass, warn or fail), a 0–100 score, and findings, each with a code, label and detail.
  • kind, pageCount, extractedChars and warnings about 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, advanced or rejected.
  • minScore: the lowest overall score (0–100) on the candidate's latest completed run.
  • page and pageSize: pageSize defaults to 25, at most 100.
  • blind=1: hides filenames, email and phone, and ignores q.

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.txt

Pass 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.

RoleWhat it can do
viewerRead jobs, rubrics, candidates, runs, the review table, search and the talent pool. Run a bias audit and record a demographics self-report.
hiring_managerThe same as viewer. No route asks for this role, so a hiring manager can't record decisions or override scores.
recruiterEverything a viewer can, plus create and edit jobs and rubrics, upload and remove candidates, score, record decisions, override scores and create share links.
ownerEverything 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.

StatusCodeWhen
400invalid_bodyThe body failed validation. Some routes add the validation issues
401unauthorizedNo session, or no active organization. The ATS webhook also uses it for a bad token
401invalid_tokenPublic parse got no valid API token
403forbiddenYour role is too low; needRole names the minimum
404not_foundNo such route, or no such record in your organization
409no_rubricYou scored a job that has no rubric yet
413payload_too_largeThe request body is over the size limit
422unreadable_documentNo text could be read from the file
429rate_limitedPublic parse went over the token's limit
500internal_errorSomething failed on the server. Quote the errorId when you report it
503llm_not_configuredNo model is configured on the server