tencent cloud

APIs

CreateListener

下载
聚焦模式
字号
最后更新时间: 2026-09-28 14:17:57

1. API Description

Domain name for API request: alb.intl.tencentcloudapi.com.

This API is used to create a listener.

A maximum of 20 requests can be initiated per second for this API.

We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

2. Input Parameters

The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

Parameter Name Required Type Description
Action Yes String Common Params. The value used for this API: CreateListener.
Version Yes String Common Params. The value used for this API: 2025-10-30.
Region Yes String Common Params. For more information, please see the list of regions supported by the product.
DefaultActions.N Yes Array of DefaultAction

Default forwarding rule action list. Currently, a listener supports adding only 1 default forwarding rule action.

ListenerPort Yes Integer

Port used by the load balancing instance frontend. Value: 1-65535.

ListenerProtocol Yes String

Listening protocol. Parameter Value: HTTP, HTTPS, or QUIC.

LoadBalancerId Yes String

Cloud Load Balancer instance ID. The format is alb- followed by 8 alphanumeric characters.

CaCertificateIds.N No Array of String

List of CA certificate IDs configured for the listener. Currently, a listener supports adding only 1 CA certificate.
This parameter is required when the CaEnabled parameter value is true.

CaEnabled No Boolean

Whether mutual authentication is enabled.
Value:
true: enabled.
false (default value): not enabled.

CertificateIds.N No Array of String

List of server certificate IDs.

ClientToken No String

Client token, used to ensure the idempotency of requests.

Generate a parameter value from your client to ensure the uniqueness of the value for different requests. ClientToken supports only ASCII characters.

GzipEnabled No Boolean

Whether Gzip compression is enabled. Value: true (default): yes. false: no

Http2Enabled No Boolean

Whether HTTP/2 is enabled. Default value: false for HTTP and true for HTTPS. Only the HTTPS protocol supports this parameter.

IdleTimeout No Integer

Connection idle timeout, in seconds.
Value range: 1–600.
Default value: 15.
If no access request is received within the timeout period, load balancing will disconnect the current connection and create a new connection when the next request arrives.

ListenerName No String

Custom listener name, containing 1–255 characters. It must contain Chinese and harmless string characters, and can contain Chinese, letters, digits, dashes (-), forward slashes (/), half-width periods (.), and underscores (_).

RequestTimeout No Integer

Connection request timeout period. Unit: second. Value: 1–600. Default value: 60. If the real server does not return a response within the timeout period, load balancing will abandon waiting and return an HTTP 504 error code to the client.

SecurityPolicyId No String

Security policy ID, format: tls- followed by 8 alphanumeric characters.

Tags.N No Array of TagInfo

Tag list. Supports up to 20.

XForwardedForConfig No XForwardedForConfig

X-Forwarded-For configuration

3. Output Parameters

Parameter Name Type Description
ListenerId String

Listener ID, in the format of lst- followed by 8 alphanumeric characters.

RequestId String The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem.

4. Example

Example1 Create a listener

Input Example

POST / HTTP/1.1
Host: alb.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateListener
<Common request parameters>

{
    "LoadBalancerId": "alb-f8q2xk9m",
    "ListenerProtocol": "HTTPS",
    "ListenerPort": 80,
    "ListenerName": "443",
    "DefaultActions": [
        {
            "Type": "TargetGroup",
            "TargetGroupConfig": {
                "TargetGroups": [
                    {
                        "TargetGroupId": "lbtg-0zrnc9qa"
                    }
                ]
            }
        }
    ],
    "CertificateIds": [
        "Fm8Wp7x8"
    ],
    "CaEnabled": false,
    "Http2Enabled": false,
    "GzipEnabled": false,
    "RequestTimeout": 60,
    "IdleTimeout": 15,
    "SecurityPolicyId": "tls-t2ckydug",
    "XForwardedForConfig": {
        "XForwardedForMode": "append",
        "XForwardedForProtoEnabled": false,
        "XForwardedForPortEnabled": false,
        "XForwardedForHostEnabled": false,
        "XForwardedForClientSrcPortEnabled": false,
        "XTencentClientSDNEnabled": false,
        "XTencentClientIDNEnabled": false,
        "XTencentClientSerialEnabled": false,
        "XTencentClientVerifyEnabled": false
    }
}

Output Example

{
    "Response": {
        "ListenerId": "lst-d9p3k7wa",
        "RequestId": "e3bc3ab0-e453-4a83-92c4-8fcdda1e08c1"
    }
}

5. Developer Resources

SDK

TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

Command Line Interface

6. Error Code

The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

Error Code Description
UnsupportedOperation.TargetGroupProtocolMismatch Listener protocol and target group backend forwarding protocol mismatch
UnsupportedOperation.UnsupportedProtocol Operation not supported for the CLB listener protocol.

帮助和支持

本页内容是否解决了您的问题?

填写满意度调查问卷,共创更好文档体验。

文档反馈