> 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

# GetSchemaByKey

# Package: translation

# Namespace: TranslationSchema

# Method link: https://dev.wix.com/docs/api-reference/business-management/multilingual/translation/translation-schema/get-schema-by-key.md

## Permission Scopes:
Wix Multilingual - Translation Schema Read: SCOPE.DC-MULTILINGUAL.READ_TRANSLATION_SCHEMA

## Introduction

Retrieves a translation schema by key.

---

## REST API

### Schema

```
 Method: getSchemaByKey
 Description: Retrieves a translation schema by key.
 URL: https://www.wixapis.com/translation-schema/v1/schemas/app-id/{key.appId}/entity-type/{key.entityType}/scope/{key.scope}
 Method: GET
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  key.appId, key.entityType, key.scope, key
 Method parameters: 
   param name: key | type: SchemaKey   | required: true 
        - name: appId | type: string | description: GUID of the app that created the schema. | required: true | validation: format GUID
        - 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 | validation: minLength 1, maxLength 100, immutable
        - name: scope | type: SchemaScope | description: Scope of the translation schema. | required: true | validation: immutable
             - enum:
             -     GLOBAL: Global schema for all sites.
             -     SITE: Custom schema for a specific site.
   param name: key.appId | type:   none | required: true 
   param name: key.entityType | type:   none | required: true 
   param name: key.scope | type:   none | required: true 
 Return type: GetSchemaByKeyResponse
  - name: schema | type: Schema | description: The requested translation schema.  
     - name: id | type: string | description: Translation schema GUID.  | validation: format GUID
     - name: key | type: SchemaKey | description: Translation schema unique key identifier.  
        - name: appId | type: string | description: GUID of the app that created the schema.  | validation: format GUID
        - 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'`.  | validation: minLength 1, maxLength 100, immutable
        - name: scope | type: SchemaScope | description: Scope of the translation schema.  | validation: immutable
             - enum:
             -     GLOBAL: Global schema for all sites.
             -     SITE: Custom schema for a specific site.
     - name: fields | type: Map<string,SchemaField> | description: List of fields for the translation schema. This property uses a string to map to a `SchemaField` (`Map<string, SchemaField>`). The string serves as a key, which you'll need to access each field in the schema and when adding translation content.  | validation: minItems 1, maxItems 1000, format map
        - 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 `^[^)(\\]\\[\\.]+$`.  | validation: minLength 1, maxLength 1000
        - 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).  | validation: maxLength 1000
        - name: groupName | type: string | description: Field group name.  | validation: maxLength 1000
        - name: minLength | type: integer | description: Field minimum text length.  | validation: minimum 1, format int32
        - name: maxLength | type: integer | description: Field maximum text length.  | validation: minimum 1, format int32
        - 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.  | validation: minLength 2, maxLength 20
        - 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.  | validation: minimum 0, format double
     - 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.  | validation: maxLength 1000
        - name: imageFieldId | type: string | description: GUID of the field representing the schema's image.  | validation: maxLength 1000
     - 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).  | validation: maxLength 100
     - 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`.  | validation: format GUID
     - 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.  | validation: format int64
     - name: createdDate | type: string | description: Date and time the translation schema was created.  | validation: format date-time
     - name: updatedDate | type: string | description: Date and time the translation schema was updated.  | validation: format date-time
     - 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: schemaGroupId | type: string | description: Indicate if this schema should be grouped under a custom group in the Translation Manager For more info about this field check dev-center extension `Multilingual Schema Group`  | validation: format GUID
     - 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

### Get Schema By Key
```curl
curl -X GET \
  'https://www.wixapis.com/translation-schema/v1/schemas/app-id/4ad2dfe1-a943-45a8-94ac-f1dd8b78821b/entity-type/Product/scope/GLOBAL' \
  -H 'Authorization: <AUTH>' \
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.translation.TranslationSchema.getSchemaByKey(identifiers)
 Description: Retrieves a translation schema by key.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  identifiers.keyAppId, identifiers.keyEntityType, identifiers.keyScope, identifiers
 Method parameters: 
   param name: identifiers | type: GetSchemaByKeyIdentifiers  none | required: true 
        - name: keyAppId | type: string | description: GUID of the app that created the schema. | required: true | validation: format GUID
        - name: keyEntityType | 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 | validation: minLength 1, maxLength 100, immutable
        - name: keyScope | type: SchemaScope | description: Scope of the translation schema. | required: true | validation: immutable
             - enum:
             -     GLOBAL: Global schema for all sites.
             -     SITE: Custom schema for a specific site.
 Return type: PROMISE<GetSchemaByKeyResponse>
  - name: schema | type: Schema | description: The requested translation schema.  
     - name: _id | type: string | description: Translation schema GUID.  | validation: format GUID
     - name: key | type: SchemaKey | description: Translation schema unique key identifier.  
        - name: appId | type: string | description: GUID of the app that created the schema.  | validation: format GUID
        - 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'`.  | validation: minLength 1, maxLength 100, immutable
        - name: scope | type: SchemaScope | description: Scope of the translation schema.  | validation: immutable
             - enum:
             -     GLOBAL: Global schema for all sites.
             -     SITE: Custom schema for a specific site.
     - name: fields | type: Map<string,SchemaField> | description: List of fields for the translation schema. This property uses a string to map to a `SchemaField` (`Map<string, SchemaField>`). The string serves as a key, which you'll need to access each field in the schema and when adding translation content.  | validation: minItems 1, maxItems 1000, format map
        - 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 `^[^)(\\]\\[\\.]+$`.  | validation: minLength 1, maxLength 1000
        - 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).  | validation: maxLength 1000
        - name: groupName | type: string | description: Field group name.  | validation: maxLength 1000
        - name: minLength | type: integer | description: Field minimum text length.  | validation: minimum 1, format int32
        - name: maxLength | type: integer | description: Field maximum text length.  | validation: minimum 1, format int32
        - 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.  | validation: minLength 2, maxLength 20
        - 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.  | validation: minimum 0
     - 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.  | validation: maxLength 1000
        - name: imageFieldId | type: string | description: GUID of the field representing the schema's image.  | validation: maxLength 1000
     - 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).  | validation: maxLength 100
     - 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`.  | validation: format GUID
     - 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.  | validation: format int64
     - 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: schemaGroupId | type: string | description: Indicate if this schema should be grouped under a custom group in the Translation Manager For more info about this field check dev-center extension `Multilingual Schema Group`  | validation: format GUID
     - 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

### getSchemaByKey
```javascript
import { translationSchemas } from '@wix/multilingual';

async function getSchemaByKey(identifiers) {
  const response = await translationSchemas.getSchemaByKey(identifiers);
};
```

### getSchemaByKey (with elevated permissions)
```javascript
import { translationSchemas } from '@wix/multilingual';
import { auth } from '@wix/essentials';

async function myGetSchemaByKeyMethod(identifiers) {
  const elevatedGetSchemaByKey = auth.elevate(translationSchemas.getSchemaByKey);
  const response = await elevatedGetSchemaByKey(identifiers);
}
```

### getSchemaByKey (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 getSchemaByKey(identifiers) {
  const response = await myWixClient.translationSchemas.getSchemaByKey(identifiers);
};
```

---