> For AI agents: the complete Sanity documentation index is available at [https://www.sanity.io/docs/llms.txt](https://www.sanity.io/docs/llms.txt).

# Schema deployment

Deploy your schema into your dataset to enable deep integration between your content model and Sanity apps.

Since version [3.88.0](https://www.sanity.io/changelog/525de82a-dd7b-40c7-bf38-12248136c339), Sanity Studio has supported deploying a representation of your content model, in the form of a schema, to your dataset. The schema commands became generally available in that release. It enables integration between your studios and apps like [Dashboard](https://www.sanity.io/docs/dashboard) and [Canvas](https://www.sanity.io/docs/canvas).

> [!TIP]
> The [Sanity MCP server](https://www.sanity.io/docs/ai/mcp-server) can also deploy your schema.

## What the schema commands do

The schema commands belong to the `sanity schemas` group. They let you deploy your schemas at the workspace level to the matching combination of dataset and project ID, which makes them available to Sanity apps and APIs. Requires `sanity` 3.88.0 or later.

If you aren't logged in with sufficient privileges, provide a deploy token. A deploy token is enough; these commands don't need a write token:

**CLI**

```sh
SANITY_AUTH_TOKEN=YOUR_DEPLOY_TOKEN npx sanity@latest schemas deploy
```

## How schema IDs are named

Each workspace deploys its schema to its own schema ID, built from the workspace `name`: `_.schemas.<workspaceName>`. A studio config without a `name` is a workspace named `default`, so its schema ID is `_.schemas.default`. This is the ID to pass as `schemaId` in [Agent Actions](https://www.sanity.io/docs/agent-actions/introduction) requests. If you deploy with `--tag <tag>`, the schema ID is `_.schemas.<workspaceName>.tag.<tag>` instead.

The workspace name in a schema ID can contain only letters, numbers, underscores (`_`), and hyphens (`-`), and can't start with an underscore or hyphen. Sanity Studio enforces these rules for every workspace name, and `sanity schemas deploy` fails with a configuration error if a name breaks them, so a workspace's schema ID always uses its exact name. For example, a workspace named `blog-en` deploys to `_.schemas.blog-en`.

In a studio with multiple workspaces, `sanity schemas deploy` deploys a schema for every workspace. Run `sanity schemas list` to see the ID of each deployed schema. To configure more than one workspace, see [Workspaces](https://www.sanity.io/docs/studio/workspaces).

## Available commands

### `sanity schemas deploy`

Deploys schema documents to workspace datasets. If you've already run `sanity login`, you typically have deploy permission by default. In CI environments where `sanity login` hasn't been executed, you'll need to provide a deploy token.

**Options:**

- `--workspace <name>`: Deploy only the named workspace.
- `--tag <tag>`: Add a tag suffix to the schema ID, so you can test without overwriting an existing schema.
- `--verbose`: Show detailed deployment information, including the `schemaId`.

**Examples:**

**npm**

```shell
# Deploy all workspace schemas
npx sanity@latest schemas deploy

# Deploy the schema for a specific workspace
npx sanity@latest schemas deploy --workspace default
```

**pnpm**

```shell
# Deploy all workspace schemas
pnpm dlx sanity@latest schemas deploy

# Deploy the schema for a specific workspace
pnpm dlx sanity@latest schemas deploy --workspace default
```

**yarn**

```shell
# Deploy all workspace schemas
yarn dlx sanity@latest schemas deploy

# Deploy the schema for a specific workspace
yarn dlx sanity@latest schemas deploy --workspace default
```

**bun**

```shell
# Deploy all workspace schemas
bunx sanity@latest schemas deploy

# Deploy the schema for a specific workspace
bunx sanity@latest schemas deploy --workspace default
```

> [!WARNING]
> Deploying a schema is not registering a studio
> `sanity schemas deploy` uploads the workspace schema to your dataset. It does not write manifest files, and it does not tell Sanity where your studio is hosted.
> If you host the studio yourself, run `npx sanity@latest deploy --external --url https://example.com/studio` instead. That command registers the studio and deploys its schema in the same run, so a separate schema deployment isn't needed. Without it, Dashboard, Media Library, Canvas, and the App SDK have no registered studio to resolve workspaces from.
> See [Register the studio and deploy the schema](https://www.sanity.io/docs/studio/deployment) and the [Deploy CLI command reference](https://www.sanity.io/docs/cli-reference/deploy) for details.

### `sanity schemas list`

Lists all schemas in the current dataset. Use it to find the `schemaId` that [Agent Actions](https://www.sanity.io/docs/agent-actions) needs.

**Options:**

- `--json`: Get the schema as JSON.
- `--id <schema_id>`: Fetch a single schema by ID.

**Examples:**

**npm**

```shell
# List all schemas
npx sanity@latest schemas list

# Get a specific schema
npx sanity@latest schemas list --id _.schemas.workspaceName

# Get schemas as JSON
npx sanity@latest schemas list --json
```

**pnpm**

```shell
# List all schemas
pnpm dlx sanity@latest schemas list

# Get a specific schema
pnpm dlx sanity@latest schemas list --id _.schemas.workspaceName

# Get schemas as JSON
pnpm dlx sanity@latest schemas list --json
```

**yarn**

```shell
# List all schemas
yarn dlx sanity@latest schemas list

# Get a specific schema
yarn dlx sanity@latest schemas list --id _.schemas.workspaceName

# Get schemas as JSON
yarn dlx sanity@latest schemas list --json
```

**bun**

```shell
# List all schemas
bunx sanity@latest schemas list

# Get a specific schema
bunx sanity@latest schemas list --id _.schemas.workspaceName

# Get schemas as JSON
bunx sanity@latest schemas list --json
```

### `sanity schemas delete`

Removes schema documents by ID. Useful when you need to remove schemas from Canvas or Agent Actions.

**Options:**

- `--ids <schema_id_1,schema_id_2,...>`: Comma-separated list of schema IDs to delete.
- `--dataset <dataset_name>`: Delete schemas from a specific dataset.
- `--yes` (`-y`): Delete schemas without prompting for confirmation. Required when the command runs without an interactive terminal, such as in CI; without it, the command fails.

**Examples:**

**npm**

```shell
# Delete a single schema
npx sanity@latest schemas delete --ids _.schemas.workspaceName

# Delete multiple schemas
npx sanity@latest schemas delete --ids _.schemas.workspaceName,_.schemas.otherWorkspace.tag.taggedSchema
```

**pnpm**

```shell
# Delete a single schema
pnpm dlx sanity@latest schemas delete --ids _.schemas.workspaceName

# Delete multiple schemas
pnpm dlx sanity@latest schemas delete --ids _.schemas.workspaceName,_.schemas.otherWorkspace.tag.taggedSchema
```

**yarn**

```shell
# Delete a single schema
yarn dlx sanity@latest schemas delete --ids _.schemas.workspaceName

# Delete multiple schemas
yarn dlx sanity@latest schemas delete --ids _.schemas.workspaceName,_.schemas.otherWorkspace.tag.taggedSchema
```

**bun**

```shell
# Delete a single schema
bunx sanity@latest schemas delete --ids _.schemas.workspaceName

# Delete multiple schemas
bunx sanity@latest schemas delete --ids _.schemas.workspaceName,_.schemas.otherWorkspace.tag.taggedSchema
```

The `--help` output for this command still shows IDs in the form `sanity.workspace.schema.workspaceName`. That form is rejected. Use `_.schemas.<workspaceName>` or `_.schemas.<workspaceName>.tag.<tag>` instead.

### `sanity schemas extract`

Extracts the studio schema as a single JSON file, `schema.json` in the project root by default. It is the prerequisite for `sanity typegen generate`, which reads that file. See [TypeGen](https://www.sanity.io/docs/apis-and-sdks/sanity-typegen). It does not write manifest files.

**Options:**

- `--path <path>`: Destination for the extracted schema file. Defaults to `schema.json` in the project root, or to `schemaExtraction.path` from `sanity.cli.ts` when that is set.
- `--watch`: Re-run the extraction as the schema changes.
- `--workspace <name>`: The workspace to generate a schema for.
- `--enforce-required-fields`: Treat fields marked as required as non-optional. Defaults to `false`.
- `--force`: Overwrite an existing schema file without prompting. Without it, an existing file prompts for confirmation, and the command fails outright when it runs without an interactive terminal, such as in CI.
- `--format <groq-type-nodes>`: Output format. `groq-type-nodes` is both the default and the only available format.
- `--watch-patterns <glob>`: Additional glob patterns to watch. Can be specified multiple times.

**Examples:**

**npm**

```shell
# Extract the schema to schema.json in the project root
npx sanity@latest schemas extract

# Extract to a specific path
npx sanity@latest schemas extract --path ./src/sanity/schema.json

# Extract and re-run on schema changes
npx sanity@latest schemas extract --watch
```

**pnpm**

```shell
# Extract the schema to schema.json in the project root
pnpm dlx sanity@latest schemas extract

# Extract to a specific path
pnpm dlx sanity@latest schemas extract --path ./src/sanity/schema.json

# Extract and re-run on schema changes
pnpm dlx sanity@latest schemas extract --watch
```

**yarn**

```shell
# Extract the schema to schema.json in the project root
yarn dlx sanity@latest schemas extract

# Extract to a specific path
yarn dlx sanity@latest schemas extract --path ./src/sanity/schema.json

# Extract and re-run on schema changes
yarn dlx sanity@latest schemas extract --watch
```

**bun**

```shell
# Extract the schema to schema.json in the project root
bunx sanity@latest schemas extract

# Extract to a specific path
bunx sanity@latest schemas extract --path ./src/sanity/schema.json

# Extract and re-run on schema changes
bunx sanity@latest schemas extract --watch
```

## Manifest file structure

The extracted manifest follows this structure:

```typescript
interface CreateManifest {
  version: number        // Current version: 3
  createdAt: string      // ISO timestamp
  studioVersion: string | null  // installed sanity version
  workspaces: ManifestWorkspaceFile[]
}

interface ManifestWorkspaceFile {
  name: string
  title?: string
  subtitle?: string
  basePath: string
  dataset: string
  projectId: string
  schema: string        // filename with serialized schema
  tools: string         // filename
  icon: string | null
}
```

## How manifest files are produced

Two commands write manifest files:

- `sanity deploy`: Writes manifest files into your build output when deploying to Sanity hosting. It skips that step for `--external` deployments.
- `sanity manifest extract`: Writes manifest files to a directory you choose with `--path`. This is the only way to produce them without deploying to Sanity hosting.

## More schema commands

Two more commands work with schemas and manifests:

### `sanity schemas validate`

Validates schema types in a workspace. `sanity schemas deploy` runs the same validation before deploying and reports the same output, so a schema error here also blocks a deployment.

**Options:**

- `--workspace <name>`: The workspace to validate.
- `--format <pretty|ndjson|json>`: Output format. Default: `pretty`.
- `--level <error|warning>`: Minimum reporting level. Default: `warning`.

### `sanity manifest extract`

Extracts the studio configuration as one or more JSON manifest files. This is the only command that writes manifest files without deploying to Sanity hosting, and it is intended for use with Create.

**Options:**

- `--path`: Destination directory for the manifest files. Default: `dist/static`.

## Related commands

- `sanity deploy`: Deploys a studio to Sanity hosting and includes schema deployment in the process. Use `sanity deploy --external` to register a studio you host yourself.
- `sanity typegen generate`: Creates TypeScript types from schema types and GROQ queries.

## Manifests, permissions, and registration

- You don't need to keep your manifest in version control since it's derived from your codebase.
- For embedded studios, the manifest has to be served at `<studio-url>/static/create-manifest.json`. Write it there with `npx sanity@latest manifest extract --path`. No other command writes those files.
- Serving the manifest at your own domain does not register the studio. An externally hosted studio has to be registered with `npx sanity@latest deploy --external` before Dashboard and Media Library can resolve its workspaces.
- Deploying, listing, and deleting schemas requires the `deployStudio` grant on `sanity.project`. A deploy token carries it; a write token isn't required. Extracting and validating schemas run locally and need no token.

## Errors you might see

- `Failed to deploy schemas:` The deployment failed. The underlying reason follows on the next line of output.
- `Failed to deploy 1/3 schemas. Successfully deployed 2/3 schemas.` Some workspaces deployed and others didn't. The output names which ones failed.
- `No permissions to write schema for workspace "..." in dataset "...". For multi-project workspaces, set SANITY_AUTH_TOKEN environment variable to a token with access to the workspace projects.` The token lacks the `deployStudio` grant, or it doesn't cover every project a multi-project workspace spans.



## Related changelog entries

Entries are listed newest first; each link points to the full entry as markdown. Follow one when you need to know what changed, when, or why — for example, to summarize recent updates, explain behavior that differs from older documentation, or check whether a fix has shipped.

- [Sanity Studio v5.5.0: Improved schema extraction with watch mode, CLI config support, and key bug fixes](https://www.sanity.io/docs/changelog/266c75da-9959-4693-82c9-e1d133bcac91.md) — January 19, 2026
- [Sanity Studio v3.88.0: Introducing schema deployment + bugfixes and refinements](https://www.sanity.io/docs/changelog/525de82a-dd7b-40c7-bf38-12248136c339.md) — May 6, 2025