Build a site

Schema

Push a site's content schema, read it back, list the section types and upload section thumbnails.

View as Markdown

These four endpoints connect a site repo to its store. All live under /v1/api/objects and need the objects module (403 {"error":"Module not enabled: objects"} otherwise). The two writes need objects:schema, which only a connected site's push key carries (see The two keys); the two reads need objects:read.

PUT /v1/api/objects/schema

Plans or applies a compiled manifest. The body is the manifest as JSON. Requires the objects:schema scope.

NameTypeRequiredDescription
dry_runquery, 0 or 1no1 plans and writes nothing. Default 0.
yesquery, 0 or 1no1 lets an apply archive properties, types or section types that hold values or records. Without it such a push is planned but not applied. Default 0.
Request
curl -X PUT "https://api.borkol.com/v1/api/objects/schema?dry_run=1" \
  -H "Authorization: Bearer {push_key}" \
  -H "Content-Type: application/json" \
  --data @manifest.json

Status: 200 OK, also when the plan refuses something (then applied is false).

FieldTypeDescription
planarrayThe ops in the order they apply, each {op, target, key, detail}. op is add, update, archive, unarchive or refuse; target is type, property, section_type, section_field or page. See The plan.
appliedbooleantrue when the push changed the store. false on a dry run, when any op is refuse, when an archive holds values and yes was not 1, when the manifest is unchanged, and when the plan has no ops (the new hash is still stored).
needs_yesbooleantrue when the plan archives values or records, so it applies only with yes=1.
refusedbooleantrue when any op is refuse; nothing applies until the manifest changes.
manifest_hashstringSHA-256 (64 hex characters) of the normalized manifest. When it equals the hash of the last applied push, plan is [] and nothing runs.
Response
{
  "plan": [
    { "op": "add", "target": "section_type", "key": "hero", "detail": "2 fields, looks full, split, thumbnail" },
    { "op": "add", "target": "type", "key": "bread", "detail": "2 properties" },
    { "op": "add", "target": "property", "key": "bread.name", "detail": "text" },
    { "op": "add", "target": "property", "key": "bread.body", "detail": "sections" }
  ],
  "applied": false,
  "needs_yes": false,
  "refused": false,
  "manifest_hash": "f78d42f8be58f6d5a4157b40a4ecbff94eb46e742ad56f7e1bc6327b8ba8c860"
}

Every call, dry runs and failed ones included, is kept in the site's push history (a failed one with its errors). The starter section types are created first when missing, so a manifest may name them without declaring them. An applied push records the hash, the time and the key that pushed it, and sends the webhook event object_schema.updated. An apply runs in one transaction: it applies every op or none.

Errors

  • 422 {"code": "no_site", "message": "No website is connected. Connect one under Settings > Website first."} when the store has no connected site.
  • 422 {"message": "...", "errors": {"types.0.key": ["..."]}} when the manifest has the wrong shape. Errors are keyed by dotted path into the manifest.
  • 422 {"code": "site_mismatch", "message": "The manifest is for site other-web; this store's site is bakery-web."} when the manifest's site is not the connected site's key.
  • 403 {"message":"Invalid ability provided."} when the key lacks objects:schema.

GET /v1/api/objects/schema

The connected site, every object type with its active properties, and every active section type. The CLI's drift check compares a local manifest with it. Requires the objects:read scope. No parameters.

Request
curl https://api.borkol.com/v1/api/objects/schema \
  -H "Authorization: Bearer {api_key}"

Status: 200 OK.

FieldTypeDescription
siteobject or null{key, name, site_url} of the connected site; null when none is connected.
typesarrayEvery object type, in the shape of GET /v1/api/objects/types, ordered by name.
section_typesarrayEvery active section type, in the shape of GET /v1/api/objects/section-types below, ordered by name.
Response
{
  "site": { "key": "bakery-web", "name": "Bakery", "site_url": "https://bakery.example.com" },
  "types": [
    {
      "name": "Bread",
      "plural_name": "Breads",
      "key": "bread",
      "system_key": null,
      "site": "bakery-web",
      "help": "One loaf per record.",
      "settings": {
        "publishable": true,
        "menu": { "placement": "objects", "icon": null, "position": 100 },
        "singleton": false,
        "hierarchical": false,
        "slug": { "source": "name", "prefixes": { "en": "/bread" } }
      },
      "properties": [
        { "key": "name", "label": "Name", "help": "Max 4 words.", "type": "text", "options": null, "localized": false, "config": null, "is_required": true, "position": 0 },
        { "key": "body", "label": "Body", "help": null, "type": "sections", "options": null, "localized": false, "config": null, "is_required": false, "position": 1, "section_type_keys": ["hero"] }
      ]
    }
  ],
  "section_types": [
    {
      "key": "hero",
      "name": "Hero",
      "site": "bakery-web",
      "icon": "image",
      "group": "Intro",
      "help": "The first block of a page.",
      "looks": [{ "key": "full", "name": "Full" }, { "key": "split", "name": "Split" }],
      "fields": [{ "key": "title", "label": "Title", "kind": "text", "required": true, "localized": true, "help": "Max 6 words." }],
      "item_label_field": "title",
      "thumbnail_url": "https://cdn.borkol.com/tenants/abc/media/2b3c/hero.png"
    }
  ]
}

Errors

  • 403 {"message":"Invalid ability provided."} when the key lacks objects:read.

GET /v1/api/objects/section-types

The store's active section types: the vocabulary a sections value can hold. Archived section types are left out; the starter section types are always listed unless a site archived them. Requires the objects:read scope. No parameters.

Request
curl https://api.borkol.com/v1/api/objects/section-types \
  -H "Authorization: Bearer {api_key}"

Status: 200 OK. data is a plain array, ordered by name; each item contains:

FieldTypeDescription
keystringThe section type key, the type of a section instance.
namestringDisplay name.
sitestring or nullThe connected site's key when the site pushed this section type; null for a starter or dashboard-made section type.
iconstring or nullLucide icon name.
groupstring or nullThe group the section picker shows it under.
helpstring or nullWhat the section is for, shown in the picker.
looksarray{key, name} per visual variant. An empty list means one look, default.
fieldsarrayThe field definitions: {key, label, kind, required, localized, config, help?}; config carries row fields of a repeater. Field kinds and value shapes are those of the property types.
item_label_fieldstring or nullThe field that names an instance in the editor.
thumbnail_urlstring or nullPublic URL of the picker thumbnail; null when none was uploaded.
Response
{
  "data": [
    {
      "key": "hero",
      "name": "Hero",
      "site": "bakery-web",
      "icon": "image",
      "group": "Intro",
      "help": "The first block of a page.",
      "looks": [{ "key": "full", "name": "Full" }, { "key": "split", "name": "Split" }],
      "fields": [{ "key": "title", "label": "Title", "kind": "text", "required": true, "localized": true, "help": "Max 6 words." }],
      "item_label_field": "title",
      "thumbnail_url": "https://cdn.borkol.com/tenants/abc/media/2b3c/hero.png"
    }
  ]
}

The route is read-only: POST, PUT and DELETE answer 405. Section types change through a schema push.

Errors

  • 403 {"message":"Invalid ability provided."} when the key lacks objects:read.

POST /v1/api/objects/media

Uploads a section type thumbnail during a push. Send multipart/form-data. Requires the objects:schema scope. The image is re-encoded like a dashboard upload (metadata stripped) and kept out of the merchant's media library.

NameTypeRequiredDescription
filefileyesA jpeg, png, webp or avif image, at most 20 MB. SVG and other formats are refused.
Request
curl -X POST https://api.borkol.com/v1/api/objects/media \
  -H "Authorization: Bearer {push_key}" \
  -F "file=@borkol/thumbs/hero.png"

Status: 201 Created.

FieldTypeDescription
idstring (UUID)The media id. Put it in the section type's thumbnail_media_id in the manifest.
urlstringPublic URL of the stored image.
Response
{
  "id": "2b3c4d5e-6f7a-4b8c-9d0e-1f2a3b4c5d6e",
  "url": "https://cdn.borkol.com/tenants/abc/media/2b3c4d5e-6f7a-4b8c-9d0e-1f2a3b4c5d6e/hero.png"
}

Errors

  • 422 {"message": "...", "errors": {"file": ["..."]}} when the file is missing, too large or not one of the allowed formats.
  • 422 {"message": "The file is not a processable image."} when the bytes are not an image the server can decode.
  • 422 {"message": "Images may be at most 25 megapixels (for example 5000 x 5000)."} when the image has more than 25 million pixels.
  • 403 {"message":"Invalid ability provided."} when the key lacks objects:schema.