Set a macro translation
curl --request PUT \
--url http://localhost:8080/macros/{id}/translations/{language} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"title": "<string>",
"content": "<string>",
"options": [
{
"id": "<string>",
"label": "<string>"
}
]
}
'import requests
url = "http://localhost:8080/macros/{id}/translations/{language}"
payload = {
"title": "<string>",
"content": "<string>",
"options": [
{
"id": "<string>",
"label": "<string>"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
title: '<string>',
content: '<string>',
options: [{id: '<string>', label: '<string>'}]
})
};
fetch('http://localhost:8080/macros/{id}/translations/{language}', 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/{id}/translations/{language}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'title' => '<string>',
'content' => '<string>',
'options' => [
[
'id' => '<string>',
'label' => '<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/{id}/translations/{language}"
payload := strings.NewReader("{\n \"title\": \"<string>\",\n \"content\": \"<string>\",\n \"options\": [\n {\n \"id\": \"<string>\",\n \"label\": \"<string>\"\n }\n ]\n}")
req, _ := http.NewRequest("PUT", 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.put("http://localhost:8080/macros/{id}/translations/{language}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"title\": \"<string>\",\n \"content\": \"<string>\",\n \"options\": [\n {\n \"id\": \"<string>\",\n \"label\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:8080/macros/{id}/translations/{language}")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"title\": \"<string>\",\n \"content\": \"<string>\",\n \"options\": [\n {\n \"id\": \"<string>\",\n \"label\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"saved_reply_id": "<string>",
"source_language": "<string>",
"items": [
{
"language": "<string>",
"status": "pending",
"title": "<string>",
"content": "<string>",
"options": [
{
"id": "<string>",
"label": "<string>"
}
],
"overridden_by": {
"user_id": 123,
"name": "<string>"
},
"updated_at": "2023-11-07T05:31:56Z"
}
]
}{
"statusCode": 123,
"message": "<string>",
"error": "<string>"
}Macros
Set a macro translation
Replace one macro’s translation into one chosen language with your own wording.
PUT
/
macros
/
{id}
/
translations
/
{language}
Set a macro translation
curl --request PUT \
--url http://localhost:8080/macros/{id}/translations/{language} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"title": "<string>",
"content": "<string>",
"options": [
{
"id": "<string>",
"label": "<string>"
}
]
}
'import requests
url = "http://localhost:8080/macros/{id}/translations/{language}"
payload = {
"title": "<string>",
"content": "<string>",
"options": [
{
"id": "<string>",
"label": "<string>"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
title: '<string>',
content: '<string>',
options: [{id: '<string>', label: '<string>'}]
})
};
fetch('http://localhost:8080/macros/{id}/translations/{language}', 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/{id}/translations/{language}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'title' => '<string>',
'content' => '<string>',
'options' => [
[
'id' => '<string>',
'label' => '<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/{id}/translations/{language}"
payload := strings.NewReader("{\n \"title\": \"<string>\",\n \"content\": \"<string>\",\n \"options\": [\n {\n \"id\": \"<string>\",\n \"label\": \"<string>\"\n }\n ]\n}")
req, _ := http.NewRequest("PUT", 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.put("http://localhost:8080/macros/{id}/translations/{language}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"title\": \"<string>\",\n \"content\": \"<string>\",\n \"options\": [\n {\n \"id\": \"<string>\",\n \"label\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:8080/macros/{id}/translations/{language}")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"title\": \"<string>\",\n \"content\": \"<string>\",\n \"options\": [\n {\n \"id\": \"<string>\",\n \"label\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"saved_reply_id": "<string>",
"source_language": "<string>",
"items": [
{
"language": "<string>",
"status": "pending",
"title": "<string>",
"content": "<string>",
"options": [
{
"id": "<string>",
"label": "<string>"
}
],
"overridden_by": {
"user_id": 123,
"name": "<string>"
},
"updated_at": "2023-11-07T05:31:56Z"
}
]
}{
"statusCode": 123,
"message": "<string>",
"error": "<string>"
}Send the translated
title and content (HTML, like a macro body). Keep the macro’s {{variables}} as written. options relabels the macro’s options by id; leave it out to keep the current translated labels. An option you don’t list is sent with its original label.
Your wording is used exactly like a generated translation: agents get it in the inbox for customers in that language. It is kept until the macro’s title, content or options change, or a custom variable it uses changes. Then the macro is translated again. Retranslate a macro also replaces it with a generated translation. Each change is recorded in the audit log.
The response is the macro’s translations, as returned by Get macro translations. It fails with 400 when the language is not one of the chosen ones, or is the language the macro is written in.Authorizations
Path Parameters
Body
application/json
Was this page helpful?