Automate Keycloak realm and client configuration via the Admin REST API

domain: keycloak.org · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Obtain an admin access token by POSTing to https://{host}/realms/master/protocol/openid-connect/token with grant_type=client_credentials (or password) and credentials for an admin client or user.
  2. Create a new realm by POSTing a RealmRepresentation JSON body to POST /admin/realms; include at minimum the realm name, enabled true, and any initial settings.
  3. Create a client within the realm by POSTing a ClientRepresentation to POST /admin/realms/{realm}/clients; set clientId, protocol (openid-connect), redirectUris, and publicClient or serviceAccountsEnabled as appropriate.
  4. Retrieve the generated client secret for confidential clients by calling GET /admin/realms/{realm}/clients/{clientUuid}/client-secret.
  5. Add protocol mappers to the client or client scope using POST /admin/realms/{realm}/clients/{clientUuid}/protocol-mappers/models to customize token claims.
  6. Assign realm roles or composite roles to service accounts or users via the role-mappings sub-resource on the user or service account endpoint.

Known gotchas

Related routes

Create a Keycloak realm with a confidential OIDC client, configure client scopes and a custom claim mapper, and exchange tokens with token introspection
keycloak.org · 6 steps · unrated
Implement Keycloak fine-grained authorization with UMA 2.0 and policy evaluation API
keycloak.org · 6 steps · unrated
Create and manage Zendesk macros via the REST API for automated agent-facing response templates
zendesk.com · 6 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans