Errors

All non-2xx responses throw RogerIQError. Branch on code (machine readable), not message (human readable).

ts
import { RogerIQ, RogerIQError } from "@rogeriq/sdk";try { await roger.conversations.get("con_missing");} catch (e) { if (e instanceof RogerIQError) { if (e.code === "CONVERSATION_NOT_FOUND") { // handle } console.error(e.code, e.status, e.requestId, e.message); } throw e;}

Fields

FieldTypeDescription
codestringStable enum, e.g. CONVERSATION_NOT_FOUND
statusnumberHTTP status code (0 if network error)
messagestringHuman-readable summary
requestIdstring | undefinedEchoes the X-Request-Id header
issues{ path, message }[] | undefinedField-level validation errors (400 only)
retryAfternumber | undefinedSeconds to wait (429 only)

Common codes

CodeStatusMeaning
UNAUTHORIZED401Missing / invalid API key
FORBIDDEN403Authenticated but action not allowed
INSUFFICIENT_SCOPE403API key has the wrong scope
API_KEY_ORG_MISMATCH403API key belongs to a different org than the requested resource
API_KEY_PROJECT_MISMATCH403API key's org doesn't own the requested project
CONVERSATION_NOT_FOUND404Bad conversation id
PROJECT_NOT_FOUND404Bad project id
CONTACT_NOT_FOUND404Bad contact id
RESOURCE_NOT_FOUND404Generic 404
CONFLICT409Slug collision, idempotency conflict, etc.
SLUG_CONFLICT409Specifically for project / form slugs
BAD_REQUEST400Generic bad input
BAD_JSON400Body wasn't valid JSON
NO_UPDATES400PATCH with empty body
RATE_LIMITED429Slow down (the SDK auto-retries if retry_after ≤ 30s)
INTERNAL_ERROR500Server bug. Include requestId when reporting.

Validation errors

POST/PATCH bodies that fail Zod validation include a structured issues array:

json
{ "error": "Invalid body", "code": "BAD_REQUEST", "request_id": "req_abc", "issues": [ { "path": "email", "message": "Invalid email" }, { "path": "metadata.plan", "message": "Expected string" } ]}
ts
try { await roger.contacts.upsert({ email: "not-an-email" });} catch (e) { if (e instanceof RogerIQError && e.issues) { for (const issue of e.issues) { console.error(`${issue.path}: ${issue.message}`); } }}

Rate limiting

The SDK auto-retries 429 once when retry_after ≤ 30 seconds. For longer suggested delays the SDK throws so you can decide.

Watch live headroom via the onResponse callback:

ts
const roger = new RogerIQ({ apiKey: process.env.RIQ_API_KEY!, projectId: process.env.RIQ_PROJECT_ID!, onResponse: (meta) => { if (meta.rateLimit && meta.rateLimit.remaining < 10) { console.warn("approaching limit:", meta.rateLimit); } },});

See API rate limits for per-tier limits and the X-RateLimit-* header reference.

Ask a question... ⌘I