Skip to content

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:

Terminal window
yarn cli --help

Or after building:

Terminal window
node dist/cli/index.mjs --help

Authentication

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.

Terminal window
yarn cli import \
--api-key=default_sk_... \
--space-id=default \
--environment-id=main \
--schema-path=./schema.json

To import a whole directory of files:

Terminal window
yarn cli import \
--api-key=default_sk_... \
--space-id=default \
--environment-id=main \
--schema-path=./schemas/

Options:

OptionRequiredDescription
--api-keyYesYour Alokai CMS API key
--space-idYesTarget space ID
--environment-idYesTarget environment ID
--schema-pathYesPath to a JSON file or directory
--base-urlNoAlokai CMS base URL (default: http://localhost:8787)

export

Export all content from a space and environment to a directory.

Terminal window
yarn cli export \
--api-key=default_sk_... \
--space-id=default \
--environment-id=main \
--output=./export

Options:

OptionRequiredDescription
--api-keyYesYour Alokai CMS API key
--space-idYesSource space ID
--environment-idYesSource environment ID
--outputYesOutput directory path
--include-built-inNoInclude 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": []
}
}