# Discovering the content model at runtime

URL: https://kywi-docs-production.up.railway.app/integrating/discovering-the-content-model-at-runtime
Type: docPage

The content model is discoverable at runtime: five `/config` and `/openapi` reads return content types, the module palette and sites, with no credentials.

A consumer does not need `kywi.config.ts` to learn what a Kywi instance holds. Six reads describe the whole model — content types, the module palette, the sites, and an OpenAPI document — and none of them asks for a credential. That matters for more than convenience: a client generated from the config file goes stale the moment somebody adds a content type in the admin, and these routes do not.

## The content types actually in force

The merged registry: types declared in `kywi.config.ts` *and* types created through the admin, each tagged with its `source`. The built-in structural types — `page`, `folder`, `link`, `form` — are omitted, so what you get back is the site's authorable model. Each entry carries `name`, `label`, `baseType`, `source`, an optional `pluralLabel`, and a `fields` array of `{ name, type, label, required, options? }`.

{ "data": [ { "name": "docPage", "label": "Doc Page", "baseType": "content", "source": "config", "pluralLabel": "Doc Pages", "fields": [ … ] } ], "meta": { … } }

The `source` tag is the reason to read this rather than the config file. A type created in the admin exists, is writable and is queryable exactly like a config-declared one — it is simply not in your repository.

## This read is instance-wide, not per-site

The route ignores `siteId` entirely — it serves one merged registry for the whole instance, not a per-site slice. On a multi-site instance every site sees the same content-type list from this route, so do not send `?siteId=` expecting it to scope the answer.

## GET /api/v1/config/content-types — each entry’s fields array elided

## What a layout may legally contain

The full module palette — built-ins plus every module contributed by `kywi.config.ts` and by plugins — with each module's `name`, `label`, `component`, `category`, `props` and `isBuiltIn` flag. This is the authoritative answer to "what module types may appear in a layout document, and what props does each declare".

{ "data": [ { "name": "section", "label": "Section", "component": "@kywi-software/modules/Section", "category": "Layout", "props": { "backgroundColor": { "type": "color", "label": "Background Color" }, … }, "isBuiltIn": true } ], "meta": { … } }

## Sites: two ids, two routes

`/config/sites` answers from configuration and gives you the *config* id — the slug you put in `?siteId=`. `/sites` answers from the database and gives you the row, including its UUID. Both are unauthenticated, and you will need the second one: the changeset routes take a real UUID and do not accept the config slug.

## GET /api/v1/config/sites — no credentials

## The site list is public, UUIDs included

`GET /sites` has no auth check at all, so every site's name, slug, domain and database UUID is readable by anyone who can reach the API. Treat site names and domains as public strings. See [Site record public exposure](/operating/site-record-public-exposure-get-sites-is-unauthenticated/), and [Site scoping and the siteId contract](/integrating/site-scoping-and-the-siteid-contract/) for which routes take which id.

## The OpenAPI document is a starting point

`/openapi.json` and `/openapi.yaml` serve the same document — `openapi: "3.1.0"`, one `bearerAuth` security scheme, and no `servers` block, so a generator has no base URL until you add one. It is **hand-maintained**, not derived from the router: thirty paths are written out by hand, and the only generated part is two entries per content type declared in `kywi.config.ts`. Against the several hundred routes the router actually registers, the spec covers a fraction, and a type created in the admin never appears in it at all. Generate a client from it if you like, then expect to hand-write the rest.

{ "openapi": "3.1.0", "info": { "title": "Kywi CMS API", "version": "1.0.0", "description": "Auto-generated API documentation for the Kywi CMS" }, "paths": { … }, "components": { "securitySchemes": { "bearerAuth": { "type": "http", "scheme": "bearer", "bearerFormat": "JWT" } }, "schemas": { … } } }

## GET /api/v1/openapi.json — head and security scheme, verbatim (paths and components.schemas elided)

The bearer token is the same credential every other route takes — see [Authenticating an external caller](/integrating/authenticating-an-external-caller/).
