Authentication API
The Authentication API provides comprehensive security and access control for the Hystersis platform. It supports API key authentication, session-based authentication, role-based access control (RBAC), and social OAuth integration (Google, GitHub). The system implements granular permissions, multi-factor authentication support, and comprehensive audit logging.Authentication Methods
API Key Authentication
Primary authentication method for API access using API keys. Header:Session Authentication
For web dashboard users with JWT-based session handling. Header:OAuth Authentication
Social login support for Google and GitHub authentication. Redirect URLs:- Google:
https://api.hystersis.com/auth/google/callback - GitHub:
https://api.hystersis.com/auth/github/callback
API Key Management
Create API Key
Generate a new API key for programmatic access. Endpoint:POST /api-keys
Request Body:
name(string, required): API key namedescription(string, optional): Key descriptionpermissions(array, required): List of permissionsrate_limit(object, optional): Rate limiting configurationrequests_per_minute(integer): Requests per minuteburst_limit(integer): Burst limit
expires_at(string, optional): Expiration timestampmetadata(object, optional): Additional metadata
List API Keys
Retrieve all API keys for the current user. Endpoint:GET /api-keys
Query Parameters:
status(string): Filter by status (active, expired, revoked)limit(integer, default: 20, max: 100): Results per pageoffset(integer, default: 0): Pagination offset
Get API Key
Retrieve details for a specific API key. Endpoint:GET /api-keys/{id}
Response:
Update API Key
Update an existing API key configuration. Endpoint:PUT /api-keys/{id}
Request Body:
Delete API Key
Revoke an API key. Endpoint:DELETE /api-keys/{id}
Response:
Rotate API Key
Generate a new API key and revoke the old one. Endpoint:POST /api-keys/{id}/rotate
Request Body:
User Authentication
User Registration
Register a new user account. Endpoint:POST /auth/register
Request Body:
email(string, required): User email addresspassword(string, required): User passwordname(string, required): User nameorganization(string, optional): Organization namemetadata(object, optional): Additional user metadata
User Login
Authenticate user and return session tokens. Endpoint:POST /auth/login
Request Body:
email(string, required): User emailpassword(string, required): User passwordremember_me(boolean, optional): Enable longer session
User Logout
Terminate user session. Endpoint:POST /auth/logout
Request Body:
refresh_token(string, optional): Refresh token to invalidate
Get Current User
Get current authenticated user information. Endpoint:GET /auth/me
Response:
Refresh Token
Generate new access token using refresh token. Endpoint:POST /auth/refresh
Request Body:
Change Password
Update user password. Endpoint:POST /auth/change-password
Request Body:
OAuth Authentication
Google OAuth Initiate
Initiate Google OAuth flow. Endpoint:GET /auth/google
Query Parameters:
redirect_uri(string, optional): Custom redirect URIstate(string, optional): CSRF protection tokenscope(string, optional): Additional scopes (default: email, profile)
GitHub OAuth Initiate
Initiate GitHub OAuth flow. Endpoint:GET /auth/github
Query Parameters:
redirect_uri(string, optional): Custom redirect URIstate(string, optional): CSRF protection tokenscope(string, optional): Additional scopes (default: user:email)
OAuth Callback
Handle OAuth callback from providers. Endpoint:GET /auth/callback/{provider}
Query Parameters:
code(string): Authorization codestate(string): CSRF protection tokenerror(string): Error message (if any)
Role-Based Access Control (RBAC)
User Roles
Permission Categories
Memory Permissions
memory:read- Read memoriesmemory:write- Create/update memoriesmemory:delete- Delete memories
Search Permissions
search:read- Perform searchessearch:write- Advanced search operations
Skills Permissions
skills:read- Read skillsskills:execute- Execute skillsskills:manage- Manage skills
Agent Permissions
agents:read- Read agentsagents:write- Create/update agentsagents:manage- Manage agents
System Permissions
admin:all- All administrative functions
Permission Checking
All API endpoints include permission checking middleware:Two-Factor Authentication
Enable 2FA
Enable two-factor authentication for user account. Endpoint:POST /auth/2fa/enable
Request Body:
otp(string, required): One-time password from authenticator app
Disable 2FA
Disable two-factor authentication. Endpoint:POST /auth/2fa/disable
Request Body:
Verify 2FA
Verify 2FA token during login. Request Body:Error Handling
Common Error Responses
Error Codes
Security Best Practices
API Key Security
- Key Rotation: Rotate API keys regularly
- Permission Principle: Follow least privilege principle
- Key Storage: Store keys securely (environment variables, secrets)
- Monitoring: Monitor key usage and revoke unused keys
- Rate Limiting: Implement appropriate rate limits
Session Security
- Token Expiration: Set appropriate expiration times
- Secure Storage: Store tokens securely (HTTP-only cookies)
- Token Refresh: Use refresh tokens for long-lived sessions
- Session Invalidation: Invalidate sessions on logout/suspicious activity
- IP Binding: Consider IP binding for sensitive operations
OAuth Security
- State Tokens: Use state tokens for CSRF protection
- Redirect Validation: Validate redirect URIs
- Scope Limitation: Request minimal necessary scopes
- Provider Verification: Verify OAuth providers
- Token Storage: Store OAuth tokens securely
Password Security
- Strong Passwords: Enforce strong password requirements
- Password Hashing: Use secure password hashing
- Rate Limiting: Implement login attempt limits
- 2FA: Enable two-factor authentication
- Password Policies: Implement password rotation policies
RBAC Implementation
- Principle of Least Privilege: Grant minimal necessary permissions
- Regular Reviews: Review permissions regularly
- Permission Auditing: Enable permission audit logging
- Role Separation: Separate roles by function
- Permission Inheritance: Use role hierarchy where appropriate