Skip to main content
POST
/
message
/
sendbatch
curl -X POST "http://localhost:5001/message/sendbatch" \
  -H "Content-Type: application/json" \
  -d '[
    {
      "header": {
        "no_persist": 0,
        "red_dot": 1,
        "sync_once": 0
      },
      "client_msg_no": "batch_msg_1",
      "from_uid": "system",
      "channel_id": "group123",
      "channel_type": 2,
      "expire": 0,
      "payload": "SGVsbG8gR3JvdXAgMQ==",
      "tag_key": "notification"
    },
    {
      "header": {
        "no_persist": 0,
        "red_dot": 1,
        "sync_once": 0
      },
      "client_msg_no": "batch_msg_2",
      "from_uid": "system",
      "channel_id": "group456",
      "channel_type": 2,
      "expire": 0,
      "payload": "SGVsbG8gR3JvdXAgMg==",
      "tag_key": "notification"
    }
  ]'
[
  {
    "message_id": 123456789,
    "message_seq": 1001,
    "client_msg_no": "batch_msg_1"
  },
  {
    "message_id": 123456790,
    "message_seq": 1002,
    "client_msg_no": "batch_msg_2"
  }
]

Overview

Send multiple messages in batch to improve message sending efficiency, suitable for group notifications, bulk push, and other scenarios.

Request Body

The request body is an array of message objects, each message object contains the following fields:

Required Parameters

[].payload
string
required
Base64 encoded message content
[].from_uid
string
required
Sender user ID
[].channel_id
string
required
Target channel ID
[].channel_type
integer
required
Channel type (1=personal channel, 2=group channel)

Optional Parameters

[].header
object
Message header information
[].client_msg_no
string
Client message number
[].stream_no
string
Stream message number
[].expire
integer
Message expiration time (seconds), 0 means no expiration
[].subscribers
array
Specified list of subscribers to receive the message
[].subscribers[]
string
Subscriber user ID
curl -X POST "http://localhost:5001/message/sendbatch" \
  -H "Content-Type: application/json" \
  -d '[
    {
      "header": {
        "no_persist": 0,
        "red_dot": 1,
        "sync_once": 0
      },
      "client_msg_no": "batch_msg_1",
      "from_uid": "system",
      "channel_id": "group123",
      "channel_type": 2,
      "expire": 0,
      "payload": "SGVsbG8gR3JvdXAgMQ==",
      "tag_key": "notification"
    },
    {
      "header": {
        "no_persist": 0,
        "red_dot": 1,
        "sync_once": 0
      },
      "client_msg_no": "batch_msg_2",
      "from_uid": "system",
      "channel_id": "group456",
      "channel_type": 2,
      "expire": 0,
      "payload": "SGVsbG8gR3JvdXAgMg==",
      "tag_key": "notification"
    }
  ]'
[
  {
    "message_id": 123456789,
    "message_seq": 1001,
    "client_msg_no": "batch_msg_1"
  },
  {
    "message_id": 123456790,
    "message_seq": 1002,
    "client_msg_no": "batch_msg_2"
  }
]

Response Fields

The response is an array, each element corresponds to a sent message:
message_id
integer
required
Server-generated message ID
message_seq
integer
required
Message sequence number
client_msg_no
string
required
Client message number (echo)

Status Codes

Status CodeDescription
200Batch messages sent successfully
400Request parameter error
403No sending permission
500Internal server error

Use Cases

System Notifications

  • Announcement Push: Send system announcements to multiple groups
  • Activity Notifications: Batch send activity reminder messages
  • Maintenance Notifications: Batch notifications before system maintenance

Marketing Promotion

  • Promotional Messages: Send promotional information to target user groups
  • New Feature Introduction: Batch push new feature usage guides
  • User Surveys: Send questionnaire survey messages

Operations Management

  • Data Statistics: Batch send data reports
  • Task Assignment: Batch assign tasks to team members
  • Meeting Notifications: Batch send meeting invitations

Performance Optimization

Batch Size

  • Recommended Batch: Single batch sending should not exceed 100 messages
  • Batch Processing: Large volumes of messages can be sent in batches to avoid timeouts
  • Concurrency Control: Control the number of concurrent batch requests

Message Optimization

  • Content Compression: For identical content, use templates to reduce data transmission
  • Asynchronous Processing: Use asynchronous methods to handle batch sending
  • Error Retry: Implement retry mechanism for failed messages

Best Practices

  1. Message Deduplication: Ensure each message’s client_msg_no is unique
  2. Error Handling: Handle cases where some messages fail to send
  3. Permission Verification: Verify sender’s sending permission for all target channels
  4. Content Review: Review batch message content
  5. Rate Limiting: Implement reasonable batch sending rate limits
  6. Monitoring & Alerts: Monitor batch sending success rate and performance