Skip to main content
@classet/api-client is a typed, dependency-light wrapper around the Classet v2 API. It’s just fetch under the hood — it handles X-API-KEY auth, the /v2 path prefix, the { data } / { data, meta } response envelope, per-request timeouts, typed errors, automatic retries that honor Retry-After, Idempotency-Key propagation, and X-RateLimit-* header parsing. Every example below shows the SDK call and the equivalent raw curl, so you can use whichever fits your stack.

Pilot installation

The SDK is currently available from an authorized Classet monorepo checkout and is not published to npm yet. External package installation will be documented at general availability.
The package is ESM-only and ships its own type declarations — no @types/* needed.

Initialise the client

ClassetClient takes a single options object:
Generate an API key from the Developer Settings page. The same key works on both v1 and v2. Keep it server-side — store it in an environment variable or secrets manager, never in client code.

Per-request options

Every write method (create / update / remove / sendInterview / …) accepts an optional trailing options object; timeoutMs and maxRetries also work on the raw transport:

Typed errors

Every method returns the parsed envelope and throws a typed error on a non-2xx response:
  • ClassetApiError — carries status, the machine-readable code, and requestId from the standard { error, code, request_id } envelope (message is the error string).
  • ClassetRateLimitError — thrown on 429 (extends ClassetApiError); adds retryAfter (parsed Retry-After header, in seconds) and rateLimit (parsed X-RateLimit-* headers).
Branch on err.code (stable) rather than the message text — see Error handling for the full code table.

Automatic retries

Transient failures (429, 500, 502, 503, 504, and network errors) are retried with exponential backoff, honoring the server’s Retry-After header when present:
  • GETs are retried by default (up to maxRetries, default 2).
  • Writes are retried only when you pass { idempotencyKey } — without a key the SDK can’t know a retry is safe, so it makes exactly one attempt.
  • Timeouts and caller aborts are surfaced immediately, never retried.
  • A 429 whose Retry-After exceeds maxRetryAfterMs, or whose body says exceeded_window: "daily" or "monthly", throws ClassetRateLimitError at once. Check err.retryAfter and schedule the retry yourself.
  • A 503 is retried only when its code is rate_limit_unavailable (or the body has no code). service_unavailable means the feature is off for your organization, so it is thrown at once.

Rate-limit visibility

client.lastRateLimit exposes the parsed X-RateLimit-* headers from the most recent response that carried them, so you can pace proactively:

Iterate whole collections with listAll

Paginated resources expose async iterators that walk every page for you:
  • candidates.listAll() and applications.listOrgAll() follow meta.next_cursor until it is null. Cursor pages do not shift when rows are written mid-walk.
  • jobs.listAll() and applications.listAll(jobId) page by offset and stop on a short page, because those routes take no cursor.

Create a job

classet.jobs.create() posts to POST /v2/jobs and returns { data: { job_id } } — the new job’s id, not the job itself. Call classet.jobs.get(job_id) when you need the full JobDetail. title, description, and location are required; everything else is optional.
The response data is a JobRef ({ job_id }) — that job_id is what you pass to the candidate, application, and interview calls below. Fetch the rest of the job with classet.jobs.get(job.job_id).
Pass script_id to attach a specific interview script. Omit it and the job uses your default script. List scripts with classet.scripts.list() to find an id.

Create a candidate and send an interview

There are two ways to start an interview. Pick based on whether the candidate already exists.

One step: create + send

classet.candidates.create() posts to POST /v2/candidates. Set send_sms and/or send_email to dispatch the interview invite as part of the same call. first_name, last_name, and job_id are required; phone and email are optional. The call returns 422 only when send_sms or send_email asks for a channel the candidate has no contact for (send_sms without a phone, send_email without an email).

Two steps: create now, send later

Create the candidate without send_sms/send_email, then trigger the invite when you’re ready with classet.candidates.sendInterview() (POST /v2/candidates/:id/interview).
Interview invites share one budget across the API and dashboard. If your org’s invite cap is exhausted, these calls return 429 Interview invite limit exceeded (the SDK throws a ClassetRateLimitError — check retryAfter) before any candidate or call record is created for that send. Pass { idempotencyKey } on send calls so a retry can never dispatch the invite twice — see Idempotency.
To halt an in-flight interview, use classet.candidates.stopInterview(candidateId, { only_stop_outreach }).

Fetch the aggregated interview

classet.candidates.getInterview() (GET /v2/candidates/:id/interview) returns one rolled-up InterviewDetail — status, outcome, AI summary, extracted custom data, and the recording/transcript — rather than raw per-attempt call rows. This is the call you’ll poll (or react to from a webhook) to read results.
A typed InterviewDetail looks like:
Need the raw per-attempt rows (one per call) for debugging? Use classet.candidates.calls(candidateId) or classet.calls.get(callId). For everything else, prefer getInterview — it’s the aggregated view that matches the dashboard.

Configure a webhook

The dark-launch acceptance path uses polling. Any organization with a webhook URL receives interview events (candidate.interview.updated); they need no beta admission. v2 events are a separate limited beta, enabled per organization. classet.webhooks.update() stores the URL, and classet.webhooks.test() verifies reachability; neither action opts your organization into v2 events.
Read the current configuration any time with classet.webhooks.get(). For the event payload shape, signature verification, and retry behaviour, see the Webhooks guide.

Putting it together

A complete create-job → invite-candidate → read-result flow:

Other resource groups

The client covers most of the v2 API. Each group returns the same { data } / { data, meta } envelope: Org-wide applications and stage moves:
These endpoints have no SDK method yet. Call them over HTTP with the same X-API-KEY header: See the API reference for the full request and response schema of every endpoint, and Migration from v1 if you’re upgrading an existing integration.