Sanity lets the AI query and update documents in one dataset of your Content Lake.
What you can ask for#
Show the latest ten posts from Sanity on the blog page.
Add an admin form that creates a draft post in Sanity.
Fix the typo in the About page document.
Connect Sanity#
Step 1: Find the connector
Open Tools, then Connectors, and search for Sanity. You can also go to Settings, then Connectors, in your dashboard.
Step 2: Select Connect
Select Connect to open the secure form.
Step 3: Enter the details
Fill in API key, Project ID and Dataset. Hidden fields show as dots; use the eye icon to check what you typed.
Step 4: Save
Select Save connection. Swarmz encrypts the credentials and only decrypts them to call Sanity for you. Everyone in your workspace can then use the connection.
Where to find your credentials#
In your Sanity project, open Settings, then API, then Tokens, and create a dedicated token. Use a viewer role for reading, or an editor role if the app must change documents. Also note your Project ID and Dataset, for example production.
What the AI can and can't do#
- Query documents with GROQ.
- Create, update and delete documents when the token allows it.
- The connection is tied to one project and dataset. Everyone using the published app acts through the same token.
- Apps you publish can call this connector too, not just the builder.
- Changes ask for your approval by default. You can adjust this under Agent permissions on the connection. See What an integration can access.
Troubleshooting#
A write is refused.
The token has a viewer role. Create one with the right role.
No documents appear.
Check the dataset name and the document type in your query.
The token leaked.
Delete it in Sanity, create a new one and update the connection.
General steps for any connector are in Connect an integration. Keys and secrets are covered in Secrets and API keys. To remove it, see Disconnect an integration.
What Swarmz can do with it
Content queries
Run bounded read-only GROQ queries and fetch documents.
Document management
Create, patch, and delete documents with write approval.
More in Content & CMS
Still stuck?
A person from Swarmz Support can take a look.