Build a site
Build a site
How a website repo connects to a Borkol store, declares its content schema in code and pushes it, with the two keys and the rules for coding agents.
View as MarkdownA connected website keeps its schema in its own repo and its content in Borkol. The site declares the content types, page fields and section types it renders in one file (borkol.content.ts, written with @borkol/content). A push sends that schema to the store as a compiled manifest; the merchant then edits the content in the client dashboard and the site reads it through the Objects endpoints.
A store has at most one connected site. Types and section types a push creates are managed by the site: the dashboard can edit their records, never their structure (a structure write answers 409 {"code": "managed_by_site"}). That keeps the merchant from breaking the fields the site code depends on.
The two keys
A connected site gets two API keys, each shown once:
| Key | Scopes | Where it lives |
|---|---|---|
| Site key | objects:read (plus forms:read and forms:write when the Forms module is on) | The deployed site's environment. It reads content and the schema. |
| Push key | objects:schema, objects:write, objects:read | Only on the developer's own machine. It pushes the schema and uploads section thumbnails. |
objects:schema is granted only to a connected site's push key; an API key created in the dashboard can never carry it (asking for it answers 422). Never put the push key in a deployed environment or a repo. A leaked site key can read content but never change the schema.
The flow
- Declare types, page fields and section types in
borkol.content.ts. The compiled shape is the manifest. - Upload one thumbnail per section type with
POST /v1/api/objects/mediaand put the returnedidin the section type'sthumbnail_media_id. - Plan the push with
PUT /v1/api/objects/schema?dry_run=1. The response lists every op the push would apply. - Apply it with
PUT /v1/api/objects/schema. A push that archives stored values needsyes=1; a push with anyrefuseop applies nothing. Pushing the same manifest again plans nothing. - Read the result back with
GET /v1/api/objects/schema(the CLI's drift check uses it) and the section vocabulary withGET /v1/api/objects/section-types.
An applied push sends the webhook event object_schema.updated (see Webhooks); flush every cached page when it arrives. The endpoints are described on Schema.
The borkol CLI of @borkol/content runs this flow for you (borkol push), seeds starter content (borkol seed) and checks the setup (borkol doctor). Render images with Images: resized URLs and crops that keep the merchant's focal point in view.
Rules for the agent
Coding agents that build a site on Borkol follow these rules:
- Design and build the site freely first: layout, motion, any animation library.
- Then model the meaning: every text, image and list the client might change is a field.
- One
defineSectionper visual section component, withlooksfor its variants and ahelpon every field. Collections becomedefineType, global contentdefineSingleton. - No layout fields. Unknown section types or looks render
null. - Upload a thumbnail per section type: part of done.
- Seed realistic content so the client sees the real site on day one.
- Pages read the preview token from
searchParamsand pass it to every fetcher. - Run
borkol doctorbefore reporting done. Never commit keys.
Endpoints
| Endpoint | Scope | Purpose |
|---|---|---|
PUT /v1/api/objects/schema | objects:schema | Plan or apply a manifest. |
GET /v1/api/objects/schema | objects:read | The connected site, every type and every active section type. |
GET /v1/api/objects/section-types | objects:read | Active section types only. |
POST /v1/api/objects/media | objects:schema | Upload a section type thumbnail. |
POST /v1/api/objects/seed | objects:write | Queue a create-only seed of starter content. See Seed. |
GET /v1/api/objects/seed/{job_id} | objects:write | A seed run's progress. |
GET /v1/api/objects/preview | objects:read | What a preview token opens. See Preview. |
POST /v1/api/objects/preview-tokens | objects:schema | Mint a preview token, the home page by default. |