The Tenants resource allows you to manage tenant-level settings for your Auth0 tenant. Currently, this resource provides access to tenant settings management.
Overview
The Tenants client in the Go SDK provides access to tenant configuration through nested resources:
// Access tenant settings
mgmt . Tenants . Settings
Tenant Settings
Tenant settings allow you to configure various tenant-level options. Access the settings through the Settings nested resource:
Get Tenant Settings
Retrieve current tenant settings:
ctx := context . Background ()
settings , err := mgmt . Tenants . Settings . Get ( ctx )
if err != nil {
log . Fatalf ( "Error getting tenant settings: %v " , err )
}
fmt . Printf ( "Tenant settings retrieved successfully \n " )
Update Tenant Settings
Update tenant configuration:
updateRequest := & management . UpdateTenantSettingsRequestContent {
// Add tenant setting fields here based on your requirements
}
updatedSettings , err := mgmt . Tenants . Settings . Update ( ctx , updateRequest )
if err != nil {
log . Fatalf ( "Error updating tenant settings: %v " , err )
}
fmt . Printf ( "Tenant settings updated successfully \n " )
Common Tenant Settings
Typical tenant settings you can configure include:
Session Management Configure session lifetime, idle timeout, and other session-related settings.
Security Set security policies including password requirements, MFA settings, and attack protection.
Branding Customize tenant-level branding including logos, colors, and themes.
Features Enable or disable various Auth0 features for your tenant.
Usage Example
Complete example of working with tenant settings:
package main
import (
" context "
" fmt "
" log "
" github.com/auth0/go-auth0/v2/management "
" github.com/auth0/go-auth0/v2/management/client "
" github.com/auth0/go-auth0/v2/management/option "
)
func main () {
// Initialize management client
mgmt , err := client . New (
"your-tenant.auth0.com" ,
option . WithClientCredentials (
context . Background (),
"YOUR_CLIENT_ID" ,
"YOUR_CLIENT_SECRET" ,
),
)
if err != nil {
log . Fatalf ( "Error creating management client: %v " , err )
}
ctx := context . Background ()
// Get current settings
settings , err := mgmt . Tenants . Settings . Get ( ctx )
if err != nil {
log . Fatalf ( "Error getting tenant settings: %v " , err )
}
fmt . Println ( "Current tenant settings retrieved" )
// Update settings
updateRequest := & management . UpdateTenantSettingsRequestContent {
// Configure your settings here
}
updatedSettings , err := mgmt . Tenants . Settings . Update ( ctx , updateRequest )
if err != nil {
log . Fatalf ( "Error updating tenant settings: %v " , err )
}
fmt . Println ( "Tenant settings updated successfully" )
}
Nested Resources
The Tenants client provides access to:
Settings (mgmt.Tenants.Settings) - Manage tenant-level configuration settings
Best Practices
Configuration as Code Manage tenant settings through code for version control and reproducibility across environments.
Testing Test setting changes in a development tenant before applying them to production.
Documentation Document your tenant configuration decisions for team reference and compliance.
Backup Retrieve and backup current settings before making changes to enable easy rollback if needed.
Important Considerations
Tenant settings affect all applications and users in your tenant. Always test changes thoroughly before applying them to production environments.
Some tenant settings may require specific Auth0 plans or features to be enabled. Check your plan’s capabilities before attempting to configure advanced features.