Update tags for template
Update tags for an existing template.
This endpoint allows you to replace all existing tags of a template with a new set of tags.
Request Body
Section titled “Request Body”The request body should be an array of strings containing the new tags you want to set.
Sample Request
Section titled “Sample Request”Here’s a sample request to update tags for a template:
PUT /v1/template/{templateId}/tagsfetch(`https://api.templated.io/v1/template/${template_id}/tags`, { method: 'PUT', headers: { 'Authorization': `Bearer ${API_KEY}`, 'Content-Type': 'application/json' }, body: JSON.stringify([ "new-tag1", "new-tag2", "new-tag3" ])}).then(response => response.json()).then(data => console.log(data)).catch(error => console.error('Error:', error));import requests
api_key = 'API_KEY'template_id = 'template_id'url = f'https://api.templated.io/v1/template/{template_id}/tags'
headers = { 'Authorization': f'Bearer {api_key}', 'Content-Type': 'application/json'}
tags = [ "new-tag1", "new-tag2", "new-tag3"]
response = requests.put(url, json=tags, headers=headers)
if response.status_code == 200: print(response.json())else: print('Request failed. Response code:', response.status_code) print(response.text)import java.net.HttpURLConnection;import java.net.URL;import java.io.OutputStream;import java.io.BufferedReader;import java.io.InputStreamReader;
public class UpdateTemplateTags { public static void main(String[] args) { try { String apiKey = "API_KEY"; String templateId = "template_id"; String url = "https://api.templated.io/v1/template/" + templateId + "/tags";
String jsonTags = """ ["new-tag1", "new-tag2", "new-tag3"] """;
URL apiUrl = new URL(url); HttpURLConnection connection = (HttpURLConnection) apiUrl.openConnection(); connection.setRequestMethod("PUT"); connection.setRequestProperty("Authorization", "Bearer " + apiKey); connection.setRequestProperty("Content-Type", "application/json"); connection.setDoOutput(true);
try (OutputStream os = connection.getOutputStream()) { byte[] input = jsonTags.getBytes("utf-8"); os.write(input, 0, input.length); }
int responseCode = connection.getResponseCode(); if (responseCode == HttpURLConnection.HTTP_OK) { BufferedReader in = new BufferedReader( new InputStreamReader(connection.getInputStream())); String inputLine; StringBuilder response = new StringBuilder(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); System.out.println(response.toString()); } else { System.out.println("Request failed. Response Code: " + responseCode); } } catch (Exception e) { e.printStackTrace(); } }}<?php$apiKey = 'API_KEY';$templateId = 'template_id';
$tags = [ "new-tag1", "new-tag2", "new-tag3"];
$url = "https://api.templated.io/v1/template/{$templateId}/tags";
$options = [ 'http' => [ 'header' => "Authorization: Bearer {$apiKey}\r\n" . "Content-Type: application/json\r\n", 'method' => 'PUT', 'content' => json_encode($tags) ]];
$context = stream_context_create($options);$result = file_get_contents($url, false, $context);
if ($result === FALSE) { echo "Error updating tags";} else { $data = json_decode($result, true); print_r($data);}?>