What are Service Users?
Service users in Zitadel are specialized accounts designed for machine-to-machine (M2M) communication and server-to-server authentication. Unlike regular human users who authenticate through interactive login flows, service users are intended for automated processes, backend services, and API integrations.The Zitadel Ruby SDK is specifically designed for service user authentication and does not support interactive user authentication flows like OAuth2, OIDC, or SAML for client applications.
Service Users vs. Human Users
| Feature | Service Users | Human Users |
|---|---|---|
| Purpose | Automated API access, M2M communication | Interactive application access |
| Authentication | Private key JWT, Client Credentials, PAT | OAuth2, OIDC, SAML, password |
| Login Flow | Programmatic, non-interactive | Interactive browser-based |
| Use Case | Backend services, cron jobs, integrations | Web apps, mobile apps, user portals |
| Supported by SDK | ✅ Full support | ❌ Not supported |
Use Cases for Service Users
Service users are ideal for:- Backend Services: Authenticate your Ruby application to access Zitadel APIs
- Scheduled Tasks: Automate user provisioning, synchronization, or cleanup jobs
- Microservices: Enable service-to-service communication within your architecture
- CI/CD Pipelines: Automate deployments and infrastructure management
- Data Integration: Sync user data between Zitadel and external systems
Authentication Methods
The SDK provides three authentication methods for service users:1. Private Key JWT (Recommended for Production)
Most secure option using asymmetric cryptography. The service user signs JWTs with a private key stored in a JSON file.Private Key JWT offers the strongest security as the secret never leaves your infrastructure. Learn more in the Zitadel documentation.
2. Client Credentials Grant
OAuth2-based authentication using a client ID and secret. The SDK automatically handles token acquisition and refresh.3. Personal Access Token (PAT)
Simplest method using a pre-generated token. Best for development and testing.PATs are convenient for development but should be rotated regularly in production. They don’t support automatic token refresh.
Creating a Service User
To create a service user in Zitadel:- Navigate to your Zitadel Console
- Go to Users > Service Users
- Click “New Service User”
- Configure authentication method (JWT, Client Credentials, or PAT)
- Assign necessary roles and permissions
- Download credentials (private key JSON or note client secret/PAT)
Example: Creating a service user with user management permissions
Example: Creating a service user with user management permissions
Security Best Practices
- Use Private Key JWT in production for maximum security
- Rotate credentials regularly, especially PATs
- Apply principle of least privilege - grant only necessary permissions
- Store credentials securely using environment variables or secret management services
- Monitor service user activity through Zitadel audit logs
- Never share credentials between different services or environments
Common Patterns
Environment-Based Configuration
Rails Initializer
Next Steps
- Learn about Configuration options
- Understand Error Handling patterns
- Enable Debugging for troubleshooting