Errors
Skirre uses standard HTTP status codes and returns structured JSON error responses. Every error includes a machine-readable code and a human-readable message.
Error Format
All error responses follow the same structure:
text
{
"error": {
"code": "not_found",
"message": "Index 'products' not found"
}
}| Parameter | Type | Description |
|---|---|---|
| error.code required | string | Machine-readable error code. Use this for programmatic error handling. |
| error.message required | string | Human-readable error description. May change between versions, so do not parse programmatically. |
Error Codes
| Parameter | Type | Description |
|---|---|---|
| invalid_request optional | 400 | The request is malformed: missing required fields, invalid filter syntax, validation failure, or document exceeds size limits. |
| unauthorized optional | 401 | Missing or invalid API key. Check that the Authorization header contains a valid Bearer token. |
| forbidden optional | 403 | The API key does not have permission for this operation. Search keys cannot perform write operations. |
| not_found optional | 404 | The requested index, document, or API key was not found. |
| conflict optional | 409 | A resource with this identifier already exists (e.g. duplicate index UID). |
| rate_limited optional | 429 | Too many requests. Wait and retry. See the Rate Limits page. |
| internal_error optional | 500 | An unexpected server error. If persistent, contact support. |
Handling Errors
With the SDK
The SDK throws SkirreError with typed status and code properties:
text
import { Skirre, SkirreError } from '@skirre/sdk'; try { await idx.getDocument('nonexistent'); } catch (err) { if (err instanceof SkirreError) { switch (err.code) { case 'not_found': console.log('Document does not exist'); break; case 'rate_limited': console.log('Too many requests, retrying...'); break; default: console.log(err.message); } } }
With HTTP
Check the HTTP status code first, then parse the JSON body for the error code:
text
const res = await fetch(url, { headers }); if (!res.ok) { const body = await res.json(); console.error(body.error.code, body.error.message); // "not_found" "Index 'products' not found" }