Skip to main content

Error Handling

HTTP status codes

StatusMeaning
200 OKRequest succeeded
400 Bad RequestValidation error — see error field in response body
401 UnauthorizedMissing or invalid X-Api-Key header
404 Not FoundVacancy reference not found or not accessible with your key
500 Internal Server ErrorUnexpected 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();