KosmoKrator

data

Sanity CLI for Shell Scripts

Use the Sanity CLI for shell scripts with headless JSON commands, schema discovery, credentials, and permission controls.

7 functions 4 read 3 write API token auth

Sanity CLI for Shell Scripts

Call integration functions from shell scripts with stable JSON input and output.

Use shell scripts for small local automations that need one or more integration calls. 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 Shell Scripts
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

FunctionTypeParametersDescription
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

Related Sanity CLI Pages