CLI
The Alokai CMS CLI (alokai-content) lets you import and export content models and pages programmatically. Useful for seeding environments, migrating content, and version-controlling your content schema.
Running the CLI
From the apps/alokon directory:
yarn cli --helpOr after building:
node dist/cli/index.mjs --helpAuthentication
All CLI commands require an API key. Create one in Settings → API Keys with the appropriate permissions.
Commands
import
Import content models or pages from a JSON file or directory. When given a directory, files are processed in alphabetical order — name them with a numeric prefix (e.g. 01-hero.json, 02-page.json) to control import order.
yarn cli import \ --api-key=default_sk_... \ --space-id=default \ --environment-id=main \ --schema-path=./schema.jsonOptions:
| Option | Required | Default | Description |
|---|---|---|---|
--api-key | Yes | — | Your Alokai CMS API key |
--space-id | Yes | — | Target space ID |
--environment-id | Yes | — | Target environment ID |
--schema-path | Yes | — | Path to a JSON file or directory of JSON files |
--org-id | Yes | — | Organization ID |
--base-url | No | http://localhost:8787 | Alokai CMS base URL |
export
Export all content models and pages from a space and environment to a directory. Output is split into content-models/ and content/ subdirectories.
yarn cli export \ --api-key=default_sk_... \ --space-id=default \ --environment-id=main \ --output=./exportOptions:
| Option | Required | Default | Description |
|---|---|---|---|
--api-key | Yes | — | Your Alokai CMS API key |
--space-id | Yes | — | Source space ID |
--environment-id | Yes | — | Source environment ID |
--output | Yes | — | Output directory path |
--org-id | Yes | — | Organization ID |
--base-url | No | http://localhost:8787 | Alokai CMS base URL |
--include-built-in | No | false | Include built-in models in export |
Migrating content between instances
To copy all schemas and content from one Alokai CMS instance (e.g. local) to another (e.g. production), use the export and import commands together.
Step 1: Export from the source instance
yarn cli export \ --api-key=<source-api-key> \ --org-id=<source-org-id> \ --space-id=<source-space-id> \ --environment-id=<source-environment-id> \ --base-url=http://localhost:8787 \ --output=./export \ --include-built-inThis creates ./export/content-models/ and ./export/content/ with all your data.
Step 2: Import content models to the target instance
yarn cli import \ --api-key=<target-api-key> \ --org-id=<target-org-id> \ --space-id=<target-space-id> \ --environment-id=<target-environment-id> \ --base-url=https://<target-cms-url> \ --schema-path=./export/content-modelsStep 3: Import content entries to the target instance
yarn cli import \ --api-key=<target-api-key> \ --org-id=<target-org-id> \ --space-id=<target-space-id> \ --environment-id=<target-environment-id> \ --base-url=https://<target-cms-url> \ --schema-path=./export/contentFile formats
Content model
{ "type": "content-model", "name": "Featured Collection", "api_id": "FeaturedCollection", "description": "A curated set of products", "fields": [ { "name": "title", "type": "text", "label": "Title" }, { "name": "items", "type": "components", "label": "Items" } ]}Page / content entry
{ "type": "content", "content_type": "page", "path": "/about", "locale": "en-US", "data": { "componentsAboveFold": [], "componentsBelowFold": [] }}