Sending Messages
We recommend starting with text messages for debugging. Once authentication and the target conversation are confirmed, extend to images and file messages.
Supported Chat Scenarios
TypeX Bot supports sending messages in both one-on-one and group chats.
- For one-on-one chat: just make sure the target conversation ID is correct
- For group chat: ensure the Bot has joined the target group first
Endpoint
Basic Information
| Item | Description |
|---|---|
| URL | https://api-coco.typex.im/open/robot/send_message |
| Method | POST |
| Content-Type | application/json |
Request Headers
Authorization: Bearer <bot_token>
Content-Type: application/json
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
msg_type | int | Yes | Message type: 0-text, 1-image, 3-audio, 4-video, 5-file, 9-business card, 11-rich media, 15-file group, 16-card message |
content | object | Yes | Message content, structure varies by msg_type (see examples below) |
chat_id | string | Yes | Target conversation ID |
thread_msg_id | string | No | Main message ID for creating a thread (the id returned by this API) |
thread_id | string | No | Thread ID, sends message within that thread |
visible_ids | string[] | No | Specify visible users (TypeX UID array), omit for all members |
Response Format
{
"code": 0,
"data": {
"id": "",
"chat_id": "",
"thread_id": ""
},
"msg": "ok"
}
| Field | Description |
|---|---|
data.id | Message ID |
data.chat_id | Conversation ID |
data.thread_id | Thread ID (returned when thread_msg_id is provided) |
Send Examples
Send Text
curl --location 'https://api-coco.typex.im/open/robot/send_message' \
--header 'Authorization: Bearer <bot_token>' \
--header 'Content-Type: application/json' \
--data '{
"chat_id": "123456",
"msg_type": 0,
"content": {
"text": "<p>Hello from TypeX Bot</p>"
}
}'
Send Markdown Text
curl --location 'https://api-coco.typex.im/open/robot/send_message' \
--header 'Authorization: Bearer <bot_token>' \
--header 'Content-Type: application/json' \
--data-raw '
{
"msg_type": 0,
"content": {
"is_markdown": true,
"text": "<markdown text>"
},
"chat_id": "7602566729281049630"
}'
Send @ Mention Text
curl --location 'https://api-coco.typex.im/open/robot/send_message' \
--header 'Authorization: Bearer <bot_token>' \
--header 'Content-Type: application/json' \
--data-raw '
{
"msg_type": 0,
"content": {
"at_user_ids": [
"7569868447471902876"
],
"chat_id": "7602566729281049630",
"reply_msg_id": "0",
"text": "<p><at userid=\"7569868447471902876\">User Name</at> Hello</p>"
},
"chat_id": "7602566729281049630"
}'
Send Image
Requires uploading the resource first via the upload endpoint.
curl --location 'https://api-coco.typex.im/open/robot/send_message' \
--header 'Authorization: Bearer <bot_token>' \
--header 'Content-Type: application/json' \
--data '{
"msg_type": 1,
"content": {
"object_url": "https://api-coco.typex.im/chat/get/...",
"width": 932,
"height": 114
},
"chat_id": "7602566729281049630"
}'
| content Field | Description |
|---|---|
object_url | Address returned from the upload endpoint |
width | Width returned from the upload endpoint |
height | Height returned from the upload endpoint |
Send Audio
curl --location 'https://api-coco.typex.im/open/robot/send_message' \
--header 'Authorization: Bearer <bot_token>' \
--header 'Content-Type: application/json' \
--data '
{
"msg_type": 3,
"content": {
"object_url": "https://api-coco.typex.im/chat/file?object_key=...",
"duration_second": 5
},
"chat_id": "7602566729281049630"
}'
| content Field | Description |
|---|---|
object_url | Resource address from the upload endpoint |
duration_second | Audio duration in seconds |
Send Video
curl --location 'https://api-coco.typex.im/open/robot/send_message' \
--header 'Authorization: Bearer <bot_token>' \
--header 'Content-Type: application/json' \
--data '
{
"msg_type": 4,
"content": {
"duration_second": 11,
"height": 760,
"width": 1416,
"thumb_url": "https://api-coco.typex.im/file/muti/download?object_key=...",
"image_url": "https://api-coco.typex.im/file/muti/download?object_key=...",
"video_url": "https://api-coco.typex.im/chat/file?object_key=..."
},
"chat_id": "7602566729281049630"
}'
| content Field | Description |
|---|---|
duration_second | Video duration in seconds |
height / width | Thumbnail dimensions |
thumb_url | Video thumbnail URL |
image_url | Video snapshot URL |
video_url | Video file URL |
Send File
curl --location 'https://api-coco.typex.im/open/robot/send_message' \
--header 'Authorization: Bearer <bot_token>' \
--header 'Content-Type: application/json' \
--data '
{
"msg_type": 5,
"content": {
"object_url": "https://api-coco.typex.im/chat/file?object_key=...",
"file_name": "aaaa.zip",
"file_size": 1000,
"file_type": "application/zip"
},
"chat_id": "7602566729281049630"
}'
| content Field | Description |
|---|---|
object_url | Resource address from the upload endpoint |
file_name | File name |
file_size | File size in bytes |
file_type | MIME type |
Send User Business Card
curl --location 'https://api-coco.typex.im/open/robot/send_message' \
--header 'Authorization: Bearer <bot_token>' \
--header 'Content-Type: application/json' \
--data '
{
"msg_type": 9,
"content": {
"via_type": 0,
"via_user_id": "7569548038616650888"
},
"chat_id": "7602566729281049630"
}'
| content Field | Description |
|---|---|
via_type | 0-user card, 1-group card |
via_user_id | User TypeX UID (when via_type=0) |
Send Group Business Card
curl --location 'https://api-coco.typex.im/open/robot/send_message' \
--header 'Authorization: Bearer <bot_token>' \
--header 'Content-Type: application/json' \
--data '
{
"msg_type": 9,
"content": {
"via_type": 1,
"via_chat_id": "7616707861858492432"
},
"chat_id": "7602566729281049630"
}'
| content Field | Description |
|---|---|
via_type | 0-user card, 1-group card |
via_chat_id | Group chat ID (when via_type=1) |
Send Rich Media Message
Supports mixed media with images and videos.
curl --location 'https://api-coco.typex.im/open/robot/send_message' \
--header 'Authorization: Bearer <bot_token>' \
--header 'Content-Type: application/json' \
--data-raw '
{
"msg_type": 11,
"content": {
"at_user_ids": ["7568824950807606369"],
"images": [
{
"height": 620,
"object_url": "https://api-coco.typex.im/file/muti/download?object_key=...",
"thumb_url": "https://api-coco.typex.im/file/muti/download?object_key=...",
"width": 1672
},
{
"duration_second": 11,
"height": 760,
"width": 1416,
"thumb_url": "https://api-coco.typex.im/file/muti/download?object_key=...",
"image_url": "https://api-coco.typex.im/file/muti/download?object_key=...",
"video_url": "https://api-coco.typex.im/chat/file?object_key=..."
}
],
"text": "<p>Rich media content</p>"
},
"chat_id": "7602566729281049630"
}'
| images Element Fields | Description |
|---|---|
object_url | Image URL |
thumb_url | Thumbnail URL |
width / height | Image dimensions |
video_url | Video URL (optional, for video elements) |
image_url | Video snapshot (optional) |
duration_second | Video duration (optional) |
Send File Group Message
curl --location 'https://api-coco.typex.im/open/robot/send_message' \
--header 'Authorization: Bearer <bot_token>' \
--header 'Content-Type: application/json' \
--data-raw '{
"msg_type": 15,
"content": {
"at_user_ids": ["7569868447471902876"],
"files": [
{
"file_name": "aaaa_1.zip",
"file_size": 150450,
"file_type": "application/zip",
"index": 0,
"object_url": "https://api-coco.typex.im/chat/file?object_key=...",
"status": 0
},
{
"file_name": "aaaa.zip",
"file_size": 150450,
"file_type": "application/zip",
"index": 1,
"object_url": "https://api-coco.typex.im/chat/file?object_key=...",
"status": 0
}
],
"text": "<p>File group description</p>"
},
"chat_id": "7602566729281049630"
}'
| files Element Fields | Description |
|---|---|
file_name | File name |
file_size | File size in bytes |
file_type | MIME type |
index | Sort index |
object_url | File URL |
status | Status |
Send Card Message
Supports custom title, content, and interactive buttons.
curl --location 'https://api-coco.typex.im/open/robot/send_message' \
--header 'Authorization: Bearer <bot_token>' \
--header 'Content-Type: application/json' \
--data '
{
"msg_type": 16,
"content": {
"title": "Card Title",
"content": "Card body text, supports line breaks.",
"buttons": [
{
"button_id": "btn_1",
"text": "Open Link",
"action_type": 2,
"url": "https://example.com"
},
{
"button_id": "btn_2",
"text": "Callback",
"action_type": 1,
"url": "https://your-callback.com/hook",
"action_value": "{\"custom\": \"data\"}"
}
]
},
"chat_id": "7602566729281049630"
}'
| content Field | Description |
|---|---|
title | Card title |
content | Card body |
buttons | Button array |
| button Field | Type | Description |
|---|---|---|
button_id | string | Button unique identifier |
text | string | Button text |
action_type | int | 1-callback, 2-open link |
url | string | Callback URL or link URL |
action_value | string | Extra data carried in callback (when action_type=1) |