Description

Sanity is a content platform designed to facilitate streamlined content creation and management for a wide range of digital projects. Its real-time collaborative environment enables teams to work together efficiently, iterating on content seamlessly. With customizable data modeling capabilities, users can structure content exactly as needed, accommodating complex data structures with ease.

Sanity offers robust APIs and integrations, ensuring smooth connections to various front-end frameworks, databases, and services. Whether it's a small blog or an enterprise-scale application, Sanity provides the tools and infrastructure necessary to build, manage, and deliver content effectively across any digital platform.

Supported Operations

Sanity HTTP API

Uploads an image

Uploads an image

Retrieves the latest version of documents

Retrieves the latest version of documents by their IDs

Export all documents

Export all documents from a dataset in a Sanity project. The export endpoint returns a node-stream of NDJSON data. An unauthenticated request will only return publicly available documents. If you include an authentication token, it will include documents that this token can access (for example, drafts and system documents).

Get document revision

Returns a document as it was at a point in the past as JSON. This endpoint behaves exactly same as the doc endpoint. It applies current access control for every revision of the document.

Get transactions for documents

Returns an NDJSON (Newline Delimited JSON) containing transactions for the given document ids.

Listening for content changes through the API

The listen endpoint can be used to receive events whenever documents are modified. This endpoint follows the server-sent events protocol using the mime-type text/event-stream. The backend will hold the connection open and stream events as they occur for any documents matching the GROQ query.

Mutate documents in a dataset

The Mutate API allows you to make changes to documents in a dataset. It supports various mutation operations such as creating, updating, and deleting documents. For more information you can have a look at the documentation (https://www.sanity.io/docs/http-mutations).

Query data

Retrieve data from a dataset using the GROQ query language. GROQ queries may use parameters prefixed by a dollar sign ($). String values must be enclosed in quotation marks, while numbers and booleans are written normally. Due to browser limitations, the max limit on GET queries is 11 KB. Queries longer than that must be submitted via POST.

Execute a GROQ query

Execute a GROQ query on a dataset. Queries longer than 11kB must be submitted using the POST method. Queries sent with the POST method will also be cached on the CDN.

Create an embeddings index

Create a new embeddings index for an existing database in a Sanity project.

Retrieve all embeddings indexes for a dataset

Retrieve a list of all existing embeddings indexes for an existing database in a Sanity project.

Retrieve a specific embeddings index

Retrieve a specific embeddings index for an existing database in a Sanity project.

Query an embeddings index

Query an embeddings index to retrieve documents that are closely related to the input query in the request. It returns an array of matching documents IDs with their relevance score, based on the input query in the request.

Delete an embeddings index

Delete a specific embeddings index for an existing database in a Sanity project.

List all webhooks

Retrieves a list of all webhooks for a specific project.

Create a document or transaction webhook

When creating a webhook, ensure the request body matches the type of webhook you want to create. To distinguish between the two types of webhooks, ensure that the type property in the request body is set to either "document" or "transaction", depending on the desired webhook type. Additionally, ensure that the request body structure matches the schema specified for the chosen webhook type. For more information please have a look at the documentation page (https://www.sanity.io/docs/http-webhooks#68e174c8a1d0).

Update a webhook

Update an existing webhook by its ID.

Delete a webhook

Delete an existing webhook by its ID.

List webhook attempts

Retrieve a list of webhook attempts for a specific webhook by its ID.

Retrieves the status of a job by its ID

Retrieves the current status of a job identified by its unique ID. The status can be either "running" or "completed", along with additional metadata such as authors and timestamps.

Listening for job status

Monitor the status of a job programmatically by listening for updates. Each job has a /listen endpoint to allow you to monitor its status programmatically. While listening, event data will be sent back at intervals providing updates on the status of your job.

Get all members and their roles

Retrieves a list of all members in the organization along with their assigned roles.

Get roles of a single organization member

Retrieves the roles assigned to a specific member in the organization.

Give an organization member a role

Assigns a role to a specific member in the organization.

Remove a role from an organization member

Removes a role from a specific member in the organization.

Get all grants for the current user

Retrieves all grants assigned to the current user within the organization.

List all projects

Returns a list of all projects you are a member of

Create a project

Creates a new Sanity project

List all CORS entries

Retrieves a list of all CORS origins allowed to access the API for this project.

Create a CORS entry

Allows a new origin to use your project API through CORS.

List active features

Returns a list of all active features on your project.

Check if a feature is active

Shows whether a specific feature is enabled on your project.

List project permissions

Returns a list of permissions you have as a member of a project.

List project roles

Returns a list of existing roles on a project.

Retrieve a project

Retrieve details of an existing Sanity project

Update a project

Updates a specific Sanity project with the values of the parameters passed. Any parameters not provided will be left unchanged.

Delete a project

Deletes a specific Sanity project. Use this endpoint with caution as it is irreversible.

List Users with Roles

Retrieves a list of users along with their assigned roles for the specified project.

Get User Role

Retrieves the role of a specific user in the project.

Add User Role

Assigns a role to a specific user in the project.

Delete User Role

Removes a role from a specific user in the project.

Delete a CORS entry

Deletes an existing CORS origin from your project.

List all datasets

Returns a list of all datasets available to a project.

List jobs history

Public API for returning a list of copy jobs.

Create a dataset

Creates a new dataset for your project.

Delete a dataset

Deletes an existing dataset within your project.

Retrieve dataset ACL

Retrieves the Access Control List (ACL) for the specified dataset within the project.

Copy a dataset

Copies a dataset inside Sanity's infrastructure.

Retrieve dataset grants

Retrieves the grants for the specified dataset within the project.

List dataset tags

Lists all tags assigned to the dataset.

Assign dataset tag

Assigns the tag to the dataset.

Unassign dataset tag

Removes or unassigns the tag from the dataset.

List User Grants

Retrieves a list of grants for the specified project.

Add Grants to Role

Adds grants to a specified role in the project.

List Permission Resource Schemas

Retrieves a list of permission resource schemas for the specified project.

Get Permission Resources

Retrieves the available permission resources for the specified project.

Create Permission Resource

Creates a new permission resource in the project.

List All Roles

Retrieves a list of all roles available for the specified project.

Create Role Object

Creates a custom role object with the specified title, name, and description.

Create dataset tag

Creates a dataset tag.

Edit dataset tag

Edit the name/identifier, title, description, or color of the dataset tag.

Delete dataset tag

Deletes the dataset tag if it's not assigned to any datasets.

List project tokens

Returns a list of existing tokens on the project.

Create project token

Creates a token on the project.

Delete project token

Deletes the token from the project.

Retrieve a user

Fetches the details of a user on a project.

Publish documents immediately

Publish any number of documents immediately.

Fetch all schedules

Fetch all schedules, ordered by createdAt in reverse chronological order.

Create a new schedule

Create a new schedule to publish or unpublish a set of documents.

Fetch schedules by ID

Fetch schedules by ID.

Update an existing schedule

Update an existing schedule by providing new details such as name, description, execution date and time, or documents.

Run an existing schedule immediately (publish all its documents)

Run an existing schedule immediately to publish all its documents. Multiple schedule IDs can be specified as a comma-separated list.

Unpublish documents immediately

Unpublish any number of documents immediately.

Details
Preview

This item is available for early access. It is still in development and may contain experimental features or limitations.

Last Update

2 months ago

Includes
sanity-api-client