Skip to content

Error Handling

Response Envelope

All v1 API responses use a consistent envelope format:

Success

{
"data": { ... },
"meta": {
"request_id": "req_abc123",
"rate_limit": {
"limit": 1000,
"remaining": 999,
"burst_limit": 10,
"burst_remaining": 9
}
}
}

Error

{
"error": {
"code": "INSUFFICIENT_SCOPE",
"message": "This endpoint requires the links:write scope.",
"status": 403
},
"meta": {
"request_id": "req_abc123"
}
}

HTTP Status Codes

StatusMeaning
200 OKRequest succeeded
201 CreatedResource created
204 No ContentResource deleted
400 Bad RequestInvalid request body or parameters
401 UnauthorizedMissing, invalid, revoked, or expired API key
403 ForbiddenInsufficient scopes or plan feature not available
404 Not FoundResource does not exist or belongs to another workspace
409 ConflictSlug already taken or constraint violation
429 Too Many RequestsRate limit exceeded (burst or monthly)
500 Internal Server ErrorUnexpected server error

Common Error Codes

CodeStatusDescription
INVALID_API_KEY401The API key is malformed or not found
REVOKED_API_KEY401The API key has been revoked
EXPIRED_API_KEY401The API key has expired
INSUFFICIENT_SCOPE403The API key lacks the required scope
FEATURE_NOT_AVAILABLE403Your plan does not include this feature
PLAN_LIMIT_EXCEEDED403You’ve reached your plan’s resource limit
SLUG_TAKEN409The requested custom slug is already in use
RATE_LIMIT_EXCEEDED429Monthly API quota exhausted
BURST_LIMIT_EXCEEDED429Too many requests per second

Handling Errors

const res = await fetch("https://xqr.co/api/v1/links", {
method: "POST",
headers: {
Authorization: `Bearer ${apiKey}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ url: "https://example.com" }),
});
const body = await res.json();
if (!res.ok) {
console.error(`Error ${body.error.code}: ${body.error.message}`);
// Use body.meta.request_id when contacting support
} else {
const link = body.data;
}

Request ID

Every response includes meta.request_id. Include this when reporting issues to xQR support — it helps us trace the exact request in our logs.

Detailed Error Reference

For a comprehensive guide to every error code — including common causes, fix steps, and code examples — see the Error Reference.

Was this page helpful?