KosmoKrator

data

Payload CMS CLI for AI Agents

Use the Payload CMS CLI from KosmoKrator to call Payload CMS tools headlessly, return JSON, inspect schemas, and automate workflows from coding agents, scripts, and CI.

Payload CMS CLI Setup

Payload CMS can be configured headlessly with `kosmokrator integrations:configure payload-cms`.

Install, configure, and verify
# Install KosmoKrator first if it is not available on PATH.
curl -fsSL https://raw.githubusercontent.com/OpenCompanyApp/kosmokrator/main/install.sh | bash

# Configure and verify this integration.
kosmokrator integrations:configure payload-cms --set api_token="$PAYLOAD_CMS_API_TOKEN" --enable --read allow --write ask --json
kosmokrator integrations:doctor payload-cms --json
kosmokrator integrations:status --json

Credentials

Authentication type: API token api_token. Configure credentials once, then reuse the same stored profile from scripts, coding CLIs, Lua, and MCP.

KeyEnv varTypeRequiredLabel
api_token PAYLOAD_CMS_API_TOKEN Secret secret yes API Token
base_url PAYLOAD_CMS_BASE_URL Text text no Base URL

Command Patterns

The generic command is stable across every integration. The provider shortcut is shorter for humans.

Generic CLI call
kosmo integrations:call payload-cms.payload_cms_list_collections '{}' --json
Provider shortcut
kosmo integrations:payload-cms payload_cms_list_collections '{}' --json

Discovery

These commands return structured output for coding agents that need to inspect capabilities before choosing a function.

Discovery commands
kosmo integrations:docs payload-cms --json
kosmo integrations:docs payload-cms.payload_cms_list_collections --json
kosmo integrations:schema payload-cms.payload_cms_list_collections --json
kosmo integrations:search "Payload CMS" --json
kosmo integrations:list --json

Automation Contexts

The same configured command surface works in these environments. The command does not change unless the host wrapper, credentials, or permissions change.

CLI Functions

Every function below can be called headlessly. Commands are highlighted, copyable, and scroll horizontally when payloads are long.

payload-cms.payload_cms_list_collections

List all collections defined in the Payload CMS instance. Returns each collection's slug, labels, and field configuration.

Read read
Parameters
none
Generic call
kosmo integrations:call payload-cms.payload_cms_list_collections '{}' --json
Shortcut
kosmo integrations:payload-cms payload_cms_list_collections '{}' --json

payload-cms.payload_cms_get_collection

Get detailed information about a specific collection by its slug. Returns field definitions, labels, default sort, and other configuration.

Read read
Parameters
slug
Generic call
kosmo integrations:call payload-cms.payload_cms_get_collection '{"slug":"example_slug"}' --json
Shortcut
kosmo integrations:payload-cms payload_cms_get_collection '{"slug":"example_slug"}' --json

payload-cms.payload_cms_list_documents

List documents in a Payload CMS collection. Supports pagination (limit, page), sorting, and filtering via the where parameter. Returns document IDs, timestamps, and field values.

Read read
Parameters
collection, limit, page, sort, where
Generic call
kosmo integrations:call payload-cms.payload_cms_list_documents '{"collection":"example_collection","limit":1,"page":1,"sort":"example_sort","where":"example_where"}' --json
Shortcut
kosmo integrations:payload-cms payload_cms_list_documents '{"collection":"example_collection","limit":1,"page":1,"sort":"example_sort","where":"example_where"}' --json

payload-cms.payload_cms_get_document

Get detailed information about a specific document by its ID within a collection. Returns all field values, timestamps, and metadata.

Read read
Parameters
collection, document_id
Generic call
kosmo integrations:call payload-cms.payload_cms_get_document '{"collection":"example_collection","document_id":"example_document_id"}' --json
Shortcut
kosmo integrations:payload-cms payload_cms_get_document '{"collection":"example_collection","document_id":"example_document_id"}' --json

payload-cms.payload_cms_create_document

Create a new document in a Payload CMS collection. Provide the collection slug and a JSON object of field values. The document is created as a draft by default (if versions are enabled on the collection).

Write write
Parameters
collection, data
Generic call
kosmo integrations:call payload-cms.payload_cms_create_document '{"collection":"example_collection","data":"example_data"}' --json
Shortcut
kosmo integrations:payload-cms payload_cms_create_document '{"collection":"example_collection","data":"example_data"}' --json

payload-cms.payload_cms_list_users

List users in the Payload CMS instance. Supports pagination with limit and page parameters. Returns user IDs, emails, names, and roles.

Read read
Parameters
limit, page
Generic call
kosmo integrations:call payload-cms.payload_cms_list_users '{"limit":1,"page":1}' --json
Shortcut
kosmo integrations:payload-cms payload_cms_list_users '{"limit":1,"page":1}' --json

payload-cms.payload_cms_get_current_user

Get the profile of the currently authenticated Payload CMS user. Returns email, name, roles, and account metadata.

Read read
Parameters
none
Generic call
kosmo integrations:call payload-cms.payload_cms_get_current_user '{}' --json
Shortcut
kosmo integrations:payload-cms payload_cms_get_current_user '{}' --json

Function Schemas

Use these parameter tables when building CLI payloads without calling integrations:schema first.

payload-cms.payload_cms_list_collections 0 parameters
Schema command
kosmo integrations:schema payload-cms.payload_cms_list_collections --json
ParameterTypeRequiredDescription
No parameters.
payload-cms.payload_cms_get_collection 1 parameters
Schema command
kosmo integrations:schema payload-cms.payload_cms_get_collection --json
ParameterTypeRequiredDescription
slug string yes The slug of the collection to retrieve.
payload-cms.payload_cms_list_documents 5 parameters
Schema command
kosmo integrations:schema payload-cms.payload_cms_list_documents --json
ParameterTypeRequiredDescription
collection string yes The collection slug to query.
limit integer no Maximum number of documents to return (default 10).
page integer no Page number for pagination (default 1).
sort string no Sort field. Prefix with "-" for descending. E.g. "createdAt" or "-updatedAt".
where string no JSON object for filtering. E.g. '{"title":{"equals":"Hello"}}'.
payload-cms.payload_cms_get_document 2 parameters
Schema command
kosmo integrations:schema payload-cms.payload_cms_get_document --json
ParameterTypeRequiredDescription
collection string yes The collection slug the document belongs to.
document_id string yes The ID of the document to retrieve.
payload-cms.payload_cms_create_document 2 parameters
Schema command
kosmo integrations:schema payload-cms.payload_cms_create_document --json
ParameterTypeRequiredDescription
collection string yes The collection slug to create the document in.
data string yes JSON object of field values. E.g. '{"title":"Hello","content":"World"}'.
payload-cms.payload_cms_list_users 2 parameters
Schema command
kosmo integrations:schema payload-cms.payload_cms_list_users --json
ParameterTypeRequiredDescription
limit integer no Maximum number of users to return (default 10).
page integer no Page number for pagination (default 1).
payload-cms.payload_cms_get_current_user 0 parameters
Schema command
kosmo integrations:schema payload-cms.payload_cms_get_current_user --json
ParameterTypeRequiredDescription
No parameters.

Permissions

Headless calls still follow the integration read/write permission policy. Configure read/write defaults with integrations:configure. Add --force only for trusted automation that should bypass that policy.