# Create CLB's VServer - CreateVServer

## Overview

Create a VServer instance for CLB, define the listening protocol and port, as well as the load balancing algorithm.






## Definition

### Public Parameters

| Parameter Name | Type | Description Information | Required |
|:---|:---|:---|:---|
| **Action**     | string  | Corresponding API command name, the current API is `CreateVServer`.                      | **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**|
| **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|
| **ULBId** | string | Traditional Load Balancer Instance ID |**Yes**|
| **VServerName** | string | VServer instance name, default is 'VServer'. |No|
| **ListenType** | string | Listener type, enumeration value, RequestProxy, request proxy; PacketsTransmit, packet forwarding. The default is RequestProxy. |No|
| **Protocol** | string | The protocol of the VServer instance, under the request proxy mode there are HTTP, HTTPS, TCP, under the message forwarding mode there are TCP, UDP. The default is 'HTTP'. |No|
| **FrontendPort** | int | VServer backend port, value range [1-65535]; default value is 80 |No|
| **Method** | string | VServer load balancing mode, enumeration values: Roundrobin -> Round Robin; Source -> Source Address; ConsistentHash -> Consistent Hashing; SourcePort -> Source Address (Calculate Port); ConsistentHashPort -> Consistent Hashing (Calculate Port); WeightRoundrobin -> Weighted Round Robin; Leastconn -> Least Connections; Backup -> Master-Slave Mode.<br />ConsistentHash, SourcePort, ConsistentHashPort are only used in packet forwarding; Leastconn is only used in request proxy; Roundrobin, Source, and WeightRoundrobin, Backup are used in both request proxy and packet forwarding.<br />The default is: "Roundrobin". |No|
| **PersistenceType** | string | VServer session persistence mode, session persistence is turned off by default. Enumerated values: None -> Off; ServerInsert -> Automatically generate KEY; UserDefined -> User-defined KEY. |No|
| **PersistenceInfo** | string | Confirm according to PersistenceType; None and ServerInsert: This field is meaningless; UserDefined: This field passes in a custom session hold String |No|
| **ClientTimeout** | int | When ListenType is RequestProxy, it represents the recovery time of idle connections, unit: seconds, value range: time (0, 86400], default value is 60; When ListenType is PacketsTransmit, it represents the connection holding time, unit: seconds, value range: [60, 900], 0 means disabling connection holding. |No|
| **MonitorType** | string | Health check type, enumeration values: Port -> Port check; Path -> Path check; Ping -> Ping detection; Customize -> UDP check<br />The default value for request proxy type is Port, where TCP protocol only supports Port, other protocols support Port and Path;<br />For message forwarding type, TCP protocol only supports Port, UDP protocol supports Ping, Port and Customize, the default value is Ping. |No|
| **Domain** | string | Confirm according to MonitorType; When MonitorType is Path, this field is meaningful, representing HTTP check domain. |No|
| **Path** | string | Confirm according to MonitorType; When MonitorType is Path, this field is meaningful, representing the HTTP check path. |No|
| **RequestMsg** | string | Confirm according to MonitorType; When MonitorType is Customize, this field is meaningful, representing the request message sent by UDP check. |No|
| **ResponseMsg** | string | Confirm according to MonitorType; When MonitorType is Customize, this field is meaningful, representing the response message that the UDP check request should receive. |No|
| **SecurityPolicyId** | string | Security policy group ID, default value 'Default' |No|
| **EnableCompression** | int | 0: Off 1: On, used for data compression function |No|
| **ForwardPort** | int | Redirect port, value range [0-65535]; the default value is 0, representing closure; only the HTTP protocol supports the opening of the redirect function. |No|
| **EnableHTTP2** | int | 0: Off 1: On, used to enable the http2 feature; the default value is 0 |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|
| **VServerId** | string | Id of the VServer instance |No|




## Example

### Request Example
    
```
https://api.scloudsg.com/?Action=CreateVServer
&Region=cn-bj2
&ProjectId=project-XXXXX
&Action=CreateVServer
&ULBId=ulb-XXXXX
&ListenType=RequestProxy
&PersistenceType=None
&PersistenceInfo=hsdhs
&Protocol=TCP
&VServerName=testvserver1
&Method=Source
&FrontendPort=80
&ClientTimeout=180
&MonitorType=EAWmpFKo
&Domain=HbTPGDtS
&Path=ScoEPSuy
&EnableHTTP2=1
&RequestMsg=zMpxnICB
&ResponseMsg=gKFbkkOl
&SecurityPolicyId=OEKOGXjU
&EnableCompression=1
&ForwardPort=6
```

### Response Example
    
```json
{
  "Action": "CreateVServerResponse",
  "RetCode": 0,
  "VServerId": "vserver-XXXX"
}
```





