Skip to main content

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

ItemDescription
URLhttps://api-coco.typex.im/open/robot/send_message
MethodPOST
Content-Typeapplication/json

Request Headers

Authorization: Bearer <bot_token>
Content-Type: application/json

Request Parameters

ParameterTypeRequiredDescription
msg_typeintYesMessage type: 0-text, 1-image, 3-audio, 4-video, 5-file, 9-business card, 11-rich media, 15-file group, 16-card message
contentobjectYesMessage content, structure varies by msg_type (see examples below)
chat_idstringYesTarget conversation ID
thread_msg_idstringNoMain message ID for creating a thread (the id returned by this API)
thread_idstringNoThread ID, sends message within that thread
visible_idsstring[]NoSpecify visible users (TypeX UID array), omit for all members

Response Format

{
"code": 0,
"data": {
"id": "",
"chat_id": "",
"thread_id": ""
},
"msg": "ok"
}
FieldDescription
data.idMessage ID
data.chat_idConversation ID
data.thread_idThread 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>&nbsp;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 FieldDescription
object_urlAddress returned from the upload endpoint
widthWidth returned from the upload endpoint
heightHeight 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 FieldDescription
object_urlResource address from the upload endpoint
duration_secondAudio 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 FieldDescription
duration_secondVideo duration in seconds
height / widthThumbnail dimensions
thumb_urlVideo thumbnail URL
image_urlVideo snapshot URL
video_urlVideo 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 FieldDescription
object_urlResource address from the upload endpoint
file_nameFile name
file_sizeFile size in bytes
file_typeMIME 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 FieldDescription
via_type0-user card, 1-group card
via_user_idUser 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 FieldDescription
via_type0-user card, 1-group card
via_chat_idGroup 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 FieldsDescription
object_urlImage URL
thumb_urlThumbnail URL
width / heightImage dimensions
video_urlVideo URL (optional, for video elements)
image_urlVideo snapshot (optional)
duration_secondVideo 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 FieldsDescription
file_nameFile name
file_sizeFile size in bytes
file_typeMIME type
indexSort index
object_urlFile URL
statusStatus

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 FieldDescription
titleCard title
contentCard body
buttonsButton array
button FieldTypeDescription
button_idstringButton unique identifier
textstringButton text
action_typeint1-callback, 2-open link
urlstringCallback URL or link URL
action_valuestringExtra data carried in callback (when action_type=1)