Edit a message
curl --request PATCH \
--url https://api.relayapp.im/v1/messages/{message_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"parts": [
{
"type": "<string>",
"text": "<string>"
}
]
}
'import requests
url = "https://api.relayapp.im/v1/messages/{message_id}"
payload = { "parts": [
{
"type": "<string>",
"text": "<string>"
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({parts: [{type: '<string>', text: '<string>'}]})
};
fetch('https://api.relayapp.im/v1/messages/{message_id}', 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/{message_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'parts' => [
[
'type' => '<string>',
'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/{message_id}"
payload := strings.NewReader("{\n \"parts\": [\n {\n \"type\": \"<string>\",\n \"text\": \"<string>\"\n }\n ]\n}")
req, _ := http.NewRequest("PATCH", 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.patch("https://api.relayapp.im/v1/messages/{message_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"parts\": [\n {\n \"type\": \"<string>\",\n \"text\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.relayapp.im/v1/messages/{message_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"parts\": [\n {\n \"type\": \"<string>\",\n \"text\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"message": {
"id": "msg_01JZM3T8AH",
"conversation_id": "cnv_01JZC7K4RQ",
"sequence": 123,
"sender": {
"id": "usr_01JZU1F0BD"
},
"parts": [
{
"part_index": 1,
"type": "<string>",
"text": "<string>"
}
],
"fallback_text": "<string>",
"status": "sent",
"edited_at": "2023-11-07T05:31:56Z",
"revisions": [
{
"parts": [
{
"part_index": 1,
"type": "<string>",
"text": "<string>"
}
],
"fallback_text": "<string>",
"replaced_at": "2023-11-07T05:31:56Z"
}
],
"created_at": "2023-11-07T05:31:56Z",
"reply_to": {
"message_id": "msg_01JZM3T8AH",
"part_index": 0
},
"invoked_agents": [
"<string>"
],
"suggestions": [
{
"text": "Everyone"
}
],
"reactions": [
{
"part_index": 1,
"emoji": "<string>",
"actor_id": "<string>"
}
],
"delivered_at": "2023-11-07T05:31:56Z",
"read_at": "2023-11-07T05:31:56Z"
}
}{
"error": {
"code": "invalid_request",
"message": "conversation_id is required"
}
}{
"error": {
"code": "invalid_request",
"message": "conversation_id is required"
}
}{
"error": {
"code": "invalid_request",
"message": "conversation_id is required"
}
}{
"error": {
"code": "invalid_request",
"message": "conversation_id is required"
}
}Messages
Edit a message
Replace the authenticated sender’s message parts without changing its conversation sequence. User-sent messages require that user’s session. Agent-sent messages require that agent’s token. Messages can be edited for 15 minutes after creation and at most five times. Both the stored message and replacement must be text-bearing and cannot contain attachment parts. Relay does not send a push notification for edits.
PATCH
/
v1
/
messages
/
{message_id}
Edit a message
curl --request PATCH \
--url https://api.relayapp.im/v1/messages/{message_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"parts": [
{
"type": "<string>",
"text": "<string>"
}
]
}
'import requests
url = "https://api.relayapp.im/v1/messages/{message_id}"
payload = { "parts": [
{
"type": "<string>",
"text": "<string>"
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({parts: [{type: '<string>', text: '<string>'}]})
};
fetch('https://api.relayapp.im/v1/messages/{message_id}', 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/{message_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'parts' => [
[
'type' => '<string>',
'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/{message_id}"
payload := strings.NewReader("{\n \"parts\": [\n {\n \"type\": \"<string>\",\n \"text\": \"<string>\"\n }\n ]\n}")
req, _ := http.NewRequest("PATCH", 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.patch("https://api.relayapp.im/v1/messages/{message_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"parts\": [\n {\n \"type\": \"<string>\",\n \"text\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.relayapp.im/v1/messages/{message_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"parts\": [\n {\n \"type\": \"<string>\",\n \"text\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"message": {
"id": "msg_01JZM3T8AH",
"conversation_id": "cnv_01JZC7K4RQ",
"sequence": 123,
"sender": {
"id": "usr_01JZU1F0BD"
},
"parts": [
{
"part_index": 1,
"type": "<string>",
"text": "<string>"
}
],
"fallback_text": "<string>",
"status": "sent",
"edited_at": "2023-11-07T05:31:56Z",
"revisions": [
{
"parts": [
{
"part_index": 1,
"type": "<string>",
"text": "<string>"
}
],
"fallback_text": "<string>",
"replaced_at": "2023-11-07T05:31:56Z"
}
],
"created_at": "2023-11-07T05:31:56Z",
"reply_to": {
"message_id": "msg_01JZM3T8AH",
"part_index": 0
},
"invoked_agents": [
"<string>"
],
"suggestions": [
{
"text": "Everyone"
}
],
"reactions": [
{
"part_index": 1,
"emoji": "<string>",
"actor_id": "<string>"
}
],
"delivered_at": "2023-11-07T05:31:56Z",
"read_at": "2023-11-07T05:31:56Z"
}
}{
"error": {
"code": "invalid_request",
"message": "conversation_id is required"
}
}{
"error": {
"code": "invalid_request",
"message": "conversation_id is required"
}
}{
"error": {
"code": "invalid_request",
"message": "conversation_id is required"
}
}{
"error": {
"code": "invalid_request",
"message": "conversation_id is required"
}
}Authorizations
agentTokenuserSession
Agent Token (rly_live_…), shown once at agent creation.
Path Parameters
Body
application/json
Full replacement for the stored parts. At least one text part is required. Media, voice memo, and all attachment references are rejected.
Required array length:
1 - 32 elements- Option 1
- Option 2
- Option 3
Show child attributes
Show child attributes
Response
Canonical edited message with revision history from oldest to newest.
Show child attributes
Show child attributes
⌘I