Master Data API - v2
Master Data v2 is not compatible with data entities from previous versions, such as CL and AD.
Master Data is a secure, fast, scalable, and extensible solution that allows users to create their own entities, store data, and retrieve information directly from the storefront or external integrations.
Several internal VTEX modules use Master Data as a data repository, including Orders and Sales App.
There are two main ways to use Master Data:
Directly from the storefront
When using Master Data within the storefront, consider the following:
- Use the storefront host to query or store information to avoid issues related to Cross-origin resource sharing (CORS).
- Use the relative path to avoid CORS issues.
- Configure the JSON Schema of the Data Entity to specify which information should be public and which should not be.
- Avoid creating query loops to prevent potential throttling issues or APIs being disabled due to security protection measures.
- Never add authentication keys, such as
X-VTEX-API-AppKeyorX-VTEX-API-AppToken, via JavaScript as this could pose security risks.
External integrations
When using Master Data to store data from an external integration, such as client data from another service, consider the following:
- Use the host
{{accountName}}.vtexcommercestable.com.br. - Use the authentication keys (
X-VTEX-API-AppKeyouX-VTEX-API-AppToken).
Common parameters
| Name | Description |
|---|---|
accountName |
Account name in VTEX License Manager. |
name |
Data Entity name. |
schema |
JSON Schema of a Data Entity. |
id |
Identifier of a document. |
X-VTEX-API-AppKey |
appKey. |
X-VTEX-API-AppToken |
appToken. |
Endpoints
Documents
| Summary | Method | Path |
|---|---|---|
| Create new document | POST | /api/dataentities/{dataEntityName}/documents |
| Create partial document | PATCH | /api/dataentities/{dataEntityName}/documents |
| Get document | GET | /api/dataentities/{dataEntityName}/documents/{id} |
| Create document with custom ID or update entire document | PUT | /api/dataentities/{dataEntityName}/documents/{id} |
| Update partial document | PATCH | /api/dataentities/{dataEntityName}/documents/{id} |
| Delete document | DELETE | /api/dataentities/{dataEntityName}/documents/{id} |
Search
| Summary | Method | Path |
|---|---|---|
| Search documents | GET | /api/dataentities/{dataEntityName}/search |
Scroll
| Summary | Method | Path |
|---|---|---|
| Scroll documents | GET | /api/dataentities/{dataEntityName}/scroll |
Schemas
| Summary | Method | Path |
|---|---|---|
| Get schemas | GET | /api/dataentities/{dataEntityName}/schemas |
| Get schema by name | GET | /api/dataentities/{dataEntityName}/schemas/{schemaName} |
| Save schema by name | PUT | /api/dataentities/{dataEntityName}/schemas/{schemaName} |
| Delete schema by name | DELETE | /api/dataentities/{dataEntityName}/schemas/{schemaName} |
Indices
| Summary | Method | Path |
|---|---|---|
| Get indices | GET | /api/dataentities/{dataEntityName}/indices |
| Create index | PUT | /api/dataentities/{dataEntityName}/indices |
| Get index by name | GET | /api/dataentities/{dataEntityName}/indices/{index_name} |
| Delete index by name | DELETE | /api/dataentities/{dataEntityName}/indices/{index_name} |
Clusters
| Summary | Method | Path |
|---|---|---|
| Validate document by clusters | POST | /api/dataentities/{dataEntityName}/documents/{id}/clusters |
Versions
| Summary | Method | Path |
|---|---|---|
| List versions | GET | /api/dataentities/{dataEntityName}/documents/{id}/versions |
| Get version | GET | /api/dataentities/{dataEntityName}/documents/{id}/versions/{versionId} |
| Update version | PUT | /api/dataentities/{dataEntityName}/documents/{id}/versions/{versionId} |