Create variables
curl --request POST \
--url https://api.dittowords.com/v2/variables \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"variables": [
{
"name": "user_name",
"type": "string",
"data": {
"example": "Jane Doe",
"fallback": "there"
}
},
{
"name": "help_link",
"type": "hyperlink",
"data": {
"text": "Learn more",
"url": "https://dittowords.com"
}
}
]
}
'import requests
url = "https://api.dittowords.com/v2/variables"
payload = { "variables": [
{
"name": "user_name",
"type": "string",
"data": {
"example": "Jane Doe",
"fallback": "there"
}
},
{
"name": "help_link",
"type": "hyperlink",
"data": {
"text": "Learn more",
"url": "https://dittowords.com"
}
}
] }
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({
variables: [
{
name: 'user_name',
type: 'string',
data: {example: 'Jane Doe', fallback: 'there'}
},
{
name: 'help_link',
type: 'hyperlink',
data: {text: 'Learn more', url: 'https://dittowords.com'}
}
]
})
};
fetch('https://api.dittowords.com/v2/variables', 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/variables",
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([
'variables' => [
[
'name' => 'user_name',
'type' => 'string',
'data' => [
'example' => 'Jane Doe',
'fallback' => 'there'
]
],
[
'name' => 'help_link',
'type' => 'hyperlink',
'data' => [
'text' => 'Learn more',
'url' => 'https://dittowords.com'
]
]
]
]),
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/variables"
payload := strings.NewReader("{\n \"variables\": [\n {\n \"name\": \"user_name\",\n \"type\": \"string\",\n \"data\": {\n \"example\": \"Jane Doe\",\n \"fallback\": \"there\"\n }\n },\n {\n \"name\": \"help_link\",\n \"type\": \"hyperlink\",\n \"data\": {\n \"text\": \"Learn more\",\n \"url\": \"https://dittowords.com\"\n }\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/variables")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"variables\": [\n {\n \"name\": \"user_name\",\n \"type\": \"string\",\n \"data\": {\n \"example\": \"Jane Doe\",\n \"fallback\": \"there\"\n }\n },\n {\n \"name\": \"help_link\",\n \"type\": \"hyperlink\",\n \"data\": {\n \"text\": \"Learn more\",\n \"url\": \"https://dittowords.com\"\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.dittowords.com/v2/variables")
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 \"variables\": [\n {\n \"name\": \"user_name\",\n \"type\": \"string\",\n \"data\": {\n \"example\": \"Jane Doe\",\n \"fallback\": \"there\"\n }\n },\n {\n \"name\": \"help_link\",\n \"type\": \"hyperlink\",\n \"data\": {\n \"text\": \"Learn more\",\n \"url\": \"https://dittowords.com\"\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"names": [
"user_name",
"help_link"
]
}{
"message": "<string>"
}Variables
Create variables
Creates variables in your workspace. A variable’s name is also its developer ID, so it must be unique in the workspace. The shape of data depends on type: string and number take an example and an optional fallback, hyperlink takes text and URL, list takes an array of strings, and map takes an object of string keys to string values. Either every variable is created or none is.
POST
/
variables
Create variables
curl --request POST \
--url https://api.dittowords.com/v2/variables \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"variables": [
{
"name": "user_name",
"type": "string",
"data": {
"example": "Jane Doe",
"fallback": "there"
}
},
{
"name": "help_link",
"type": "hyperlink",
"data": {
"text": "Learn more",
"url": "https://dittowords.com"
}
}
]
}
'import requests
url = "https://api.dittowords.com/v2/variables"
payload = { "variables": [
{
"name": "user_name",
"type": "string",
"data": {
"example": "Jane Doe",
"fallback": "there"
}
},
{
"name": "help_link",
"type": "hyperlink",
"data": {
"text": "Learn more",
"url": "https://dittowords.com"
}
}
] }
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({
variables: [
{
name: 'user_name',
type: 'string',
data: {example: 'Jane Doe', fallback: 'there'}
},
{
name: 'help_link',
type: 'hyperlink',
data: {text: 'Learn more', url: 'https://dittowords.com'}
}
]
})
};
fetch('https://api.dittowords.com/v2/variables', 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/variables",
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([
'variables' => [
[
'name' => 'user_name',
'type' => 'string',
'data' => [
'example' => 'Jane Doe',
'fallback' => 'there'
]
],
[
'name' => 'help_link',
'type' => 'hyperlink',
'data' => [
'text' => 'Learn more',
'url' => 'https://dittowords.com'
]
]
]
]),
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/variables"
payload := strings.NewReader("{\n \"variables\": [\n {\n \"name\": \"user_name\",\n \"type\": \"string\",\n \"data\": {\n \"example\": \"Jane Doe\",\n \"fallback\": \"there\"\n }\n },\n {\n \"name\": \"help_link\",\n \"type\": \"hyperlink\",\n \"data\": {\n \"text\": \"Learn more\",\n \"url\": \"https://dittowords.com\"\n }\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/variables")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"variables\": [\n {\n \"name\": \"user_name\",\n \"type\": \"string\",\n \"data\": {\n \"example\": \"Jane Doe\",\n \"fallback\": \"there\"\n }\n },\n {\n \"name\": \"help_link\",\n \"type\": \"hyperlink\",\n \"data\": {\n \"text\": \"Learn more\",\n \"url\": \"https://dittowords.com\"\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.dittowords.com/v2/variables")
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 \"variables\": [\n {\n \"name\": \"user_name\",\n \"type\": \"string\",\n \"data\": {\n \"example\": \"Jane Doe\",\n \"fallback\": \"there\"\n }\n },\n {\n \"name\": \"help_link\",\n \"type\": \"hyperlink\",\n \"data\": {\n \"text\": \"Learn more\",\n \"url\": \"https://dittowords.com\"\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"names": [
"user_name",
"help_link"
]
}{
"message": "<string>"
}Authorizations
Body
application/json
Array of new variables to create
Minimum array length:
1- Option 1
- Option 2
- Option 3
- Option 4
- Option 5
Show child attributes
Show child attributes
Response
Returns the names of the created variables
Names of the created variables, in request order
⌘I