Skip to main content
HydroGo
REST APIAPI overview

API overview

Base URL, the response envelope, the error shape, pagination and status codes shared by every endpoint.

The API is plain JSON over HTTP under /api/v1. Public endpoints return published content without credentials; admin endpoints live under /api/v1/admin and need one of the credentials in Authentication.

BASH
curl -s https://cms.example.com/api/v1/news?locale=en\&limit=3

Success envelope

Every successful JSON response wraps its payload in data. List endpoints add metadata with paging information.

JSON
{
  "data": [ { "id": "…", "slug": "hello-world", "title": "Hello world" } ],
  "metadata": {
    "limit": 20,
    "offset": 0,
    "has_more": true
  }
}
Metadata fieldMeaning
limitPage size used for this response.
offsetRecords skipped (offset-paged lists).
totalTotal matching records, when it is cheap to know.
has_moretrue when another page exists.
next_cursorOpaque cursor for cursor-paged lists; pass it back to continue.
localeThe locale served (content API).

Errors

Errors use a single shape, so clients can handle them in one place. Always show or log the request_id: it is also sent in the X-Request-ID response header and lets you find the matching server log line.

JSON
{
  "code": "unprocessable_entity",
  "message": "validation failed",
  "request_id": "7c2f4a1e9b3d",
  "fields": { "title": "required" }
}
HTTP status`code`When
400bad_requestMalformed JSON, invalid query parameter (for example limit out of range), unknown locale.
401unauthorizedMissing, expired or invalid credential.
403forbiddenAuthenticated but not allowed (role, permission, scope or missing CSRF token).
404not_foundUnknown route, record, or a type that is not public.
409conflictVersion conflict (someone saved a newer version first) or checkout idempotency_key reused with a different cart.
413request_entity_too_largeBody larger than the endpoint accepts (JSON bodies default to 1 MiB).
422unprocessable_entityValidation failed. fields maps field ids to codes such as required, invalid, taken.
429too_many_requestsRate limited. Honour the Retry-After header (seconds).
500 / 503internal_server_error / service_unavailableServer problem. Report the request_id.

Pagination

  • limit accepts 1 to 100. The default is 20 for pages and news and 25 for content types.
  • Content types use offset; continue while metadata.has_more is true.
  • Always loop on has_more rather than computing pages from total, which may be absent.
TS
const all = [];
let offset = 0;
for (;;) {
  const res = await fetch(`${origin}/api/v1/content/faq?limit=100&offset=${offset}`);
  const body = await res.json();
  all.push(...body.data);
  if (!body.metadata.has_more) break;
  offset += body.metadata.limit;
}

Conventions

  • Field names are snake_case; timestamps are RFC 3339 strings in UTC.
  • Ids are opaque strings. Do not parse them.
  • Query strings are strict: unsupported parameters on the content API answer 400 instead of being ignored.
  • Browsers on another origin can read published content only if the origin is listed in security.public_api_origins. Server-side callers are not affected.
The machine-readable contract is the OpenAPI baseline kept in the repository under docs/api/. CI compares every change to it, so accidental breaking changes are caught before release. Generate a typed SDK with hydro sdk generate.