Service Accounts
Service accounts enable automated systems (robots, scripts, integrations) to authenticate with Switchyard using API keys.Overview
Service accounts provide:- API Key Authentication: No user interaction required
- Role-based Permissions: Inherit permissions from assigned role
- Audit Trail: Track last usage timestamp
- Secure Storage: API keys are hashed before storage
Creating a Service Account
Use the CLI tool:Managing Service Accounts
Using a Service Account
Authentication
Making API Calls
Database Schema
| Column | Description |
|---|---|
id | Unique identifier |
name | Human-readable name |
api_key_hash | SHA-256 hash of the API key |
role_id | Associated role for permissions |
is_active | Set to false to revoke access |
last_used_at | Tracks last authentication |
Security Best Practices
Rotate Keys Regularly
Rotate Keys Regularly
Create new service accounts periodically and revoke old ones to minimize exposure from compromised keys.
Use Least Privilege
Use Least Privilege
Assign the minimum role required. Use
robot role for automated systems instead of superadmin.Monitor Usage
Monitor Usage
Regularly check
last_used_at to identify unused accounts that should be revoked.Secure Storage
Secure Storage
Store API keys in environment variables or secrets managers, never in code.
Troubleshooting
API Key Not Working
Possible causes:- Typo in API key
- Service account is inactive (
is_active = false) - Role not assigned
- Verify the key is correct (only shown once at creation)
- Check
is_activein the database - Verify
role_idis set