curl --request POST \
--url https://api.relayapp.im/v1/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"parts": [
{
"type": "text",
"text": "<string>",
"mention": "<string>",
"mention_range": [
1
],
"styles": [
{
"start": 1,
"length": 2,
"styles": []
}
]
}
],
"chat_id": "cnv_01k1m4q9vn2r7t9b4c6qdh8xwy",
"message_id": "msg_01k1m4q9vn2r7t9b4c6qdh8xwy",
"reply_to": {
"message_id": "msg_01k1m4q9vn2r7t9b4c6qdh8xwy",
"part_id": "prt_01k1m4q9vn2r7t9b4c6qdh8xwy"
},
"text": "<string>"
}
'import requests
url = "https://api.relayapp.im/v1/messages"
payload = {
"parts": [
{
"type": "text",
"text": "<string>",
"mention": "<string>",
"mention_range": [1],
"styles": [
{
"start": 1,
"length": 2,
"styles": []
}
]
}
],
"chat_id": "cnv_01k1m4q9vn2r7t9b4c6qdh8xwy",
"message_id": "msg_01k1m4q9vn2r7t9b4c6qdh8xwy",
"reply_to": {
"message_id": "msg_01k1m4q9vn2r7t9b4c6qdh8xwy",
"part_id": "prt_01k1m4q9vn2r7t9b4c6qdh8xwy"
},
"text": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
parts: [
{
type: 'text',
text: '<string>',
mention: '<string>',
mention_range: [1],
styles: [{start: 1, length: 2, styles: []}]
}
],
chat_id: 'cnv_01k1m4q9vn2r7t9b4c6qdh8xwy',
message_id: 'msg_01k1m4q9vn2r7t9b4c6qdh8xwy',
reply_to: {
message_id: 'msg_01k1m4q9vn2r7t9b4c6qdh8xwy',
part_id: 'prt_01k1m4q9vn2r7t9b4c6qdh8xwy'
},
text: '<string>'
})
};
fetch('https://api.relayapp.im/v1/messages', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.relayapp.im/v1/messages",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'parts' => [
[
'type' => 'text',
'text' => '<string>',
'mention' => '<string>',
'mention_range' => [
1
],
'styles' => [
[
'start' => 1,
'length' => 2,
'styles' => [
]
]
]
]
],
'chat_id' => 'cnv_01k1m4q9vn2r7t9b4c6qdh8xwy',
'message_id' => 'msg_01k1m4q9vn2r7t9b4c6qdh8xwy',
'reply_to' => [
'message_id' => 'msg_01k1m4q9vn2r7t9b4c6qdh8xwy',
'part_id' => 'prt_01k1m4q9vn2r7t9b4c6qdh8xwy'
],
'text' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.relayapp.im/v1/messages"
payload := strings.NewReader("{\n \"parts\": [\n {\n \"type\": \"text\",\n \"text\": \"<string>\",\n \"mention\": \"<string>\",\n \"mention_range\": [\n 1\n ],\n \"styles\": [\n {\n \"start\": 1,\n \"length\": 2,\n \"styles\": []\n }\n ]\n }\n ],\n \"chat_id\": \"cnv_01k1m4q9vn2r7t9b4c6qdh8xwy\",\n \"message_id\": \"msg_01k1m4q9vn2r7t9b4c6qdh8xwy\",\n \"reply_to\": {\n \"message_id\": \"msg_01k1m4q9vn2r7t9b4c6qdh8xwy\",\n \"part_id\": \"prt_01k1m4q9vn2r7t9b4c6qdh8xwy\"\n },\n \"text\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.relayapp.im/v1/messages")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"parts\": [\n {\n \"type\": \"text\",\n \"text\": \"<string>\",\n \"mention\": \"<string>\",\n \"mention_range\": [\n 1\n ],\n \"styles\": [\n {\n \"start\": 1,\n \"length\": 2,\n \"styles\": []\n }\n ]\n }\n ],\n \"chat_id\": \"cnv_01k1m4q9vn2r7t9b4c6qdh8xwy\",\n \"message_id\": \"msg_01k1m4q9vn2r7t9b4c6qdh8xwy\",\n \"reply_to\": {\n \"message_id\": \"msg_01k1m4q9vn2r7t9b4c6qdh8xwy\",\n \"part_id\": \"prt_01k1m4q9vn2r7t9b4c6qdh8xwy\"\n },\n \"text\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.relayapp.im/v1/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"parts\": [\n {\n \"type\": \"text\",\n \"text\": \"<string>\",\n \"mention\": \"<string>\",\n \"mention_range\": [\n 1\n ],\n \"styles\": [\n {\n \"start\": 1,\n \"length\": 2,\n \"styles\": []\n }\n ]\n }\n ],\n \"chat_id\": \"cnv_01k1m4q9vn2r7t9b4c6qdh8xwy\",\n \"message_id\": \"msg_01k1m4q9vn2r7t9b4c6qdh8xwy\",\n \"reply_to\": {\n \"message_id\": \"msg_01k1m4q9vn2r7t9b4c6qdh8xwy\",\n \"part_id\": \"prt_01k1m4q9vn2r7t9b4c6qdh8xwy\"\n },\n \"text\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"message_id": "msg_01k1m4q9vn2r7t9b4c6qdh8xwy",
"message": {
"id": "msg_01k1m4q9vn2r7t9b4c6qdh8xwy",
"chat_id": "cnv_01k1m4q9vn2r7t9b4c6qdh8xwy",
"sequence": 123,
"item_type": 0,
"sender_handle": {
"kind": "user",
"id": "usr_01JZU1F0BD"
},
"is_from_me": true,
"parts": [
{
"type": "text",
"text": "<string>",
"part_index": 1,
"part_id": "prt_01k1m4q9vn2r7t9b4c6qdh8xwy",
"position": 1,
"mention": "<string>",
"mention_range": [
1
],
"styles": [
{
"start": 1,
"length": 2,
"styles": [
"bold"
]
}
]
}
],
"reply_to": {
"message_id": "msg_01k1m4q9vn2r7t9b4c6qdh8xwy",
"part_id": "prt_01k1m4q9vn2r7t9b4c6qdh8xwy"
},
"text": "<string>",
"status": "sent",
"created_at": "2023-11-07T05:31:56Z",
"group_action_type": 0,
"other_handle": "<string>",
"group_title": "<string>",
"is_audio_message": true,
"reactions": [
{
"target_part_id": "prt_01k1m4q9vn2r7t9b4c6qdh8xwy",
"type": "love",
"actor_kind": "user",
"actor_id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"custom_emoji": "<string>"
}
],
"delivered_at": "2023-11-07T05:31:56Z",
"read_at": "2023-11-07T05:31:56Z"
}
}{
"error": {
"code": "invalid_request",
"message": "chat_id is required"
}
}{
"error": {
"code": "invalid_request",
"message": "chat_id is required"
}
}{
"error": {
"code": "invalid_request",
"message": "chat_id is required"
}
}{
"error": {
"code": "invalid_request",
"message": "chat_id is required"
}
}{
"error": {
"code": "invalid_request",
"message": "chat_id is required"
}
}{
"error": {
"code": "invalid_request",
"message": "chat_id is required"
}
}{
"error": {
"code": "invalid_request",
"message": "chat_id is required"
}
}{
"error": {
"code": "invalid_request",
"message": "chat_id is required"
}
}Send a message
Send as the authenticated agent. One send is one message: text and media handed over together stay together as the ordered parts of a single message, and every committed part is given a permanent part_id.
message_id is the canonical id of the resulting message and the send’s idempotency key. Mint it before queueing the send: retrying with the same id replays the stored message, and an id already committed by another sender answers 409 idempotency_conflict without revealing whose it is. Omit it and Relay mints one, which makes the send non-idempotent; an Idempotency-Key header is read only when it is itself a msg_ id.
reply_to is a pointer, never a copy: it names a message of this conversation and optionally one exact part of it, and the client draws the quote from the target.
curl --request POST \
--url https://api.relayapp.im/v1/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"parts": [
{
"type": "text",
"text": "<string>",
"mention": "<string>",
"mention_range": [
1
],
"styles": [
{
"start": 1,
"length": 2,
"styles": []
}
]
}
],
"chat_id": "cnv_01k1m4q9vn2r7t9b4c6qdh8xwy",
"message_id": "msg_01k1m4q9vn2r7t9b4c6qdh8xwy",
"reply_to": {
"message_id": "msg_01k1m4q9vn2r7t9b4c6qdh8xwy",
"part_id": "prt_01k1m4q9vn2r7t9b4c6qdh8xwy"
},
"text": "<string>"
}
'import requests
url = "https://api.relayapp.im/v1/messages"
payload = {
"parts": [
{
"type": "text",
"text": "<string>",
"mention": "<string>",
"mention_range": [1],
"styles": [
{
"start": 1,
"length": 2,
"styles": []
}
]
}
],
"chat_id": "cnv_01k1m4q9vn2r7t9b4c6qdh8xwy",
"message_id": "msg_01k1m4q9vn2r7t9b4c6qdh8xwy",
"reply_to": {
"message_id": "msg_01k1m4q9vn2r7t9b4c6qdh8xwy",
"part_id": "prt_01k1m4q9vn2r7t9b4c6qdh8xwy"
},
"text": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
parts: [
{
type: 'text',
text: '<string>',
mention: '<string>',
mention_range: [1],
styles: [{start: 1, length: 2, styles: []}]
}
],
chat_id: 'cnv_01k1m4q9vn2r7t9b4c6qdh8xwy',
message_id: 'msg_01k1m4q9vn2r7t9b4c6qdh8xwy',
reply_to: {
message_id: 'msg_01k1m4q9vn2r7t9b4c6qdh8xwy',
part_id: 'prt_01k1m4q9vn2r7t9b4c6qdh8xwy'
},
text: '<string>'
})
};
fetch('https://api.relayapp.im/v1/messages', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.relayapp.im/v1/messages",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'parts' => [
[
'type' => 'text',
'text' => '<string>',
'mention' => '<string>',
'mention_range' => [
1
],
'styles' => [
[
'start' => 1,
'length' => 2,
'styles' => [
]
]
]
]
],
'chat_id' => 'cnv_01k1m4q9vn2r7t9b4c6qdh8xwy',
'message_id' => 'msg_01k1m4q9vn2r7t9b4c6qdh8xwy',
'reply_to' => [
'message_id' => 'msg_01k1m4q9vn2r7t9b4c6qdh8xwy',
'part_id' => 'prt_01k1m4q9vn2r7t9b4c6qdh8xwy'
],
'text' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.relayapp.im/v1/messages"
payload := strings.NewReader("{\n \"parts\": [\n {\n \"type\": \"text\",\n \"text\": \"<string>\",\n \"mention\": \"<string>\",\n \"mention_range\": [\n 1\n ],\n \"styles\": [\n {\n \"start\": 1,\n \"length\": 2,\n \"styles\": []\n }\n ]\n }\n ],\n \"chat_id\": \"cnv_01k1m4q9vn2r7t9b4c6qdh8xwy\",\n \"message_id\": \"msg_01k1m4q9vn2r7t9b4c6qdh8xwy\",\n \"reply_to\": {\n \"message_id\": \"msg_01k1m4q9vn2r7t9b4c6qdh8xwy\",\n \"part_id\": \"prt_01k1m4q9vn2r7t9b4c6qdh8xwy\"\n },\n \"text\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.relayapp.im/v1/messages")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"parts\": [\n {\n \"type\": \"text\",\n \"text\": \"<string>\",\n \"mention\": \"<string>\",\n \"mention_range\": [\n 1\n ],\n \"styles\": [\n {\n \"start\": 1,\n \"length\": 2,\n \"styles\": []\n }\n ]\n }\n ],\n \"chat_id\": \"cnv_01k1m4q9vn2r7t9b4c6qdh8xwy\",\n \"message_id\": \"msg_01k1m4q9vn2r7t9b4c6qdh8xwy\",\n \"reply_to\": {\n \"message_id\": \"msg_01k1m4q9vn2r7t9b4c6qdh8xwy\",\n \"part_id\": \"prt_01k1m4q9vn2r7t9b4c6qdh8xwy\"\n },\n \"text\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.relayapp.im/v1/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"parts\": [\n {\n \"type\": \"text\",\n \"text\": \"<string>\",\n \"mention\": \"<string>\",\n \"mention_range\": [\n 1\n ],\n \"styles\": [\n {\n \"start\": 1,\n \"length\": 2,\n \"styles\": []\n }\n ]\n }\n ],\n \"chat_id\": \"cnv_01k1m4q9vn2r7t9b4c6qdh8xwy\",\n \"message_id\": \"msg_01k1m4q9vn2r7t9b4c6qdh8xwy\",\n \"reply_to\": {\n \"message_id\": \"msg_01k1m4q9vn2r7t9b4c6qdh8xwy\",\n \"part_id\": \"prt_01k1m4q9vn2r7t9b4c6qdh8xwy\"\n },\n \"text\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"message_id": "msg_01k1m4q9vn2r7t9b4c6qdh8xwy",
"message": {
"id": "msg_01k1m4q9vn2r7t9b4c6qdh8xwy",
"chat_id": "cnv_01k1m4q9vn2r7t9b4c6qdh8xwy",
"sequence": 123,
"item_type": 0,
"sender_handle": {
"kind": "user",
"id": "usr_01JZU1F0BD"
},
"is_from_me": true,
"parts": [
{
"type": "text",
"text": "<string>",
"part_index": 1,
"part_id": "prt_01k1m4q9vn2r7t9b4c6qdh8xwy",
"position": 1,
"mention": "<string>",
"mention_range": [
1
],
"styles": [
{
"start": 1,
"length": 2,
"styles": [
"bold"
]
}
]
}
],
"reply_to": {
"message_id": "msg_01k1m4q9vn2r7t9b4c6qdh8xwy",
"part_id": "prt_01k1m4q9vn2r7t9b4c6qdh8xwy"
},
"text": "<string>",
"status": "sent",
"created_at": "2023-11-07T05:31:56Z",
"group_action_type": 0,
"other_handle": "<string>",
"group_title": "<string>",
"is_audio_message": true,
"reactions": [
{
"target_part_id": "prt_01k1m4q9vn2r7t9b4c6qdh8xwy",
"type": "love",
"actor_kind": "user",
"actor_id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"custom_emoji": "<string>"
}
],
"delivered_at": "2023-11-07T05:31:56Z",
"read_at": "2023-11-07T05:31:56Z"
}
}{
"error": {
"code": "invalid_request",
"message": "chat_id is required"
}
}{
"error": {
"code": "invalid_request",
"message": "chat_id is required"
}
}{
"error": {
"code": "invalid_request",
"message": "chat_id is required"
}
}{
"error": {
"code": "invalid_request",
"message": "chat_id is required"
}
}{
"error": {
"code": "invalid_request",
"message": "chat_id is required"
}
}{
"error": {
"code": "invalid_request",
"message": "chat_id is required"
}
}{
"error": {
"code": "invalid_request",
"message": "chat_id is required"
}
}{
"error": {
"code": "invalid_request",
"message": "chat_id is required"
}
}Authorizations
Agent Token (rly_live_…), shown once when the agent is created.
Headers
A legacy way to carry message_id for clients that cannot put it in the body. It is read only when it is itself a msg_ id; any other value is ignored and the server mints the id.
^msg_[0-9a-hjkmnp-tv-z]{26}$Body
The /v1 send body. Unknown fields are ignored rather than refused; /v2 refuses them.
Ordered parts of one message. An absent or empty array returns 422.
1 - 32 elements- Option 1
- Option 2
- Option 3
- Option 4
- Option 5
Show child attributes
Show child attributes
Conversation to send into, from message.received.
^cnv_"cnv_01k1m4q9vn2r7t9b4c6qdh8xwy"
The client-minted canonical id and idempotency key. Omit it and Relay mints one, which makes the send non-idempotent.
^msg_[0-9a-hjkmnp-tv-z]{26}$"msg_01k1m4q9vn2r7t9b4c6qdh8xwy"
A reply target on a send: a message of this conversation, optionally one exact part of it.
Show child attributes
Show child attributes
Optional plain-language representation for notifications and search. Relay derives one when it is absent.
Response
Send accepted; the committed message.
The canonical id, equal to message.id.
"msg_01k1m4q9vn2r7t9b4c6qdh8xwy"
One committed message. Content is immutable: there is no edit, no unsend, no version and no tombstone, so a message a client has stored never changes underneath it. Only the receipt stamps and the reactions move.
Show child attributes
Show child attributes

