curl --request PATCH \
--url https://api.dittowords.com/v2/components/link \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"componentId": "component-id-1",
"textItemIds": [
"text-item-id-1",
"text-item-id-2"
]
}
'import requests
url = "https://api.dittowords.com/v2/components/link"
payload = {
"componentId": "component-id-1",
"textItemIds": ["text-item-id-1", "text-item-id-2"]
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
componentId: 'component-id-1',
textItemIds: ['text-item-id-1', 'text-item-id-2']
})
};
fetch('https://api.dittowords.com/v2/components/link', 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/components/link",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'componentId' => 'component-id-1',
'textItemIds' => [
'text-item-id-1',
'text-item-id-2'
]
]),
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/components/link"
payload := strings.NewReader("{\n \"componentId\": \"component-id-1\",\n \"textItemIds\": [\n \"text-item-id-1\",\n \"text-item-id-2\"\n ]\n}")
req, _ := http.NewRequest("PATCH", 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.patch("https://api.dittowords.com/v2/components/link")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"componentId\": \"component-id-1\",\n \"textItemIds\": [\n \"text-item-id-1\",\n \"text-item-id-2\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.dittowords.com/v2/components/link")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"componentId\": \"component-id-1\",\n \"textItemIds\": [\n \"text-item-id-1\",\n \"text-item-id-2\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"linkedCount": 2,
"skippedDeveloperIds": []
}{
"message": "Component with developer ID component-id-1 not found"
}Link text items to a component
Links one or more existing text items to an existing component by developer ID, so they share the component’s text going forward.
Each linked text item takes on the component’s current text, variables, variants, and other fields, including its developer ID: the text item’s own developer ID is replaced by the component’s, so it can no longer be looked up by the old one. In workspaces that have opted into component versioning, linked text items instead take the component’s latest published version and keep their own Developer IDs. Text items already linked to a different component are skipped.
curl --request PATCH \
--url https://api.dittowords.com/v2/components/link \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"componentId": "component-id-1",
"textItemIds": [
"text-item-id-1",
"text-item-id-2"
]
}
'import requests
url = "https://api.dittowords.com/v2/components/link"
payload = {
"componentId": "component-id-1",
"textItemIds": ["text-item-id-1", "text-item-id-2"]
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
componentId: 'component-id-1',
textItemIds: ['text-item-id-1', 'text-item-id-2']
})
};
fetch('https://api.dittowords.com/v2/components/link', 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/components/link",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'componentId' => 'component-id-1',
'textItemIds' => [
'text-item-id-1',
'text-item-id-2'
]
]),
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/components/link"
payload := strings.NewReader("{\n \"componentId\": \"component-id-1\",\n \"textItemIds\": [\n \"text-item-id-1\",\n \"text-item-id-2\"\n ]\n}")
req, _ := http.NewRequest("PATCH", 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.patch("https://api.dittowords.com/v2/components/link")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"componentId\": \"component-id-1\",\n \"textItemIds\": [\n \"text-item-id-1\",\n \"text-item-id-2\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.dittowords.com/v2/components/link")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"componentId\": \"component-id-1\",\n \"textItemIds\": [\n \"text-item-id-1\",\n \"text-item-id-2\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"linkedCount": 2,
"skippedDeveloperIds": []
}{
"message": "Component with developer ID component-id-1 not found"
}Body
Response
Returns success status of the link operation, the number of text items actually linked, and the developer IDs of any that were skipped because they're already linked to a different component