Errors
Error response format and all error codes explained.
Error response format
When something goes wrong, the API returns a JSON error response with a consistent structure:
Error response
{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Missing required field: name"
}
}| Parameter | Type | Description |
|---|---|---|
success* | boolean | Always false for error responses. |
error.code* | string | A machine-readable error code. See the table below. |
error.message* | string | A human-readable description of the error. |
Error codes
| Parameter | Type | Description |
|---|---|---|
UNAUTHORIZED | 401 | Missing or invalid API key. Check the Authorization header. |
FORBIDDEN | 403 | The API key doesn't have the required scope, or the brand is restricted. |
NOT_FOUND | 404 | The requested resource doesn't exist, or you don't have access to it. |
VALIDATION_ERROR | 400 | The request body or query parameters failed validation. |
RATE_LIMITED | 429 | You've exceeded the rate limit. Wait for the Retry-After duration and try again. |
PLAN_LIMIT_EXCEEDED | 403 | Your current plan doesn't allow this action (e.g. you've reached the maximum number of brands or scheduled posts). |
INTERNAL_ERROR | 500 | Something went wrong on our end. If this persists, contact support. |
Handling errors
JavaScript
const response = await fetch("https://api.wahlu.com/v1/brands", {
headers: {
Authorization: "Bearer wahlu_live_your_api_key_here",
},
});
if (!response.ok) {
const body = await response.json();
console.error(`API error: ${body.error.code} — ${body.error.message}`);
if (response.status === 429) {
const retryAfter = response.headers.get("Retry-After");
console.log(`Retry after ${retryAfter} seconds`);
}
return;
}
const { data } = await response.json();