curl --request POST \
--url https://api.relayapp.im/v2/chats/{chat_id}/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"message_id": "msg_01k1m4q9vn2r7t9b4c6qdh8xwy",
"parts": [
{
"type": "text",
"text": "<string>",
"mention": "<string>",
"mention_range": [
1
],
"styles": [
{
"start": 1,
"length": 2,
"styles": []
}
]
}
],
"reply_to": {
"message_id": "msg_01k1m4q9vn2r7t9b4c6qdh8xwy",
"part_id": "prt_01k1m4q9vn2r7t9b4c6qdh8xwy"
},
"text": "<string>"
}
'import requests
url = "https://api.relayapp.im/v2/chats/{chat_id}/messages"
payload = {
"message_id": "msg_01k1m4q9vn2r7t9b4c6qdh8xwy",
"parts": [
{
"type": "text",
"text": "<string>",
"mention": "<string>",
"mention_range": [1],
"styles": [
{
"start": 1,
"length": 2,
"styles": []
}
]
}
],
"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({
message_id: 'msg_01k1m4q9vn2r7t9b4c6qdh8xwy',
parts: [
{
type: 'text',
text: '<string>',
mention: '<string>',
mention_range: [1],
styles: [{start: 1, length: 2, styles: []}]
}
],
reply_to: {
message_id: 'msg_01k1m4q9vn2r7t9b4c6qdh8xwy',
part_id: 'prt_01k1m4q9vn2r7t9b4c6qdh8xwy'
},
text: '<string>'
})
};
fetch('https://api.relayapp.im/v2/chats/{chat_id}/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/v2/chats/{chat_id}/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([
'message_id' => 'msg_01k1m4q9vn2r7t9b4c6qdh8xwy',
'parts' => [
[
'type' => 'text',
'text' => '<string>',
'mention' => '<string>',
'mention_range' => [
1
],
'styles' => [
[
'start' => 1,
'length' => 2,
'styles' => [
]
]
]
]
],
'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/v2/chats/{chat_id}/messages"
payload := strings.NewReader("{\n \"message_id\": \"msg_01k1m4q9vn2r7t9b4c6qdh8xwy\",\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 \"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/v2/chats/{chat_id}/messages")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"message_id\": \"msg_01k1m4q9vn2r7t9b4c6qdh8xwy\",\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 \"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/v2/chats/{chat_id}/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 \"message_id\": \"msg_01k1m4q9vn2r7t9b4c6qdh8xwy\",\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 \"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",
"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 one message
The current send. One send is one message, the response is the message on its own, and the request body is validated strictly: any field outside message_id, parts, reply_to and text answers 422.
The client mints message_id before queueing the send. It is the canonical id and the idempotency key: retrying with the same id and the same request replays the original 201, and an id already taken by another sender answers 409 idempotency_conflict without revealing whose it is. No Idempotency-Key header is involved, and unlike /v1 the id is required.
curl --request POST \
--url https://api.relayapp.im/v2/chats/{chat_id}/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"message_id": "msg_01k1m4q9vn2r7t9b4c6qdh8xwy",
"parts": [
{
"type": "text",
"text": "<string>",
"mention": "<string>",
"mention_range": [
1
],
"styles": [
{
"start": 1,
"length": 2,
"styles": []
}
]
}
],
"reply_to": {
"message_id": "msg_01k1m4q9vn2r7t9b4c6qdh8xwy",
"part_id": "prt_01k1m4q9vn2r7t9b4c6qdh8xwy"
},
"text": "<string>"
}
'import requests
url = "https://api.relayapp.im/v2/chats/{chat_id}/messages"
payload = {
"message_id": "msg_01k1m4q9vn2r7t9b4c6qdh8xwy",
"parts": [
{
"type": "text",
"text": "<string>",
"mention": "<string>",
"mention_range": [1],
"styles": [
{
"start": 1,
"length": 2,
"styles": []
}
]
}
],
"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({
message_id: 'msg_01k1m4q9vn2r7t9b4c6qdh8xwy',
parts: [
{
type: 'text',
text: '<string>',
mention: '<string>',
mention_range: [1],
styles: [{start: 1, length: 2, styles: []}]
}
],
reply_to: {
message_id: 'msg_01k1m4q9vn2r7t9b4c6qdh8xwy',
part_id: 'prt_01k1m4q9vn2r7t9b4c6qdh8xwy'
},
text: '<string>'
})
};
fetch('https://api.relayapp.im/v2/chats/{chat_id}/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/v2/chats/{chat_id}/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([
'message_id' => 'msg_01k1m4q9vn2r7t9b4c6qdh8xwy',
'parts' => [
[
'type' => 'text',
'text' => '<string>',
'mention' => '<string>',
'mention_range' => [
1
],
'styles' => [
[
'start' => 1,
'length' => 2,
'styles' => [
]
]
]
]
],
'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/v2/chats/{chat_id}/messages"
payload := strings.NewReader("{\n \"message_id\": \"msg_01k1m4q9vn2r7t9b4c6qdh8xwy\",\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 \"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/v2/chats/{chat_id}/messages")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"message_id\": \"msg_01k1m4q9vn2r7t9b4c6qdh8xwy\",\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 \"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/v2/chats/{chat_id}/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 \"message_id\": \"msg_01k1m4q9vn2r7t9b4c6qdh8xwy\",\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 \"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",
"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.
Path Parameters
^cnv_[0-9a-hjkmnp-tv-z]{26}$Body
The client mints this before queueing the send: a lowercase Crockford base32 ULID with a msg_ prefix. It is the canonical id of the resulting message and the send's idempotency key, and unlike /v1 it is required.
^msg_[0-9a-hjkmnp-tv-z]{26}$"msg_01k1m4q9vn2r7t9b4c6qdh8xwy"
Ordered parts of one message.
1 - 32 elements- Option 1
- Option 2
- Option 3
- Option 4
- Option 5
Show child attributes
Show child attributes
A reply target on a send: a message of this conversation, optionally one exact part of it.
Show child attributes
Show child attributes
Plain-language representation for notifications and search.
Response
The committed message.
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

