Skip to Content
CoworkingView Docs
Public API

Errors

The error format of the CoworkingView API (RFC 9457 problem+json), every error code and what your code should do about each.

Every failed request returns a problem document as defined by RFC 9457, with the content type application/problem+json. Branch on the HTTP status and on the code member, never on the text.

400 Bad Request
{
  "type": "https://coworkingview.com/problems/validation-failed",
  "title": "Validation failed",
  "status": 400,
  "code": "VALIDATION_FAILED",
  "errors": [
    { "path": "pageSize", "message": "Too big: expected number to be <=50" }
  ],
  "traceId": "…"
}
FieldMeaning
typeA URI that identifies the kind of problem. Use it as an identifier.
titleA short, stable summary. Not meant for your end users.
statusThe HTTP status, repeated in the body.
codeThe machine-readable code. This is what your code should switch on.
detailOptional explanation of this occurrence. Wording can change.
errorsOn VALIDATION_FAILED: a list of { path, message }, one per invalid parameter.
traceIdOptional. When present, quote it when you contact us: it lets us find your request.

The set of codes only grows. Treat an unknown code like a generic failure for its HTTP status.

Codes

codeStatusMeaningRetry?
VALIDATION_FAILED400A parameter or body is malformed or out of range. errors[] says which.No: fix the request
NOT_FOUND404The thing doesn't exist or isn't public, or the route doesn't exist.No
RATE_LIMITED429You are over your budget. Retry-After says how long to wait.Yes, after waiting
CHALLENGE_FAILED403The anti-abuse challenge token on a lead request is missing or was rejected.Only with a new token
UPSTREAM_UNAVAILABLE502A service behind the API is briefly unavailable.Yes, with backoff
INTERNAL_ERROR500An unexpected failure on our side.Once or twice, then report it
IDEMPOTENCY_KEY_CONFLICT422An Idempotency-Key was reused with a different body. See Leads.No: use a new key
CLIENT_TOO_OLD426Only for the official CoworkingView apps. You won't see it from a plain integration.No

Unknown routes also answer 404 with code: "NOT_FOUND", so a typo in a path looks like any other missing resource: check the path against the OpenAPI document.

What to do with each code

  1. Is the status 400 (VALIDATION_FAILED)?
    Yes
    Read errors[].path, fix the parameter and send it again. Retrying unchanged will fail again.
    No
  2. No
  3. No
  4. Is the status 502 (UPSTREAM_UNAVAILABLE)?
    Yes
    Retry shortly with growing waits. Serve what you cached meanwhile.
    No
  5. Is the status 500 (INTERNAL_ERROR)?
    Yes
    Retry once or twice. If it stays, contact us with the traceId.
    No
  6. Is the status 403 or 422 on a lead request?
    Yes
    Fix the challenge token or use a fresh Idempotency-Key. →
    No
  7. Any other status: treat it as a failure, don't retry blindly and log the body.
Start at the top and stop at the first yes.

A small error handler

Branch on the code
async function api(path: string) {
  const res = await fetch(`https://api.coworkingview.com${path}`);
  if (res.ok) return res.json();

  const problem = await res.json().catch(() => null); // application/problem+json
  switch (problem?.code) {
    case 'VALIDATION_FAILED':
      throw new Error(`Bad request: ${problem.errors?.map((e) => e.path).join(', ')}`);
    case 'RATE_LIMITED': {
      const wait = Number(res.headers.get('Retry-After') ?? 5);
      await new Promise((r) => setTimeout(r, wait * 1000));
      return api(path); // in real code, cap the number of attempts
    }
    case 'UPSTREAM_UNAVAILABLE':
      throw new Error('Temporarily unavailable, try again shortly');
    default:
      throw new Error(`API error ${res.status} (trace ${problem?.traceId ?? 'n/a'})`);
  }
}

On this page