> Portal Navigation:
>
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt
# UpdateSchema
# Package: translation
# Namespace: TranslationSchema
# Method link: https://dev.wix.com/docs/api-reference/business-management/multilingual/translation/translation-schema/update-schema.md
## Permission Scopes:
Wix Multilingual - Translation Schema Write: SCOPE.DC-MULTILINGUAL.WRITE_TRANSLATION_SCHEMA
## Introduction
Updates a translation schema.
To remove a field, pass the field key with an empty object as the value. For example:
```json
{
"fields": {
"title": {}
}
}
```
Caution:
Removing a schema field makes the corresponding content field unavailable.
---
## REST API
### Schema
```
Method: updateSchema
Description: Updates a translation schema. To remove a field, pass the field key with an empty object as the value. For example: ```json { "fields": { "title": {} } } ``` Caution: Removing a schema field makes the corresponding content field unavailable.
URL: https://www.wixapis.com/v1/schemas/{schema.id}
Method: PATCH
# Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
Required parameters: schema, schema.id, schema.revision
Method parameters:
param name: schema | type: Schema | required: true
- name: id | type: string | description: Translation schema GUID. | required: true
- name: key | type: SchemaKey | description: Translation schema unique key identifier.
- name: entityType | type: string | description: A unique name defined by the app developer to differentiate translation schemas for various entities within their app. For example, if an app developer is creating a translation schema for blog posts, the `entityType` can be `'blog-posts'`.
- name: scope | type: SchemaScope | description: Scope of the translation schema.
- enum:
- GLOBAL: Global schema for all sites.
- SITE: Custom schema for a specific site.
- name: fields | type: Map | description: List of fields for the translation schema. This property uses a string to map to a `SchemaField` (`Map`). The string serves as a key, which you'll need to access each field in the schema and when adding translation content.
- name: type | type: FieldType | description: **Required.** Field type.
- enum:
- SHORT_TEXT: Short plain text displayed as a single line in the UI.
- LONG_TEXT: Long plain text displayed as multiple lines in the UI.
- HTML: Long text including styles, images, and links.
- RICH_CONTENT: Rich-Content using the Wix Ricos format.
- IMAGE: Wix Media Manager image.
- IMAGE_LINK: Image URL without metadata.
- VIDEO: Wix Media Manager video.
- DOCUMENT: Wix Media Manager document.
- name: displayName | type: string | description: Field name displayed in the [Translation Manager](https://support.wix.com/en/article/wix-multilingual-using-the-translation-manager).
- name: groupName | type: string | description: Field group name.
- name: minLength | type: integer | description: Field minimum text length.
- name: maxLength | type: integer | description: Field maximum text length.
- name: format | type: string | description: Field format. Content is validated based on the format set here in the field schema. For example, if the format is `EMAIL`, then the content for this field must be a valid email address.
- name: hidden | type: boolean | description: Whether the field is hidden from the site. Hidden fields are still validated.
- name: displayOnly | type: boolean | description: Whether the field is read-only, and not intended to be translated. For example, an image. Use this field when you want an image to remain in the [Translation Manager](https://support.wix.com/en/article/wix-multilingual-using-the-translation-manager) for context, but without being translated.
- name: index | type: number | description: Field index. Use for cases where the order of the fields are relevant.
- name: previewFields | type: PreviewFields | description: Fields displayed in content previews. For example, a product name for a product translation schema.
- name: titleFieldId | type: string | description: GUID of the field representing the schema's title.
- name: imageFieldId | type: string | description: GUID of the field representing the schema's image.
- name: hidden | type: boolean | description: Whether the translation schema is hidden from the site. Default: `false`
- name: displayName | type: string | description: Translation schema name displayed in the [Translation Manager](https://support.wix.com/en/article/wix-multilingual-using-the-translation-manager).
- name: parentId | type: string | description: A reference to the parent schema. For example, if the schema is for a menu item, this property would contain the schema GUID of the menu it belongs to. Required when `require_parent_entity` is set to `true`.
- name: revision | type: string | description: Revision number, which increments by 1 each time the schema is updated. To prevent conflicting changes, the existing `revision` must be used when updating a schema. | required: true
- name: duplicateContent | type: boolean | description: Whether to duplicate the translated content when a site containing the translation schema and content is duplicated. Default: `false`
- name: requireParentEntity | type: boolean | description: Whether content created or updated with this schema must include a `parent_entity_id`. When set to `true`, any Create Content or Update Content call targeting this schema will fail if `parent_entity_id` is missing or empty. The schema itself must also have a `parent_id` defined, otherwise the schema Create or Update call will fail with `SchemaRequireParentEntityWithoutParentIdException`. Default: `false` Example: A "menu-item" schema that always belongs to a "menu" parent schema would set `require_parent_entity = true` and `parent_id` to the "menu" schema GUID. Every translation content item created for "menu-item" must then specify which menu it belongs to via `parent_entity_id`.
Return type: UpdateSchemaResponse
- name: schema | type: Schema | description: Updated Schema.
- name: id | type: string | description: Translation schema GUID.
- name: key | type: SchemaKey | description: Translation schema unique key identifier.
- name: appId | type: string | description: GUID of the app that created the schema.
- name: entityType | type: string | description: A unique name defined by the app developer to differentiate translation schemas for various entities within their app. For example, if an app developer is creating a translation schema for blog posts, the `entityType` can be `'blog-posts'`.
- name: scope | type: SchemaScope | description: Scope of the translation schema.
- enum:
- GLOBAL: Global schema for all sites.
- SITE: Custom schema for a specific site.
- name: fields | type: Map | description: List of fields for the translation schema. This property uses a string to map to a `SchemaField` (`Map`). The string serves as a key, which you'll need to access each field in the schema and when adding translation content.
- name: id | type: string | description: Field GUID. Validated according to Regex `^[A-Za-z0-9-_)(]+$`. Field GUIDs may contain parentheses to reference repeated items, such as images. These parentheses can't be nested and each opening parenthesis must be followed by a closing one. For example, `title()()` is valid, while `title)(` and `title(())` aren't valid. The value inside the parenthesis is validated according to Regex `^[^)(\\]\\[\\.]+$`.
- name: type | type: FieldType | description: **Required.** Field type.
- enum:
- SHORT_TEXT: Short plain text displayed as a single line in the UI.
- LONG_TEXT: Long plain text displayed as multiple lines in the UI.
- HTML: Long text including styles, images, and links.
- RICH_CONTENT: Rich-Content using the Wix Ricos format.
- IMAGE: Wix Media Manager image.
- IMAGE_LINK: Image URL without metadata.
- VIDEO: Wix Media Manager video.
- DOCUMENT: Wix Media Manager document.
- name: displayName | type: string | description: Field name displayed in the [Translation Manager](https://support.wix.com/en/article/wix-multilingual-using-the-translation-manager).
- name: groupName | type: string | description: Field group name.
- name: minLength | type: integer | description: Field minimum text length.
- name: maxLength | type: integer | description: Field maximum text length.
- name: format | type: string | description: Field format. Content is validated based on the format set here in the field schema. For example, if the format is `EMAIL`, then the content for this field must be a valid email address.
- name: hidden | type: boolean | description: Whether the field is hidden from the site. Hidden fields are still validated.
- name: displayOnly | type: boolean | description: Whether the field is read-only, and not intended to be translated. For example, an image. Use this field when you want an image to remain in the [Translation Manager](https://support.wix.com/en/article/wix-multilingual-using-the-translation-manager) for context, but without being translated.
- name: index | type: number | description: Field index. Use for cases where the order of the fields are relevant.
- name: previewFields | type: PreviewFields | description: Fields displayed in content previews. For example, a product name for a product translation schema.
- name: titleFieldId | type: string | description: GUID of the field representing the schema's title.
- name: imageFieldId | type: string | description: GUID of the field representing the schema's image.
- name: hidden | type: boolean | description: Whether the translation schema is hidden from the site. Default: `false`
- name: displayName | type: string | description: Translation schema name displayed in the [Translation Manager](https://support.wix.com/en/article/wix-multilingual-using-the-translation-manager).
- name: parentId | type: string | description: A reference to the parent schema. For example, if the schema is for a menu item, this property would contain the schema GUID of the menu it belongs to. Required when `require_parent_entity` is set to `true`.
- name: revision | type: string | description: Revision number, which increments by 1 each time the schema is updated. To prevent conflicting changes, the existing `revision` must be used when updating a schema.
- name: createdDate | type: string | description: Date and time the translation schema was created.
- name: updatedDate | type: string | description: Date and time the translation schema was updated.
- name: duplicateContent | type: boolean | description: Whether to duplicate the translated content when a site containing the translation schema and content is duplicated. Default: `false`
- name: requireParentEntity | type: boolean | description: Whether content created or updated with this schema must include a `parent_entity_id`. When set to `true`, any Create Content or Update Content call targeting this schema will fail if `parent_entity_id` is missing or empty. The schema itself must also have a `parent_id` defined, otherwise the schema Create or Update call will fail with `SchemaRequireParentEntityWithoutParentIdException`. Default: `false` Example: A "menu-item" schema that always belongs to a "menu" parent schema would set `require_parent_entity = true` and `parent_id` to the "menu" schema GUID. Every translation content item created for "menu-item" must then specify which menu it belongs to via `parent_entity_id`.
```
### Examples
### Update Schema
```curl
curl -X PATCH \
'https://www.wixapis.com/translation-schema/v1/schemas/8046df3c-7575-4098-a5ab-c91ad8f33c47' \
-H 'Authorization: ' \
-H 'Content-Type: application/json' \
--data-binary '{
"schema": {
"displayName": "A New Display Name",
"revision": 1,
},
}'
```
---
## JavaScript SDK
### Schema
```
Method: wixClientAdmin.translation.TranslationSchema.updateSchema(_id, schema)
Description: Updates a translation schema. To remove a field, pass the field key with an empty object as the value. For example: ```json { "fields": { "title": {} } } ``` Caution: Removing a schema field makes the corresponding content field unavailable.
# Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
Required parameters: schema, _id, schema.revision
Method parameters:
param name: _id | type: string | description: Translation schema GUID. | required: true
param name: schema | type: UpdateSchema | required: true
- name: key | type: SchemaKey | description: Translation schema unique key identifier.
- name: entityType | type: string | description: A unique name defined by the app developer to differentiate translation schemas for various entities within their app. For example, if an app developer is creating a translation schema for blog posts, the `entityType` can be `'blog-posts'`.
- name: scope | type: SchemaScope | description: Scope of the translation schema.
- enum:
- GLOBAL: Global schema for all sites.
- SITE: Custom schema for a specific site.
- name: fields | type: Map | description: List of fields for the translation schema. This property uses a string to map to a `SchemaField` (`Map`). The string serves as a key, which you'll need to access each field in the schema and when adding translation content.
- name: type | type: FieldType | description: **Required.** Field type.
- enum:
- SHORT_TEXT: Short plain text displayed as a single line in the UI.
- LONG_TEXT: Long plain text displayed as multiple lines in the UI.
- HTML: Long text including styles, images, and links.
- RICH_CONTENT: Rich-Content using the Wix Ricos format.
- IMAGE: Wix Media Manager image.
- IMAGE_LINK: Image URL without metadata.
- VIDEO: Wix Media Manager video.
- DOCUMENT: Wix Media Manager document.
- name: displayName | type: string | description: Field name displayed in the [Translation Manager](https://support.wix.com/en/article/wix-multilingual-using-the-translation-manager).
- name: groupName | type: string | description: Field group name.
- name: minLength | type: integer | description: Field minimum text length.
- name: maxLength | type: integer | description: Field maximum text length.
- name: format | type: string | description: Field format. Content is validated based on the format set here in the field schema. For example, if the format is `EMAIL`, then the content for this field must be a valid email address.
- name: hidden | type: boolean | description: Whether the field is hidden from the site. Hidden fields are still validated.
- name: displayOnly | type: boolean | description: Whether the field is read-only, and not intended to be translated. For example, an image. Use this field when you want an image to remain in the [Translation Manager](https://support.wix.com/en/article/wix-multilingual-using-the-translation-manager) for context, but without being translated.
- name: index | type: number | description: Field index. Use for cases where the order of the fields are relevant.
- name: previewFields | type: PreviewFields | description: Fields displayed in content previews. For example, a product name for a product translation schema.
- name: titleFieldId | type: string | description: GUID of the field representing the schema's title.
- name: imageFieldId | type: string | description: GUID of the field representing the schema's image.
- name: hidden | type: boolean | description: Whether the translation schema is hidden from the site. Default: `false`
- name: displayName | type: string | description: Translation schema name displayed in the [Translation Manager](https://support.wix.com/en/article/wix-multilingual-using-the-translation-manager).
- name: parentId | type: string | description: A reference to the parent schema. For example, if the schema is for a menu item, this property would contain the schema GUID of the menu it belongs to. Required when `require_parent_entity` is set to `true`.
- name: revision | type: string | description: Revision number, which increments by 1 each time the schema is updated. To prevent conflicting changes, the existing `revision` must be used when updating a schema. | required: true
- name: duplicateContent | type: boolean | description: Whether to duplicate the translated content when a site containing the translation schema and content is duplicated. Default: `false`
- name: requireParentEntity | type: boolean | description: Whether content created or updated with this schema must include a `parent_entity_id`. When set to `true`, any Create Content or Update Content call targeting this schema will fail if `parent_entity_id` is missing or empty. The schema itself must also have a `parent_id` defined, otherwise the schema Create or Update call will fail with `SchemaRequireParentEntityWithoutParentIdException`. Default: `false` Example: A "menu-item" schema that always belongs to a "menu" parent schema would set `require_parent_entity = true` and `parent_id` to the "menu" schema GUID. Every translation content item created for "menu-item" must then specify which menu it belongs to via `parent_entity_id`.
Return type: PROMISE
- name: _id | type: string | description: Translation schema GUID.
- name: key | type: SchemaKey | description: Translation schema unique key identifier.
- name: appId | type: string | description: GUID of the app that created the schema.
- name: entityType | type: string | description: A unique name defined by the app developer to differentiate translation schemas for various entities within their app. For example, if an app developer is creating a translation schema for blog posts, the `entityType` can be `'blog-posts'`.
- name: scope | type: SchemaScope | description: Scope of the translation schema.
- enum:
- GLOBAL: Global schema for all sites.
- SITE: Custom schema for a specific site.
- name: fields | type: Map | description: List of fields for the translation schema. This property uses a string to map to a `SchemaField` (`Map`). The string serves as a key, which you'll need to access each field in the schema and when adding translation content.
- name: _id | type: string | description: Field GUID. Validated according to Regex `^[A-Za-z0-9-_)(]+$`. Field GUIDs may contain parentheses to reference repeated items, such as images. These parentheses can't be nested and each opening parenthesis must be followed by a closing one. For example, `title()()` is valid, while `title)(` and `title(())` aren't valid. The value inside the parenthesis is validated according to Regex `^[^)(\\]\\[\\.]+$`.
- name: type | type: FieldType | description: **Required.** Field type.
- enum:
- SHORT_TEXT: Short plain text displayed as a single line in the UI.
- LONG_TEXT: Long plain text displayed as multiple lines in the UI.
- HTML: Long text including styles, images, and links.
- RICH_CONTENT: Rich-Content using the Wix Ricos format.
- IMAGE: Wix Media Manager image.
- IMAGE_LINK: Image URL without metadata.
- VIDEO: Wix Media Manager video.
- DOCUMENT: Wix Media Manager document.
- name: displayName | type: string | description: Field name displayed in the [Translation Manager](https://support.wix.com/en/article/wix-multilingual-using-the-translation-manager).
- name: groupName | type: string | description: Field group name.
- name: minLength | type: integer | description: Field minimum text length.
- name: maxLength | type: integer | description: Field maximum text length.
- name: format | type: string | description: Field format. Content is validated based on the format set here in the field schema. For example, if the format is `EMAIL`, then the content for this field must be a valid email address.
- name: hidden | type: boolean | description: Whether the field is hidden from the site. Hidden fields are still validated.
- name: displayOnly | type: boolean | description: Whether the field is read-only, and not intended to be translated. For example, an image. Use this field when you want an image to remain in the [Translation Manager](https://support.wix.com/en/article/wix-multilingual-using-the-translation-manager) for context, but without being translated.
- name: index | type: number | description: Field index. Use for cases where the order of the fields are relevant.
- name: previewFields | type: PreviewFields | description: Fields displayed in content previews. For example, a product name for a product translation schema.
- name: titleFieldId | type: string | description: GUID of the field representing the schema's title.
- name: imageFieldId | type: string | description: GUID of the field representing the schema's image.
- name: hidden | type: boolean | description: Whether the translation schema is hidden from the site. Default: `false`
- name: displayName | type: string | description: Translation schema name displayed in the [Translation Manager](https://support.wix.com/en/article/wix-multilingual-using-the-translation-manager).
- name: parentId | type: string | description: A reference to the parent schema. For example, if the schema is for a menu item, this property would contain the schema GUID of the menu it belongs to. Required when `require_parent_entity` is set to `true`.
- name: revision | type: string | description: Revision number, which increments by 1 each time the schema is updated. To prevent conflicting changes, the existing `revision` must be used when updating a schema.
- name: _createdDate | type: Date | description: Date and time the translation schema was created.
- name: _updatedDate | type: Date | description: Date and time the translation schema was updated.
- name: duplicateContent | type: boolean | description: Whether to duplicate the translated content when a site containing the translation schema and content is duplicated. Default: `false`
- name: requireParentEntity | type: boolean | description: Whether content created or updated with this schema must include a `parent_entity_id`. When set to `true`, any Create Content or Update Content call targeting this schema will fail if `parent_entity_id` is missing or empty. The schema itself must also have a `parent_id` defined, otherwise the schema Create or Update call will fail with `SchemaRequireParentEntityWithoutParentIdException`. Default: `false` Example: A "menu-item" schema that always belongs to a "menu" parent schema would set `require_parent_entity = true` and `parent_id` to the "menu" schema GUID. Every translation content item created for "menu-item" must then specify which menu it belongs to via `parent_entity_id`.
```
### Examples
### updateSchema
```javascript
import { translationSchemas } from '@wix/multilingual';
async function updateSchema(_id,schema) {
const response = await translationSchemas.updateSchema(_id,schema);
};
```
### updateSchema (with elevated permissions)
```javascript
import { translationSchemas } from '@wix/multilingual';
import { auth } from '@wix/essentials';
async function myUpdateSchemaMethod(_id,schema) {
const elevatedUpdateSchema = auth.elevate(translationSchemas.updateSchema);
const response = await elevatedUpdateSchema(_id,schema);
}
```
### updateSchema (self-hosted)
Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).
```javascript
import { createClient } from '@wix/sdk';
import { translationSchemas } from '@wix/multilingual';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed
const myWixClient = createClient ({
modules: { translationSchemas },
// Include the auth strategy and host as relevant
});
async function updateSchema(_id,schema) {
const response = await myWixClient.translationSchemas.updateSchema(_id,schema);
};
```
---