Error Handling
HTTP status codes
| Status | Meaning |
|---|---|
200 OK | Request succeeded |
400 Bad Request | Validation error — see error field in response body |
401 Unauthorized | Missing or invalid X-Api-Key header |
404 Not Found | Vacancy reference not found or not accessible with your key |
500 Internal Server Error | Unexpected server error |
Error response body
All error responses return a JSON body with a human-readable message:
{
"error": "Human-readable error message"
}
Handling errors in JavaScript
const response = await fetch('/api/vacancies', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ take: 10 }),
});
if (!response.ok) {
const { error } = await response.json();
console.error(`API error ${response.status}: ${error}`);
return;
}
const data = await response.json();