openapi: 3.1.0 info: title: Aegis AI Gateway API description: | # 🛡️ Aegis AI Control Plane API The **Aegis AI Gateway** is the high-performance orchestration layer for the Aegis offensive cyberdefense platform. It provides secure, unified access to scan orchestration, vulnerability intelligence, team management, and billing operations. ### 🚀 Core Missions * **Automated Pentesting**: Trigger and monitor large-scale security scans powered by Temporal workflows. * **Threat Intelligence**: Access technical proofs and CVE data extracted by specialized worker fleets. * **Enterprise RBAC**: Manage multi-tenant organizations with granular roles (SuperAdmin, Admin, Billing, etc.). * **Financial Governance**: Monitor token consumption, manage licenses, and track audit trails. ### 🔒 Security & Authentication Aegis AI enforces a Zero-Trust architecture: 1. **Primary Auth**: JWT Bearer Token (short-lived). 2. **Session Persistence**: HTTP-only Secure Refresh Token (Rotation enforced). 3. **Permission Scopes**: Every endpoint is gated by specific RBAC scopes. --- *Internal Version: 3.1.0 (Agent onboarding, token rotation, dashboard status)* version: 3.1.0 contact: name: Aegis Security Engineering url: https://aegis-ai.fr email: security@aegis.ai license: name: Proprietary servers: - url: https://api.aegis-ai.fr/ description: Production Environment (TLS 1.3 enforced) - url: http://localhost/ description: Local Development Environment (via Nginx Proxy) tags: - name: Authentication description: Identity management, session lifecycle, and profile control - name: Pentest Operations description: Large-scale offensive security workflow orchestration - name: Vulnerabilities description: Security intelligence on discovered threats and technical evidences - name: Administration description: High-privilege management of companies, users, and audit logs - name: Billing & Finance description: Token management, ledger tracking, and usage analytics - name: Platform description: Health monitoring and environment status - name: Agent Operations description: Remote probe registration and heartbeat telemetry security: - BearerAuth: [] paths: # --- Platform --- /health: get: summary: Retrieve platform health status (K8s) description: Performs a shallow check of the API Gateway. tags: - Platform security: [] responses: "200": description: System is operational /api/health: get: summary: Retrieve API health status tags: - Platform security: [] responses: "200": description: API is operational /api/: get: summary: Retrieve root metadata description: Returns versioning and service identification for initial environment handshake. tags: - Platform security: [] responses: "200": description: Metadata retrieved content: application/json: schema: $ref: "#/components/schemas/RootMetadata" # --- Authentication --- /api/auth/login: post: summary: Authenticate and establish a session description: | Validates credentials and returns a short-lived Access Token. Sets an `refresh_token` cookie (HTTP-only, Secure, SameSite=Lax). tags: - Authentication security: [] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/LoginRequest" responses: "200": description: Successfully authenticated content: application/json: schema: $ref: "#/components/schemas/AuthResponse" "401": description: Invalid credentials /api/auth/refresh: post: summary: Rotate session tokens description: Uses the secure refresh cookie to issue a new Access Token. tags: - Authentication security: [] responses: "200": description: Token rotated content: application/json: schema: $ref: "#/components/schemas/AuthResponse" "401": description: Refresh token missing, invalid, or expired /api/auth/setup-password: post: summary: Activate invited account and return the one-time agent token description: | Finalizes first-login activation from an invitation token, sets the secure refresh cookie, returns an access token, and returns the initial company deployment token as `agent_token`. The agent token is displayed only once and must be stored by the owner. tags: - Authentication security: [] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/SetupPasswordRequest" responses: "200": description: Account activated content: application/json: schema: $ref: "#/components/schemas/SetupPasswordResponse" "400": description: Invalid body or weak password content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "401": description: Invalid or expired invitation token "404": description: Invited user not found /api/auth/logout: post: summary: Terminate current session tags: - Authentication responses: "204": description: Logged out successfully /api/auth/me: get: summary: Retrieve current session profile tags: - Authentication responses: "200": description: Profile retrieved content: application/json: schema: $ref: "#/components/schemas/User" # --- Agent Operations --- /api/agents/register: post: summary: Register a new remote agent description: | Exchanges a company deployment token for a unique agent identity and secret. The deployment token is provided both as a Bearer token for the agent middleware and in the JSON body consumed by the registration handler. tags: - Agent Operations security: - AgentDeploymentToken: [] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AgentRegisterRequest" responses: "200": description: Agent registered successfully content: application/json: schema: $ref: "#/components/schemas/AgentRegisterResponse" "400": description: Invalid registration payload "401": description: Deployment token is invalid /api/agents/{id}/status: post: summary: Update agent operational status description: Sends a heartbeat and telemetry status update. Requires Agent Secret in Authorization header. tags: - Agent Operations security: - AgentSecret: [] parameters: - name: id in: path required: true schema: type: string format: uuid requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AgentStatusUpdateRequest" responses: "200": description: Status updated successfully "400": description: Invalid status payload "401": description: Agent secret is invalid "500": description: Status update failed /api/agents/{id}/upload-url: get: summary: Generate presigned upload URL description: Returns a MinIO PUT URL for log/telemetry ingestion. Requires Agent Secret. tags: - Agent Operations security: - AgentSecret: [] parameters: - name: id in: path required: true schema: type: string format: uuid - name: filename in: query required: true schema: type: string responses: "200": description: Presigned URL generated content: application/json: schema: $ref: "#/components/schemas/AgentUploadLinkResponse" "400": description: Missing filename query parameter "401": description: Agent secret is invalid "500": description: Upload URL generation failed /api/agents: get: summary: List agents visible to the authenticated company description: Returns registered agents for the current company scope. Superadmin/admin flows may pass `company_id`. tags: - Agent Operations parameters: - name: company_id in: query required: false schema: type: string format: uuid description: Optional company scope for privileged users. responses: "200": description: Agent list content: application/json: schema: $ref: "#/components/schemas/AgentListResponse" "500": description: Failed to list agents /api/agents/status: get: summary: Retrieve dashboard agent status summary description: Aggregated agent health used by the Dashboard empty-state and monitoring widget. tags: - Agent Operations parameters: - name: company_id in: query required: false schema: type: string format: uuid responses: "200": description: Agent status summary content: application/json: schema: $ref: "#/components/schemas/AgentStatusSummary" "500": description: Failed to retrieve status summary # --- User Profile Management --- /api/users/me/profile: put: summary: Update personal profile tags: - Authentication requestBody: required: true content: application/json: schema: type: object properties: name: type: string responses: "200": description: Profile updated /api/users/me/profile/avatar: delete: summary: Remove profile avatar tags: - Authentication responses: "200": description: Avatar removed /api/users/me/email: put: summary: Change account email tags: - Authentication requestBody: required: true content: application/json: schema: type: object required: [email, password] properties: email: type: string format: email password: type: string responses: "200": description: Email updated /api/users/me/password: put: summary: Change account password tags: - Authentication requestBody: required: true content: application/json: schema: type: object required: [old_password, new_password] properties: old_password: type: string new_password: type: string responses: "200": description: Password updated # --- User Storage --- /api/storage/upload-url: get: summary: Generate presigned upload URL (User) description: Requires User JWT. tags: - Platform parameters: - name: prefix in: query schema: type: string description: Optional directory prefix (e.g., avatars, evidence) responses: "200": description: URL generated content: application/json: schema: type: object properties: url: type: string object_name: type: string expires_in: type: string example: "15m" # --- Companies --- /api/companies: get: summary: List accessible companies description: Retrieves companies associated with the user. SuperAdmins see all. tags: - Administration responses: "200": description: Companies list content: application/json: schema: type: object properties: companies: type: array items: $ref: "#/components/schemas/CompanySummary" post: summary: Register a new company tags: - Administration requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateCompanyRequest" responses: "201": description: Company registered /api/companies/onboard: post: summary: Post-payment client onboarding description: Creates company and owner in pending activation, then sends a first-login invitation email. tags: - Administration requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/OnboardCompanyRequest" responses: "201": description: Company and pending owner created content: application/json: schema: $ref: "#/components/schemas/OnboardCompanyResponse" "400": description: Invalid onboarding request "500": description: Onboarding failed /api/companies/me/agent-token/rotate: post: summary: Rotate current company deployment token description: Generates and returns a new one-time deployment token for the authenticated company. tags: - Agent Operations responses: "201": description: New deployment token generated content: application/json: schema: $ref: "#/components/schemas/AgentTokenResponse" "400": description: Invalid company context "403": description: Missing permission "404": description: Company not found /api/companies/me/agent-token/revoke: post: summary: Revoke current company deployment token description: Invalidates the active deployment token. Already registered agents keep using their `agent_secret`. tags: - Agent Operations responses: "204": description: Deployment token revoked "403": description: Missing permission "404": description: Company not found # --- Admin & Search --- /api/admin/companies: get: summary: Search for companies description: Advanced search with filters for administrative oversight. tags: - Administration parameters: - name: search in: query schema: type: string description: Partial name match or exact ID responses: "200": description: Search results content: application/json: schema: type: array items: $ref: "#/components/schemas/CompanySearchResult" /api/admin/users: get: summary: Search for users tags: - Administration parameters: - name: search in: query schema: type: string - name: company_id in: query schema: type: string responses: "200": description: Search results content: application/json: schema: type: array items: $ref: "#/components/schemas/UserSearchResult" post: summary: Administrative user invitation description: Create a pending user and send a one-time activation email. tags: - Administration requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AdminCreateUserRequest" responses: "201": description: Invitation sent /api/admin/audit-logs: get: summary: Retrieve system audit trails description: Logs of every security-sensitive action across the platform. tags: - Administration parameters: - name: company_id in: query schema: type: string - name: limit in: query schema: type: integer default: 50 - name: offset in: query schema: type: integer default: 0 responses: "200": description: Audit logs list content: application/json: schema: $ref: "#/components/schemas/AuditLogResponse" /api/admin/teams/stream: get: summary: Real-time team updates (SSE) description: Stream of events related to user and company lifecycle. tags: - Administration responses: "200": description: SSE stream established # --- Scans --- /api/scans: get: summary: List pentest operations tags: - Pentest Operations responses: "200": description: List of scans content: application/json: schema: type: array items: $ref: "#/components/schemas/Scan" post: summary: Initialize a pentest workflow description: Dispatches a new mission to the worker fleet via Temporal. tags: - Pentest Operations requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateScanRequest" responses: "201": description: Scan queued content: application/json: schema: $ref: "#/components/schemas/CreateScanResponse" /api/scans/{id}: get: summary: Retrieve specific scan status tags: - Pentest Operations parameters: - name: id in: path required: true schema: type: string responses: "200": description: Scan details content: application/json: schema: $ref: "#/components/schemas/Scan" /api/scans/{id}/vulnerabilities: get: summary: Retrieve discoveries for a scan tags: - Vulnerabilities parameters: - name: id in: path required: true schema: type: string responses: "200": description: Vulnerabilities list content: application/json: schema: type: array items: $ref: "#/components/schemas/Vulnerability" /api/scans/{id}/report: get: summary: Download PDF pentest report tags: - Pentest Operations parameters: - name: id in: path required: true schema: type: string responses: "200": description: PDF Binary data content: application/pdf: schema: type: string format: binary /api/scans/stream: get: summary: Universal scan status stream (SSE) tags: - Pentest Operations responses: "200": description: SSE established /api/scans/{id}/stream: get: summary: Mission-specific status stream (SSE) tags: - Pentest Operations parameters: - name: id in: path required: true schema: type: string responses: "200": description: SSE established # --- Vulnerabilities --- /api/vulnerabilities/{id}/evidences: get: summary: Retrieve technical evidences description: Detailed proofs (payloads, loot) for a specific vulnerability. tags: - Vulnerabilities parameters: - name: id in: path required: true schema: type: string responses: "200": description: Evidences list content: application/json: schema: type: array items: $ref: "#/components/schemas/Evidence" # --- Billing --- /api/billing/balance: get: summary: Get current token balance tags: - Billing & Finance responses: "200": description: Balance details content: application/json: schema: $ref: "#/components/schemas/BalanceResponse" /api/billing/ledger: get: summary: Retrieve transaction history tags: - Billing & Finance parameters: - name: limit in: query schema: type: integer - name: offset in: query schema: type: integer responses: "200": description: Ledger entries content: application/json: schema: $ref: "#/components/schemas/LedgerResponse" /api/billing/stats: get: summary: Usage analytics tags: - Billing & Finance parameters: - name: days in: query schema: type: integer default: 30 responses: "200": description: Consumption stats content: application/json: schema: $ref: "#/components/schemas/UsageStatsResponse" # --- Admin Billing --- /api/admin/companies/{id}/tokens/adjust: post: summary: Adjust company balance description: Add or remove tokens with a mandatory reason. tags: - Billing & Finance parameters: - name: id in: path required: true schema: type: string requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AdjustTokensRequest" responses: "200": description: Tokens adjusted content: application/json: schema: $ref: "#/components/schemas/BalanceResponse" /api/admin/companies/{id}/agent-token/rotate: post: summary: Admin rotate company deployment token description: Generates a new deployment token for the target company. tags: - Agent Operations parameters: - name: id in: path required: true schema: type: string format: uuid responses: "201": description: New deployment token generated content: application/json: schema: $ref: "#/components/schemas/AgentTokenResponse" "400": description: Missing or invalid company id "403": description: Missing admin permission "404": description: Company not found /api/admin/companies/{id}/billing/balance: get: summary: Admin view of company balance tags: - Billing & Finance parameters: - name: id in: path required: true schema: type: string responses: "200": description: Balance details content: application/json: schema: $ref: "#/components/schemas/BalanceResponse" /api/admin/companies/{id}/billing/ledger: get: summary: Admin view of company ledger tags: - Billing & Finance parameters: - name: id in: path required: true schema: type: string responses: "200": description: Ledger entries content: application/json: schema: $ref: "#/components/schemas/LedgerResponse" /api/admin/companies/{id}/billing/stats: get: summary: Admin view of company usage tags: - Billing & Finance parameters: - name: id in: path required: true schema: type: string responses: "200": description: Consumption stats content: application/json: schema: $ref: "#/components/schemas/UsageStatsResponse" components: securitySchemes: BearerAuth: type: http scheme: bearer bearerFormat: JWT description: Access Token returned by /auth/login AgentDeploymentToken: type: http scheme: bearer bearerFormat: ag_<43+ URL-safe chars> description: One-time company deployment token used only on /api/agents/register AgentSecret: type: http scheme: bearer bearerFormat: agent_secret description: Per-agent operational secret returned by /api/agents/register schemas: # --- Auth & User --- LoginRequest: type: object required: [email, password] properties: email: type: string format: email password: type: string format: password AuthResponse: type: object properties: access_token: type: string expires_in: type: integer description: Seconds until expiration token_type: type: string example: Bearer SetupPasswordRequest: type: object required: [token, password] properties: token: type: string description: Invitation token received by email. password: type: string format: password minLength: 8 SetupPasswordResponse: type: object properties: access_token: type: string agent_token: type: string description: One-time company deployment token displayed once. pattern: "^ag_[A-Za-z0-9_-]{43,}$" expires_in: type: integer example: 900 User: type: object properties: id: type: string format: uuid email: type: string format: email name: type: string role: $ref: "#/components/schemas/UserRole" company_id: type: string format: uuid avatar_url: type: string nullable: true UserRole: type: string enum: [ superadmin, admin, billing_aegis, technicien, support, owner, billing_client, operateur, viewer, ] # --- Companies --- CompanySummary: type: object properties: id: type: string format: uuid name: type: string owner_id: type: string format: uuid owner_email: type: string member_count: type: integer deployment_token: type: string avatar_url: type: string token_balance: type: integer CreateCompanyRequest: type: object required: [name, owner_email] properties: name: type: string owner_email: type: string OnboardCompanyRequest: type: object required: [company_name, owner_name, owner_email] properties: company_name: type: string owner_name: type: string owner_email: type: string plan_id: type: string enum: [starter, pro, scale] OnboardCompanyResponse: type: object properties: company_id: type: string owner_id: type: string CompanySearchResult: type: object properties: id: type: string name: type: string deployment_token: type: string owner_email: type: string avatar_url: type: string UserSearchResult: type: object properties: id: type: string name: type: string email: type: string role: type: string AdminCreateUserRequest: type: object required: [email, name, role, company_id] properties: email: type: string format: email name: type: string role: $ref: "#/components/schemas/UserRole" company_id: type: string format: uuid # --- Agents --- AgentRegisterRequest: type: object required: [token] properties: token: type: string pattern: "^ag_[A-Za-z0-9_-]{43,}$" description: Company deployment token. name: type: string description: Friendly agent name. example: prod-node-01 AgentRegisterResponse: type: object properties: agent_id: type: string format: uuid agent_secret: type: string description: Operational secret returned once and persisted by the agent. AgentStatusUpdateRequest: type: object required: [status] properties: status: type: string enum: [IDLE, RUNNING, ERROR, OFFLINE] AgentUploadLinkResponse: type: object properties: url: type: string format: uri method: type: string example: PUT AgentRecord: type: object properties: id: type: string format: uuid company_id: type: string format: uuid name: type: string status: type: string last_seen: type: string format: date-time nullable: true created_at: type: string format: date-time nullable: true AgentListResponse: type: object properties: agents: type: array items: $ref: "#/components/schemas/AgentRecord" AgentStatusSummary: type: object properties: total_agents: type: integer active_agents: type: integer inactive_agents: type: integer last_seen: type: string format: date-time nullable: true AgentTokenResponse: type: object properties: agent_token: type: string pattern: "^ag_[A-Za-z0-9_-]{43,}$" description: New deployment token displayed once. # --- Scans & Vulns --- Scan: type: object properties: id: type: string format: uuid target: type: string status: type: string enum: [PENDING, RUNNING, COMPLETED, FAILED] created_at: type: string format: date-time CreateScanRequest: type: object required: [target] properties: target: type: string example: "https://example.com" CreateScanResponse: type: object properties: scan_id: type: string format: uuid Vulnerability: type: object properties: id: type: string format: uuid title: type: string severity: type: string enum: [CRITICAL, HIGH, MEDIUM, LOW, INFO] cve_id: type: string nullable: true Evidence: type: object properties: id: type: string format: uuid type: type: string data: type: string # --- Billing & Finance --- BalanceResponse: type: object properties: company_id: type: string balance: type: integer AdjustTokensRequest: type: object required: [amount, reason] properties: amount: type: integer reason: type: string LedgerResponse: type: object properties: entries: type: array items: $ref: "#/components/schemas/LedgerEntry" LedgerEntry: type: object properties: id: type: string amount: type: integer type: type: string reason: type: string created_at: type: string format: date-time UsageStatsResponse: type: object properties: stats: type: array items: type: object properties: date: type: string format: date tokens: type: integer # --- Platform --- HealthStatus: type: object properties: status: type: string example: healthy services: type: object RootMetadata: type: object properties: version: type: string environment: type: string # --- Audit Logs --- AuditLogResponse: type: object properties: logs: type: array items: $ref: "#/components/schemas/AuditLogEntry" total: type: integer AuditLogEntry: type: object properties: id: type: string action: type: string actor_email: type: string company_id: type: string metadata: type: object created_at: type: string format: date-time # --- Errors --- ErrorResponse: type: object properties: error: type: string