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 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.
| Key | Env var | Type | Required | Label |
|---|---|---|---|---|
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.
kosmo integrations:call payload-cms.payload_cms_list_collections '{}' --json 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.
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 - Parameters
- none
kosmo integrations:call payload-cms.payload_cms_list_collections '{}' --json 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 - Parameters
- slug
kosmo integrations:call payload-cms.payload_cms_get_collection '{"slug":"example_slug"}' --json 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 - Parameters
- collection, limit, page, sort, where
kosmo integrations:call payload-cms.payload_cms_list_documents '{"collection":"example_collection","limit":1,"page":1,"sort":"example_sort","where":"example_where"}' --json 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 - Parameters
- collection, document_id
kosmo integrations:call payload-cms.payload_cms_get_document '{"collection":"example_collection","document_id":"example_document_id"}' --json 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 - Parameters
- collection, data
kosmo integrations:call payload-cms.payload_cms_create_document '{"collection":"example_collection","data":"example_data"}' --json 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 - Parameters
- limit, page
kosmo integrations:call payload-cms.payload_cms_list_users '{"limit":1,"page":1}' --json 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 - Parameters
- none
kosmo integrations:call payload-cms.payload_cms_get_current_user '{}' --json 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
kosmo integrations:schema payload-cms.payload_cms_list_collections --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
payload-cms.payload_cms_get_collection 1 parameters
kosmo integrations:schema payload-cms.payload_cms_get_collection --json | Parameter | Type | Required | Description |
|---|---|---|---|
slug | string | yes | The slug of the collection to retrieve. |
payload-cms.payload_cms_list_documents 5 parameters
kosmo integrations:schema payload-cms.payload_cms_list_documents --json | Parameter | Type | Required | Description |
|---|---|---|---|
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
kosmo integrations:schema payload-cms.payload_cms_get_document --json | Parameter | Type | Required | Description |
|---|---|---|---|
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
kosmo integrations:schema payload-cms.payload_cms_create_document --json | Parameter | Type | Required | Description |
|---|---|---|---|
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
kosmo integrations:schema payload-cms.payload_cms_list_users --json | Parameter | Type | Required | Description |
|---|---|---|---|
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
kosmo integrations:schema payload-cms.payload_cms_get_current_user --json | Parameter | Type | Required | Description |
|---|---|---|---|
| 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.