tencent cloud

SendMessages
Last updated: 2025-11-25 10:54:28
SendMessages
Last updated: 2025-11-25 10:54:28

1. API Description

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

This API is used to send a single message.
The message cannot be sent to a persistent topic.

A maximum of 1000 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: SendMessages.
Version Yes String Common Params. The value used for this API: 2020-02-17.
Region Yes String Common Params. For more information, please see the list of regions supported by the product. This API only supports: ap-bangkok, ap-beijing, ap-chengdu, ap-chongqing, ap-guangzhou, ap-hongkong, ap-jakarta, ap-nanjing, ap-seoul, ap-shanghai, ap-shanghai-fsi, ap-shenzhen-fsi, ap-singapore, ap-tokyo, eu-frankfurt, na-ashburn, na-siliconvalley.
Topic Yes String Name of the topic to which to send the message. It is better to be the full path of the topic, such as tenant/namespace/topic. If it is not specified, public/default will be used by default.
Payload Yes String Content of the message to be sent
StringToken No String Token used for authentication, which is optional and will be automatically obtained by the system.
ProducerName No String Producer name, which is randomly generated and must be globally unique. If you set the producer name manually, the producer may fail to be created, causing message sending failure.
This parameter is used only when a specific producer is allowed to produce messages. It won’t be used in most cases.
SendTimeout No Integer Message sending timeout period, which is 30s by default.
MaxPendingMessages No Integer Maximum number of produced messages which can be cached in the memory. Default value: 1000

3. Output Parameters

Parameter Name Type Description
MessageId String The messageID of the message is globally unique and is used to identify the message's metadata information.
ErrorMsg String Returned error message. If returned as "", it means there is no error.
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 Successfully Send Single Message

This example shows you how to successfully send a single message.
This example shows you how to work with unsupported non-persistent topics.

Input Example

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

{
    "Topic": "tenant/namespace/topic",
    "Payload": "\"hello TDMQ\""
}

Output Example

{
    "Response": {
        "RequestId": "36713f94-d07d-4b96-babf-42d139276f23",
        "MessageId": "71:11:0:0",
        "ErrorMsg": "success"
    }
}

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.CreateProducerError An error occurred while creating the producer.
FailedOperation.CreatePulsarClientError An error occurred while creating the TDMQ client.
FailedOperation.MaxMessageSizeError The message size exceeds the upper limit of 1 MB.
FailedOperation.MessageIDError The uploaded msgID is incorrect.
FailedOperation.ReceiveError An error occurred while receiving the message.
FailedOperation.ReceiveTimeout Message receiving timed out. Please try again.
FailedOperation.SendMessageTimeoutError Message sending timed out.
FailedOperation.TopicTypeError Please use a partition topic.
InvalidParameter.TenantNotFound The uploaded tenant name is incorrect.
InvalidParameter.TokenNotFound The correct token was not obtained.
InvalidParameterValue.TopicNotFound The uploaded topic name is incorrect.
Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback