cURL
curl --request DELETE \ --url https://app.tokencraft.dev/api/v1/tokensets/{id}/modes/{modeId}/tokens/{tokenId} \ --header 'Authorization: Bearer <token>'
Permanently delete a token
write:tokens
owner
admin
editor
viewer
403
DELETE /tokensets/{id}/modes/{modeId}/tokens/{tokenId}
id
modeId
tokenId
200 OK
{ "message": "Token deleted successfully" }
curl -X DELETE https://app.tokencraft.dev/api/v1/tokensets/tokenset-123/modes/mode-light/tokens/token-123 \ -H "Authorization: Bearer tkc_your_token_here"
{ "error": "Token not found" }
async function safeDeleteToken(tokensetId, modeId, tokenId, tokenName) { // Get all tokens const { tokens } = await getTokens(tokensetId, modeId); // Check for aliases const aliases = tokens.filter(t => t.alias_to === tokenName); if (aliases.length > 0) { console.warn(`Warning: ${aliases.length} tokens reference this token`); console.log('Aliases:', aliases.map(t => t.name)); // Option 1: Delete aliases first for (const alias of aliases) { await deleteToken(tokensetId, modeId, alias.id); } } // Then delete the token await deleteToken(tokensetId, modeId, tokenId); }
async function deleteTokens(tokensetId, modeId, tokenIds) { for (const tokenId of tokenIds) { await deleteToken(tokensetId, modeId, tokenId); } } // Usage await deleteTokens('tokenset-123', 'mode-light', [ 'token-1', 'token-2', 'token-3' ]);
async function exportAndDelete(tokensetId, modeId, tokenId) { // Get token details first const token = await getToken(tokensetId, modeId, tokenId); // Save to backup fs.writeFileSync( `backup-${token.name}.json`, JSON.stringify(token, null, 2) ); // Then delete await deleteToken(tokensetId, modeId, tokenId); }