RCS Message
Send RCS messages with Messente's Omnichannel API.
RCS account setup required
Sending RCS messages requires us to prepare your account with a dedicated RCS setup. For more details, contact us at support@messente.com.
tip
The easiest way to use Omnichannel API is with our official libraries. Libraries will take care of authentication, request validation and response handling.
Send an RCS Message
Use the following example to send a simple RCS text message using Omnichannel API.
- Python
- Node
- PHP
- Java
- Ruby
- .NET
- cURL
from pprint import pprint
from messente_api import (
OmnimessageApi,
Omnimessage,
Configuration,
ApiClient,
Rcs,
OmnimessageMessagesInner,
)
from messente_api.rest import ApiException
configuration = Configuration(
username="YOUR_MESSENTE_API_USERNAME",
password="YOUR_MESSENTE_API_PASSWORD",
)
api_instance = OmnimessageApi(ApiClient(configuration))
# Build the RCS message payload
rcs = Rcs(
sender='<sender name (optional)>',
text="hello, world!"
)
omnimessage = Omnimessage(
to='<recipient_phone_number>',
messages=[OmnimessageMessagesInner(rcs)],
)
try:
# Send the omnimessage
response = api_instance.send_omnimessage(omnimessage)
print(
"Successfully sent Omnimessage with id: %s that consists of the following messages:"
% response.omnimessage_id
)
for message in response.messages:
pprint(message)
except ApiException as exception:
print("Exception while sending the Omnimessage: %s\n" % exception)
const MessenteApi = require("messente_api");
const defaultClient = MessenteApi.ApiClient.instance;
const basicAuth = defaultClient.authentications["basicAuth"];
basicAuth.username = "YOUR_MESSENTE_API_USERNAME";
basicAuth.password = "YOUR_MESSENTE_API_PASSWORD";
const api = new MessenteApi.OmnimessageApi();
const rcs = MessenteApi.Rcs.constructFromObject({
sender: "<sender name (optional)>",
text: "Hello, world!"
});
const omnimessage = MessenteApi.Omnimessage.constructFromObject({
messages: [rcs],
to: "<recipient_phone_number>",
});
api.sendOmnimessage(omnimessage, (error, data) => {
if (error) {
console.error(error);
} else {
console.log("API called successfully. Returned data: ", data);
}
});
<?php
require_once(__DIR__ . '/vendor/autoload.php');
use Messente\Api\Api\OmnimessageApi;
use Messente\Api\Model\Omnimessage;
use Messente\Api\Configuration;
use Messente\Api\Model\Rcs;
$config = Configuration::getDefaultConfiguration()
->setUsername('YOUR_MESSENTE_API_USERNAME')
->setPassword('YOUR_MESSENTE_API_PASSWORD');
$apiInstance = new OmnimessageApi(
new GuzzleHttp\Client(),
$config
);
$rcs = new Rcs([
'sender' => 'YOUR_SENDER_NAME (optional)',
'text' => 'Hello, world!',
]);
$omnimessage = new Omnimessage([
'to' => 'RECIPIENT_PHONE_NUMBER',
]);
$omnimessage->setMessages([$rcs]);
try {
$result = $apiInstance->sendOmnimessage($omnimessage);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling sendOmnimessage: ', $e->getMessage(), PHP_EOL;
}
package org.example;
import com.messente.ApiClient;
import com.messente.ApiException;
import com.messente.api.*;
import com.messente.auth.HttpBasicAuth;
import java.util.List;
public class SendRcsTextMessage {
public static void main(String[] args) {
ApiClient apiClient = new ApiClient();
OmnimessageApi apiInstance = new OmnimessageApi(apiClient);
HttpBasicAuth basicAuth = (HttpBasicAuth) apiClient.getAuthentication("basicAuth");
basicAuth.setUsername("YOUR_MESSENTE_API_USERNAME");
basicAuth.setPassword("YOUR_MESSENTE_API_PASSWORD");
Rcs rcs = new Rcs();
rcs.setSender("<sender name(optional)>");
rcs.setText("Hello, World!");
OmnimessageMessagesInner rcsOmnimessageInner = new OmnimessageMessagesInner(rcs);
rcsOmnimessageInner.setActualInstance(rcs);
Omnimessage omnimessage = new Omnimessage();
omnimessage.setMessages(List.of(rcsOmnimessageInner));
omnimessage.setTo("<recipient_phone_number>");
try {
OmniMessageCreateSuccessResponse result = apiInstance.sendOmnimessage(omnimessage);
System.out.println(result);
} catch (ApiException e) {
System.err.println(e.getResponseBody());
}
}
}
require 'messente_api'
MessenteApi.configure do |config|
config.username = 'YOUR_MESSENTE_API_USERNAME'
config.password = 'YOUR_MESSENTE_API_PASSWORD'
end
api_instance = MessenteApi::OmnimessageApi.new
text_message = MessenteApi::Rcs.new(
sender: 'YOUR_SENDER_NAME (optional)',
text: 'Hello, world!'
)
omnimessage = MessenteApi::Omnimessage.new(
to: 'RECIPIENT_PHONE_NUMBER',
messages: [text_message]
)
begin
result = api_instance.send_omnimessage(omnimessage)
puts result
rescue MessenteApi::ApiError => e
puts "Exception when calling send_omnimessage: #{e}"
puts e.response_body
end
using com.Messente.Api.Api;
using com.Messente.Api.Client;
using com.Messente.Api.Model;
namespace SendRcsTextMessageExample
{
public class SendRcsTextMessageExample
{
public static void Main()
{
var conf = new Configuration
{
Username = "YOUR_MESSENTE_API_USERNAME",
Password = "YOUR_MESSENTE_API_PASSWORD",
};
var apiInstance = new OmnimessageApi(conf);
var rcs = new Rcs(
sender: "YOUR_SENDER_NAME (optional)",
text: "Hello, world!"
);
var rcsOmnimessageInner = new OmnimessageMessagesInner(rcs)
{
ActualInstance = rcs
};
var omnimessage = new Omnimessage(
to: "RECIPIENT_PHONE_NUMBER",
messages: new List<OmnimessageMessagesInner> { rcsOmnimessageInner }
);
try
{
var result = apiInstance.SendOmnimessage(omnimessage);
Console.WriteLine(result.ToJson());
}
catch (Exception e)
{
Console.WriteLine("Exception when calling SendOmnimessage: " + e.Message);
}
}
}
}
curl -X POST "https://api.messente.com/v1/omnimessage" \
-u YOUR_MESSENTE_API_USERNAME:YOUR_MESSENTE_API_PASSWORD \
-H "Content-Type: application/json" \
-d '{
"to": "<recipient_phone_number>",
"messages": [
{
"channel": "rcs",
"sender": "<sender name (optional)>",
"text": "Hello, world!"
}
]
}'
Response
The API will return a response with an omnimessage_id, as well as a message_id for each "sub-message" (fallback channel). You can use these IDs to track the delivery status of the message.
{
"messages": [
{
"channel": "rcs",
"message_id": "fr593ce7-68de-5e44-bc50-044a3ad0a7fa",
"sender": "SENDER_ID"
}
],
"omnimessage_id": "632c6f3d-49d0-4a8f-5k2n-74023d31e51d",
"to": "RECIPIENT_PHONE_NUMBER"
}
Error example
{
"errors": [
{
"code": "105",
"detail": "Invalid or disallowed sender",
"source": "payload[rcs][sender]",
"title": "Invalid data"
}
]
}
| title | Error message |
|---|---|
| detail | Longer description of the error message |
| source | Location in the request body for this error message |
| code | Machine-readable error code: 101 - Not found 102 - Forbidden 103 - Unauthorized 104 - Internal Server Error 105 - Invalid data 106 - Missing data 107 - Method not allowed |