tencent cloud

APIs

CreateListener

下载
聚焦模式
字号
最后更新时间: 2026-09-14 20:56:25

1. API Description

Domain name for API request: ga2.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-01-15.
Region No String Common Params. This parameter is not required.
GlobalAcceleratorId Yes String

Global acceleration instance ID.

Name Yes String

Name.

Parameter format: starting with a letter or Chinese characters, 2–128 characters in length, supporting letters, digits, Chinese characters, . - _

PortRanges Yes PortRanges

Port range.

Description No String

Description. Maximum length cannot exceed 100 characters.

ListenerType No String

Listening type, defaults to smart routing.

Enumeration values:

  • Standard: Smart routing.
Protocol No String

Protocol. Default value: TCP. Supports configuration of 'TCP', 'UDP', 'HTTP', and 'HTTPS'.

IdleTimeout No Integer

Connection idle wait time.

1. For HTTP/HTTPS listener, the default value is 15, with a supported range of 1-60.
2. For TCP listener, the default value is 900, with a supported range of 10-900.
3. For UDP listener, the default value is 20, with a supported range of 10-20.

GetRealIpType No String

Layer-4 source IP retrieval mode. Supports 'TOA', 'ProxyProtocol', and 'ProxyProtocolV2'.

This parameter can be filled in only when the Layer-4 source IP retrieval mode is enabled.

ClientAffinity No String

Whether to enable session persistence. Supports configuration of 'Open' and 'Close'.

Enumeration values:

  • Open: enable.
  • Close: disable.

Only supported for layer-4 listeners. For layer-7 listeners, modification is not supported.

RequestTimeout No Integer

Request timeout.

Value range: [1, 180]

Default value: 60

This parameter is configurable only for HTTPS listeners.

XForwardedForRealIp No Boolean

Whether to enable layer-7 source IP retrieval mode.

CertificationType No String

Parsing method.

Enumeration values:

  • UNIDIRECTIONAL: two-way.
  • U: one-way.

For an HTTPS listener, this field is required.

CipherPolicyId No String

Encryption algorithm kit. Supports configuration of 'tls_policy_1.0-2', 'tls_policy_1.1-2', 'tls_policy_1.2', 'tls_policy_1.2_strict', 'tls_policy_1.2_strict-1.3'.

ServerCertificates.N No Array of String

Server certificate.

Input limit: currently only support importing one cert; to use multiple certs, use the cert api CreateListenerAdditionalCert to add other certs.

This field is required for HTTPS listeners.

ClientCaCertificates.N No Array of String

Client certificate.

Input limit: 1. Currently only support importing one cert. To use multiple certs, use the cert api CreateListenerAdditionalCert to add other certs. 2. The cert must be a CA certificate.

This field is required when HTTPS listener and mutual authentication are enabled.

HttpVersion No String

HTTPS listener supports version selection

Enumeration values:

  • HTTP/1.1: HTTP/1.1
  • HTTP/2: HTTP/2

3. Output Parameters

Parameter Name Type Description
TaskId String

Task ID.

ListenerId String

Listener ID.

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: ga2.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateListener
<Common request parameters>

{
    "GlobalAcceleratorId": "ga-80bzejka",
    "Name": "garendu-UDP",
    "PortRanges": {
        "FromPort": 12,
        "ToPort": 12
    },
    "Description": "garendu-UDP-desc",
    "ListenerType": "Standard",
    "IdleTimeout": 13,
    "GetRealIpType": "TOA",
    "ClientAffinity": "Open"
}

Output Example

{
    "Response": {
        "ListenerId": "lsr-5lkfom8v",
        "RequestId": "3ca6812c-4782-4ca8-8ef7-e3753ab8a4c7",
        "TaskId": "85233b38-72cf-49ef-b3e8-c63ac9be774c"
    }
}

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
FailedOperation.InsufficientResources Insufficient resources to create the port range.
InvalidParameter.ApplicationLayerListenerCannotCarryParameters Layer-7 listeners do not support carrying the parameter %(value)s.
InvalidParameter.HttpListenerCannotCarryParameters Http listeners do not support carrying the parameter %(value)s.
InvalidParameter.HttpsListenerCanCarryParameters
InvalidParameter.SinglePort Only a single port is supported.
InvalidParameter.TcpListenerCarryParameters
InvalidParameter.TransportLayerListenerCannotCarryParameters Layer-4 listeners do not support carrying the parameter %(value)s.
InvalidParameterValue.InstanceName Instance name must start with an uppercase/lowercase character or Chinese character, and support digits, periods, hyphens, and underscores.
InvalidParameterValue.Malformed Parameter value %(value)s of %(parameter)s is invalid. A correct and complete value is in the form of %(template)s.
InvalidParameterValue.Range The value %(value)s of the parameter %(parameter)s must be within the range %(value_range)s.
InvalidParameterValue.SegmentPortRange FromPort %(fromPort)s should be less than or equal to ToPort %(toPort)s.
InvalidParameterValue.TcpSeriesListenerPortEqual The current TCP protocol series listener port duplicates an existing listener port.
InvalidParameterValue.ThirdAreaListenerPortEqual Currently, the global acceleration instance has third-party node acceleration regions configured. The listener port cannot be the same.
InvalidParameterValue.ThirdAreaListenerPortSegment Currently, the global acceleration instance does not support configuring listener port ranges for third-party nodes.
InvalidParameterValue.TooLong Parameter value %(value)s length cannot be greater than %(max_size)s.
InvalidParameterValue.UdpSeriesListenerPortEqual The current UDP listener port is duplicated with an existing listener port.
LimitExceeded The quota limit is exceeded.
MissingParameter Parameters are missing.
UnsupportedOperation.CurrentAccountNotAllowed The current account does not support this operation.
UnsupportedOperation.InstanceStateNotAllowedOperate Current instance status does not allow this operation.
UnsupportedOperation.ListenerPortSegment The current account does not support port range configuration.
UnsupportedOperation.OnlyTcpListenerSupportToa For TCP listeners only, client IP can be obtained through TOA.
UnsupportedOperation.TOAFeatureNotEnabled The TOA feature is not enabled for the current global acceleration instance. Contact Tencent Cloud customer service to submit a request.
UnsupportedOperation.UdpListenerNotSupportProxyProtocol
UnsupportedOperation.UnlawfulCertificate

帮助和支持

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

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

文档反馈