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.
{
"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": "…"
}| Field | Meaning |
|---|---|
type | A URI that identifies the kind of problem. Use it as an identifier. |
title | A short, stable summary. Not meant for your end users. |
status | The HTTP status, repeated in the body. |
code | The machine-readable code. This is what your code should switch on. |
detail | Optional explanation of this occurrence. Wording can change. |
errors | On VALIDATION_FAILED: a list of { path, message }, one per invalid parameter. |
traceId | Optional. 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
code | Status | Meaning | Retry? |
|---|---|---|---|
VALIDATION_FAILED | 400 | A parameter or body is malformed or out of range. errors[] says which. | No: fix the request |
NOT_FOUND | 404 | The thing doesn't exist or isn't public, or the route doesn't exist. | No |
RATE_LIMITED | 429 | You are over your budget. Retry-After says how long to wait. | Yes, after waiting |
CHALLENGE_FAILED | 403 | The anti-abuse challenge token on a lead request is missing or was rejected. | Only with a new token |
UPSTREAM_UNAVAILABLE | 502 | A service behind the API is briefly unavailable. | Yes, with backoff |
INTERNAL_ERROR | 500 | An unexpected failure on our side. | Once or twice, then report it |
IDEMPOTENCY_KEY_CONFLICT | 422 | An Idempotency-Key was reused with a different body. See Leads. | No: use a new key |
CLIENT_TOO_OLD | 426 | Only 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
- Is the status 400 (VALIDATION_FAILED)?YesRead errors[].path, fix the parameter and send it again. Retrying unchanged will fail again.No
- Is the status 404 (NOT_FOUND)?YesStop. Check the slug or path, for example with a search suggestion. →No
- No
- Is the status 502 (UPSTREAM_UNAVAILABLE)?YesRetry shortly with growing waits. Serve what you cached meanwhile.No
- Is the status 500 (INTERNAL_ERROR)?YesRetry once or twice. If it stays, contact us with the traceId.No
- Is the status 403 or 422 on a lead request?YesFix the challenge token or use a fresh Idempotency-Key. →No
- Any other status: treat it as a failure, don't retry blindly and log the body.
A small error handler
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'})`);
}
}