Only agents’ messages can be edited.
1
//native
2
type Brevo = {
3
apiKey: string;
4
};
5
/**
6
* Update a message sent by an agent
7
* Only agents’ messages can be edited.
8
*/
9
export async function main(auth: Brevo, id: string, body: { text: string }) {
10
const url = new URL(`https://api.brevo.com/v3/conversations/messages/${id}`);
11
12
const response = await fetch(url, {
13
method: "PUT",
14
headers: {
15
"Content-Type": "application/json",
16
"api-key": auth.apiKey,
17
},
18
body: JSON.stringify(body),
19
});
20
if (!response.ok) {
21
const text = await response.text();
22
throw new Error(`${response.status} ${text}`);
23
}
24
return await response.json();
25
26