English
English
Appearance
English
English
Appearance
/public/chat/{chatId}/messageSend a new message in a chat conversation. The message can be text, an image, a video, an audio file, a document, or text with link buttons.
| Type | Description | Supported Platforms |
|---|---|---|
text | Plain text message | Facebook, Instagram, TikTok, Telegram |
image | Image file | Facebook, Instagram, Telegram |
video | Video file | Facebook, Instagram, Telegram |
audio | Audio file | Facebook, Instagram, Telegram |
document | File attachment, like a PDF | Facebook, Telegram |
button | Text or an image card with link buttons | Facebook, Instagram |
The platform is the one of the account the chat belongs to. Sending a type that platform doesn't support returns 400 invalid type message.
Authorization: Basic Base64(AccessKey:SecretKey))| Parameter | Type | Required | Description |
|---|---|---|---|
chatId | string | Yes | The unique identifier of the chat conversation. |
| Field | Type | Required | Description |
|---|---|---|---|
type | string | Yes | Message type: text, image, video, audio, document, or button. It decides which of the fields below is read. |
text | string | For text | Message text. With image, video, or document, Telegram sends it as the caption (see Text with media). |
image | object | For image | The image to send. See Image Object. |
video | object | For video | The video to send. See Video Object. |
audio | object | For audio | The audio file to send. See Audio Object. |
document | object | For document | The file to send. See Document Object. |
button | object | For button | The text and its link buttons. See Button Object. The text goes in button.text, not in text. |
Media is sent by URL
The url of an image, video, audio, or document must be public and point straight at the file, because the platform downloads the file from it. You can host the file in Repliz Storage, see the Storage Upload guide.
{
"type": "text",
"text": "Hello there, this is from Repliz"
}Only Telegram sends text together with an image, video, or document, as its caption. Audio on Telegram has no caption, and Facebook and Instagram send the file without any text. To send text with a file on every platform, send it as its own text message first, then the file. The Repliz inbox does the same.
| Field | Type | Required | Description |
|---|---|---|---|
url | string | Yes | Public URL of the image file. |
mimetype | string | Yes | MIME type of the image, like image/jpeg or image/png. |
thumbnail | string | No | Smaller preview shown in the Repliz inbox. Without it, the inbox shows url. It isn't sent to the recipient. |
{
"type": "image",
"image": {
"url": "https://storage.repliz.com/uploads/repliz-dashboard.png",
"thumbnail": "https://storage.repliz.com/uploads/repliz-dashboard-thumbnail.png",
"mimetype": "image/png"
}
}| Field | Type | Required | Description |
|---|---|---|---|
url | string | Yes | Public URL of the video file. MP4 is the safest choice. |
mimetype | string | Yes | MIME type of the video, like video/mp4. |
duration | number | Yes | Video length in seconds, greater than 0. |
thumbnail | string | No | Cover image URL. The Repliz inbox shows it, and Telegram uses it as the video cover. Without it, Telegram uses the first frame. |
{
"type": "video",
"video": {
"url": "https://storage.repliz.com/uploads/repliz-tutorial.mp4",
"thumbnail": "https://storage.repliz.com/uploads/repliz-tutorial-thumbnail.jpg",
"duration": 45,
"mimetype": "video/mp4"
}
}| Field | Type | Required | Description |
|---|---|---|---|
url | string | Yes | Public URL of the audio file. MP3 is the safest choice. |
mimetype | string | Yes | MIME type of the audio, like audio/mpeg. |
duration | number | Yes | Audio length in seconds. |
On Telegram, audio is sent as a regular audio file that plays in the music player, not as a voice note.
{
"type": "audio",
"audio": {
"url": "https://storage.repliz.com/uploads/repliz-greeting.mp3",
"duration": 12,
"mimetype": "audio/mpeg"
}
}| Field | Type | Required | Description |
|---|---|---|---|
url | string | Yes | Public URL of the file. |
name | string | Yes | File name shown in the chat, like repliz-guide.pdf. On Telegram, its extension decides the file type. |
size | number | Yes | File size in kilobytes (bytes ÷ 1000), greater than 0. For example, a 245,760-byte file is 245.76. |
mimetype | string | Yes | MIME type of the file, like application/pdf. |
{
"type": "document",
"document": {
"url": "https://storage.repliz.com/uploads/repliz-guide.pdf",
"name": "repliz-guide.pdf",
"size": 245.76,
"mimetype": "application/pdf"
}
}Sends a text with link buttons below it. With image, the message is sent as a card instead: the image on top, text as the card title, and the buttons below.
| Field | Type | Required | Description |
|---|---|---|---|
text | string | Yes | Text above the buttons, up to 640 characters. With image, it's the card title, so keep it to 80 characters. |
image | string | No | Public URL of an image. Turns the message into a card with this image on top. |
buttons | array | Yes | 1 to 3 link buttons. See the table below. |
Each item in buttons:
| Field | Type | Required | Description |
|---|---|---|---|
type | string | Yes | Always web_url. |
title | string | Yes | Button label, up to 20 characters, like Visit Repliz. |
url | string | Yes | The link opened when the button is tapped. |
{
"type": "button",
"button": {
"text": "Hello there, this is from Repliz",
"buttons": [
{
"type": "web_url",
"title": "Visit Repliz",
"url": "https://repliz.com"
},
{
"type": "web_url",
"title": "Read the Docs",
"url": "https://docs.repliz.com"
}
]
}
}{
"type": "button",
"button": {
"text": "Manage every account from one Repliz inbox",
"image": "https://storage.repliz.com/uploads/repliz-dashboard.png",
"buttons": [
{
"type": "web_url",
"title": "Try Repliz",
"url": "https://repliz.com"
}
]
}
}The buttons aren't saved in the Repliz inbox. Get Message returns a button message as a text message, or as an image message when image is set.
curl -X POST "https://api.repliz.com/public/chat/680affa5ce12f2f72916f67e/message" \
-H "Authorization: Basic $(echo -n 'YOUR_ACCESS_KEY:YOUR_SECRET_KEY' | base64)" \
-H "Content-Type: application/json" \
-d '{"type":"text","text":"Hello there, this is from Repliz"}'import axios from 'axios';
const chatId = '680affa5ce12f2f72916f67e';
const response = await axios.post(
`https://api.repliz.com/public/chat/${chatId}/message`,
{
type: 'text',
text: 'Hello there, this is from Repliz',
},
{
auth: {
username: 'YOUR_ACCESS_KEY',
password: 'YOUR_SECRET_KEY',
},
},
);
console.log(response.data);const credentials = btoa('YOUR_ACCESS_KEY:YOUR_SECRET_KEY');
const chatId = '680affa5ce12f2f72916f67e';
const response = await fetch(
`https://api.repliz.com/public/chat/${chatId}/message`,
{
method: 'POST',
headers: {
Authorization: `Basic ${credentials}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
type: 'text',
text: 'Hello there, this is from Repliz',
}),
},
);
const data = await response.json();
console.log(data);{
"messageId": "m_ab2lk1uLlqxSwS_E6ufOaaDllBn-ZQje_xFEJPRwKTzIXkUK_ykxcfo9GDvv26nfY0g-1zNA7K_hcSKuUZ18XA"
}// Type Not Supported by the Platform
{
"code": 400,
"message": "invalid type message"
}
// Object for the Type Is Missing
{
"code": 400,
"message": "image should not be empty"
}// Chat Not Found
{
"code": 404,
"message": "chat not found"
}
// Account Not Found
{
"code": 404,
"message": "account not found"
}{
"code": 401,
"message": "unauthorized"
}