Skip to main content

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:
Parameters:
  • name (string, required): API key name
  • description (string, optional): Key description
  • permissions (array, required): List of permissions
  • rate_limit (object, optional): Rate limiting configuration
    • requests_per_minute (integer): Requests per minute
    • burst_limit (integer): Burst limit
  • expires_at (string, optional): Expiration timestamp
  • metadata (object, optional): Additional metadata
Response:
Note: The API key is only shown once. Store it securely.

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 page
  • offset (integer, default: 0): Pagination offset
Response:

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:
Response:

User Authentication

User Registration

Register a new user account. Endpoint: POST /auth/register Request Body:
Parameters:
  • email (string, required): User email address
  • password (string, required): User password
  • name (string, required): User name
  • organization (string, optional): Organization name
  • metadata (object, optional): Additional user metadata
Response:

User Login

Authenticate user and return session tokens. Endpoint: POST /auth/login Request Body:
Parameters:
  • email (string, required): User email
  • password (string, required): User password
  • remember_me (boolean, optional): Enable longer session
Response:

User Logout

Terminate user session. Endpoint: POST /auth/logout Request Body:
Parameters:
  • 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 URI
  • state (string, optional): CSRF protection token
  • scope (string, optional): Additional scopes (default: email, profile)
Response:

GitHub OAuth Initiate

Initiate GitHub OAuth flow. Endpoint: GET /auth/github Query Parameters:
  • redirect_uri (string, optional): Custom redirect URI
  • state (string, optional): CSRF protection token
  • scope (string, optional): Additional scopes (default: user:email)
Response:

OAuth Callback

Handle OAuth callback from providers. Endpoint: GET /auth/callback/{provider} Query Parameters:
  • code (string): Authorization code
  • state (string): CSRF protection token
  • error (string): Error message (if any)
Response:

Role-Based Access Control (RBAC)

User Roles

Permission Categories

Memory Permissions

  • memory:read - Read memories
  • memory:write - Create/update memories
  • memory:delete - Delete memories

Search Permissions

  • search:read - Perform searches
  • search:write - Advanced search operations

Skills Permissions

  • skills:read - Read skills
  • skills:execute - Execute skills
  • skills:manage - Manage skills

Agent Permissions

  • agents:read - Read agents
  • agents:write - Create/update agents
  • agents: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:
Parameters:
  • 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

  1. Key Rotation: Rotate API keys regularly
  2. Permission Principle: Follow least privilege principle
  3. Key Storage: Store keys securely (environment variables, secrets)
  4. Monitoring: Monitor key usage and revoke unused keys
  5. Rate Limiting: Implement appropriate rate limits

Session Security

  1. Token Expiration: Set appropriate expiration times
  2. Secure Storage: Store tokens securely (HTTP-only cookies)
  3. Token Refresh: Use refresh tokens for long-lived sessions
  4. Session Invalidation: Invalidate sessions on logout/suspicious activity
  5. IP Binding: Consider IP binding for sensitive operations

OAuth Security

  1. State Tokens: Use state tokens for CSRF protection
  2. Redirect Validation: Validate redirect URIs
  3. Scope Limitation: Request minimal necessary scopes
  4. Provider Verification: Verify OAuth providers
  5. Token Storage: Store OAuth tokens securely

Password Security

  1. Strong Passwords: Enforce strong password requirements
  2. Password Hashing: Use secure password hashing
  3. Rate Limiting: Implement login attempt limits
  4. 2FA: Enable two-factor authentication
  5. Password Policies: Implement password rotation policies

RBAC Implementation

  1. Principle of Least Privilege: Grant minimal necessary permissions
  2. Regular Reviews: Review permissions regularly
  3. Permission Auditing: Enable permission audit logging
  4. Role Separation: Separate roles by function
  5. Permission Inheritance: Use role hierarchy where appropriate