curl --request POST \
--url http://localhost:8080/macros \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"category": "<string>",
"title": "<string>",
"content": "<string>",
"options": [
{
"label": "<string>",
"id": "<string>"
}
]
}
'import requests
url = "http://localhost:8080/macros"
payload = {
"category": "<string>",
"title": "<string>",
"content": "<string>",
"options": [
{
"label": "<string>",
"id": "<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({
category: '<string>',
title: '<string>',
content: '<string>',
options: [{label: '<string>', id: '<string>'}]
})
};
fetch('http://localhost:8080/macros', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8080",
CURLOPT_URL => "http://localhost:8080/macros",
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([
'category' => '<string>',
'title' => '<string>',
'content' => '<string>',
'options' => [
[
'label' => '<string>',
'id' => '<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 := "http://localhost:8080/macros"
payload := strings.NewReader("{\n \"category\": \"<string>\",\n \"title\": \"<string>\",\n \"content\": \"<string>\",\n \"options\": [\n {\n \"label\": \"<string>\",\n \"id\": \"<string>\"\n }\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("http://localhost:8080/macros")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"category\": \"<string>\",\n \"title\": \"<string>\",\n \"content\": \"<string>\",\n \"options\": [\n {\n \"label\": \"<string>\",\n \"id\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:8080/macros")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"category\": \"<string>\",\n \"title\": \"<string>\",\n \"content\": \"<string>\",\n \"options\": [\n {\n \"label\": \"<string>\",\n \"id\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"org_id": "<string>",
"category": "<string>",
"title": "<string>",
"content": "<string>",
"attachments": [
{
"id": "<string>",
"name": "<string>",
"size": 123,
"type": "<string>",
"url": "<string>"
}
],
"options": [
{
"id": "<string>",
"label": "<string>",
"type": "text"
}
],
"user_id": 123,
"overrides_saved_reply_id": "<string>",
"exclude_from_suggestions": true,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}{
"statusCode": 123,
"message": "<string>",
"error": "<string>"
}Create a macro
Create an org-wide macro (saved reply) with an HTML body, placeholders, up to 3 tappable options, and an optional opt-out of suggestions.
curl --request POST \
--url http://localhost:8080/macros \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"category": "<string>",
"title": "<string>",
"content": "<string>",
"options": [
{
"label": "<string>",
"id": "<string>"
}
]
}
'import requests
url = "http://localhost:8080/macros"
payload = {
"category": "<string>",
"title": "<string>",
"content": "<string>",
"options": [
{
"label": "<string>",
"id": "<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({
category: '<string>',
title: '<string>',
content: '<string>',
options: [{label: '<string>', id: '<string>'}]
})
};
fetch('http://localhost:8080/macros', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8080",
CURLOPT_URL => "http://localhost:8080/macros",
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([
'category' => '<string>',
'title' => '<string>',
'content' => '<string>',
'options' => [
[
'label' => '<string>',
'id' => '<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 := "http://localhost:8080/macros"
payload := strings.NewReader("{\n \"category\": \"<string>\",\n \"title\": \"<string>\",\n \"content\": \"<string>\",\n \"options\": [\n {\n \"label\": \"<string>\",\n \"id\": \"<string>\"\n }\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("http://localhost:8080/macros")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"category\": \"<string>\",\n \"title\": \"<string>\",\n \"content\": \"<string>\",\n \"options\": [\n {\n \"label\": \"<string>\",\n \"id\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:8080/macros")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"category\": \"<string>\",\n \"title\": \"<string>\",\n \"content\": \"<string>\",\n \"options\": [\n {\n \"label\": \"<string>\",\n \"id\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"org_id": "<string>",
"category": "<string>",
"title": "<string>",
"content": "<string>",
"attachments": [
{
"id": "<string>",
"name": "<string>",
"size": 123,
"type": "<string>",
"url": "<string>"
}
],
"options": [
{
"id": "<string>",
"label": "<string>",
"type": "text"
}
],
"user_id": 123,
"overrides_saved_reply_id": "<string>",
"exclude_from_suggestions": true,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}{
"statusCode": 123,
"message": "<string>",
"error": "<string>"
}{
"category": "Billing",
"title": "Refund status",
"content": "<p>Hi {{contact.full_name}}, your refund is on its way and should arrive within 5 business days.</p>",
"exclude_from_suggestions": false
}
{{variable}} names with List macro variables. Attachments cannot be set through the API.Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
Macro body as HTML, limited to what every channel can carry:
,
, , , , , [blocked]
- and inline images as
<img src="…">pointing at a file uploaded for this organization. Other markup is dropped (its text is kept); escape literal < and & as HTML entities, and use
orfor line breaks. Reference variables with {{variable}} syntax.
- /
20000Up to 3 options the customer can tap instead of typing, sent with the macro on channels that show them. Each label is up to 20 characters. type is text (the tap reaches the session as the customer's reply) or workflow (the tap runs the macro's Macro Option Clicked workflows and the AI doesn't reply). This is the full list: on update, pass an existing option's id to keep it (workflows branching on that id keep working); options left out are removed, [] removes all, and omitting the field leaves them untouched. A macro with options needs body text.
3Show child attributes
Show child attributes
Response
Default Response
Macro body as channel-safe HTML, with {{variable}} references.
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Was this page helpful?