Log in

Errors

Understand API error responses and status codes.

Errors

The OJobs API uses conventional HTTP status codes. Codes in the 2xx range indicate success; 4xx indicates a problem with the request (bad/missing key, not found, etc.); 5xx indicates something went wrong on our end.

Error shape

Every error response is a JSON object with a single error field describing what went wrong:

{
  "error": "Invalid API key."
}

There's no machine-readable error code field yet — match on the HTTP status code, and treat the error string as a human-readable message rather than something to branch logic on.

Status codes

PropTypeDefault
401
Unauthorized
-
403
Forbidden
-
404
Not Found
-
500
Internal Server Error
-

Common causes

PropTypeDefault
Missing API key.
401
-
Invalid API key.
401
-
API key has been revoked.
401
-
API key has expired.
401
-
Origin not allowed.
403
-
API keys may only be used by approved organisation accounts.
403
-
Job not found.
404
-

Handling errors with the SDK

The SDK throws OJobsAPIError for any non-2xx response, with status and the parsed response body attached:

import { OJobsAPIError } from "@ojobs/sdk";

try {
  const job = await ojobs.jobs.get(id);
} catch (err) {
  if (OJobsAPIError.isNotFound(err)) {
    // handle 404
  } else if (OJobsAPIError.isAuthError(err)) {
    // handle 401/403 — check your key
  } else if (OJobsAPIError.isRateLimit(err)) {
    // handle 429 — back off and retry
  } else {
    throw err;
  }
}

A request that times out (default 15s) throws OJobsTimeoutError instead — this is a client-side timeout, not a response from the server, so it has no status or body.