The Admin API provides endpoints for user and team management. All admin endpoints require authentication via the CEMS_ADMIN_KEY set during deployment.Base URL:http://localhost:8765/adminAuthentication: Bearer token (use CEMS_ADMIN_KEY)
{ "user": { "id": "550e8400-e29b-41d4-a716-446655440000", "username": "alice", "email": "[email protected]", "is_admin": false, "api_key_prefix": "cems_ak_a1b2c3d4" }, "api_key": "cems_ak_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6", "message": "User created. Save the API key - it will not be shown again."}
Save the API key immediately! It will only be shown once. The key is hashed with bcrypt before storage.
3
Give the API key to the user
Send the API key to Alice securely. She will use it to configure her client:
# Alice runs this on her machineexport CEMS_API_KEY="cems_ak_a1b2c3d4..."export CEMS_API_URL="https://cems.example.com"curl -fsSL https://getcems.com/install.sh | bash
{ "user": { "id": "uuid", "username": "bob", "email": "[email protected]", "is_admin": false, "api_key_prefix": "cems_ak_x1y2z3a4" }, "api_key": "cems_ak_x1y2z3a4...", // Only shown once! "message": "User created. Save the API key - it will not be shown again."}
Reset a user’s API key (e.g., if compromised).Request:
curl -X POST http://localhost:8765/admin/users/{user_id}/reset-key \ -H "Authorization: Bearer $CEMS_ADMIN_KEY"
Response:
{ "user": { "id": "uuid", "username": "alice", "api_key_prefix": "cems_ak_z9y8x7w6" // New prefix }, "api_key": "cems_ak_z9y8x7w6...", // New key (shown once!) "message": "API key reset. Save the new key - it will not be shown again."}
-- UsersCREATE TABLE users ( id UUID PRIMARY KEY, username VARCHAR(255) UNIQUE NOT NULL, email VARCHAR(255) UNIQUE, api_key_hash VARCHAR(255) NOT NULL, api_key_prefix VARCHAR(20) NOT NULL, created_at TIMESTAMP WITH TIME ZONE, last_active TIMESTAMP WITH TIME ZONE, is_active BOOLEAN DEFAULT true, is_admin BOOLEAN DEFAULT false, settings JSONB DEFAULT '{}');-- TeamsCREATE TABLE teams ( id UUID PRIMARY KEY, name VARCHAR(255) UNIQUE NOT NULL, company_id VARCHAR(255) NOT NULL, created_at TIMESTAMP WITH TIME ZONE, settings JSONB DEFAULT '{}');-- Team MembershipCREATE TABLE team_members ( user_id UUID REFERENCES users(id) ON DELETE CASCADE, team_id UUID REFERENCES teams(id) ON DELETE CASCADE, role VARCHAR(50) DEFAULT 'member', joined_at TIMESTAMP WITH TIME ZONE, PRIMARY KEY (user_id, team_id));