This document describes the Auth0 Management API integration added to the API server.
The Management API client requires the following environment variables in .env.local:
AUTH0_DOMAIN=your-tenant.auth0.com
AUTH0_CLIENT_ID=your-client-id
AUTH0_CLIENT_SECRET=your-client-secret
AUTH0_AUDIENCE=your-api-audienceLists all users from your Auth0 tenant.
Query Parameters:
page(optional): Page number (default: 0)per_page(optional): Number of users per page (default: 50)include_totals(optional): Include total count (default: true)
Example Request:
GET /api/users?page=0&per_page=10&include_totals=trueExample Response:
{
"success": true,
"data": {
"users": [
{
"user_id": "auth0|123456789",
"email": "user@example.com",
"name": "John Doe",
"created_at": "2023-01-01T00:00:00.000Z",
"updated_at": "2023-01-01T00:00:00.000Z"
}
],
"total": 1,
"start": 0,
"limit": 10,
"length": 1
}
}Health check endpoint to verify Management API connection.
Example Response:
{
"success": true,
"message": "Management API connection is healthy"
}All endpoints require a valid JWT token with the appropriate audience. The token should be included in the Authorization header:
Authorization: Bearer <your-jwt-token>
All endpoints return standardized error responses:
{
"success": false,
"error": "Error message description"
}The Management API client is configured with the following scopes:
read:users- Read user informationread:user_idp_tokens- Read user identity provider tokens
To add new Management API endpoints, follow this pattern:
app.get('/api/endpoint-name', checkJwt, async (req, res) => {
try {
const result = await management.someMethod(req.query);
res.json({
success: true,
data: result
});
} catch (error) {
console.error('Error:', error);
res.status(500).json({
success: false,
error: error.message || 'Operation failed'
});
}
});The management client provides access to various Auth0 resources:
management.users- User managementmanagement.clients- Application managementmanagement.connections- Database and social connectionsmanagement.rules- Rules managementmanagement.actions- Actions managementmanagement.organizations- Organizations management- And many more...
Refer to the Auth0 Management API documentation for complete details.