Skip to main content
DELETE
/
api
/
v1
/
tokensets
/
{id}
/
modes
/
{modeId}
/
tokens
/
{tokenId}
Delete Token
curl --request DELETE \
  --url https://app.tokencraft.dev/api/v1/api/v1/tokensets/{id}/modes/{modeId}/tokens/{tokenId} \
  --header 'Authorization: Bearer <token>'

Delete Token

Permanently deletes a design token. This action cannot be undone.
PRO Plan Required - This endpoint requires a PRO or TEAM subscription plan. API write access is not available on the FREE plan.

Endpoint

DELETE /api/v1/tokensets/{id}/modes/{modeId}/tokens/{tokenId}

Request

Path Parameters

ParameterTypeRequiredDescription
idstringYesTokenset ID
modeIdstringYesMode ID
tokenIdstringYesToken ID

Response

Status: 200 OK
{
  "message": "Token deleted successfully"
}

Examples

curl -X DELETE https://app.tokencraft.dev/api/v1/tokensets/tokenset-123/modes/mode-light/tokens/token-123 \
  -H "Authorization: Bearer dtk_your_token_here"

Error Responses

404 Not Found

{
  "error": "Token not found"
}
This operation is irreversible. The token will be permanently deleted. Consider exporting your tokens before deletion.

Considerations

1. Alias Dependencies

If other tokens reference this token as an alias, they will break. Check for dependencies first:
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);
}

2. Batch Deletion

Delete multiple tokens:
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'
]);

3. Export Before Deletion

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);
}

Recovery

Deleted tokens cannot be recovered. There is no undo or trash bin. Make sure you have backups of important tokens.

Next Steps