Browse Platform API
Platform API

Send a message

Copy

Use this endpoint to send one message from a business backend as a selected user or system account. It is intended for system messages, operational notifications, agent-assisted sending, and historical message migration. Normal user chat should generally be sent by the client SDK under the signed-in user's identity.

HTTP request

POST {API_ADDRESS}/msg/send_msg

Request example

curl --request POST "${API_ADDRESS}/msg/send_msg" \
  --header "Content-Type: application/json; charset=utf-8" \
  --header "operationID: ${OPERATION_ID}" \
  --header "token: ${ADMIN_TOKEN}" \
  --data-raw '{
  "sendID": "openIMAdmin",
  "recvID": "user_001",
  "groupID": "",
  "senderNickname": "System",
  "senderFaceURL": "https://example.com/system.png",
  "senderPlatformID": 10,
  "content": {"content": "hello"},
  "contentType": 101,
  "sessionType": 1,
  "isOnlineOnly": false,
  "notOfflinePush": false,
  "sendTime": 1719800000000,
  "offlinePushInfo": {
    "title": "OpenIM message",
    "desc": "You have a new message",
    "ex": "",
    "iOSPushSound": "default",
    "iOSBadgeCount": true,
    "signalInfo": ""
  },
  "ex": ""
}'

Request body

ParameterRequiredTypeDescription
sendIDYesstringSender user ID, including a system notification account or ordinary user.
recvIDOne-to-onestringRecipient user ID when sessionType is 1.
groupIDGroupstringTarget group ID when sessionType is 3.
senderNicknameNostringSender nickname.
senderFaceURLNostringSender avatar URL.
senderPlatformIDNointSender platform. Administrative sending normally uses 10; see PlatformID.
contentYesobjectMessage payload determined by contentType. See Message content types.
contentTypeYesintMessage content type.
sessionTypeYesintConversation type. See ConversationType.
isOnlineOnlyNobooleanWhen true, deliver online only and disable history, persistence, sender synchronization, and conversation updates.
notOfflinePushNobooleanWhen true, do not trigger offline push.
sendTimeNointSend time as a Unix timestamp in milliseconds. Use it to preserve time during migration.
offlinePushInfoNoobjectOffline push title, description, extension data, iOS sound and badge behavior, and signaling data.
exNostringMessage extension data.

For one-to-one chat, use sessionType: 1 with recvID. For group chat, use sessionType: 3 with groupID.

Response

{
  "errCode": 0,
  "errMsg": "",
  "errDlt": "",
  "data": {
    "serverMsgID": "server_msg_001",
    "clientMsgID": "client_msg_001",
    "sendTime": 1719800000000,
    "modify": null
  }
}
FieldTypeDescription
data.serverMsgIDstringServer message ID.
data.clientMsgIDstringClient message ID.
data.sendTimeintEffective send time in Unix milliseconds.
data.modifyobjectMessage data modified by a Webhook or server rule; may be null.

For migration, write messages in conversation order, preserve the original sendTime, and retain a source message ID in extension data for idempotency. Import users, groups, and relationships before messages.