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.
yarn cli import \ --api-key=default_sk_... \ --space-id=default \ --environment-id=main \ --schema-path=./schema.jsonTo import a whole directory of files:
yarn cli import \ --api-key=default_sk_... \ --space-id=default \ --environment-id=main \ --schema-path=./schemas/Options:
| Option | Required | 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 |
--base-url | No | Alokai CMS base URL (default: http://localhost:8787) |
export
Export all content from a space and environment to a directory.
yarn cli export \ --api-key=default_sk_... \ --space-id=default \ --environment-id=main \ --output=./exportOptions:
| Option | Required | 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 |
--include-built-in | No | Include built-in models in export |
File 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
{ "type": "content", "content_type": "page", "path": "/about", "locale": "en-US", "data": { "componentsAboveFold": [], "componentsBelowFold": [] }}