Examples
- API Request
- TypeScript
- Python (Sync)
Understanding Sub-Tenant Deletion
What Gets Deleted
When you delete a sub-tenant, the following occurs:- All Data Removal: All documents, embeddings, and metadata associated with the sub-tenant are permanently deleted
- Complete Cleanup: The sub-tenant ID is removed from the tenant’s sub-tenant list
- Irreversible Action: This operation cannot be undone - all data is permanently lost
What Cannot Be Deleted
- Default Sub-Tenant: The automatically created default sub-tenant cannot be deleted
- Primary Tenant: You cannot delete the main tenant itself using this API
Default Sub-Tenant Protection: Cortex automatically protects the default sub-tenant from deletion to ensure your organization always has a primary workspace. If you need to clean up the default sub-tenant, you would need to delete and recreate the entire tenant.
Query Parameters
- tenant_id: Required string - The primary tenant identifier (e.g., your organization ID)
- sub_tenant_id: Required string - The sub-tenant identifier to delete (e.g., department or team name)
Use Cases
Department Restructuring
- Team Consolidation: Merge departments by deleting unused sub-tenants
- Organizational Changes: Remove sub-tenants for departments that no longer exist
- Cleanup: Remove test or temporary sub-tenants created during development
Data Management
- Compliance: Remove sub-tenants containing sensitive data that’s no longer needed
- Storage Optimization: Delete sub-tenants with outdated or irrelevant content
- Privacy: Remove sub-tenants for users who have left the organization
Application Lifecycle
- Project Cleanup: Remove sub-tenants for completed projects
- Client Management: Delete sub-tenants for clients who have ended their contracts
- Testing: Clean up test sub-tenants after development phases
Example Requests
Delete a Department Sub-Tenant
Delete a User Sub-Tenant (B2C)
Delete a Project Sub-Tenant
Sample Response
Error Responses
All endpoints return consistent error responses following the standard format. For detailed error information, see our Error Responses documentation.Best Practices
Before Deletion
- Verify Sub-Tenant: Use the List Sub-Tenant IDs endpoint to confirm the sub-tenant exists
- Backup Important Data: Export any critical data before deletion
- Check Dependencies: Ensure no active integrations depend on the sub-tenant
After Deletion
- Update Applications: Remove references to the deleted sub-tenant from your applications
- Notify Users: Inform relevant users that the sub-tenant workspace is no longer available
- Update Documentation: Remove the sub-tenant from any internal documentation
Safety Measures
- Test in Development: Always test sub-tenant deletion in a development environment first
- Gradual Rollout: Consider a phased approach for large-scale sub-tenant cleanup
- Audit Trail: Keep records of which sub-tenants were deleted and when
Recovery: Once a sub-tenant is deleted, it cannot be recovered. The sub-tenant ID can be reused by creating new content with the same ID, but all previous data will be lost.