Delete fonts
Delete one or multiple fonts by their names. All fonts with the specified names will be deleted for your account. If you have multiple fonts with the same name, all of them will be deleted.
Sample Request
Here’s a sample request to delete fonts:
DELETE /v1/fonts?fonts=FONT_NAME_1&fonts=FONT_NAME_2
// Delete single fontfetch(`https://api.templated.io/v1/fonts?fonts=${encodeURIComponent('My Custom Font')}`, { method: 'DELETE', headers: { 'Authorization': `Bearer ${API_KEY}` }}).then(response => response.json()).then(data => console.log('Response:', data)).catch(error => console.error('Error:', error));
// Delete multiple fontsconst fontNames = ['My Custom Font', 'Another Font'];const params = fontNames.map(name => `fonts=${encodeURIComponent(name)}`).join('&');
fetch(`https://api.templated.io/v1/fonts?${params}`, { method: 'DELETE', headers: { 'Authorization': `Bearer ${API_KEY}` }}).then(response => response.json()).then(data => console.log('Response:', data)).catch(error => console.error('Error:', error));
import requests
api_key = 'API_KEY'font_names = ['My Custom Font', 'Another Font']
# Prepare query parametersparams = {'fonts': font_names}url = 'https://api.templated.io/v1/fonts'headers = {'Authorization': f'Bearer {api_key}'}
response = requests.delete(url, headers=headers, params=params)
if response.status_code == 200: result = response.json() print(f"Successfully deleted: {result['deleted']}") print(f"Deleted by name: {result['deleted_by_name']}") print(result['message'])else: print('Request failed. Response code:', response.status_code) print(response.text)
import java.net.HttpURLConnection;import java.net.URL;import java.net.URLEncoder;import java.io.BufferedReader;import java.io.InputStreamReader;
public class DeleteFonts { public static void main(String[] args) { try { String apiKey = "API_KEY"; String[] fontNames = {"My Custom Font", "Another Font"};
// Build query parameters StringBuilder params = new StringBuilder(); for (int i = 0; i < fontNames.length; i++) { if (i > 0) params.append("&"); params.append("fonts=").append(URLEncoder.encode(fontNames[i], "UTF-8")); }
URL url = new URL("https://api.templated.io/v1/fonts?" + params.toString());
HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("DELETE"); connection.setRequestProperty("Authorization", "Bearer " + apiKey);
int responseCode = connection.getResponseCode(); if (responseCode == HttpURLConnection.HTTP_OK) { BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); String response = reader.readLine(); System.out.println("Response: " + response); } else { System.out.println("Request failed. Response Code: " + responseCode); } } catch (Exception e) { e.printStackTrace(); } }}
<?php$apiKey = 'API_KEY';$fontNames = ['My Custom Font', 'Another Font'];
// Build query parameters$params = http_build_query(['fonts' => $fontNames]);$url = "https://api.templated.io/v1/fonts?{$params}";
$options = [ 'http' => [ 'header' => "Authorization: Bearer {$apiKey}\r\n", 'method' => 'DELETE' ]];
$context = stream_context_create($options);$result = file_get_contents($url, false, $context);
if ($result !== false) { $response = json_decode($result, true); echo "Successfully deleted: " . implode(', ', $response['deleted']) . "\n"; echo "Deleted by name: " . json_encode($response['deleted_by_name']) . "\n"; echo $response['message'] . "\n";} else { echo "Error deleting fonts\n";}?>
Response
Success Response
A successful deletion will return a 200 OK
response with details about the deleted fonts:
{ "deleted": ["font-id-1", "font-id-2", "font-id-3"], "deleted_by_name": { "My Custom Font": 2, "Another Font": 1 }, "message": "Successfully deleted 3 font(s)"}
The deleted_by_name
object shows how many fonts were deleted for each font name. This is useful when you have multiple fonts with the same name.
Error Responses
Status Code | Description | Response Body |
---|---|---|
400 | Bad Request - Font name(s) not found | {"not_found": ["Font Name"], "error": "Cannot delete fonts: no fonts found with the specified name(s) for this user"} |
400 | Bad Request - No font names provided | {"error": "At least one font name must be provided"} |
401 | Not authorized - Invalid or missing API key | {"error": "Not authorized"} |
404 | Not Found - User not found | {"error": "User not found"} |
500 | Internal Server Error - An unexpected error occurred | {"error": "An unexpected error occurred"} |
Important Notes
- Atomic Operation: Either all fonts with the specified names are deleted, or none are deleted. If any font name has no matching fonts, the entire operation fails.
- Bulk Support: You can delete fonts with multiple names in a single request by passing multiple
fonts
parameters. - Multiple Fonts: If you have multiple fonts with the same name, all of them will be deleted when that name is specified.
- Name Matching: Font names must match exactly (case-sensitive).
Query Parameters
Parameter | Type | Required | Description |
---|---|---|---|
fonts | string[] | Yes | One or more font names to delete. Pass multiple fonts parameters for bulk deletion. All fonts with matching names will be deleted. |