CLI

npm install -D @blokcms/cli
npx blokcms login --token blok_pat_…        # Account → Access tokens

Or set BLOKCMS_TOKEN (and BLOKCMS_API_URL) in CI.

Command
blokcms spacesList your organization's spaces.
blokcms schema pull --space spc_…Write the content model to blokcms.schema.json.
blokcms schema push --space spc_… blokcms.schema.ts [--prune] [--dry-run]Create and update types from code; --prune deletes types missing from the file.
blokcms types generate --space spc_… --out src/blokcms.d.tsTypeScript types for your content.
blokcms migrate --space spc_… migrations/001.ts [--dry-run]Run a content migration.
blokcms export --space spc_… --out space.ndjsonExport everything (runs as a background job).
blokcms import --space spc_… space.ndjsonImport an export (upserts by id).

Schema as code

import { defineSchema } from "@blokcms/cli";

export default defineSchema({
  types: [
    {
      key: "page", kind: "content", name: "Page",
      fields: [
        { key: "title", label: "Title", type: "text", required: true, translatable: true },
        { key: "body", label: "Body", type: "blocks", types: ["hero"] },
      ],
    },
    {
      key: "hero", kind: "block", name: "Hero",
      fields: [{ key: "headline", label: "Headline", type: "text", required: true }],
    },
  ],
});

Content migrations

import { defineMigration } from "@blokcms/cli";

export default defineMigration(async ({ entries, getEntry, saveDraft, log }) => {
  for await (const summary of entries("article")) {
    const entry = await getEntry(summary.id);
    const fields = { ...entry.draft.fields, subtitle: entry.draft.fields.teaser };
    await saveDraft(entry.id, entry.version, { ...entry.draft, fields }, "Copy teaser to subtitle");
    log(`updated ${summary.path}`);
  }
});