

# CreateSchema
<a name="API_CreateSchema"></a>

Creates an Amazon Personalize schema from the specified schema string. The schema you create must be in Avro JSON format.

Amazon Personalize recognizes three schema variants. Each schema is associated with a dataset type and has a set of required field and keywords. If you are creating a schema for a dataset in a Domain dataset group, you provide the domain of the Domain dataset group. You specify a schema when you call [CreateDataset](https://docs.amazonaws.cn/personalize/latest/dg/API_CreateDataset.html).

For more information on schemas, see [Datasets and schemas](https://docs.amazonaws.cn/personalize/latest/dg/how-it-works-dataset-schema.html).

**Related APIs**
+  [ListSchemas](https://docs.amazonaws.cn/personalize/latest/dg/API_ListSchemas.html) 
+  [DescribeSchema](https://docs.amazonaws.cn/personalize/latest/dg/API_DescribeSchema.html) 
+  [DeleteSchema](https://docs.amazonaws.cn/personalize/latest/dg/API_DeleteSchema.html) 

## Request Syntax
<a name="API_CreateSchema_RequestSyntax"></a>

```
{
   "domain": "string",
   "name": "string",
   "schema": "string"
}
```

## Request Parameters
<a name="API_CreateSchema_RequestParameters"></a>

The request accepts the following data in JSON format.

 ** [domain](#API_CreateSchema_RequestSyntax) **   <a name="personalize-CreateSchema-request-domain"></a>
The domain for the schema. If you are creating a schema for a dataset in a Domain dataset group, specify the domain you chose when you created the Domain dataset group.  
Type: String  
Valid Values: `ECOMMERCE | VIDEO_ON_DEMAND`   
Required: No

 ** [name](#API_CreateSchema_RequestSyntax) **   <a name="personalize-CreateSchema-request-name"></a>
The name for the schema.  
Type: String  
Length Constraints: Minimum length of 1. Maximum length of 63.  
Pattern: `^[a-zA-Z0-9][a-zA-Z0-9\-_]*`   
Required: Yes

 ** [schema](#API_CreateSchema_RequestSyntax) **   <a name="personalize-CreateSchema-request-schema"></a>
A schema in Avro JSON format.  
Type: String  
Length Constraints: Maximum length of 20000.  
Required: Yes

## Response Syntax
<a name="API_CreateSchema_ResponseSyntax"></a>

```
{
   "schemaArn": "string"
}
```

## Response Elements
<a name="API_CreateSchema_ResponseElements"></a>

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

 ** [schemaArn](#API_CreateSchema_ResponseSyntax) **   <a name="personalize-CreateSchema-response-schemaArn"></a>
The Amazon Resource Name (ARN) of the created schema.  
Type: String  
Length Constraints: Maximum length of 256.  
Pattern: `arn:([a-z\d-]+):personalize:.*:.*:.+` 

## Errors
<a name="API_CreateSchema_Errors"></a>

 ** InvalidInputException **   
Provide a valid value for the field or parameter.  
HTTP Status Code: 400

 ** LimitExceededException **   
The limit on the number of requests per second has been exceeded.  
HTTP Status Code: 400

 ** ResourceAlreadyExistsException **   
The specified resource already exists.  
HTTP Status Code: 400

## See Also
<a name="API_CreateSchema_SeeAlso"></a>

For more information about using this API in one of the language-specific Amazon SDKs, see the following:
+  [Amazon Command Line Interface V2](https://docs.amazonaws.cn/goto/cli2/personalize-2018-05-22/CreateSchema) 
+  [Amazon SDK for .NET V4](https://docs.amazonaws.cn/goto/DotNetSDKV4/personalize-2018-05-22/CreateSchema) 
+  [Amazon SDK for C\$1\$1](https://docs.amazonaws.cn/goto/SdkForCpp/personalize-2018-05-22/CreateSchema) 
+  [Amazon SDK for Go v2](https://docs.amazonaws.cn/goto/SdkForGoV2/personalize-2018-05-22/CreateSchema) 
+  [Amazon SDK for Java V2](https://docs.amazonaws.cn/goto/SdkForJavaV2/personalize-2018-05-22/CreateSchema) 
+  [Amazon SDK for JavaScript V3](https://docs.amazonaws.cn/goto/SdkForJavaScriptV3/personalize-2018-05-22/CreateSchema) 
+  [Amazon SDK for Kotlin](https://docs.amazonaws.cn/goto/SdkForKotlin/personalize-2018-05-22/CreateSchema) 
+  [Amazon SDK for PHP V3](https://docs.amazonaws.cn/goto/SdkForPHPV3/personalize-2018-05-22/CreateSchema) 
+  [Amazon SDK for Python](https://docs.amazonaws.cn/goto/boto3/personalize-2018-05-22/CreateSchema) 
+  [Amazon SDK for Ruby V3](https://docs.amazonaws.cn/goto/SdkForRubyV3/personalize-2018-05-22/CreateSchema) 