REST API integration
Sanity REST API integration for Draftbit
Query Sanity datasets from apps
What is Sanity?
Sanity's CDN-backed HTTP API is useful for public app reads. Add your project ID and dataset, and optionally a bearer token for private datasets.
Use Sanity with Draftbit
- Built-in endpoints: Query documents, Get document, Get document by ID query.
- Bind any Sanity endpoint to a screen, list, form, or AI agent action.
- Authentication is configured once per app — secrets stay on the server.
- Add custom request and response transforms without forking Sanity's client library.
Example
sanity-example.ts // Example: fetch from Sanity
const response = await fetch("https://{project_id}.apicdn.sanity.io/v2025-02-19/data/query/{dataset}", {
headers: {
"Authorization": "Bearer YOUR_SANITY_TOKEN",
},
});
const data = await response.json();Use cases
- Drive a blog, news feed, or content section from a headless CMS
- Let non-engineers publish app content without a release
- Localize copy and assets without code changes
Authentication
Authentication uses the `Authorization` header. Paste your key once in Draftbit and every request to Sanity carries it automatically — secrets stay on the server side.
Use Sanity in a Draftbit app today
Start free, connect Sanity in minutes, and ship with AI agents that know how to use it.
Frequently asked questions
What is the Sanity REST integration?
Sanity's CDN-backed HTTP API is useful for public app reads. Add your project ID and dataset, and optionally a bearer token for private datasets.
How do I connect Sanity to a Draftbit app?
Go to Integrations → REST APIs in your Draftbit app and pick Sanity from the catalog. Paste your API key or token, set any base-URL variables (project IDs, hosts), and the endpoints become available across your screens.
Does Sanity require authentication?
Most Sanity endpoints expect a key or token sent as a header. Built-in endpoints include: Query documents, Get document, Get document by ID query.
What can I build with Sanity and Draftbit?
Use Sanity as a headless CMS for your mobile or web app: Drive a blog, news feed, or content section from a headless CMS; Let non-engineers publish app content without a release.