Create a new chat
curl --request POST \
--url https://api.relayapp.im/v1/chats \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"from": "<string>",
"to": [
"<string>"
],
"message": {
"parts": [
{
"type": "text",
"value": "<string>",
"mention": "<string>",
"mention_range": "<array>"
}
],
"idempotency_key": "<string>"
}
}
'import requests
url = "https://api.relayapp.im/v1/chats"
payload = {
"from": "<string>",
"to": ["<string>"],
"message": {
"parts": [
{
"type": "text",
"value": "<string>",
"mention": "<string>",
"mention_range": "<array>"
}
],
"idempotency_key": "<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({
from: '<string>',
to: ['<string>'],
message: {
parts: [
{type: 'text', value: '<string>', mention: '<string>', mention_range: '<array>'}
],
idempotency_key: '<string>'
}
})
};
fetch('https://api.relayapp.im/v1/chats', 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/chats",
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([
'from' => '<string>',
'to' => [
'<string>'
],
'message' => [
'parts' => [
[
'type' => 'text',
'value' => '<string>',
'mention' => '<string>',
'mention_range' => '<array>'
]
],
'idempotency_key' => '<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/chats"
payload := strings.NewReader("{\n \"from\": \"<string>\",\n \"to\": [\n \"<string>\"\n ],\n \"message\": {\n \"parts\": [\n {\n \"type\": \"text\",\n \"value\": \"<string>\",\n \"mention\": \"<string>\",\n \"mention_range\": \"<array>\"\n }\n ],\n \"idempotency_key\": \"<string>\"\n }\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/chats")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"from\": \"<string>\",\n \"to\": [\n \"<string>\"\n ],\n \"message\": {\n \"parts\": [\n {\n \"type\": \"text\",\n \"value\": \"<string>\",\n \"mention\": \"<string>\",\n \"mention_range\": \"<array>\"\n }\n ],\n \"idempotency_key\": \"<string>\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.relayapp.im/v1/chats")
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 \"from\": \"<string>\",\n \"to\": [\n \"<string>\"\n ],\n \"message\": {\n \"parts\": [\n {\n \"type\": \"text\",\n \"value\": \"<string>\",\n \"mention\": \"<string>\",\n \"mention_range\": \"<array>\"\n }\n ],\n \"idempotency_key\": \"<string>\"\n }\n}"
response = http.request(request)
puts response.read_body{
"chat": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"display_name": "<string>",
"is_group": true,
"handles": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"handle": "<string>",
"joined_at": "2023-11-07T05:31:56Z",
"status": "active",
"left_at": "2023-11-07T05:31:56Z",
"is_me": true,
"kind": "user",
"display_name": "<string>",
"avatar_url": "<string>"
}
],
"message": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"parts": [
{
"type": "text",
"value": "<string>",
"reactions": [
{
"is_me": true,
"handle": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"handle": "<string>",
"joined_at": "2023-11-07T05:31:56Z",
"status": "active",
"left_at": "2023-11-07T05:31:56Z",
"is_me": true,
"kind": "user",
"display_name": "<string>",
"avatar_url": "<string>"
},
"type": "love",
"custom_emoji": "<string>"
}
],
"mention": "<string>",
"mention_range": "<array>"
}
],
"created_at": "2023-11-07T05:31:56Z",
"sent_at": "2023-11-07T05:31:56Z",
"delivery_status": "sent",
"delivered_at": "2023-11-07T05:31:56Z",
"from_handle": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"handle": "<string>",
"joined_at": "2023-11-07T05:31:56Z",
"status": "active",
"left_at": "2023-11-07T05:31:56Z",
"is_me": true,
"kind": "user",
"display_name": "<string>",
"avatar_url": "<string>"
},
"reply_to": {
"message_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"part_index": 1
}
}
}
}{
"error": {
"status": 123,
"code": 123,
"message": "<string>",
"doc_url": "<string>",
"retry_after": 123
},
"success": true,
"trace_id": "<string>"
}{
"error": {
"status": 123,
"code": 123,
"message": "<string>",
"doc_url": "<string>",
"retry_after": 123
},
"success": true,
"trace_id": "<string>"
}{
"error": {
"status": 123,
"code": 123,
"message": "<string>",
"doc_url": "<string>",
"retry_after": 123
},
"success": true,
"trace_id": "<string>"
}{
"error": {
"status": 123,
"code": 123,
"message": "<string>",
"doc_url": "<string>",
"retry_after": 123
},
"success": true,
"trace_id": "<string>"
}{
"error": {
"status": 123,
"code": 123,
"message": "<string>",
"doc_url": "<string>",
"retry_after": 123
},
"success": true,
"trace_id": "<string>"
}Chats
Create a new chat
Create a direct or group Chat with its first Message.
POST
/
v1
/
chats
Create a new chat
curl --request POST \
--url https://api.relayapp.im/v1/chats \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"from": "<string>",
"to": [
"<string>"
],
"message": {
"parts": [
{
"type": "text",
"value": "<string>",
"mention": "<string>",
"mention_range": "<array>"
}
],
"idempotency_key": "<string>"
}
}
'import requests
url = "https://api.relayapp.im/v1/chats"
payload = {
"from": "<string>",
"to": ["<string>"],
"message": {
"parts": [
{
"type": "text",
"value": "<string>",
"mention": "<string>",
"mention_range": "<array>"
}
],
"idempotency_key": "<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({
from: '<string>',
to: ['<string>'],
message: {
parts: [
{type: 'text', value: '<string>', mention: '<string>', mention_range: '<array>'}
],
idempotency_key: '<string>'
}
})
};
fetch('https://api.relayapp.im/v1/chats', 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/chats",
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([
'from' => '<string>',
'to' => [
'<string>'
],
'message' => [
'parts' => [
[
'type' => 'text',
'value' => '<string>',
'mention' => '<string>',
'mention_range' => '<array>'
]
],
'idempotency_key' => '<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/chats"
payload := strings.NewReader("{\n \"from\": \"<string>\",\n \"to\": [\n \"<string>\"\n ],\n \"message\": {\n \"parts\": [\n {\n \"type\": \"text\",\n \"value\": \"<string>\",\n \"mention\": \"<string>\",\n \"mention_range\": \"<array>\"\n }\n ],\n \"idempotency_key\": \"<string>\"\n }\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/chats")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"from\": \"<string>\",\n \"to\": [\n \"<string>\"\n ],\n \"message\": {\n \"parts\": [\n {\n \"type\": \"text\",\n \"value\": \"<string>\",\n \"mention\": \"<string>\",\n \"mention_range\": \"<array>\"\n }\n ],\n \"idempotency_key\": \"<string>\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.relayapp.im/v1/chats")
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 \"from\": \"<string>\",\n \"to\": [\n \"<string>\"\n ],\n \"message\": {\n \"parts\": [\n {\n \"type\": \"text\",\n \"value\": \"<string>\",\n \"mention\": \"<string>\",\n \"mention_range\": \"<array>\"\n }\n ],\n \"idempotency_key\": \"<string>\"\n }\n}"
response = http.request(request)
puts response.read_body{
"chat": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"display_name": "<string>",
"is_group": true,
"handles": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"handle": "<string>",
"joined_at": "2023-11-07T05:31:56Z",
"status": "active",
"left_at": "2023-11-07T05:31:56Z",
"is_me": true,
"kind": "user",
"display_name": "<string>",
"avatar_url": "<string>"
}
],
"message": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"parts": [
{
"type": "text",
"value": "<string>",
"reactions": [
{
"is_me": true,
"handle": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"handle": "<string>",
"joined_at": "2023-11-07T05:31:56Z",
"status": "active",
"left_at": "2023-11-07T05:31:56Z",
"is_me": true,
"kind": "user",
"display_name": "<string>",
"avatar_url": "<string>"
},
"type": "love",
"custom_emoji": "<string>"
}
],
"mention": "<string>",
"mention_range": "<array>"
}
],
"created_at": "2023-11-07T05:31:56Z",
"sent_at": "2023-11-07T05:31:56Z",
"delivery_status": "sent",
"delivered_at": "2023-11-07T05:31:56Z",
"from_handle": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"handle": "<string>",
"joined_at": "2023-11-07T05:31:56Z",
"status": "active",
"left_at": "2023-11-07T05:31:56Z",
"is_me": true,
"kind": "user",
"display_name": "<string>",
"avatar_url": "<string>"
},
"reply_to": {
"message_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"part_index": 1
}
}
}
}{
"error": {
"status": 123,
"code": 123,
"message": "<string>",
"doc_url": "<string>",
"retry_after": 123
},
"success": true,
"trace_id": "<string>"
}{
"error": {
"status": 123,
"code": 123,
"message": "<string>",
"doc_url": "<string>",
"retry_after": 123
},
"success": true,
"trace_id": "<string>"
}{
"error": {
"status": 123,
"code": 123,
"message": "<string>",
"doc_url": "<string>",
"retry_after": 123
},
"success": true,
"trace_id": "<string>"
}{
"error": {
"status": 123,
"code": 123,
"message": "<string>",
"doc_url": "<string>",
"retry_after": 123
},
"success": true,
"trace_id": "<string>"
}{
"error": {
"status": 123,
"code": 123,
"message": "<string>",
"doc_url": "<string>",
"retry_after": 123
},
"success": true,
"trace_id": "<string>"
}Authorizations
Bearer token authentication. Include your API token in the Authorization header.
Format: Authorization: Bearer <your-token>
Headers
Optional 1–255 character key for safe retries. If message.idempotency_key is also present, the two values must match.
Required string length:
1 - 255Body
application/json
Authenticated sender's Relay Handle.
Required array length:
1 - 31 elementsInitial message for the new chat.
First outbound message link restriction: The initial message cannot be a link. A
request is rejected with 400 (error code 1005) if it includes a link
part or any text part containing a URL. Follow-up messages via
POST /v1/chats/{chatId}/messages may contain links.
Show child attributes
Show child attributes
Response
Chat created successfully
Response for creating a new chat with an initial message
Show child attributes
Show child attributes

