logo
In-app Chat
Powered Byspreading
On this page

MessageBody Introduction

ZIM server supports developers to send different types of messages to the session through the server API, and the supported types are shown in the table below:

Message TypeMessageType ValueApplicable Conversation TypeSupports Broadcast to All Members
Text1
  • One-on-one Chat
  • Group chat
  • Room
✔️
Command2
Image11✔️
File12✔️
Audio13✔️
Video14✔️
Custom200✔️
Pop-up20Room

When you call the ZIM server interface to send messages, you need to pass the message content through the parameter MessageBody. The format of MessageBody varies depending on the message type. This article will introduce the corresponding parameters for each message type.

Text message, custom message and pop-up message

MessageBody structure 

The MessageBody structure is the same for text messages, custom messages and pop-up messages, as described below:

ParametersTypeRequired or notDescription
MessageStringYesThe message content, by default, is 2 KB. If necessary, please contact ZEGO technical support for configuration, with a maximum capacity of up to 32 KB.
ExtendedDataStringNoExtended field with a maximum length of 1 KB.
OfflinePushObjectNoOffline Push, see OfflinePush introduction for more information.
HasReceiptNumberNoMessage includes a receipt:
  • 0: No.
  • 1: Yes.
Warning

Pop-up message does not support receipts.

OfflinePush introduction (inapplicable for room messages)

ParametersTypeRequired or notDescription
EnableNumberNo

Whether to enable offline push:

  • 0:Not to push (default).
  • 1:Push.
TitleStringNoThe title of the offline push display.
ContentStringNoOffline Push Displayed Content
PayloadStringNoExtended fields allow developers to customise the behaviour after receiving an offline push message.
PushStrategyIdStringNoThe customized push strategy, which should be configured by ZEGOCLOUD techinical support.
Warning
This parameter only support when requesting to push message to all users.
PushImageInfoObjectNoImage push information.
Warning
This parameter only support when requesting to push message to all users.
ApnsObjectNoApple push extra information.
ImageStringNoThis field is used to identify the image URL pushed by APNs. When the client receives this field, the client can download the image and display it in a pop-up window.
FCMObjectNoGoogle FCM configuration.
ImageStringNoImage URL. The image size should be no more than 1 MB (megabyte).
IconStringNoIcon URL.

MessageBody example

Untitled
{
    "MessageBody": {
        "Message":"hello world",
        "ExtendedData":"extendedData",
        "OfflinePush" :{
            "Enable":0, 
            "Title":"Title",
            "Content":"Content", 
            "Payload":"data"
        },
        "HasReceipt": 1
    }
}
1
Copied!

Command message

MessageBody structure

ParametersTypeRequired or notDescription
MessageStringYes

The content of signaling messages is by default limited to 2 KB. If necessary, please contact ZEGO technical support for configuration, and the maximum limit can be extended to 32 KB.

Warning
If the message is base64 encoded, the length limit here refers to the original message length before base64 encoding.
ExtendedDataStringNoExtended field, up to 1 KB in length.
IsBase64NumberNoWhether the message is base64 encoded.
  • 0: No (default).
  • 1:Yes. After receiving this message, the ZIM server will perform base64 decoding to obtain the actual message content, and then send it to the ZIM SDK.

MessageBody example

Untitled
{
    "MessageBody": {
        "Message":"hello world",
        "ExtendedData":"extendedData",
        "IsBase64":0
    }
}
1
Copied!

Picture message

MessageBody structure

ParametersTypeRequired or notDescription
MessageStringYes

Picture message content, a JSON byte string generated according to Message structure , defaults to 2 KB. Please contact ZEGO technical support for configurations up to 32 KB if needed.

ExtendedDataStringNoExtended field, up to 1 KB in length.
OfflinePushObjectNoOffline Push, see OfflinePush introduction for more information.
HasReceiptNumberNoMessage includes a receipt:
  • 0: No.
  • 1: Yes.

Message structure

ParametersTypeRequired or notDescription
UidStringYesThe unique ID of the image, whihc is generated by the developer.
OriginObjectYesOriginal image.
UrlStringYesThe URL address of the image, with a maximum length of 500 bytes.
WidthNumberYesPicture width in pixels(px).
HeightNumberYesPicture heightin pixels(px).
FileNameStringYesFile name in the recommended format "xxx.file extension" with a maximum length of 150 bytes.
SizeNumberNoImage data size in bytes.

Message example

Untitled
{
    "Uid":"343649807833778782", 
    "Origin": {
        "Url":"https:xxx", 
        "Width":100,
        "Height":200
    },
    "FileName":"FileName.jpg", 
    "Size":1024
}
1
Copied!

MessageBody example

Untitled
{
    "MessageBody": {
        "Message":"", // The content of the image message is a JSON byte string generated according to the Message structure of the image message.
        "ExtendedData":"extendedData",
        "OfflinePush" :{
                "Enable":0, 
                "Title":"Title",
                "Content":"Content", 
                "Payload":"data"
        },
        "HasReceipt": 1
    }
}
1
Copied!

File message

MessageBody structure

ParametersTypeRequired or notDescription
MessageStringYes

The content of the file message, a JSON byte string generated according to the Message structure of the file message, defaults to 2 KB. Please contact ZEGOCLOUD technical support for configurations up to 32 KB if needed.

ExtendedDataStringNoExtended field with a maximum length of 1 KB.
OfflinePushObjectNoOffline Push, see OfflinePush introduction for more information.
HasReceiptNumberNoMessage includes a receipt:
  • 0: No.
  • 1: Yes.

Message structure

ParametersTypeRequired or notDescription
UidStringYesThe unique ID of the file. generated by the developer.
UrlStringYesThe URL address of the file, and the maximum length is 500 bytes.
FileNameStringYesFile name in the recommended format "xxx.file extension" with a maximum length of 150 bytes
SizeNumberNoFile data size in bytes.

Message example

Untitled
{
      "Uid":"343649807833778782", 
      "Url":"https:xxx", 
      "FileName":"FileName.txt", 
      "Size":1024
}
1
Copied!

MessageBody example

Untitled
{
    "MessageBody": {
        "Message":"", // The content of the file message, which is a JSON byte string generated according to the Message structure of the file message.
        "ExtendedData":"extendedData",
        "OfflinePush" :{
            "Enable":0, 
            "Title":"Title",
            "Content":"Content", 
            "Payload":"data"
        },
        "HasReceipt": 1
    }
}
1
Copied!

Audio message

MessageBody structure

ParametersTypeRequired or notDescription
MessageStringYes

The content of the video message, a JSON byte string generated according to the Message structure of the audio message, defaults to 2 KB. Please contact ZEGO technical support for configurations up to 32 KB if needed.

ExtendedDataStringNoExtended field with a maximum length of 1 KB.
OfflinePushObjectNoOffline Push, see OfflinePush introduction for more information.
HasReceiptNumberNoMessage includes a receipt:
  • 0: No.
  • 1: Yes.

Message structure

ParametersTypeRequired or notDescription
UidStringYesA unique ID for the audio. generated by the developer.
UrlStringYesURL address of the audi, and the maximum length is 500 bytes.
FileNameStringYesAudio name in the recommended format "xxx.file extension" with a maximum length of 150 bytes.
SizeNumberNoAudio data size in bytes.
MediaDurationNumberNoAudio duration in seconds.

Message example

Untitled
{
    "Uid":"343649807833778782", 
    "Url":"https:xxx", 
    "FileName":"FileName.mp3", 
    "Size":1024,
    "MediaDuration":30
}
1
Copied!

MessageBody example

Untitled
{
    "MessageBody": {
        "Message":"", // The content of the audio message, a JSON byte string generated according to the Message structure of the audio message.
        "ExtendedData":"extendedData",
        "OfflinePush" :{
            "Enable":0, 
            "Title":"Title",
            "Content":"Content", 
            "Payload":"data"
        },
        "HasReceipt": 1
    }
}
1
Copied!

Video message

MessageBody structure

ParametersTypeRequired or notDescription
MessageStringYes

Video message content, a JSON byte string generated according to Message structure defaults to 2 KB. Please contact ZEGO technical support for configurations up to 32 KB if needed.

ExtendedDataStringNoExtended field with a maximum length of 1 KB.
OfflinePushObjectNoOffline Push, see OfflinePush introduction for more information.
HasReceiptNumberNoMessage includes a receipt:
  • 0: No.
  • 1: Yes.

Message structure

ParametersTypeRequired or notDescription
UidStringYesThe unique ID of the file. generated by the developer.
UrlStringYesThe URL address of the video, the maximum length is 500 bytes.
FileNameStringYesVideo name in the recommended format "xxx.file extension" with a maximum length of 150 bytes.
SizeNumberNoVideo data size, measured in bytes.
MediaDurationNumberNoVideo duration in seconds.
ThumbnailObjectNoVideo first frame.
UrlStringYes(Only if the first frame of the video is required)The URL address of the thumbnail, the maximum length is 500 bytes.
WidthNumberYes(Only if the first frame of the video is required)Picture width in pixels(px).
HeightNumberYes(Only if the first frame of the video is required)Picture height in pixels(px).

Message example

Untitled
{
    "Uid":"343649807833778782", 
    "Url":"https:xxx", 
    "FileName":"FileName.mp4", 
    "Size":1024,
    "MediaDuration":300,
    "Thumbnail": {
        "Url":"https:xxx", 
        "Width":100,
        "Height":200
    }
}
1
Copied!

MessageBody example

Untitled
{
    "MessageBody": {
        "Message":"", // The content of the video message as a JSON byte string generated from the Message structure of the audio message.
        "ExtendedData":"extendedData",
        "OfflinePush" :{
            "Enable":0, 
            "Title":"Title",
            "Content":"Content", 
            "Payload":"data"
        },
        "HasReceipt": 1
    }
}
1
Copied!

Previous

Import group messages

Next

Send a call invitation