> 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 # CreateSchema # Package: translation # Namespace: TranslationSchema # Method link: https://dev.wix.com/docs/api-reference/business-management/multilingual/translation/translation-schema/create-schema.md ## Permission Scopes: Wix Multilingual - Translation Schema Write: SCOPE.DC-MULTILINGUAL.WRITE_TRANSLATION_SCHEMA ## Introduction Creates a translation schema. --- ## REST API ### Schema ``` Method: createSchema Description: Creates a translation schema. URL: https://www.wixapis.com/v1/schemas Method: POST # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: schema, schema.key, schema.key.entityType, schema.key.scope, schema.fields Method parameters: param name: schema | type: Schema | required: true - name: key | type: SchemaKey | description: Translation schema unique key identifier. | required: true - 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'`. | required: true - name: scope | type: SchemaScope | description: Scope of the translation schema. | required: true - 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. | required: true - 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: 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: CreateSchemaResponse - name: schema | type: Schema | description: Newly created translation 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 ### Create a Schema with a Site Scope ```curl curl -X POST \ 'https://www.wixapis.com/translation-schema/v1/schemas' \ -H 'Authorization: ' \ -H 'Content-Type: application/json' \ --data-binary '{ "schema": { "key": { "entityType": "My-Pet-Collection", "scope": "SITE" }, "fields": { "petMame": { "type": "SHORT_TEXT", "displayName": "Pet Name", "minLength": 1, "maxLength": 54, "hidden": false, "displayOnly": false }, "petType": { "type": "LONG_TEXT", "displayName": "Pet Type (cat, dog, etc)", "minLength": 1, "maxLength": 256, "hidden": false, "displayOnly": false }, "medicalState": { "type": "RICH_CONTENT", "displayName": "Pet Medical State", "hidden": false, "displayOnly": false } } } }' ``` ### Create Schema with a Global Scope ```curl curl -X POST \ 'https://www.wixapis.com/translation-schema/v1/schemas' \ -H 'Authorization: ' \ -H 'Content-Type: application/json' \ --data-binary '{ "schema": { "key": { "entityType": "Product", "scope": "GLOBAL" }, "fields": { "title": { "type": "SHORT_TEXT", "displayName": "Title", "minLength": 1, "maxLength": 54, "hidden": false, "displayOnly": false }, "description": { "type": "RICH_CONTENT", "displayName": "Description", "minLength": 1, "maxLength": 256, "hidden": false, "displayOnly": false }, "image()": { "type": "IMAGE", "displayName": "Product Image", "hidden": false, "displayOnly": false } } } }' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.translation.TranslationSchema.createSchema(schema) Description: Creates a translation schema. # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: schema, schema.key, schema.key.entityType, schema.key.scope, schema.fields Method parameters: param name: schema | type: Schema | required: true - name: key | type: SchemaKey | description: Translation schema unique key identifier. | required: true - 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'`. | required: true - name: scope | type: SchemaScope | description: Scope of the translation schema. | required: true - 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. | required: true - 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: 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 ### createSchema ```javascript import { translationSchemas } from '@wix/multilingual'; async function createSchema(schema) { const response = await translationSchemas.createSchema(schema); }; ``` ### createSchema (with elevated permissions) ```javascript import { translationSchemas } from '@wix/multilingual'; import { auth } from '@wix/essentials'; async function myCreateSchemaMethod(schema) { const elevatedCreateSchema = auth.elevate(translationSchemas.createSchema); const response = await elevatedCreateSchema(schema); } ``` ### createSchema (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 createSchema(schema) { const response = await myWixClient.translationSchemas.createSchema(schema); }; ``` ---