curl --request POST \
--url https://api.dittowords.com/v2/components/publish \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"textItemId": "text-item-id-1",
"name": "New Component",
"folderId": "my-folder-id"
}
'import requests
url = "https://api.dittowords.com/v2/components/publish"
payload = {
"textItemId": "text-item-id-1",
"name": "New Component",
"folderId": "my-folder-id"
}
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({textItemId: 'text-item-id-1', name: 'New Component', folderId: 'my-folder-id'})
};
fetch('https://api.dittowords.com/v2/components/publish', 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/publish",
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([
'textItemId' => 'text-item-id-1',
'name' => 'New Component',
'folderId' => 'my-folder-id'
]),
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/publish"
payload := strings.NewReader("{\n \"textItemId\": \"text-item-id-1\",\n \"name\": \"New Component\",\n \"folderId\": \"my-folder-id\"\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/components/publish")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"textItemId\": \"text-item-id-1\",\n \"name\": \"New Component\",\n \"folderId\": \"my-folder-id\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.dittowords.com/v2/components/publish")
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 \"textItemId\": \"text-item-id-1\",\n \"name\": \"New Component\",\n \"folderId\": \"my-folder-id\"\n}"
response = http.request(request)
puts response.read_body{
"developerId": "text-item-id-1"
}{
"message": "1 text item with developer ID text-item-id-1 not found"
}Publish a text item to the library
Publishes an existing project text item to the component library, turning it into a reusable library component.
The text item’s current text, variables, variants, and other fields are carried over to the new component, and the text item becomes its first linked instance. The text item must not already be a library instance.
The new component keeps the text item’s existing Developer ID. In workspaces that have opted into library component versioning, the new component instead gets a new Developer ID generated from its name, and the text item keeps its own.
curl --request POST \
--url https://api.dittowords.com/v2/components/publish \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"textItemId": "text-item-id-1",
"name": "New Component",
"folderId": "my-folder-id"
}
'import requests
url = "https://api.dittowords.com/v2/components/publish"
payload = {
"textItemId": "text-item-id-1",
"name": "New Component",
"folderId": "my-folder-id"
}
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({textItemId: 'text-item-id-1', name: 'New Component', folderId: 'my-folder-id'})
};
fetch('https://api.dittowords.com/v2/components/publish', 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/publish",
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([
'textItemId' => 'text-item-id-1',
'name' => 'New Component',
'folderId' => 'my-folder-id'
]),
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/publish"
payload := strings.NewReader("{\n \"textItemId\": \"text-item-id-1\",\n \"name\": \"New Component\",\n \"folderId\": \"my-folder-id\"\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/components/publish")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"textItemId\": \"text-item-id-1\",\n \"name\": \"New Component\",\n \"folderId\": \"my-folder-id\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.dittowords.com/v2/components/publish")
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 \"textItemId\": \"text-item-id-1\",\n \"name\": \"New Component\",\n \"folderId\": \"my-folder-id\"\n}"
response = http.request(request)
puts response.read_body{
"developerId": "text-item-id-1"
}{
"message": "1 text item with developer ID text-item-id-1 not found"
}Authorizations
Body
Response
Returns the developer ID of the newly created library component
Developer ID of the newly created library component. This is the Developer ID the text item had before publishing, except in workspaces that have opted into library component versioning, where it's newly generated from the component's name.