Skip to content

Delete Routing Rule

Permanently deletes a routing rule. This action cannot be undone.

DELETE /v1/routing-rules/{id}
ParameterTypeRequiredDescription
idintegerYesThe routing rule ID
import Tokenrouter from 'tokenrouter';
const client = new Tokenrouter({
apiKey: process.env.TOKENROUTER_API_KEY
});
await client.routingRules.delete(123);
console.log('Rule deleted successfully');
{
"success": true
}
{
"error": {
"message": "Routing rules are not available on the free plan",
"type": "authorization_error",
"http_status": 403
}
}
{
"error": {
"message": "Routing rule not found",
"type": "not_found_error",
"http_status": 404
}
}

Always verify before deleting:

// Get rule details first
const rule = await client.routingRules.retrieve(ruleId);
console.log(`About to delete: ${rule.data.name}`);
console.log(`Priority: ${rule.data.priority}`);
// Confirm deletion
const confirmed = confirm('Delete this rule?');
if (confirmed) {
await client.routingRules.delete(ruleId);
console.log('Rule deleted');
}

Delete multiple rules:

// Delete all disabled rules
const rules = await client.routingRules.list();
const disabledRules = rules.data.filter(r => !r.is_enabled);
for (const rule of disabledRules) {
await client.routingRules.delete(rule.id);
console.log(`Deleted: ${rule.name}`);
}

Save rule before deleting:

// Backup rule before deleting
const rule = await client.routingRules.retrieve(ruleId);
const backup = {
name: rule.data.name,
priority: rule.data.priority,
is_enabled: rule.data.is_enabled,
match_json: rule.data.match_json,
action_json: rule.data.action_json
};
// Save to file/database
console.log('Backup:', JSON.stringify(backup, null, 2));
// Delete
await client.routingRules.delete(ruleId);

Consider disabling rules instead of deleting:

// Instead of deleting, disable the rule
await client.routingRules.update(ruleId, {
is_enabled: false
});
// Can be re-enabled later if needed
await client.routingRules.update(ruleId, {
is_enabled: true
});
ScenarioRecommendation
Testing a ruleDisable it
Seasonal rule (e.g., holiday promotions)Disable it
Temporary overrideDisable it
Deprecated providerDelete it
Duplicate ruleDelete it
Experimental rule that failedDelete it
  1. Always get rule details before deleting
  2. Backup important rules before deletion
  3. Prefer disabling over deleting when unsure
  4. Delete in batches carefully to avoid accidents
  5. Document deletion reasons in your change log