---
title: "Save schema by name"
method: PUT
path: "/api/dataentities/{dataEntityName}/schemas/{schemaName}"
tags: ["Schemas"]
---

# Save schema by name

`PUT /api/dataentities/{dataEntityName}/schemas/{schemaName}`

Creates or edits a data entity schema. Learn more about [Master Data schemas](https://developers.vtex.com/vtex-rest-api/docs/master-data-schema-lifecycle).

> Note that if you send a `schemaName` that does not exist for that data entity, this request will create it.

This request can also be used to [create or edit Master Data v2 triggers](https://developers.vtex.com/vtex-rest-api/docs/setting-up-triggers-in-master-data-v2).

> Each Master Data v2 data entity can have up to 60 schemas.

## Indexing fields for search, scroll and sort

To filter or sort by a field in [Search documents](https://developers.vtex.com/docs/api-reference/master-data-api-v2#get-/api/dataentities/-dataEntityName-/search) or [Scroll documents](https://developers.vtex.com/docs/api-reference/master-data-api-v2#get-/api/dataentities/-dataEntityName-/scroll), add that field to the `v-indexed` array in the schema. This is the schema-level index (separate from the [indices](https://developers.vtex.com/docs/api-reference/master-data-api-v2#get-/api/dataentities/-dataEntityName-/indices) endpoint).

- `v-indexed`: Array of property names that Master Data v2 must index for `/search`, `/scroll`, and `_sort`. Use it whenever you want to use `_where`, `_sort`, or range filters (e.g. `_where=postalCode between 10000 AND 20000`) on that field. Indexing runs asynchronously after the schema is saved.
- `filterable` and `searchable`: Apply to the UI (e.g. Master Data v1/CRM-style behavior). They do **not** create the index used by `/search`; only `v-indexed` does.

**Example request body with `v-indexed`:**

```json
{
  "properties": {
    "skuId": { "type": "string" },
    "postalCode": { "type": "string" }
  },
  "v-indexed": ["postalCode"]
}
```

> ℹ️ Use `v-indexed` when you need fields to be filterable/sortable in `/search`. Use the [/indices](https://developers.vtex.com/docs/api-reference/master-data-api-v2#put-/api/dataentities/-dataEntityName-/indices) endpoint when you need entity-level uniqueness, composite keys, or relationships between entities.

## Permissions

Any user or [API key](https://developers.vtex.com/docs/guides/api-authentication-using-api-keys) must have at least one of the appropriate [License Manager resources](https://help.vtex.com/en/tutorial/license-manager-resources--3q6ztrC8YynQf6rdc6euk3) to be able to successfully run this request. Otherwise they will receive a status code `403` error. These are the applicable resources for this endpoint:

| **Product** | **Category** | **Resource** |
| --------------- | ----------------- | ----------------- |
| Dynamic Storage | Dynamic storage generic resources | **Master Data administrator** |

There are no applicable [predefined roles](https://help.vtex.com/en/tutorial/predefined-roles--jGDurZKJHvHJS13LnO7Dy) for this resource list. You must [create a custom role](https://help.vtex.com/en/tutorial/roles--7HKK5Uau2H6wxE1rH5oRbc#creating-a-role) and add at least one of the resources above in order to use this endpoint.To learn more about machine authentication at VTEX, see [Authentication overview](https://developers.vtex.com/docs/guides/authentication).

>❗ To prevent integrations from having excessive permissions, consider the [best practices for managing API keys](https://help.vtex.com/en/tutorial/best-practices-api-keys--7b6nD1VMHa49aI5brlOvJm) when assigning License Manager roles to integrations.

## Path parameters

- `dataEntityName` string, required
- `schemaName` string, required

## Request body

- SaveschemabynameRequest — JSON Schema of the data entity. Add `v-indexed` with an array of property names to make those fields filterable and sortable in /search and /scroll.
  - `properties` object, required — Object containing schema properties.
    - `name` object — Property name.
      - `type` 'array' | 'boolean' | 'integer' | 'number' | 'object' | 'string', required — Type of property.
  - `v-indexed` string[] — Names of properties to index for /search, /scroll, and _sort. Required for reliable filtering (e.g. _where=field=value) and sorting (_sort=field ASC). Indexing is asynchronous after schema save.

## Response `200`

OK

- object — Response body object.
  - `Message` string — Success message.

## Changes

- **2026-03-02** `5b679637de7c` — 1 info
  - added the new optional request property `v-indexed`
- **2026-01-27** `33ba08390ac8` — 1 info
  - the request property `properties/name` became optional
- **2023-10-19** `acb826776d02` — 1 breaking, 7 info
  - request property `properties/name/type` was restricted to a list of enum values
  - added the new `array` enum value to the request property `properties/name/type`
  - added the new `boolean` enum value to the request property `properties/name/type`
  - added the new `integer` enum value to the request property `properties/name/type`
  - …4 more

[Change history](https://skmtc.dev/vtex/apis/master-data-api-v2/changes/api/dataentities/:dataEntityName/schemas/:schemaName/put.md)

---

[API](https://skmtc.dev/vtex/apis/master-data-api-v2.md) · [All operations](https://skmtc.dev/vtex/apis/master-data-api-v2/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/vtex/master-data-api-v2/revisions/6d3f8010fa54/schema)
