# Create Application Load Balancer Listener - CreateListener

## Overview

Create a listener for an application load balancer






## Definition

### Public Parameters

| Parameter Name | Type | Description Information | Required |
|:---|:---|:---|:---|
| **Action**     | string  | Corresponding API command name, the current API is `CreateListener`.                      | **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). |**Yes**|
| **LoadBalancerId** | string | ID of the Load Balancing Instance |**Yes**|
| **Name** | string | The name of the listener. Character length limit: [1-255]; Special characters supported: "-", "_", "."; Default value: listener. |No|
| **Remark** | string | Description of the listener. Character limit: [0-255] |No|
| **ListenerPort** | int | The listening port of the listener. For application type, the value range is: [1-65535], the default value is 80. |No|
| **ListenerProtocol** | string | Listening Protocol. Application-specific limited values: "HTTP"/"HTTPS", default value "HTTP". |No|
| **Certificates.N** | string | (Application-specific) Default server certificate ID. Only supported by HTTPS listening and is required; currently only supports a maximum length of 1. |No|
| **SecurityPolicyId** | string | (Application-specific) Security policy group ID. Only HTTPS listening supports binding; the default value "Default" means binding to the native policy. |No|
| **IdleTimeout** | int | Connection idle timeout period. Unit: seconds. Application type limit value: [1-86400]; default value is 60. |No|
| **Scheduler** | string | Load balancing algorithm. Application-specific limited values: "Roundrobin"/"Source"/"WeightRoundrobin"/"Leastconn"/"Backup", default value "Roundrobin". |No|
| **StickinessConfig.Enabled** | boolean | Whether to enable the session persistence function. The application load balancing instance is implemented based on Cookie; the default value is: false |No|
| **StickinessConfig.Type** | string | (Application-specific) Cookie processing method. Limited enumeration values: "ServerInsert" / "UserDefined"; The default value is: "ServerInsert". |No|
| **StickinessConfig.CookieName** | string | (Application-specific) Custom Cookie. Effective when StickinessType is set to "UserDefined"; character length limit: [0-255] |No|
| **HealthCheckConfig.Enabled** | boolean | Whether to enable the health check function. Temporarily does not support shutting down. The default value is: true |No|
| **HealthCheckConfig.Type** | string | Health check method. Application type limited value: 'Port'/'HTTP/GRPC', default value: 'Port'. |No|
| **HealthCheckConfig.Domain** | string | (Application-specific) HTTP Check Domain |No|
| **HealthCheckConfig.Path** | string | (Application-specific) HTTP check path |No|
| **HealthCheckConfig.Method** | string | (Application-specific) HTTP check method |No|
| **HealthCheckConfig.ResponseCode** | string | (Application-specific) GRPC check response code |No|
| **CompressionEnabled** | boolean | (Application-specific) Whether to enable the data compression feature. Currently, only gzip is supported for compressing specific file types. The default value is: false |No|
| **HTTP2Enabled** | boolean | (Application-specific) Whether to enable the HTTP/2 feature. Only HTTPS listening supports enabling; the default value is: false |No|
| **RedirectEnabled** | boolean | (Application-specific) Whether to enable HTTP redirection to HTTPS. Only HTTP listening supports enabling; the default value is: false |No|
| **RedirectPort** | int | (Application-specific) Redirect port. Limited value range: [1-65535], default value 443 |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|
| **ListenerId** | string | Listener's ID |**Yes**|




## Example

### Request Example
    
```
https://api.scloudsg.com/?Action=CreateListener
&Region=cn-zj
&Zone=cn-zj-01
&ProjectId=uvNplLqt
&LoadBalancerId=TrMQMxgz
&Name=kHEiMUtI
&Remark=VHkpyFlw
&ListenPort=3
&ListenProtocol=OjJEdAaO
&Certificates.n=WuscVHDW
&SecurityPolicyId=zwsYdamE
&IdleTimeout=3
&Scheduler=lHorTbNl
&StickinessConfig.Enabled=false
&StickinessConfig.Type=fuuciPzx
&StickinessConfig.CookieName=TnXwVeSq
&HealthCheckConfig.Enabled=true
&HealthCheckConfig.Type=pDlMtNon
&HealthCheckConfig.Domain=TWoxQhFA
&HealthCheckConfig.Path=KnPWkCVd
&CompressionEnabled=false
&HTTP2Enabled=false
&RedirectEnabled=false
&RedirectPort=1
&HealthCheckConfig.Method=jGeXqSDV
&HealthCheckConfig.ResponseCode=qDsVpfRH
```

### Response Example
    
```json
{
  "Action": "CreateListenerResponse",
  "ListenerId": "pCtZUlZc",
  "RetCode": 0
}
```





