Skip to content

Send Message ​

POST /public/chat/{chatId}/message

Send 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.

Supported Message Types ​

TypeDescriptionSupported Platforms
textPlain text messageFacebook, Instagram, TikTok, Telegram
imageImage fileFacebook, Instagram, Telegram
videoVideo fileFacebook, Instagram, Telegram
audioAudio fileFacebook, Instagram, Telegram
documentFile attachment, like a PDFFacebook, Telegram
buttonText or an image card with link buttonsFacebook, 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.

Endpoint Details ​

  • Authentication: Basic Auth (Authorization: Basic Base64(AccessKey:SecretKey))
  • Access Tier: Gold+

Parameters ​

ParameterTypeRequiredDescription
chatIdstringYesThe unique identifier of the chat conversation.

Request Body ​

FieldTypeRequiredDescription
typestringYesMessage type: text, image, video, audio, document, or button. It decides which of the fields below is read.
textstringFor textMessage text. With image, video, or document, Telegram sends it as the caption (see Text with media).
imageobjectFor imageThe image to send. See Image Object.
videoobjectFor videoThe video to send. See Video Object.
audioobjectFor audioThe audio file to send. See Audio Object.
documentobjectFor documentThe file to send. See Document Object.
buttonobjectFor buttonThe 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.

Text ​

json
{
  "type": "text",
  "text": "Hello there, this is from Repliz"
}

Text with Media ​

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.

Image Object ​

FieldTypeRequiredDescription
urlstringYesPublic URL of the image file.
mimetypestringYesMIME type of the image, like image/jpeg or image/png.
thumbnailstringNoSmaller preview shown in the Repliz inbox. Without it, the inbox shows url. It isn't sent to the recipient.
json
{
  "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"
  }
}

Video Object ​

FieldTypeRequiredDescription
urlstringYesPublic URL of the video file. MP4 is the safest choice.
mimetypestringYesMIME type of the video, like video/mp4.
durationnumberYesVideo length in seconds, greater than 0.
thumbnailstringNoCover image URL. The Repliz inbox shows it, and Telegram uses it as the video cover. Without it, Telegram uses the first frame.
json
{
  "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"
  }
}

Audio Object ​

FieldTypeRequiredDescription
urlstringYesPublic URL of the audio file. MP3 is the safest choice.
mimetypestringYesMIME type of the audio, like audio/mpeg.
durationnumberYesAudio length in seconds.

On Telegram, audio is sent as a regular audio file that plays in the music player, not as a voice note.

json
{
  "type": "audio",
  "audio": {
    "url": "https://storage.repliz.com/uploads/repliz-greeting.mp3",
    "duration": 12,
    "mimetype": "audio/mpeg"
  }
}

Document Object ​

FieldTypeRequiredDescription
urlstringYesPublic URL of the file.
namestringYesFile name shown in the chat, like repliz-guide.pdf. On Telegram, its extension decides the file type.
sizenumberYesFile size in kilobytes (bytes ÷ 1000), greater than 0. For example, a 245,760-byte file is 245.76.
mimetypestringYesMIME type of the file, like application/pdf.
json
{
  "type": "document",
  "document": {
    "url": "https://storage.repliz.com/uploads/repliz-guide.pdf",
    "name": "repliz-guide.pdf",
    "size": 245.76,
    "mimetype": "application/pdf"
  }
}

Button Object ​

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.

FieldTypeRequiredDescription
textstringYesText above the buttons, up to 640 characters. With image, it's the card title, so keep it to 80 characters.
imagestringNoPublic URL of an image. Turns the message into a card with this image on top.
buttonsarrayYes1 to 3 link buttons. See the table below.

Each item in buttons:

FieldTypeRequiredDescription
typestringYesAlways web_url.
titlestringYesButton label, up to 20 characters, like Visit Repliz.
urlstringYesThe link opened when the button is tapped.
json
{
  "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"
      }
    ]
  }
}
json
{
  "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.

Example Request ​

bash
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"}'
javascript
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);
javascript
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);

Response ​

json
{
  "messageId": "m_ab2lk1uLlqxSwS_E6ufOaaDllBn-ZQje_xFEJPRwKTzIXkUK_ykxcfo9GDvv26nfY0g-1zNA7K_hcSKuUZ18XA"
}
json
// 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"
}
json
// Chat Not Found
{
  "code": 404,
  "message": "chat not found"
}

// Account Not Found
{
  "code": 404,
  "message": "account not found"
}
json
{
  "code": 401,
  "message": "unauthorized"
}