curl --request POST \
--url https://api.dittowords.com/v2/variants \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"variants": [
{
"name": "Spanish",
"localeCode": "es"
},
{
"name": "Canadian French",
"developerId": "fr-ca",
"description": "French translations for Canada"
}
]
}
'import requests
url = "https://api.dittowords.com/v2/variants"
payload = { "variants": [
{
"name": "Spanish",
"localeCode": "es"
},
{
"name": "Canadian French",
"developerId": "fr-ca",
"description": "French translations for Canada"
}
] }
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
variants: [
{name: 'Spanish', localeCode: 'es'},
{
name: 'Canadian French',
developerId: 'fr-ca',
description: 'French translations for Canada'
}
]
})
};
fetch('https://api.dittowords.com/v2/variants', 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.dittowords.com/v2/variants",
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([
'variants' => [
[
'name' => 'Spanish',
'localeCode' => 'es'
],
[
'name' => 'Canadian French',
'developerId' => 'fr-ca',
'description' => 'French translations for Canada'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"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.dittowords.com/v2/variants"
payload := strings.NewReader("{\n \"variants\": [\n {\n \"name\": \"Spanish\",\n \"localeCode\": \"es\"\n },\n {\n \"name\": \"Canadian French\",\n \"developerId\": \"fr-ca\",\n \"description\": \"French translations for Canada\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
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.dittowords.com/v2/variants")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"variants\": [\n {\n \"name\": \"Spanish\",\n \"localeCode\": \"es\"\n },\n {\n \"name\": \"Canadian French\",\n \"developerId\": \"fr-ca\",\n \"description\": \"French translations for Canada\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.dittowords.com/v2/variants")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"variants\": [\n {\n \"name\": \"Spanish\",\n \"localeCode\": \"es\"\n },\n {\n \"name\": \"Canadian French\",\n \"developerId\": \"fr-ca\",\n \"description\": \"French translations for Canada\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"developerIds": [
"spanish",
"fr-ca"
]
}{
"message": "Duplicate locale codes in request: es"
}{
"message": "Locale code already attached to another variant: es. A locale code can belong to at most one variant."
}Create variants
Creates one or more variants in the workspace. A variant is a named alternative that text items and library components can each have their own text for — most often a locale to translate into, but also a tone or brand variation. Creating a variant adds no text on its own; use the text item endpoints to set a text item’s text for that variant. Each variant can optionally specify a developerId (must be unique within the workspace), a description, and a localeCode. At most one variant in a workspace can hold a given locale code. When no developerId is given, one is generated from the name, so read the developer IDs off the response rather than assuming them.
curl --request POST \
--url https://api.dittowords.com/v2/variants \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"variants": [
{
"name": "Spanish",
"localeCode": "es"
},
{
"name": "Canadian French",
"developerId": "fr-ca",
"description": "French translations for Canada"
}
]
}
'import requests
url = "https://api.dittowords.com/v2/variants"
payload = { "variants": [
{
"name": "Spanish",
"localeCode": "es"
},
{
"name": "Canadian French",
"developerId": "fr-ca",
"description": "French translations for Canada"
}
] }
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
variants: [
{name: 'Spanish', localeCode: 'es'},
{
name: 'Canadian French',
developerId: 'fr-ca',
description: 'French translations for Canada'
}
]
})
};
fetch('https://api.dittowords.com/v2/variants', 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.dittowords.com/v2/variants",
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([
'variants' => [
[
'name' => 'Spanish',
'localeCode' => 'es'
],
[
'name' => 'Canadian French',
'developerId' => 'fr-ca',
'description' => 'French translations for Canada'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"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.dittowords.com/v2/variants"
payload := strings.NewReader("{\n \"variants\": [\n {\n \"name\": \"Spanish\",\n \"localeCode\": \"es\"\n },\n {\n \"name\": \"Canadian French\",\n \"developerId\": \"fr-ca\",\n \"description\": \"French translations for Canada\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
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.dittowords.com/v2/variants")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"variants\": [\n {\n \"name\": \"Spanish\",\n \"localeCode\": \"es\"\n },\n {\n \"name\": \"Canadian French\",\n \"developerId\": \"fr-ca\",\n \"description\": \"French translations for Canada\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.dittowords.com/v2/variants")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"variants\": [\n {\n \"name\": \"Spanish\",\n \"localeCode\": \"es\"\n },\n {\n \"name\": \"Canadian French\",\n \"developerId\": \"fr-ca\",\n \"description\": \"French translations for Canada\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"developerIds": [
"spanish",
"fr-ca"
]
}{
"message": "Duplicate locale codes in request: es"
}{
"message": "Locale code already attached to another variant: es. A locale code can belong to at most one variant."
}Authorizations
Body
Array of new variants to create
1Show child attributes
Show child attributes
Response
Returns the developer IDs of the created variants, in request order
Array of developer IDs for the created variants, in request order