# Create Database - CreateUDBInstance

## Overview

Creating UDB instance (including creating mysql master node, mongodb primary/configsvr node and restoring instance from backup)

 > 💡 To create a Kuaijie MySQL instance, please use the CreateUDBMySQLInstance interface. To create a Kuaijie SQL Server instance, please use the CreateUDBSQLServerInstance interface,Creating High Availability Across Availability Zones Notes:1. Parameter BackupZone is required: The value is the ZoneId for disaster recovery of high availability.2. Parameter ParamGroupId: The value is the configuration file across availability zones, which can be obtained through DescribeUDBParamGroup.




## Definition

### Public Parameters

| Parameter Name | Type | Description Information | Required |
|:---|:---|:---|:---|
| **Action**     | string  | Corresponding API command name, the current API is `CreateUDBInstance`.                      | **Yes** |
| **PublicKey**  | string  | The user's public key can be obtained from [Console](https://console.scloudsg.com/uaccount/api_manage)                                             | **Yes** |
| **Signature**  | string  | User signature generated based on public key and API command, see [Signature Algorithm](/docs/api/summary/signature.md)  | **Yes** |

### Request Parameters

| Parameter Name | Type | Description Information | Required |
|:---|:---|:---|:---|
| **Region** | string | Region. See [List of Regions and Availability Zones](/docs/api/summary/regionlist) |**Yes**|
| **Zone** | string | Availability Zone. See [Availability Zone List](/docs/api/summary/regionlist) |**Yes**|
| **ProjectId** | string | Project ID. If not filled in, the default project is used, sub-accounts must be filled in. Please refer to the [GetProjectList interface](/docs/api/summary/get_project_list). |No|
| **Name** | string | Instance name, at least 6 characters |**Yes**|
| **AdminPassword** | string | Administrator Password |**Yes**|
| **DBTypeId** | string | DB type, mysql/mongodb/postgesql/sqlserver subdivided by version mysql-8.0, mysql-5.5, percona-5.5, mysql-5.6, percona-5.6, mysql-5.7, percona-5.7, mariadb-10.0, postgresql-9.6, postgresql-10.4, postgresql-12.8, postgresql-13.4, mongodb-2.6, mongodb-3.0, mongodb-3.6, mongodb-4.0, sqlserver-2017 |**Yes**|
| **Port** | int | Port number, mysql default 3306, mongodb default 27017, postgresql default 5432 |**Yes**|
| **DiskSpace** | int | Disk Space (GB), temporarily supports 20G - 32T |**Yes**|
| **ParamGroupId** | int | Configuration parameter group id used by the DB instance |**Yes**|
| **MemoryLimit** | int | Memory Limit (MB), currently supports the following levels 2000M/4000M/ 6000M/8000M/12000M/16000M/ 24000M/32000M/48000M/ 64000M/96000M/128000M/192000M/256000M/320000M |No|
| **ChargeType** | string | Yearly, Monthly, Dynamic, Trial, Default: Monthly |No|
| **Quantity** | int | Purchase duration, default value 1 |No|
| **AdminUser** | string | Administrator account name, default is root |No|
| **BackupCount** | int | Backup strategy, number of backups per week, default is 7 times |No|
| **BackupTime** | int | Backup strategy, backup start time, calculated in units of hours, default is 1 o'clock |No|
| **BackupDuration** | int | Backup strategy, backup time interval, calculated in hours, default is 24 hours. |No|
| **BackupId** | int | Backup ID, if specified, it means to restore the instance from the backup. |No|
| **InstanceType** | string | When creating high-performance instances, please use the latest SpecificationClass and StorageClass fields.<br />Currently, only a limited number of regions support the SATA_SSD storage type. For SATA_SSD instances, this field can be used to specify the storage type. |No|
| **SSDType** | string | SSD type, optional values are "SATA" or "NVMe", default is "SATA". |No|
| **InstanceMode** | string | UDB instance mode type, optional values are as follows: "Normal": Standard version UDB instance "HA": High availability version UDB instance The default is "Normal". |No|
| **CPU** | int | Number of CPU cores, a required parameter if the DB type is SQL Server. |No|
| **BackupZone** | string | The availability zone where the cross-availability zone high-availability backup library is located, see [Availability Zone List](/docs/api/summary/regionlist) |No|
| **SubnetId** | string | Subnet ID |No|
| **VPCId** | string | ID of VPC |No|
| **DisableSemisync** | boolean | Whether to enable asynchronous high availability, not filled by default, can be set to true |No|
| **ClusterRole** | string | When the DB type (DBTypeId) is mongodb, you need to specify the role of mongo. The optional values are configsrv (configuration node) and shardsrv (data node). |No|
| **Tag** | string | The name of the business group where the instance is located |No|
| **DBSubVersion** | string | MySQL minor version. Specifying a minor version during instance creation is supported. Please use the DescribeUDBType API to obtain the available versions. |No|
| **CaseSensitivityParam** | int | MySQL case sensitivity parameter, 0 for case sensitive, 1 for case insensitive, currently only effective for MySQL 8.0 |No|
| **SpecificationType** | string | The type of instance computing specification, 0 or no transmission means purchasing by memory method, 1 means purchasing by optional memory-cpu ratio method, need to fill in MachineType. |No|
| **MachineType** | string | Specification type ID. This field is valid only when SpecificationType = 1. Please retrieve the value through the ListUDBMachineType API. |No|
| **AlarmTemplateId** | string | ID of the alarm template |No|
| **BackupURL** | string | Internal network address for downloading backup files from US3 |No|
| **StorageClass** | string | Storage Type CLOUD_SSD: SSD Cloud Disk, CLOUD_RSSD: RSSD Cloud Disk, CLOUD_SSD_ESSENTIAL: SSD Essential Cloud Disk. This field combined with SpecificationClass has a higher priority than the InstanceType field. |No|
| **SpecificationClass** | string | Specification Type O: NVME, OM: Shared Type, N: General Type |No|
| **SemisyncFlag** | int | Semi-synchronous toggle switch: 1 indicates enabling semi-synchronous, 2 indicates disabling semi-synchronous, 0 indicates the default value, which is also enabling semi-synchronous by default. |No|
| **Labels.N.Key** | string | Keys of User Resource Label |No|
| **Labels.N.Value** | string | Values of User Resource Label |No|
| **CouponId** | string | ID of the voucher used |No|

### Response Field

| Field Name | Type | Description Information | Required |
|:---|:---|:---|:---|
| **RetCode** | int | Return status code. If it is 0, it means successful return. If it is not 0, it means failure. |**Yes**|
| **Action** | string | Operation command name. |**Yes**|
| **Message** | string | Returns an error message, providing detailed description when `RetCode` is non-zero. |No|
| **DBId** | string | BD Instance ID |No|




## Example

### Request Example
    
```
https://api.scloudsg.com/?Action=CreateUDBInstance
&Region=cn-bj2
&Zone=cn-bj2-04
&DBTypeId=mysql-5.6
&ChargeType=Month   
&Name=my_test_udb
&AdminUser=root
&AdminPassword=mysql_12
&Port=3306
&ParamGroupId=10
&MemoryLimit=1500
&DiskSpace=200
&InstanceMode=HA
&ClusterRole=IcPiHioG
&HAArch=haproxy
&Tag=awpGFPaP
&EnableIpV6=true
&BackupUrl=ArIyIIyj
&DBSubVersion=8.0.16
&CaseSensitivityParam=5
&SpecificationType=IWYpQrmi
&MachineType=ZINkjHvV
&AlarmTemplateId=ZhRasRaR
&BackupURL=oshESfOV
&StorageClass=EdRLHUsN
&SpecificationClass=ZFvDzuMA
&SemisyncFlag=6
&Labels.N.Key=HFdaujOo
&Labels.N.Value=JlcpTDgc
```

### Response Example
    
```json
{
  "Action": "CreateUDBInstanceResponse",
  "DBId": "udbha-xxxxxx",
  "RetCode": 0
}
```





