data
Sanity CLI for Cron Jobs
Use the Sanity CLI for cron jobs with headless JSON commands, schema discovery, credentials, and permission controls.
7 functions 4 read 3 write API token auth
Sanity CLI for Cron Jobs
Schedule repeatable integration workflows from cron while keeping credentials in KosmoKrator config.
Use the headless CLI from cron when an operation should run without an interactive agent session. The Sanity CLI uses the same integration registry as the TUI, Lua runtime, and MCP gateway, but returns predictable command output for automation.
Command Shape
# Sanity CLI for Cron Jobs
kosmokrator integrations:configure sanity --set api_token="$SANITY_API_TOKEN" --set project_id="$SANITY_PROJECT_ID" --enable --read allow --write ask --json
kosmo integrations:call sanity.sanity_query_documents '{"query":"example_query","params":"example_params"}' --json Discovery Before Execution
Agents and scripts can inspect Sanity docs and schemas before choosing a function.
kosmo integrations:docs sanity --json
kosmo integrations:docs sanity.sanity_query_documents --json
kosmo integrations:schema sanity.sanity_query_documents --json
kosmo integrations:search "Sanity" --json
kosmo integrations:list --json Useful Sanity CLI Functions
| Function | Type | Parameters | Description |
|---|---|---|---|
sanity.sanity_query_documents | Read | query, params | Query documents in Sanity using GROQ (Graph-Relational Object Queries). Returns matching documents with their fields. |
sanity.sanity_get_document | Read | id | Retrieve a single Sanity document by its ID. Returns the full document with all fields. |
sanity.sanity_create_document | Write | document | Create a new document in the Sanity dataset. The document data must include a _type field matching a schema type. |
sanity.sanity_update_document | Write | id, set | Update an existing Sanity document by applying a patch with the specified fields. |
sanity.sanity_delete_document | Write | id | Delete a document from the Sanity dataset by its ID. This action is permanent. |
sanity.sanity_list_projects | Read | none | List all Sanity projects accessible to the authenticated user. Requires a management API token. |
sanity.sanity_get_current_user | Read | none | Get the currently authenticated Sanity user. Useful for verifying credentials and checking user identity. |
Automation Notes
- Use
--jsonfor machine-readable output. - Keep credentials out of argv by using environment variables or stored KosmoKrator configuration.
- Configure read/write policy before unattended runs; use
--forceonly for trusted automation. - Use the MCP gateway instead when the agent needs dynamic tool discovery inside a conversation.