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.

7 functions 6 read 1 write API token auth

Payload CMS CLI Setup

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

# 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 use the same stored profile from scripts, coding CLIs, Lua code mode, and the MCP gateway.

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

Call Payload CMS Headlessly

Use the generic call form when another coding CLI or script needs a stable universal interface.

kosmo integrations:call payload-cms.payload_cms_list_collections '{}' --json

Use the provider shortcut form for shorter human-facing commands.

kosmo integrations:payload-cms payload_cms_list_collections '{}' --json

Agent Discovery Commands

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

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

All CLI Functions

Every function below can be called headlessly. The generic form is stable across all integrations; the provider shortcut is shorter but specific to Payload CMS.

payload-cms.payload_cms_list_collections

Read read

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

Parameters
none

Generic CLI call

kosmo integrations:call payload-cms.payload_cms_list_collections '{}' --json

Provider shortcut

kosmo integrations:payload-cms payload_cms_list_collections '{}' --json

payload-cms.payload_cms_get_collection

Read read

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

Parameters
slug

Generic CLI call

kosmo integrations:call payload-cms.payload_cms_get_collection '{"slug":"example_slug"}' --json

Provider shortcut

kosmo integrations:payload-cms payload_cms_get_collection '{"slug":"example_slug"}' --json

payload-cms.payload_cms_list_documents

Read read

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.

Parameters
collection, limit, page, sort, where

Generic CLI call

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

Provider 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

Read read

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

Parameters
collection, document_id

Generic CLI call

kosmo integrations:call payload-cms.payload_cms_get_document '{"collection":"example_collection","document_id":"example_document_id"}' --json

Provider shortcut

kosmo integrations:payload-cms payload_cms_get_document '{"collection":"example_collection","document_id":"example_document_id"}' --json

payload-cms.payload_cms_create_document

Write write

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).

Parameters
collection, data

Generic CLI call

kosmo integrations:call payload-cms.payload_cms_create_document '{"collection":"example_collection","data":"example_data"}' --json

Provider shortcut

kosmo integrations:payload-cms payload_cms_create_document '{"collection":"example_collection","data":"example_data"}' --json

payload-cms.payload_cms_list_users

Read read

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

Parameters
limit, page

Generic CLI call

kosmo integrations:call payload-cms.payload_cms_list_users '{"limit":1,"page":1}' --json

Provider shortcut

kosmo integrations:payload-cms payload_cms_list_users '{"limit":1,"page":1}' --json

payload-cms.payload_cms_get_current_user

Read read

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

Parameters
none

Generic CLI call

kosmo integrations:call payload-cms.payload_cms_get_current_user '{}' --json

Provider 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

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

Operation
Read read
Schema command
kosmo integrations:schema payload-cms.payload_cms_list_collections --json
ParameterTypeRequiredDescription
No parameters.

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.

Operation
Read read
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

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.

Operation
Read read
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

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

Operation
Read read
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

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).

Operation
Write write
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

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

Operation
Read read
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

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

Operation
Read read
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.