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 Markdown

A 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:

KeyScopesWhere it lives
Site keyobjects: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 keyobjects:schema, objects:write, objects:readOnly 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

  1. Declare types, page fields and section types in borkol.content.ts. The compiled shape is the manifest.
  2. Upload one thumbnail per section type with POST /v1/api/objects/media and put the returned id in the section type's thumbnail_media_id.
  3. Plan the push with PUT /v1/api/objects/schema?dry_run=1. The response lists every op the push would apply.
  4. Apply it with PUT /v1/api/objects/schema. A push that archives stored values needs yes=1; a push with any refuse op applies nothing. Pushing the same manifest again plans nothing.
  5. Read the result back with GET /v1/api/objects/schema (the CLI's drift check uses it) and the section vocabulary with GET /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:

  1. Design and build the site freely first: layout, motion, any animation library.
  2. Then model the meaning: every text, image and list the client might change is a field.
  3. One defineSection per visual section component, with looks for its variants and a help on every field. Collections become defineType, global content defineSingleton.
  4. No layout fields. Unknown section types or looks render null.
  5. Upload a thumbnail per section type: part of done.
  6. Seed realistic content so the client sees the real site on day one.
  7. Pages read the preview token from searchParams and pass it to every fetcher.
  8. Run borkol doctor before reporting done. Never commit keys.

Endpoints

EndpointScopePurpose
PUT /v1/api/objects/schemaobjects:schemaPlan or apply a manifest.
GET /v1/api/objects/schemaobjects:readThe connected site, every type and every active section type.
GET /v1/api/objects/section-typesobjects:readActive section types only.
POST /v1/api/objects/mediaobjects:schemaUpload a section type thumbnail.
POST /v1/api/objects/seedobjects:writeQueue a create-only seed of starter content. See Seed.
GET /v1/api/objects/seed/{job_id}objects:writeA seed run's progress.
GET /v1/api/objects/previewobjects:readWhat a preview token opens. See Preview.
POST /v1/api/objects/preview-tokensobjects:schemaMint a preview token, the home page by default.