# Delete category div strong 🔨 In Development — This section is still being developed and may change. Permanently delete a custom rule category from your organization. This action cannot be undone and will affect how rules in this category are displayed and filtered. Remove a category from your organization. Categories can only be deleted if they contain no active rules. Default system categories cannot be deleted. #### Path Parameters **`organizationId`** string required The organization identifier that owns the category. **`category_id`** string required The unique identifier of the category to delete. This is the `name` field from the category object. ## Returns A [DeleteRuleResponse](#deleteruleresponse) object containing the API response data. Delete custom category ```bash curl -X DELETE "https://api.freddy.aitronos.com/v1/organizations/org_123/rules/categories/brand_voice" \ -H "Authorization: Bearer $FREDDY_API_KEY" ``` ```python import requests organization_id = "org_123" category_id = "brand_voice" response = requests.delete( f"https://api.freddy.aitronos.com/v1/organizations/{organization_id}/rules/categories/{category_id}", headers={ "Authorization": f"Bearer {api_key}" } ) if response.status_code == 200: deleted_category = response.json() print(f"Category deleted: {deleted_category['name']}") elif response.status_code == 204: print("Category deleted successfully") else: print(f"Error: {response.status_code}") ``` ```javascript const organizationId = 'org_123'; const categoryId = 'brand_voice'; const response = await fetch(`https://api.freddy.aitronos.com/v1/organizations/${organizationId}/rules/categories/${categoryId}`, { method: 'DELETE', headers: { 'Authorization': `Bearer ${apiKey}` } }); if (response.ok) { const deletedCategory = await response.json(); console.log('Category deleted successfully'); console.log(`Deleted category: ${deletedCategory.name}`); } else { console.error(`Error: ${response.status}`); } ``` Error handling ```bash # Attempting to delete a category with active rules curl -X DELETE "https://api.freddy.aitronos.com/v1/organizations/org_123/rules/categories/compliance" \ -H "Authorization: Bearer $FREDDY_API_KEY" ``` ```python import requests organization_id = "org_123" category_id = "compliance" # Category with active rules response = requests.delete( f"https://api.freddy.aitronos.com/v1/organizations/{organization_id}/rules/categories/{category_id}", headers={ "Authorization": f"Bearer {api_key}" } ) if response.status_code == 409: error = response.json() print(f"Cannot delete category: {error['error']['message']}") elif response.status_code == 404: print("Category not found") ``` ## Response 200 OK Returns the deleted category object. ```json { "id": "cat_brand_voice_001", "name": "brand_voice", "display_name": "Brand Voice & Tone", "description": "Guidelines for maintaining consistent brand voice and communication style", "priority_range": "70-89", "recommended_limit": 4000, "rule_count": 0, "is_default": false, "is_active": false, "organization_id": "org_xyz789", "deleted_at": "2024-10-30T17:00:00Z", "deleted_by": "user_123", "created_by": "user_123", "created_at": "2024-10-04T12:00:00Z", "updated_at": "2024-10-04T12:00:00Z", "metadata": { "department": "marketing" } } ``` 204 No Content Empty response indicating successful deletion. Errors ```json { "error": { "type": "invalid_request_error", "message": "No category found with the specified ID", "code": "resource_not_found", "param": "category_id" } } ``` ```json { "error": { "type": "invalid_request_error", "message": "Cannot delete category 'compliance' because it contains 12 active rules. Move or delete all rules in this category first.", "code": "category_in_use", "param": "category_id" } } ``` ```json { "error": { "type": "permission_error", "message": "Cannot delete system default categories", "code": "cannot_delete_default_category" } } ``` ```json { "error": { "type": "permission_error", "message": "You do not have permission to delete organization categories", "code": "insufficient_permissions" } } ``` ### Important Notes - **Irreversible**: Once deleted, categories cannot be recovered. Consider archiving important categories instead. - **Active Rules**: Categories containing active rules cannot be deleted. Move rules to other categories or delete them first. - **System Categories**: Default system categories (`safety`, `professional`, `creative`, `technical`, `formatting`, `compliance`) cannot be deleted. - **Permissions**: Organization and team categories require appropriate permissions. User categories can be deleted by their creator. - **Audit Trail**: All deletions are logged in the audit log with user attribution.