POST sendMessage Send a text message
The message will be added to the queue for sending and delivered even if the phone is disconnected from the Internet or authorization is not passed.
Only one of two parameters is needed to determine the destination - chatId or phone.
https://api.replier.net/sendMessage
Parameters
| Name | Type | Description |
|---|---|---|
| instanceid required | string |
The instance sending the request. You will find it beside the instance in your dashboard.
Example:
YOUR_INSTANCE_ID
|
| token required | string |
The API token of that instance. Treat it as a secret: it authorises every call below.
Example:
YOUR_INSTANCE_TOKEN
|
| phone required | string |
A phone number starting with the country code. or the chatId
For example: 17472822486 or 17472822486 @c.us
Example:
447700900123
|
| body required | string |
Message text, UTF-8 or UTF-16 string with emoji 🍏. Can be used with mentionedPhones, example: this text for @78005553535
Example:
Hello from the API 👋
|
| options optional | string |
Optional JSON object of extra send options, for instance quotedMessageId to reply to a specific message. Send it as a JSON string on a GET or form request, or as a nested object in a JSON body.
Example:
{"quotedMessageId":"true_447700900123@c.us_3EB0A1C2D3E4F5"}
|
Request test
sends a real request
Request samples
curl --request POST \
--url 'https://api.replier.net/sendMessage' \
--data-urlencode 'instanceid=YOUR_INSTANCE_ID' \
--data-urlencode 'token=YOUR_INSTANCE_TOKEN' \
--data-urlencode 'phone=447700900123' \
--data-urlencode 'body=Hello from the API 👋' \
--data-urlencode 'options={"quotedMessageId":"true_447700900123@c.us_3EB0A1C2D3E4F5"}'
<?php
$payload = [
'instanceid' => 'YOUR_INSTANCE_ID',
'token' => 'YOUR_INSTANCE_TOKEN',
'phone' => '447700900123',
'body' => 'Hello from the API 👋',
'options' => '{"quotedMessageId":"true_447700900123@c.us_3EB0A1C2D3E4F5"}',
];
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => 'https://api.replier.net/sendMessage',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query($payload),
]);
$response = curl_exec($ch);
$error = curl_error($ch);
curl_close($ch);
if ($error !== '') {
throw new RuntimeException($error);
}
$result = json_decode($response, true);
// Every endpoint answers with {"success": bool, "msg": [...]} on failure.
if (isset($result['success']) && $result['success'] === false) {
throw new RuntimeException('API error ' . implode(', ', $result['msg']));
}
print_r($result);
import requests
url = 'https://api.replier.net/sendMessage'
payload = {
'instanceid': 'YOUR_INSTANCE_ID',
'token': 'YOUR_INSTANCE_TOKEN',
'phone': '447700900123',
'body': 'Hello from the API 👋',
'options': '{"quotedMessageId":"true_447700900123@c.us_3EB0A1C2D3E4F5"}',
}
response = requests.post(url, data=payload, timeout=30)
response.raise_for_status()
result = response.json()
if result.get('success') is False:
raise RuntimeError('API error: %s' % result.get('msg'))
print(result)
const url = 'https://api.replier.net/sendMessage';
const payload = new URLSearchParams({
instanceid: 'YOUR_INSTANCE_ID',
token: 'YOUR_INSTANCE_TOKEN',
phone: '447700900123',
body: 'Hello from the API 👋',
options: '{"quotedMessageId":"true_447700900123@c.us_3EB0A1C2D3E4F5"}',
});
const response = await fetch(url, {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: payload,
});
const result = await response.json();
if (result.success === false) {
throw new Error(`API error: ${result.msg.join(', ')}`);
}
console.log(result);
const axios = require('axios');
const payload = new URLSearchParams({
instanceid: 'YOUR_INSTANCE_ID',
token: 'YOUR_INSTANCE_TOKEN',
phone: '447700900123',
body: 'Hello from the API 👋',
options: '{"quotedMessageId":"true_447700900123@c.us_3EB0A1C2D3E4F5"}',
});
(async () => {
try {
const { data } = await axios.post('https://api.replier.net/sendMessage', payload, { timeout: 30000 });
if (data.success === false) {
throw new Error(`API error: ${data.msg.join(', ')}`);
}
console.log(data);
} catch (err) {
console.error(err.message);
}
})();
$.ajax({
url: 'https://api.replier.net/sendMessage',
method: 'POST',
data: {
instanceid: 'YOUR_INSTANCE_ID',
token: 'YOUR_INSTANCE_TOKEN',
phone: '447700900123',
body: 'Hello from the API 👋',
options: '{"quotedMessageId":"true_447700900123@c.us_3EB0A1C2D3E4F5"}',
},
dataType: 'json',
})
.done(function (result) {
if (result.success === false) {
console.error('API error: ' + result.msg.join(', '));
return;
}
console.log(result);
})
.fail(function (xhr) {
console.error(xhr.status, xhr.responseText);
});
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static readonly HttpClient client = new HttpClient();
static async Task Main()
{
var payload = new Dictionary<string, string>
{
{ "instanceid", "YOUR_INSTANCE_ID" },
{ "token", "YOUR_INSTANCE_TOKEN" },
{ "phone", "447700900123" },
{ "body", "Hello from the API 👋" },
{ "options", "{\"quotedMessageId\":\"true_447700900123@c.us_3EB0A1C2D3E4F5\"}" },
};
var response = await client.PostAsync("https://api.replier.net/sendMessage", new FormUrlEncodedContent(payload));
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
}
import java.io.IOException;
import okhttp3.*;
public class Example {
public static void main(String[] args) throws IOException {
OkHttpClient client = new OkHttpClient();
FormBody.Builder form = new FormBody.Builder();
form.add("instanceid", "YOUR_INSTANCE_ID");
form.add("token", "YOUR_INSTANCE_TOKEN");
form.add("phone", "447700900123");
form.add("body", "Hello from the API 👋");
form.add("options", "{\"quotedMessageId\":\"true_447700900123@c.us_3EB0A1C2D3E4F5\"}");
Request request = new Request.Builder()
.url("https://api.replier.net/sendMessage")
.post(form.build())
.build();
try (Response response = client.newCall(request).execute()) {
System.out.println(response.body().string());
}
}
}
require 'net/http'
require 'json'
require 'uri'
uri = URI('https://api.replier.net/sendMessage')
response = Net::HTTP.post_form(uri, {
'instanceid' => 'YOUR_INSTANCE_ID',
'token' => 'YOUR_INSTANCE_TOKEN',
'phone' => '447700900123',
'body' => 'Hello from the API 👋',
'options' => '{"quotedMessageId":"true_447700900123@c.us_3EB0A1C2D3E4F5"}',
})
result = JSON.parse(response.body)
raise "API error: #{result['msg'].join(', ')}" if result['success'] == false
puts result
package main
import (
"fmt"
"io"
"net/http"
"net/url"
"strings"
)
func main() {
form := url.Values{}
form.Set("instanceid", "YOUR_INSTANCE_ID")
form.Set("token", "YOUR_INSTANCE_TOKEN")
form.Set("phone", "447700900123")
form.Set("body", "Hello from the API 👋")
form.Set("options", "{\"quotedMessageId\":\"true_447700900123@c.us_3EB0A1C2D3E4F5\"}")
resp, err := http.Post(
"https://api.replier.net/sendMessage",
"application/x-www-form-urlencoded",
strings.NewReader(form.Encode()),
)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
panic(err)
}
fmt.Println(string(body))
}
Samples use POST with a form-encoded body so credentials stay out of the URL. The API reads JSON bodies, form bodies and query strings alike. A GET with the same parameters in the query string works too.
Response
On success:
{
"sent": true,
"id": "true_447700900123@c.us_3EB0A1C2D3E4F5",
"from": "447700900123@c.us",
"to": "447700900123@c.us",
"timestamp": 1712345678,
"type": "chat"
}
On failure, every endpoint answers with HTTP 200 and this envelope, where the string is a code from the error reference:
{
"success": false,
"msg": ["0008"]
}