{"openapi":"3.1.0","info":{"title":"Identity API — LiveOne","version":"1.0.0","description":"Enterprise authentication & identity service providing:\n- Session-based authentication with secure cookies\n- Email/password registration and login\n- Email verification with codes and links\n- Password reset flow\n- Session management (list, revoke)\n- Account lockout protection\n- Rate limiting\n- Admin impersonation with audit trails\n- Security event logging","contact":{"name":"LiveOne API Support","email":"support@liveone.com","url":"https://dash.liveone.ai"}},"servers":[{"url":"https://identity.liveone.ai","description":"Production"}],"components":{"schemas":{"LoginResponse":{"anyOf":[{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"sessionToken":{"type":"string"},"user":{"$ref":"#/components/schemas/BaseUser"},"organizations":{"type":"array","items":{"$ref":"#/components/schemas/BaseOrganizationMembership"}}},"required":["success","sessionToken","user","organizations"]},{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"requires2FA":{"type":"boolean","enum":[true]},"challengeToken":{"type":"string"},"method":{"type":"string"}},"required":["success","requires2FA","challengeToken","method"]}]},"BaseUser":{"type":"object","properties":{"id":{"type":"string","example":"user_123"},"email":{"type":"string","format":"email","example":"user@example.com"},"username":{"type":["string","null"],"example":"johndoe"},"fullName":{"type":["string","null"],"example":"John Doe"},"displayName":{"type":["string","null"],"example":"Johnny"},"bio":{"type":["string","null"],"example":"Software developer"},"avatarUrl":{"type":["string","null"],"example":"https://example.com/avatar.jpg"},"profilePhotoUrl":{"type":["string","null"],"example":"https://example.com/photo.jpg"},"profilePhotoAssetId":{"type":["string","null"],"example":"asset_123"},"phoneNumber":{"type":["string","null"],"example":"+1234567890"},"emailVerified":{"type":"boolean","example":true},"status":{"type":["string","null"],"example":"active"},"isPlatformOperator":{"type":"boolean","example":false},"createdAt":{"type":["string","null"],"example":"2024-01-01T00:00:00Z"},"updatedAt":{"type":["string","null"],"example":"2024-01-01T00:00:00Z"},"deletedAt":{"type":["string","null"],"example":null}},"required":["id","email","username","fullName","displayName","bio","avatarUrl","profilePhotoUrl","profilePhotoAssetId","phoneNumber","emailVerified","status","createdAt","updatedAt","deletedAt"]},"BaseOrganizationMembership":{"type":"object","properties":{"id":{"type":"string","example":"org_123"},"name":{"type":"string","example":"Acme Corp"},"slug":{"type":"string","example":"acme-corp"},"role":{"type":"string","example":"admin"},"logoUrl":{"type":["string","null"],"example":"https://r2.liveone.app/logos/org_123.png"},"faviconUrl":{"type":["string","null"],"example":"https://r2.liveone.app/favicons/org_123.ico"},"themeUrl":{"type":["string","null"],"example":"preset:ocean-dark"},"themeVersion":{"type":"integer","example":1}},"required":["id","name","slug","role"]},"ApiError":{"type":"object","properties":{"success":{"type":"boolean","enum":[false],"example":false},"error":{"type":"object","properties":{"code":{"type":"string","example":"UNAUTHORIZED"},"message":{"type":"string","example":"Authentication required"},"docsUrl":{"type":"string","example":"/api/reference#tag/errors/unauthorized"},"details":{"type":"object","additionalProperties":{},"example":{"field":"email"}},"retryAfter":{"type":"number","example":60},"field":{"type":"string","example":"email"}},"required":["code","message"]},"requestId":{"type":"string","example":"550e8400-e29b-41d4-a716-446655440000"}},"required":["success","error"]},"LoginRequest":{"type":"object","properties":{"email":{"type":"string","format":"email","example":"user@example.com"},"password":{"type":"string","minLength":1,"example":"password123"}},"required":["email","password"]},"LogoutResponse":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"}},"required":["success"]},"MeResponse":{"type":"object","properties":{"user":{"$ref":"#/components/schemas/MeUser"},"organizations":{"type":"array","items":{"$ref":"#/components/schemas/BaseOrganizationMembership"}},"activeOrganizationId":{"type":["string","null"]}},"required":["user"]},"MeUser":{"allOf":[{"$ref":"#/components/schemas/BaseUser"},{"type":"object","properties":{"impersonation":{"$ref":"#/components/schemas/ImpersonationData"}}}]},"ImpersonationData":{"type":["object","null"],"properties":{"isImpersonating":{"type":"boolean"},"impersonatorId":{"type":["string","null"]},"sessionId":{"type":["string","null"]},"startedAt":{"type":["string","null"]},"reason":{"type":["string","null"]}},"required":["impersonatorId","sessionId","startedAt","reason"]},"SignupResponse":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"},"signupClaimToken":{"type":"string"},"user":{"$ref":"#/components/schemas/SignupUser"},"organization":{"$ref":"#/components/schemas/SignupOrganization"}},"required":["success","message","user","organization"]},"SignupUser":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string","format":"email"},"username":{"type":["string","null"]},"fullName":{"type":["string","null"]},"emailVerified":{"type":"boolean"}},"required":["id","email","username","fullName","emailVerified"]},"SignupOrganization":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"type":{"type":"string","enum":["personal","organization"]}},"required":["id","name","slug","type"]},"SignupRequest":{"type":"object","properties":{"email":{"type":"string","format":"email","example":"user@example.com"},"username":{"type":"string","minLength":3,"maxLength":30,"pattern":"^[a-zA-Z0-9_.-]+$","example":"john_doe"},"password":{"type":"string","minLength":8,"pattern":"[A-Z]","example":"SecurePass123!"},"name":{"type":"string","minLength":1,"example":"John Doe"}},"required":["email","password","name"]},"SuccessMessageResponse":{"type":"object","properties":{"success":{"type":"boolean","example":true},"message":{"type":"string","example":"Operation completed successfully"}},"required":["success","message"]},"ForgotPasswordRequest":{"type":"object","properties":{"email":{"type":"string","format":"email","example":"user@example.com"}},"required":["email"]},"ResetPasswordResponse":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"},"sessionToken":{"type":"string"},"user":{"$ref":"#/components/schemas/BaseUser"},"organizations":{"type":"array","items":{"$ref":"#/components/schemas/BaseOrganizationMembership"}}},"required":["success","message","sessionToken","user","organizations"]},"ResetPasswordRequest":{"type":"object","properties":{"token":{"type":"string","minLength":1,"example":"reset_token_abc123"},"password":{"type":"string","minLength":8,"pattern":"[A-Z]","example":"NewSecurePass123!"}},"required":["token","password"]},"ChangePasswordRequest":{"type":"object","properties":{"currentPassword":{"type":"string","minLength":1},"newPassword":{"type":"string","minLength":8,"pattern":"[A-Z]","example":"NewSecurePass123!"}},"required":["currentPassword","newPassword"]},"VerifyEmailResponse":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"},"alreadyVerified":{"type":"boolean"},"sessionToken":{"type":"string"},"user":{"$ref":"#/components/schemas/BaseUser"},"organizations":{"type":"array","items":{"$ref":"#/components/schemas/BaseOrganizationMembership"}}},"required":["success","message"]},"VerifyEmailRequest":{"anyOf":[{"$ref":"#/components/schemas/VerifyEmailByTokenRequest"},{"$ref":"#/components/schemas/VerifyEmailByCodeRequest"}]},"VerifyEmailByTokenRequest":{"type":"object","properties":{"token":{"type":"string","minLength":1}},"required":["token"]},"VerifyEmailByCodeRequest":{"type":"object","properties":{"email":{"type":"string","format":"email"},"code":{"type":"string","minLength":6,"maxLength":6}},"required":["email","code"]},"ResendVerificationRequest":{"type":"object","properties":{"email":{"type":"string","format":"email"}},"required":["email"]},"ListSessionsResponse":{"type":"object","properties":{"sessions":{"type":"array","items":{"$ref":"#/components/schemas/Session"}}},"required":["sessions"]},"Session":{"type":"object","properties":{"id":{"type":"string"},"device":{"$ref":"#/components/schemas/SessionDevice"},"location":{"$ref":"#/components/schemas/SessionLocation"},"latitude":{"type":["number","null"]},"longitude":{"type":["number","null"]},"ipAddress":{"type":["string","null"]},"isActive":{"type":"boolean"},"isCurrent":{"type":"boolean"},"lastActivityAt":{"type":"string","format":"date-time"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","isActive","isCurrent","lastActivityAt","createdAt"]},"SessionDevice":{"type":["object","null"],"properties":{"type":{"type":"string","enum":["desktop","mobile","tablet"]},"browser":{"type":"string"},"browserVersion":{"type":"string"},"os":{"type":"string"},"osVersion":{"type":"string"},"vendor":{"type":"string"},"model":{"type":"string"}}},"SessionLocation":{"type":["object","null"],"properties":{"country":{"type":"string"},"city":{"type":"string"},"region":{"type":"string"},"timezone":{"type":"string"}}},"RevokeSessionRequest":{"type":"object","properties":{"sessionId":{"type":"string","minLength":1,"description":"The ID of the session to revoke","example":"sess_abc123"}},"required":["sessionId"]},"CheckUsernameResponse":{"type":"object","properties":{"available":{"type":"boolean"},"message":{"type":"string"}},"required":["available","message"]},"CheckEmailResponse":{"type":"object","properties":{"available":{"type":"boolean"},"message":{"type":"string"}},"required":["available","message"]},"ChangeEmailResponse":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"},"token":{"type":"string"}},"required":["success","message"]},"EmailChangeError":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]},"ChangeEmailRequest":{"type":"object","properties":{"newEmail":{"type":"string","format":"email","description":"New email address","example":"newemail@example.com"},"password":{"type":"string","minLength":1,"description":"Current password for verification","example":"CurrentPass123!"}},"required":["newEmail","password"]},"VerifyEmailChangeResponse":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"}},"required":["success","message"]},"VerifyEmailChangeRequest":{"type":"object","properties":{"token":{"type":"string","minLength":1,"description":"Verification token from email"}},"required":["token"]},"CancelEmailChangeResponse":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"}},"required":["success","message"]},"CancelEmailChangeRequest":{"type":"object","properties":{"token":{"type":"string","minLength":1,"description":"Token from email change request"}},"required":["token"]},"ImpersonationResponse":{"type":"object","properties":{"success":{"type":"boolean","example":true},"sessionId":{"type":"string","example":"session_xyz789"},"sessionToken":{"type":"string","example":"tok_abc123..."},"message":{"type":"string","example":"Now impersonating John Doe"}},"required":["success"]},"ImpersonationError":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string","example":"FORBIDDEN"},"message":{"type":"string","example":"Insufficient permissions: user.impersonate required"},"docsUrl":{"type":"string","example":"/api/reference#tag/errors/forbidden"}},"required":["code","message","docsUrl"]}},"required":["success","error"]},"StartImpersonationRequest":{"type":"object","properties":{"targetUserId":{"type":"string","minLength":1,"example":"user_abc123","description":"The ID of the user to impersonate"},"reason":{"type":"string","minLength":1,"example":"Debugging user-reported issue #12345","description":"The reason for impersonation (required for audit trail)"},"confirmPassword":{"type":"string","minLength":1,"example":"mySecurePassword123","description":"Admin password confirmation required before impersonation is granted"}},"required":["targetUserId","reason","confirmPassword"]},"ImpersonationStatusResponse":{"type":"object","properties":{"isImpersonating":{"type":"boolean","example":true},"impersonatorId":{"type":["string","null"],"example":"admin_abc123"},"targetUserId":{"type":["string","null"],"example":"user_xyz789"},"startedAt":{"type":["string","null"],"format":"date-time","example":"2024-01-15T10:30:00Z"},"reason":{"type":["string","null"],"example":"Debugging user-reported issue #12345"}},"required":["isImpersonating","impersonatorId","targetUserId","startedAt","reason"]},"ListProvidersResponse":{"type":"object","properties":{"providers":{"type":"array","items":{"$ref":"#/components/schemas/OAuthProviderInfo"}}},"required":["providers"]},"OAuthProviderInfo":{"type":"object","properties":{"type":{"$ref":"#/components/schemas/OAuthProvider"},"displayName":{"type":"string"},"configured":{"type":"boolean"},"iconUrl":{"type":"string"}},"required":["type","displayName","configured"]},"OAuthProvider":{"type":"string","enum":["google","apple"]},"InitiateResponse":{"type":"object","properties":{"authUrl":{"type":"string","format":"uri"},"state":{"type":"string"}},"required":["authUrl","state"]},"OAuthError":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"}},"required":["error","message"]},"VerifyOAuthLinkResponse":{"type":"object","properties":{"success":{"type":"boolean"},"user":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string"},"displayName":{"type":["string","null"]},"avatarUrl":{"type":["string","null"]}},"required":["id","email","displayName","avatarUrl"]}},"required":["success","user"]},"VerifyOAuthLinkRequest":{"type":"object","properties":{"email":{"type":"string","format":"email","description":"Email address of the existing account"},"code":{"type":"string","minLength":6,"maxLength":6,"description":"Verification code sent to email"}},"required":["email","code"]},"LinkedProvidersResponse":{"type":"object","properties":{"providers":{"type":"array","items":{"$ref":"#/components/schemas/LinkedProvider"}}},"required":["providers"]},"LinkedProvider":{"type":"object","properties":{"provider":{"$ref":"#/components/schemas/OAuthProvider"},"email":{"type":"string","format":"email"},"linkedAt":{"type":"number"}},"required":["provider","email","linkedAt"]},"LinkProviderRequest":{"type":"object","properties":{"provider":{"$ref":"#/components/schemas/OAuthProvider"},"code":{"type":"string"},"redirectUri":{"type":"string","format":"uri"}},"required":["provider","code","redirectUri"]},"UnlinkProviderRequest":{"type":"object","properties":{"provider":{"$ref":"#/components/schemas/OAuthProvider"}},"required":["provider"]},"SystemHealthResponse":{"type":"object","properties":{"status":{"type":"string","enum":["healthy","degraded","unhealthy"]},"timestamp":{"type":"string","format":"date-time"},"uptime":{"type":"number"},"components":{"type":"object","properties":{"database":{"type":"object","properties":{"status":{"type":"string","enum":["healthy","unhealthy"]},"responseTime":{"type":"number"}},"required":["status"]},"cache":{"type":"object","properties":{"status":{"type":"string","enum":["healthy","unhealthy"]},"responseTime":{"type":"number"}},"required":["status"]}},"required":["database","cache"]}},"required":["status","timestamp","uptime","components"]},"ListAppOAuthConfigsResponse":{"type":"object","properties":{"apps":{"type":"array","items":{"$ref":"#/components/schemas/AppOAuthConfig"}}},"required":["apps"]},"AppOAuthConfig":{"type":"object","properties":{"appId":{"type":"string"},"appName":{"type":"string"},"appSlug":{"type":"string"},"domain":{"type":["string","null"]},"google":{"type":"object","properties":{"configured":{"type":"boolean"},"clientId":{"type":["string","null"]},"hasSecret":{"type":"boolean"},"authorizedDomains":{"type":"array","items":{"type":"string"}}},"required":["configured","clientId","hasSecret","authorizedDomains"]},"apple":{"type":"object","properties":{"configured":{"type":"boolean"},"clientId":{"type":["string","null"]},"teamId":{"type":["string","null"]},"hasKeyFile":{"type":"boolean"}},"required":["configured","clientId","teamId","hasKeyFile"]}},"required":["appId","appName","appSlug","domain","google","apple"]},"AdminError":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]},"SuccessResponse":{"type":"object","properties":{"success":{"type":"boolean"}},"required":["success"]},"UpdateGoogleConfig":{"type":"object","properties":{"clientId":{"type":"string","minLength":1},"clientSecret":{"type":"string","minLength":1},"authorizedDomains":{"type":"array","items":{"type":"string","format":"uri"}}},"required":["clientId","clientSecret"]},"UpdateAppleConfig":{"type":"object","properties":{"clientId":{"type":"string","minLength":1},"teamId":{"type":"string","minLength":1},"keyId":{"type":"string","minLength":1},"privateKey":{"type":"string","minLength":1}},"required":["clientId","teamId","keyId","privateKey"]},"TestOAuthResponse":{"type":"object","properties":{"success":{"type":"boolean"},"error":{"type":"string"},"details":{"type":"object","properties":{"clientIdValid":{"type":"boolean"},"secretValid":{"type":"boolean"},"domainsConfigured":{"type":"boolean"}},"required":["clientIdValid","secretValid","domainsConfigured"]}},"required":["success"]},"UserListResponse":{"type":"object","properties":{"users":{"type":"array","items":{"$ref":"#/components/schemas/UserListItem"}},"total":{"type":"number","example":100},"page":{"type":"number","example":1},"limit":{"type":"number","example":20},"totalPages":{"type":"number","example":5},"stats":{"$ref":"#/components/schemas/UserStats"}},"required":["users","total","page","limit","totalPages"]},"UserListItem":{"type":"object","properties":{"id":{"type":"string","example":"user_123"},"email":{"type":"string","example":"user@example.com"},"username":{"type":["string","null"],"example":"johndoe"},"name":{"type":"string","example":"John Doe"},"avatar":{"type":["string","null"],"example":"https://example.com/avatar.jpg"},"emailVerified":{"type":["boolean","null"],"example":true},"status":{"type":"string","enum":["active","inactive","suspended","banned"],"example":"active"},"platformRole":{"type":"string","enum":["platform_operator","support_admin","system_auditor","user"],"example":"user"},"isOnline":{"type":["boolean","null"],"example":false},"lastSeenAt":{"type":["string","null"],"format":"date-time","example":"2024-01-15T10:30:00.000Z"},"suspendedAt":{"type":["string","null"],"format":"date-time","example":null},"createdAt":{"type":"string","format":"date-time","example":"2024-01-01T00:00:00.000Z"},"lastLoginIp":{"type":["string","null"],"example":"192.168.1.1"},"organizationCount":{"type":"number","example":2},"sessionCount":{"type":"number","example":1}},"required":["id","email","username","name","avatar","emailVerified","status","platformRole","isOnline","lastSeenAt","suspendedAt","createdAt","lastLoginIp","organizationCount","sessionCount"]},"UserStats":{"type":"object","properties":{"totalUsers":{"type":"number","example":150},"activeUsers":{"type":"number","example":120},"suspendedUsers":{"type":"number","example":3},"verifiedUsers":{"type":"number","example":100},"newThisWeek":{"type":"number","example":5},"withActiveSessions":{"type":"number","example":12},"signupChart":{"type":"array","items":{"type":"object","properties":{"date":{"type":"string"},"count":{"type":"number"}},"required":["date","count"]},"example":[{"date":"2026-03-25","count":2}]},"topOrganizations":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"memberCount":{"type":"number"}},"required":["id","name","memberCount"]},"example":[{"id":"org_1","name":"Acme Corp","memberCount":12}]},"recentSecurityAlerts":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"eventType":{"type":"string"},"severity":{"type":"string"},"title":{"type":"string"},"userId":{"type":["string","null"]},"ipAddress":{"type":["string","null"]},"location":{"type":["string","null"]},"resolved":{"type":"boolean"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","eventType","severity","title","userId","ipAddress","location","resolved","createdAt"]},"example":[]},"unresolvedAlertCount":{"type":"number","example":0},"geoBreakdown":{"type":"array","items":{"type":"object","properties":{"location":{"type":"string"},"count":{"type":"number"}},"required":["location","count"]},"example":[{"location":"San Francisco, US","count":5}]}},"required":["totalUsers","activeUsers","suspendedUsers","verifiedUsers","newThisWeek","withActiveSessions","signupChart","topOrganizations","recentSecurityAlerts","unresolvedAlertCount","geoBreakdown"]},"BulkUserOperationResponse":{"type":"object","properties":{"success":{"type":"boolean","example":true},"processed":{"type":"number","example":10},"failed":{"type":"number","example":0},"errors":{"type":"array","items":{"type":"object","properties":{"userId":{"type":"string","example":"user_123"},"error":{"type":"string","example":"User is already suspended"}},"required":["userId","error"]}}},"required":["success","processed","failed"]},"BulkUserOperationRequest":{"type":"object","properties":{"action":{"type":"string","enum":["suspend","unsuspend","delete"],"example":"suspend"},"userIds":{"type":"array","items":{"type":"string"},"minItems":1,"maxItems":100,"example":["user_123","user_456"]},"reason":{"type":"string","example":"Bulk suspension for policy violation"}},"required":["action","userIds"]},"UserDetailResponse":{"type":"object","properties":{"id":{"type":"string","example":"user_123"},"email":{"type":"string","example":"user@example.com"},"username":{"type":["string","null"],"example":"johndoe"},"name":{"type":"string","example":"John Doe"},"bio":{"type":["string","null"],"example":"Software developer"},"avatar":{"type":["string","null"],"example":"https://example.com/avatar.jpg"},"emailVerified":{"type":["boolean","null"],"example":true},"status":{"type":"string","enum":["active","inactive","suspended","banned"],"example":"active"},"isOnline":{"type":["boolean","null"],"example":false},"lastSeenAt":{"type":["string","null"],"format":"date-time","example":"2024-01-15T10:30:00.000Z"},"timezone":{"type":["string","null"],"example":"America/New_York"},"suspendedAt":{"type":["string","null"],"format":"date-time","example":null},"suspendedBy":{"type":["string","null"],"example":null},"suspensionReason":{"type":["string","null"],"example":null},"lockedUntil":{"type":["string","null"],"format":"date-time","example":null,"description":"ISO timestamp until which the account is administratively locked. Null if not locked."},"createdAt":{"type":"string","format":"date-time","example":"2024-01-01T00:00:00.000Z"},"updatedAt":{"type":"string","format":"date-time","example":"2024-01-10T00:00:00.000Z"},"deletedAt":{"type":["string","null"],"format":"date-time","example":null}},"required":["id","email","username","name","bio","avatar","emailVerified","status","isOnline","lastSeenAt","timezone","suspendedAt","suspendedBy","suspensionReason","lockedUntil","createdAt","updatedAt","deletedAt"]},"SuspendUserResponse":{"type":"object","properties":{"success":{"type":"boolean","example":true},"message":{"type":"string","example":"User suspended successfully"},"user":{"$ref":"#/components/schemas/UserDetailResponse"}},"required":["success","message"]},"SuspendUserRequest":{"type":"object","properties":{"reason":{"type":"string","minLength":1,"maxLength":500,"example":"Violation of terms of service"}},"required":["reason"]},"LockUserResponse":{"type":"object","properties":{"success":{"type":"boolean","example":true},"message":{"type":"string","example":"Account locked successfully"},"lockedUntil":{"type":["string","null"],"format":"date-time","example":"2026-05-01T00:00:00.000Z"}},"required":["success","message","lockedUntil"]},"LockUserRequest":{"type":"object","properties":{"reason":{"type":"string","minLength":1,"maxLength":500,"example":"Suspected account compromise"},"durationHours":{"type":"integer","minimum":1,"maximum":8760,"example":24,"description":"Lock duration in hours. Omit to apply a permanent admin lock (1 year)."}},"required":["reason"]},"UserDevicesListResponse":{"type":"object","properties":{"devices":{"type":"array","items":{"$ref":"#/components/schemas/UserDeviceItem"}},"total":{"type":"number","example":5},"page":{"type":"number","example":1},"limit":{"type":"number","example":50},"totalPages":{"type":"number","example":1}},"required":["devices","total","page","limit","totalPages"]},"UserDeviceItem":{"type":"object","properties":{"id":{"type":"string","example":"device_123"},"deviceName":{"type":["string","null"],"example":"Chrome on MacOS"},"deviceType":{"type":["string","null"],"example":"desktop"},"ipAddress":{"type":["string","null"],"example":"192.168.1.1"},"location":{"type":["string","null"],"example":"New York, US"},"lastActiveAt":{"type":["string","null"],"format":"date-time","example":"2024-01-15T10:30:00.000Z"},"isTrusted":{"type":"boolean","example":true},"revokedAt":{"type":["string","null"],"format":"date-time","example":null},"createdAt":{"type":"string","format":"date-time","example":"2024-01-01T00:00:00.000Z"}},"required":["id","deviceName","deviceType","ipAddress","location","lastActiveAt","isTrusted","revokedAt","createdAt"]},"RevokeUserDeviceResponse":{"type":"object","properties":{"success":{"type":"boolean","example":true},"message":{"type":"string","example":"Device revoked successfully"}},"required":["success","message"]},"UserSecurityEventsListResponse":{"type":"object","properties":{"events":{"type":"array","items":{"$ref":"#/components/schemas/UserSecurityEventItem"}},"total":{"type":"number","example":10},"page":{"type":"number","example":1},"limit":{"type":"number","example":50},"totalPages":{"type":"number","example":1}},"required":["events","total","page","limit","totalPages"]},"UserSecurityEventItem":{"type":"object","properties":{"id":{"type":"string","example":"evt_123"},"eventType":{"type":"string","example":"failed_login"},"severity":{"type":"string","enum":["low","medium","high","critical"],"example":"medium"},"location":{"type":["string","null"],"example":"New York, US"},"ipAddress":{"type":["string","null"],"example":"192.168.1.1"},"description":{"type":["string","null"],"example":"Failed login attempt"},"resolved":{"type":"boolean","example":false},"createdAt":{"type":"string","format":"date-time","example":"2024-01-15T10:30:00.000Z"}},"required":["id","eventType","severity","location","ipAddress","description","resolved","createdAt"]},"RevokeUserSessionsResponse":{"type":"object","properties":{"success":{"type":"boolean","example":true},"message":{"type":"string","example":"All sessions revoked successfully"},"revokedCount":{"type":"number","example":3}},"required":["success","message","revokedCount"]},"ListRolesResponse":{"type":"object","properties":{"roles":{"type":"array","items":{"$ref":"#/components/schemas/RoleData"}},"total":{"type":"number"},"page":{"type":"number"},"limit":{"type":"number"}},"required":["roles","total","page","limit"]},"RoleData":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"description":{"type":["string","null"]},"isSystemRole":{"type":"boolean"},"organizationId":{"type":["string","null"]},"permissions":{"type":"array","items":{"$ref":"#/components/schemas/PermissionData"}},"userCount":{"type":"number"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","name","slug","description","isSystemRole","organizationId","createdAt","updatedAt"]},"PermissionData":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"resource":{"type":"string"},"action":{"type":"string"},"description":{"type":["string","null"]},"isSystemPermission":{"type":"boolean"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","name","resource","action","description","isSystemPermission","createdAt"]},"GetRoleResponse":{"type":"object","properties":{"role":{"$ref":"#/components/schemas/RoleData"}},"required":["role"]},"CreateRoleResponse":{"type":"object","properties":{"message":{"type":"string"},"role":{"$ref":"#/components/schemas/RoleData"}},"required":["message","role"]},"CreateRoleRequest":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100},"slug":{"type":"string","minLength":1,"maxLength":50,"pattern":"^[a-z0-9_-]+$"},"description":{"type":"string","maxLength":500},"organizationId":{"type":"string"},"permissionIds":{"type":"array","items":{"type":"string"}}},"required":["name","slug"]},"UpdateRoleResponse":{"type":"object","properties":{"message":{"type":"string"},"role":{"$ref":"#/components/schemas/RoleData"}},"required":["message","role"]},"UpdateRoleRequest":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100},"description":{"type":"string","maxLength":500},"permissionIds":{"type":"array","items":{"type":"string"}}}},"DeleteRoleResponse":{"type":"object","properties":{"message":{"type":"string"}},"required":["message"]},"ListPermissionsResponse":{"type":"object","properties":{"permissions":{"type":"array","items":{"$ref":"#/components/schemas/PermissionData"}},"total":{"type":"number"}},"required":["permissions","total"]},"AssignRoleResponse":{"type":"object","properties":{"message":{"type":"string"}},"required":["message"]},"AssignRoleRequest":{"type":"object","properties":{"userId":{"type":"string"},"roleId":{"type":"string"},"organizationId":{"type":"string"}},"required":["userId","roleId"]},"RemoveRoleRequest":{"type":"object","properties":{"userId":{"type":"string"},"roleId":{"type":"string"},"organizationId":{"type":"string"}},"required":["userId","roleId"]},"UserRolesResponse":{"type":"object","properties":{"roles":{"type":"array","items":{"$ref":"#/components/schemas/RoleData"}}},"required":["roles"]},"AdminOrganizationListResponse":{"type":"object","properties":{"organizations":{"type":"array","items":{"$ref":"#/components/schemas/OrganizationStatsItem"}},"total":{"type":"number","example":50},"page":{"type":"number","example":1},"limit":{"type":"number","example":20},"totalPages":{"type":"number","example":3}},"required":["organizations","total","page","limit","totalPages"]},"OrganizationStatsItem":{"type":"object","properties":{"id":{"type":"string","example":"org_123"},"name":{"type":"string","example":"Acme Corp"},"slug":{"type":"string","example":"acme-corp"},"plan":{"type":["string","null"],"enum":["free","starter","professional","enterprise",null],"example":"professional"},"status":{"type":"string","enum":["active","suspended","cancelled"],"example":"active"},"memberCount":{"type":"number","example":25},"activeMembers":{"type":"number","example":20},"createdAt":{"type":"string","format":"date-time","example":"2024-01-01T00:00:00.000Z"},"lastActivity":{"type":["string","null"],"format":"date-time","example":"2024-01-15T10:30:00.000Z"}},"required":["id","name","slug","plan","status","memberCount","activeMembers","createdAt","lastActivity"]},"AdminOrganizationsError":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]},"AdminOrganizationResponse":{"type":"object","properties":{"organization":{"$ref":"#/components/schemas/AdminOrganizationDetail"}},"required":["organization"]},"AdminOrganizationDetail":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"logo":{"type":["string","null"]},"website":{"type":["string","null"]},"industry":{"type":["string","null"]},"size":{"type":["string","null"]},"status":{"type":"string","enum":["active","suspended","cancelled"]},"ownerId":{"type":["string","null"]},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","name","slug","logo","website","industry","size","status","ownerId","createdAt","updatedAt"]},"AdminUpdateOrganizationResponse":{"type":"object","properties":{"success":{"type":"boolean"},"organization":{"$ref":"#/components/schemas/AdminOrganizationDetail"}},"required":["success","organization"]},"AdminUpdateOrganizationRequest":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":255,"example":"Acme Corporation"},"logo":{"type":"string","format":"uri","example":"https://example.com/logo.png"},"website":{"type":"string","format":"uri","example":"https://acme.com"},"industry":{"type":"string","example":"Technology"},"size":{"type":"string","enum":["1-10","11-50","51-200","201-500","501-1000","1001+"]},"taxIdNumber":{"type":"string","example":"12-3456789"},"billingEmail":{"type":"string","format":"email","example":"billing@acme.com"},"supportEmail":{"type":"string","format":"email","example":"support@acme.com"},"phoneNumber":{"type":"string","example":"+1-555-123-4567"},"addressLine1":{"type":"string","example":"123 Main St"},"addressLine2":{"type":"string","example":"Suite 100"},"city":{"type":"string","example":"San Francisco"},"state":{"type":"string","example":"CA"},"postalCode":{"type":"string","example":"94105"},"country":{"type":"string","example":"US"}}},"AdminUpdateOrganizationStatusRequest":{"type":"object","properties":{"status":{"type":"string","enum":["active","suspended"],"example":"suspended"},"reason":{"type":"string","example":"Violation of terms of service"}},"required":["status"]},"ByokSettingsResponse":{"type":"object","properties":{"byokEnabled":{"type":"boolean","example":true},"byokProviders":{"type":"array","items":{"type":"string"},"example":["openai","elevenlabs"]},"organizationId":{"type":"string","example":"org_123"},"updatedAt":{"type":["string","null"],"format":"date-time","example":"2024-01-15T10:30:00.000Z"}},"required":["byokEnabled","byokProviders","organizationId","updatedAt"]},"UpdateByokSettingsRequest":{"type":"object","properties":{"byokEnabled":{"type":"boolean","example":true},"byokProviders":{"type":"array","items":{"type":"string"},"example":["openai","elevenlabs"]}}},"AdminRevokeAllSessionsResponse":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"message":{"type":"string"},"revokedAt":{"type":"string","format":"date-time"}},"required":["success","message","revokedAt"]},"AdminSessionsError":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"string"}},"required":["success","error"]},"AdminRevokeOrgSessionsResponse":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"message":{"type":"string"},"affectedUsers":{"type":"number"},"revokedAt":{"type":"string","format":"date-time"}},"required":["success","message","affectedUsers","revokedAt"]},"OrganizationSettings":{"type":"object","properties":{"id":{"type":"string","example":"set_abc123"},"organizationId":{"type":"string","example":"org_xyz789"},"timezone":{"type":"string","example":"America/Los_Angeles"},"currency":{"type":"string","example":"USD"},"language":{"type":"string","example":"en"},"dateFormat":{"type":"string","example":"MM/DD/YYYY"},"timeFormat":{"type":"string","example":"12h"},"primaryColor":{"type":["string","null"],"example":"#3B82F6"},"secondaryColor":{"type":["string","null"],"example":"#10B981"},"textColor":{"type":["string","null"],"example":"#FFFFFF"},"secondaryTextColor":{"type":["string","null"],"example":"#000000"},"primaryColorDark":{"type":["string","null"],"example":"#60A5FA"},"secondaryColorDark":{"type":["string","null"],"example":"#34D399"},"textColorDark":{"type":["string","null"],"example":"#FFFFFF"},"secondaryTextColorDark":{"type":["string","null"],"example":"#000000"},"logoUrl":{"type":["string","null"],"example":"https://example.com/logo.png"},"faviconUrl":{"type":["string","null"],"example":"https://example.com/favicon.ico"},"customDomain":{"type":["string","null"],"example":"app.acme.com"},"enabledFeatures":{"type":["object","null"],"additionalProperties":{"type":"boolean"},"example":{"analytics":true}},"notificationPreferences":{"type":["object","null"],"additionalProperties":{},"example":{}},"requireTwoFactor":{"type":"boolean","example":false},"allowedDomains":{"type":["array","null"],"items":{"type":"string"},"example":["acme.com"]},"ipWhitelist":{"type":["array","null"],"items":{"type":"string"},"example":[]},"sessionTimeoutMinutes":{"type":"number","example":60},"integrationSettings":{"type":["object","null"],"additionalProperties":{},"example":{}},"trashRetentionDays":{"type":["number","null"],"example":30},"archiveRetentionDays":{"type":["number","null"],"example":90}},"required":["id","organizationId","timezone","currency","language","dateFormat","timeFormat","primaryColor","secondaryColor","textColor","secondaryTextColor","primaryColorDark","secondaryColorDark","textColorDark","secondaryTextColorDark","logoUrl","faviconUrl","customDomain","enabledFeatures","notificationPreferences","requireTwoFactor","allowedDomains","ipWhitelist","sessionTimeoutMinutes","integrationSettings","trashRetentionDays","archiveRetentionDays"]},"UpdateCurrentSettings":{"type":"object","properties":{"timezone":{"type":"string","maxLength":50},"currency":{"type":"string","minLength":3,"maxLength":3},"language":{"type":"string","maxLength":10},"dateFormat":{"type":"string","maxLength":20},"timeFormat":{"type":"string","enum":["12h","24h"]},"primaryColor":{"type":["string","null"],"pattern":"^#[0-9a-fA-F]{6}$"},"secondaryColor":{"type":["string","null"],"pattern":"^#[0-9a-fA-F]{6}$"},"textColor":{"type":["string","null"],"pattern":"^#[0-9a-fA-F]{6}$"},"secondaryTextColor":{"type":["string","null"],"pattern":"^#[0-9a-fA-F]{6}$"},"primaryColorDark":{"type":["string","null"],"pattern":"^#[0-9a-fA-F]{6}$"},"secondaryColorDark":{"type":["string","null"],"pattern":"^#[0-9a-fA-F]{6}$"},"textColorDark":{"type":["string","null"],"pattern":"^#[0-9a-fA-F]{6}$"},"secondaryTextColorDark":{"type":["string","null"],"pattern":"^#[0-9a-fA-F]{6}$"}}},"OrganizationMember":{"type":"object","properties":{"id":{"type":"string","example":"mem_abc123"},"organizationId":{"type":"string","example":"org_xyz789"},"userId":{"type":"string","example":"usr_def456"},"roleId":{"type":"string","example":"role_org_member"},"status":{"type":"string","example":"active"},"invitedBy":{"type":["string","null"],"example":"usr_owner123"},"joinedAt":{"type":["string","null"],"format":"date-time","example":"2024-01-01T00:00:00.000Z"},"customPermissions":{"type":["object","null"],"additionalProperties":{"type":"boolean"},"example":{"assets.upload":true}},"user":{"$ref":"#/components/schemas/MemberUser"}},"required":["id","organizationId","userId","roleId","status","invitedBy","joinedAt","customPermissions"]},"MemberUser":{"type":"object","properties":{"id":{"type":"string","example":"usr_abc123"},"name":{"type":["string","null"],"example":"John Doe"},"email":{"type":"string","example":"john@example.com"},"avatar":{"type":["string","null"],"example":"https://example.com/avatar.jpg"}},"required":["id","name","email","avatar"]},"OrganizationInvitation":{"type":"object","properties":{"id":{"type":"string","example":"inv_abc123"},"organizationId":{"type":"string","example":"org_xyz789"},"email":{"type":"string","example":"newuser@example.com"},"roleId":{"type":"string","example":"role_org_member"},"status":{"type":"string","example":"pending"},"invitedBy":{"type":"string","example":"usr_owner123"},"token":{"type":"string","example":"abc123def456"},"customMessage":{"type":["string","null"],"example":"Welcome to our team!"},"expiresAt":{"type":"string","format":"date-time","example":"2024-01-08T00:00:00.000Z"},"acceptedAt":{"type":["string","null"],"format":"date-time","example":null},"acceptedBy":{"type":["string","null"],"example":null},"revokedAt":{"type":["string","null"],"format":"date-time","example":null},"revokedBy":{"type":["string","null"],"example":null},"createdAt":{"type":"string","format":"date-time","example":"2024-01-01T00:00:00.000Z"}},"required":["id","organizationId","email","roleId","status","invitedBy","token","customMessage","expiresAt","acceptedAt","acceptedBy","revokedAt","revokedBy","createdAt"]},"Organization":{"type":"object","properties":{"id":{"type":"string","example":"org_abc123"},"name":{"type":"string","example":"Acme Inc"},"slug":{"type":"string","example":"acme-inc"},"type":{"type":"string","enum":["customer","agency","personal","organization"],"example":"organization","description":"Organization type"},"logo":{"type":["string","null"],"example":"https://example.com/logo.png"},"website":{"type":["string","null"],"example":"https://acme.com"},"industry":{"type":["string","null"],"example":"Technology"},"size":{"type":["string","null"],"example":"11-50"},"status":{"type":"string","example":"active"},"ownerId":{"type":"string","example":"usr_xyz789"},"taxIdNumber":{"type":["string","null"],"example":"12-3456789"},"billingEmail":{"type":["string","null"],"example":"billing@acme.com"},"supportEmail":{"type":["string","null"],"example":"support@acme.com"},"phoneNumber":{"type":["string","null"],"example":"+1-555-123-4567"},"addressLine1":{"type":["string","null"],"example":"123 Main St"},"addressLine2":{"type":["string","null"],"example":"Suite 100"},"city":{"type":["string","null"],"example":"San Francisco"},"state":{"type":["string","null"],"example":"CA"},"postalCode":{"type":["string","null"],"example":"94105"},"country":{"type":["string","null"],"example":"US"},"createdAt":{"type":"string","format":"date-time","example":"2024-01-01T00:00:00.000Z"},"updatedAt":{"type":["string","null"],"format":"date-time","example":"2024-01-15T00:00:00.000Z"},"version":{"type":"number","example":1}},"required":["id","name","slug","type","logo","website","industry","size","status","ownerId","taxIdNumber","billingEmail","supportEmail","phoneNumber","addressLine1","addressLine2","city","state","postalCode","country","createdAt","updatedAt","version"]},"SwitchOrganizationResponse":{"type":"object","properties":{"success":{"type":"boolean"},"organization":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"type":{"type":"string","enum":["personal","team","enterprise"]},"role":{"type":"string"}},"required":["id","name","slug","type","role"]}},"required":["success","organization"]},"SwitchOrganizationError":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error"]},"SwitchOrganizationRequest":{"type":"object","properties":{"organizationId":{"type":"string","description":"The ID of the organization to switch to","example":"org_abc123"}},"required":["organizationId"]},"UserProfile":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string","format":"email"},"emailVerified":{"type":"boolean"},"fullName":{"type":["string","null"]},"displayName":{"type":["string","null"]},"bio":{"type":["string","null"]},"username":{"type":["string","null"]},"avatarUrl":{"type":["string","null"]},"profilePhotoUrl":{"type":["string","null"]},"profilePhotoAssetId":{"type":["string","null"]},"phoneNumber":{"type":["string","null"]},"isPlatformOperator":{"type":"boolean"},"organizations":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"role":{"type":"string"},"isPersonal":{"type":"boolean"},"isActive":{"type":"boolean"},"logoUrl":{"type":["string","null"]}},"required":["id","name","slug","role","isPersonal","isActive","logoUrl"]}},"createdAt":{"type":"string"},"updatedAt":{"type":"string"},"impersonation":{"type":"object","properties":{"isImpersonating":{"type":"boolean"},"impersonatorId":{"type":["string","null"]},"startedAt":{"type":["string","null"]},"reason":{"type":["string","null"]}},"required":["isImpersonating","impersonatorId","startedAt","reason"]}},"required":["id","email","emailVerified","fullName","displayName","bio","username","avatarUrl","profilePhotoUrl","profilePhotoAssetId","phoneNumber","isPlatformOperator","organizations","createdAt","updatedAt"]},"UpdateUser":{"type":"object","properties":{"fullName":{"type":"string","minLength":1,"maxLength":100},"displayName":{"type":"string","minLength":1,"maxLength":50},"bio":{"type":"string","maxLength":500},"username":{"type":"string","minLength":3,"maxLength":30,"pattern":"^[a-z0-9_-]+$"},"avatarUrl":{"type":["string","null"],"format":"uri"},"profilePhotoUrl":{"type":["string","null"],"format":"uri"},"profilePhotoAssetId":{"type":["string","null"]},"phoneNumber":{"type":["string","null"],"maxLength":20}}},"GetEmailsResponse":{"type":"object","properties":{"emails":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string","format":"email"},"isPrimary":{"type":"boolean"},"isVerified":{"type":"boolean"},"createdAt":{"type":"string"}},"required":["id","email","isPrimary","isVerified","createdAt"]}}},"required":["emails"]},"AddEmailResponse":{"type":"object","properties":{"email":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string","format":"email"},"isPrimary":{"type":"boolean"},"isVerified":{"type":"boolean"},"createdAt":{"type":"string"}},"required":["id","email","isPrimary","isVerified","createdAt"]},"message":{"type":"string"}},"required":["email","message"]},"AddEmail":{"type":"object","properties":{"email":{"type":"string","format":"email"}},"required":["email"]},"DeleteEmailResponse":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"}},"required":["success","message"]},"GetUserOrganizationsResponse":{"type":"object","properties":{"organizations":{"type":"array","items":{"$ref":"#/components/schemas/OrganizationMembership"}},"activeOrganizationId":{"type":["string","null"]}},"required":["organizations","activeOrganizationId"]},"OrganizationMembership":{"type":"object","properties":{"organizationId":{"type":"string"},"roleId":{"type":"string"},"roleName":{"type":"string"},"status":{"type":"string","enum":["active","inactive","invited"]},"organization":{"type":["object","null"],"properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":["string","null"]},"type":{"type":"string","enum":["personal","organization","customer","agency"]},"logo":{"type":["string","null"]},"apps":{"type":"array","items":{"$ref":"#/components/schemas/OrganizationApp"}},"hasAgencyRelationship":{"type":"boolean"}},"required":["id","name","slug","type","logo"]}},"required":["organizationId","roleId","roleName","status"]},"OrganizationApp":{"type":"object","properties":{"appId":{"type":"string"},"appSlug":{"type":"string"},"plan":{"type":["string","null"]},"isActive":{"type":"boolean"}},"required":["appId","appSlug","plan","isActive"]},"SetActiveOrganizationResponse":{"type":"object","properties":{"success":{"type":"boolean"},"activeOrganizationId":{"type":"string"},"organizationRole":{"type":"string"},"organization":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":["string","null"]},"type":{"type":"string","enum":["personal","organization","customer","agency"]},"logo":{"type":["string","null"]},"apps":{"type":"array","items":{"$ref":"#/components/schemas/OrganizationApp"}},"hasAgencyRelationship":{"type":"boolean"}},"required":["id","name","slug","type","logo"]}},"required":["success","activeOrganizationId","organizationRole","organization"]},"SetActiveOrganizationRequest":{"type":"object","properties":{"organizationId":{"type":"string","minLength":1}},"required":["organizationId"]},"GetPreferencesResponse":{"type":"object","properties":{"preferences":{"type":"object","properties":{"theme":{"type":"string","enum":["light","dark","system"],"default":"system"},"fontSize":{"type":"string","enum":["small","medium","large"],"default":"medium"},"reduceMotion":{"type":"boolean","default":false},"highContrast":{"type":"boolean","default":false},"language":{"type":"string","default":"en"},"timezone":{"type":"string","default":"UTC"},"dateFormat":{"type":"string","default":"YYYY-MM-DD"},"timeFormat":{"type":"string","enum":["12h","24h"],"default":"12h"},"currency":{"type":"string","default":"USD"},"emailNotifications":{"type":"boolean","default":true},"pushNotifications":{"type":"boolean","default":true},"smsNotifications":{"type":"boolean","default":false},"marketingEmails":{"type":"boolean","default":false},"productUpdates":{"type":"boolean","default":true},"securityAlerts":{"type":"boolean","default":true},"weeklyDigest":{"type":"boolean","default":false},"defaultOrganizationId":{"type":["string","null"],"default":null},"trashRetentionDays":{"type":"number","default":30},"archiveRetentionDays":{"type":"number","default":90}}}},"required":["preferences"]},"UpdatePreferences":{"type":"object","properties":{"theme":{"type":"string","enum":["light","dark","system"]},"fontSize":{"type":"string","enum":["small","medium","large"]},"reduceMotion":{"type":"boolean"},"highContrast":{"type":"boolean"},"language":{"type":"string"},"timezone":{"type":"string"},"dateFormat":{"type":"string"},"timeFormat":{"type":"string","enum":["12h","24h"]},"currency":{"type":"string"},"emailNotifications":{"type":"boolean"},"pushNotifications":{"type":"boolean"},"smsNotifications":{"type":"boolean"},"marketingEmails":{"type":"boolean"},"productUpdates":{"type":"boolean"},"securityAlerts":{"type":"boolean"},"weeklyDigest":{"type":"boolean"},"defaultOrganizationId":{"type":["string","null"]},"trashRetentionDays":{"type":"number"},"archiveRetentionDays":{"type":"number"}}},"GetDevicesResponse":{"type":"object","properties":{"devices":{"type":"array","items":{"$ref":"#/components/schemas/TrustedDevice"}}},"required":["devices"]},"TrustedDevice":{"type":"object","properties":{"id":{"type":"string","example":"device_abc123"},"userId":{"type":"string","example":"user_123"},"deviceFingerprint":{"type":"string","example":"fp_xyz789"},"deviceName":{"type":["string","null"],"example":"Chrome on MacBook Pro"},"browser":{"type":["string","null"],"example":"Chrome"},"browserVersion":{"type":["string","null"],"example":"120.0.0"},"os":{"type":["string","null"],"example":"macOS"},"osVersion":{"type":["string","null"],"example":"14.2"},"deviceType":{"type":["string","null"],"example":"desktop"},"ipAddress":{"type":["string","null"],"example":"192.168.1.1"},"location":{"type":["string","null"],"example":"San Francisco, CA"},"lastSeenAt":{"type":["string","null"],"example":"2024-01-01T00:00:00.000Z"},"lastSeenIp":{"type":["string","null"],"example":"192.168.1.1"},"lastSeenLocation":{"type":["string","null"],"example":"San Francisco, CA"},"createdAt":{"type":"string","example":"2024-01-01T00:00:00.000Z"},"revokedAt":{"type":["string","null"],"example":null},"revokedReason":{"type":["string","null"],"example":null}},"required":["id","userId","deviceFingerprint","deviceName","browser","browserVersion","os","osVersion","deviceType","ipAddress","location","lastSeenAt","lastSeenIp","lastSeenLocation","createdAt","revokedAt","revokedReason"]},"TrustDeviceResponse":{"type":"object","properties":{"success":{"type":"boolean","example":true},"deviceId":{"type":"string","example":"device_abc123"}},"required":["success","deviceId"]},"TrustDeviceRequest":{"type":"object","properties":{"fingerprint":{"type":"string","example":"fp_xyz789"},"name":{"type":"string","example":"My MacBook Pro"},"browser":{"type":"string","example":"Chrome"},"browserVersion":{"type":"string","example":"120.0.0"},"os":{"type":"string","example":"macOS"},"osVersion":{"type":"string","example":"14.2"},"deviceType":{"type":"string","example":"desktop"}},"required":["fingerprint"]},"RenameDeviceRequest":{"type":"object","properties":{"name":{"type":"string","minLength":1,"example":"Work Laptop"}},"required":["name"]},"SuccessCountResponse":{"type":"object","properties":{"success":{"type":"boolean","example":true},"count":{"type":"number","example":5}},"required":["success","count"]},"ListNotificationsResponse":{"type":"object","properties":{"notifications":{"type":"array","items":{"$ref":"#/components/schemas/Notification"}},"total":{"type":"number"},"unreadCount":{"type":"number"},"page":{"type":"number"},"limit":{"type":"number"},"hasMore":{"type":"boolean"}},"required":["notifications","total","unreadCount","page","limit","hasMore"]},"Notification":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"actionUrl":{"type":["string","null"]},"actionText":{"type":["string","null"]},"icon":{"type":["string","null"]},"priority":{"type":"string","enum":["low","normal","high","urgent"]},"isRead":{"type":"boolean"},"readAt":{"type":["number","null"]},"isDismissed":{"type":"boolean"},"relatedResourceType":{"type":["string","null"]},"relatedResourceId":{"type":["string","null"]},"createdAt":{"type":"number"}},"required":["id","type","title","message","actionUrl","actionText","icon","priority","isRead","readAt","isDismissed","relatedResourceType","relatedResourceId","createdAt"]},"UnreadCountResponse":{"type":"object","properties":{"count":{"type":"number"}},"required":["count"]},"MarkReadResponse":{"type":"object","properties":{"success":{"type":"boolean"},"count":{"type":"number"}},"required":["success","count"]},"TestNotificationResponse":{"type":"object","properties":{"success":{"type":"boolean","example":true},"message":{"type":"string","example":"Test notification sent successfully"},"sentTo":{"type":"string","format":"email","example":"john@example.com"}},"required":["success","message","sentTo"]},"UserSecurityAlertsResponse":{"type":"object","properties":{"alerts":{"type":"array","items":{"$ref":"#/components/schemas/SecurityAlert"}},"count":{"type":"number","example":5}},"required":["alerts","count"]},"SecurityAlert":{"type":"object","properties":{"id":{"type":"string","example":"alert_abc123"},"userId":{"type":"string","example":"user_123"},"eventType":{"type":"string","example":"new_device_login"},"severity":{"type":"string","enum":["low","medium","high","critical"],"example":"medium"},"ipAddress":{"type":["string","null"],"example":"192.168.1.1"},"userAgent":{"type":["string","null"],"example":"Mozilla/5.0..."},"location":{"type":["string","null"],"example":"San Francisco, CA"},"latitude":{"type":["number","null"],"example":37.7749},"longitude":{"type":["number","null"],"example":-122.4194},"details":{"type":["object","null"],"properties":{},"additionalProperties":{},"example":{"deviceType":"desktop"}},"resolved":{"type":"boolean","example":false},"createdAt":{"type":"string","example":"2024-01-01T00:00:00.000Z"},"title":{"type":["string","null"],"example":"Login from New Device"},"description":{"type":["string","null"],"example":"A new device was used to access your account."},"deviceFingerprint":{"type":["string","null"],"example":"fp_xyz789"},"isRead":{"type":"boolean","example":false},"readAt":{"type":["string","null"],"example":null},"isDismissed":{"type":"boolean","example":false},"dismissedAt":{"type":["string","null"],"example":null},"emailSentAt":{"type":["string","null"],"example":null},"resolvedBy":{"type":["string","null"],"example":null},"resolvedAt":{"type":["string","null"],"example":null},"resolutionNotes":{"type":["string","null"],"example":null}},"required":["id","userId","eventType","severity","ipAddress","userAgent","location","latitude","longitude","details","resolved","createdAt","title","description","deviceFingerprint","isRead","readAt","isDismissed","dismissedAt","emailSentAt","resolvedBy","resolvedAt","resolutionNotes"]},"GetAlertCountResponse":{"type":"object","properties":{"count":{"type":"number","example":3}},"required":["count"]},"SecurityEventsResponse":{"type":"object","properties":{"events":{"type":"array","items":{"$ref":"#/components/schemas/SecurityEvent"}},"total":{"type":"number","example":100},"hasMore":{"type":"boolean","example":true}},"required":["events","total","hasMore"]},"SecurityEvent":{"type":"object","properties":{"id":{"type":"string","example":"evt_123"},"userId":{"type":"string","example":"user_123"},"eventType":{"type":"string","example":"login"},"severity":{"type":"string","enum":["low","medium","high","critical"],"example":"low"},"ipAddress":{"type":["string","null"],"example":"192.168.1.1"},"userAgent":{"type":["string","null"],"example":"Mozilla/5.0..."},"location":{"type":["string","null"],"example":"New York, US"},"latitude":{"type":["number","null"],"example":40.7128},"longitude":{"type":["number","null"],"example":-74.006},"details":{"type":["object","null"],"additionalProperties":{},"example":{}},"resolved":{"type":"boolean","example":false},"createdAt":{"type":"string","format":"date-time","example":"2024-01-01T00:00:00.000Z"}},"required":["id","userId","eventType","severity","ipAddress","userAgent","location","latitude","longitude","details","resolved","createdAt"]},"ExportUserDataResponse":{"type":"object","properties":{"exportedAt":{"type":"string","format":"date-time","example":"2024-01-01T00:00:00.000Z"},"version":{"type":"string","example":"1.0"},"user":{"$ref":"#/components/schemas/ExportedUser"},"emails":{"type":"array","items":{"$ref":"#/components/schemas/ExportedEmail"}},"preferences":{"$ref":"#/components/schemas/ExportedPreferences"},"securityEvents":{"type":"array","items":{"$ref":"#/components/schemas/ExportedSecurityEvent"}},"sessions":{"type":"array","items":{"$ref":"#/components/schemas/ExportedSession"}},"organizations":{"type":"array","items":{"$ref":"#/components/schemas/ExportedOrganization"}}},"required":["exportedAt","version","user","emails","preferences","securityEvents","sessions","organizations"]},"ExportedUser":{"type":"object","properties":{"id":{"type":"string","example":"user_123"},"email":{"type":"string","example":"john@example.com"},"username":{"type":"string","example":"johndoe"},"fullName":{"type":["string","null"],"example":"John Doe"},"displayName":{"type":["string","null"],"example":"Johnny"},"bio":{"type":["string","null"],"example":"Software developer"},"avatarUrl":{"type":["string","null"],"example":"https://example.com/avatar.jpg"},"emailVerified":{"type":"boolean","example":true},"phoneNumber":{"type":["string","null"],"example":"+1234567890"},"status":{"type":"string","example":"active"},"createdAt":{"type":"string","format":"date-time","example":"2024-01-01T00:00:00.000Z"},"updatedAt":{"type":["string","null"],"format":"date-time","example":"2024-01-01T00:00:00.000Z"}},"required":["id","email","username","fullName","displayName","bio","avatarUrl","emailVerified","phoneNumber","status","createdAt","updatedAt"]},"ExportedEmail":{"type":"object","properties":{"email":{"type":"string","example":"john@example.com"},"isPrimary":{"type":"boolean","example":true},"verified":{"type":"boolean","example":true},"verifiedAt":{"type":["string","null"],"format":"date-time","example":"2024-01-01T00:00:00.000Z"},"createdAt":{"type":"string","format":"date-time","example":"2024-01-01T00:00:00.000Z"}},"required":["email","isPrimary","verified","verifiedAt","createdAt"]},"ExportedPreferences":{"type":["object","null"],"properties":{"theme":{"type":["string","null"],"example":"dark"},"language":{"type":["string","null"],"example":"en"},"timezone":{"type":["string","null"],"example":"America/New_York"},"emailNotifications":{"type":["boolean","null"],"example":true},"marketingEmails":{"type":["boolean","null"],"example":false}},"required":["theme","language","timezone","emailNotifications","marketingEmails"]},"ExportedSecurityEvent":{"type":"object","properties":{"type":{"type":"string","example":"login"},"severity":{"type":"string","example":"low"},"ipAddress":{"type":["string","null"],"example":"192.168.1.1"},"location":{"type":["string","null"],"example":"New York, US"},"timestamp":{"type":"string","format":"date-time","example":"2024-01-01T00:00:00.000Z"}},"required":["type","severity","ipAddress","location","timestamp"]},"ExportedSession":{"type":"object","properties":{"deviceType":{"type":["string","null"],"example":"desktop"},"deviceName":{"type":["string","null"],"example":"Chrome on Mac"},"location":{"type":["string","null"],"example":"New York, US"},"lastActivityAt":{"type":["string","null"],"format":"date-time","example":"2024-01-01T00:00:00.000Z"},"createdAt":{"type":"string","format":"date-time","example":"2024-01-01T00:00:00.000Z"}},"required":["deviceType","deviceName","location","lastActivityAt","createdAt"]},"ExportedOrganization":{"type":"object","properties":{"id":{"type":"string","example":"org_123"},"name":{"type":"string","example":"Acme Corp"},"role":{"type":"string","example":"admin"},"joinedAt":{"type":"string","format":"date-time","example":"2024-01-01T00:00:00.000Z"}},"required":["id","name","role","joinedAt"]},"GetCompanionProfileResponse":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"},"profile":{"$ref":"#/components/schemas/CompanionProfile"},"traits":{"$ref":"#/components/schemas/PersonalityTraits"},"preset":{"$ref":"#/components/schemas/PersonalityPreset"}},"required":["success","profile","traits","preset"]},"CompanionProfile":{"type":["object","null"],"properties":{"id":{"type":"string"},"userId":{"type":"string"},"organizationId":{"type":["string","null"]},"name":{"type":"string"},"pronouns":{"type":"string"},"personalityPresetId":{"type":["string","null"]},"customTraits":{},"onboardingComplete":{"type":"boolean"},"onboardingStep":{"type":["string","null"]},"createdAt":{"type":"number"},"updatedAt":{"type":"number"}},"required":["id","userId","organizationId","name","pronouns","personalityPresetId","onboardingComplete","onboardingStep","createdAt","updatedAt"]},"PersonalityTraits":{"type":["object","null"],"properties":{"id":{"type":"string"},"profileId":{"type":"string"},"friendliness":{"type":"number"},"formality":{"type":"number"},"humor":{"type":"number"},"enthusiasm":{"type":"number"},"verbosity":{"type":"number"},"proactivity":{"type":"number"},"empathy":{"type":"number"},"directness":{"type":"number"},"emojiUsage":{"type":"string"},"responseLength":{"type":"string"},"explanationStyle":{"type":"string"},"greetingStyle":{"type":"string"},"customGreeting":{"type":["string","null"]},"signoffStyle":{"type":"string"},"updatedAt":{"type":"number"}},"required":["id","profileId","friendliness","formality","humor","enthusiasm","verbosity","proactivity","empathy","directness","emojiUsage","responseLength","explanationStyle","greetingStyle","customGreeting","signoffStyle","updatedAt"]},"PersonalityPreset":{"type":["object","null"],"properties":{"id":{"type":"string"},"slug":{"type":"string"},"name":{"type":"string"},"description":{"type":["string","null"]},"icon":{"type":["string","null"]},"friendliness":{"type":"number"},"formality":{"type":"number"},"humor":{"type":"number"},"enthusiasm":{"type":"number"},"verbosity":{"type":"number"},"proactivity":{"type":"number"},"empathy":{"type":"number"},"directness":{"type":"number"},"isActive":{"type":"boolean"},"sortOrder":{"type":"number"}},"required":["id","slug","name","description","icon","friendliness","formality","humor","enthusiasm","verbosity","proactivity","empathy","directness","isActive","sortOrder"]},"UpdateCompanionProfileResponse":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"},"profile":{"$ref":"#/components/schemas/CompanionProfile"}},"required":["success","profile"]},"UpdateCompanionProfileRequest":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":32,"example":"Luna"},"pronouns":{"type":"string","enum":["he/him","she/her","they/them","it/its","custom"],"example":"she/her"},"personalityPresetId":{"type":"string","example":"preset_friendly"}}},"GetPersonalityPresetsResponse":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"},"presets":{"type":"array","items":{"$ref":"#/components/schemas/PersonalityPreset"}}},"required":["success","presets"]},"GetPersonalityTraitsResponse":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"},"traits":{"$ref":"#/components/schemas/PersonalityTraits"}},"required":["success","traits"]},"UpdatePersonalityTraitsResponse":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"},"traits":{"$ref":"#/components/schemas/PersonalityTraits"}},"required":["success","traits"]},"UpdatePersonalityTraitsRequest":{"type":"object","properties":{"friendliness":{"type":"number","minimum":0,"maximum":1},"formality":{"type":"number","minimum":0,"maximum":1},"humor":{"type":"number","minimum":0,"maximum":1},"enthusiasm":{"type":"number","minimum":0,"maximum":1},"verbosity":{"type":"number","minimum":0,"maximum":1},"proactivity":{"type":"number","minimum":0,"maximum":1},"empathy":{"type":"number","minimum":0,"maximum":1},"directness":{"type":"number","minimum":0,"maximum":1},"emojiUsage":{"type":"string","enum":["none","minimal","moderate","expressive"]},"responseLength":{"type":"string","enum":["brief","balanced","detailed"]},"explanationStyle":{"type":"string","enum":["examples","technical","analogies","stepByStep"]},"greetingStyle":{"type":"string","enum":["none","simple","time_aware","personalized"]},"customGreeting":{"type":["string","null"],"maxLength":100},"signoffStyle":{"type":"string","enum":["none","casual","formal","encouraging"]}}},"GetOnboardingResponse":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"},"onboarding":{"$ref":"#/components/schemas/OnboardingProgress"}},"required":["success","onboarding"]},"OnboardingProgress":{"type":["object","null"],"properties":{"id":{"type":"string"},"userId":{"type":"string"},"currentStep":{"type":"string"},"completedSteps":{"type":"array","items":{"type":"string"}},"quizResponses":{},"isComplete":{"type":"boolean"},"skippedAt":{"type":["number","null"]},"startedAt":{"type":"number"},"completedAt":{"type":["number","null"]}},"required":["id","userId","currentStep","completedSteps","isComplete","skippedAt","startedAt","completedAt"]},"UpdateOnboardingResponse":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"},"onboarding":{"$ref":"#/components/schemas/OnboardingProgress"}},"required":["success","onboarding"]},"UpdateOnboardingRequest":{"type":"object","properties":{"currentStep":{"type":"string","enum":["welcome","name","personality_quiz","appearance","voice","complete"]},"completedSteps":{"type":"array","items":{"type":"string","enum":["welcome","name","personality_quiz","appearance","voice","complete"]}},"quizResponses":{"type":"object","additionalProperties":{}},"skip":{"type":"boolean"}}},"GetAvatarsResponse":{"type":"object","properties":{"success":{"type":"boolean"},"avatars":{"type":"array","items":{"$ref":"#/components/schemas/AvatarBase"}},"unlockedIds":{"type":"array","items":{"type":"string"}}},"required":["success","avatars","unlockedIds"]},"AvatarBase":{"type":"object","properties":{"id":{"type":"string"},"slug":{"type":"string"},"name":{"type":"string"},"description":{"type":["string","null"]},"type":{"type":"string"},"imageUrl":{"type":"string"},"thumbnailUrl":{"type":"string"},"animationUrl":{"type":["string","null"]},"hasHeadSlot":{"type":"boolean"},"hasFaceSlot":{"type":"boolean"},"hasBodySlot":{"type":"boolean"},"hasAccessorySlot":{"type":"boolean"},"unlockType":{"type":"string"},"unlockRequirement":{"type":["string","null"]},"unlockLevel":{"type":["number","null"]},"isLimited":{"type":"boolean"},"availableUntil":{"type":["number","null"]},"sortOrder":{"type":"number"},"isActive":{"type":"boolean"}},"required":["id","slug","name","description","type","imageUrl","thumbnailUrl","animationUrl","hasHeadSlot","hasFaceSlot","hasBodySlot","hasAccessorySlot","unlockType","unlockRequirement","unlockLevel","isLimited","availableUntil","sortOrder","isActive"]},"GetItemsResponse":{"type":"object","properties":{"success":{"type":"boolean"},"items":{"type":"array","items":{"$ref":"#/components/schemas/CompanionItem"}},"category":{"type":"string"}},"required":["success","items"]},"CompanionItem":{"type":"object","properties":{"id":{"type":"string"},"slug":{"type":"string"},"name":{"type":"string"},"description":{"type":["string","null"]},"category":{"type":"string"},"type":{"type":"string"},"imageUrl":{"type":"string"},"thumbnailUrl":{"type":"string"},"unlockType":{"type":"string"},"unlockRequirement":{"type":["string","null"]},"unlockLevel":{"type":["number","null"]},"rarity":{"type":"string"},"isLimited":{"type":"boolean"},"isActive":{"type":"boolean"},"sortOrder":{"type":"number"}},"required":["id","slug","name","description","category","type","imageUrl","thumbnailUrl","unlockType","unlockRequirement","unlockLevel","rarity","isLimited","isActive","sortOrder"]},"GetInventoryResponse":{"type":"object","properties":{"success":{"type":"boolean"},"inventory":{"type":"array","items":{"$ref":"#/components/schemas/InventoryItem"}}},"required":["success","inventory"]},"InventoryItem":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"itemId":{"type":"string"},"acquiredAt":{"type":"number"},"acquiredVia":{"type":"string"},"item":{"$ref":"#/components/schemas/CompanionItem"}},"required":["id","userId","itemId","acquiredAt","acquiredVia"]},"GetOutfitResponse":{"type":"object","properties":{"success":{"type":"boolean"},"outfit":{"$ref":"#/components/schemas/Outfit"},"avatar":{"allOf":[{"$ref":"#/components/schemas/AvatarBase"},{"type":["object","null"]}]},"equippedItems":{"type":"object","additionalProperties":{"allOf":[{"$ref":"#/components/schemas/CompanionItem"},{"type":["object","null"]}]}}},"required":["success","outfit","avatar","equippedItems"]},"Outfit":{"type":["object","null"],"properties":{"id":{"type":"string"},"profileId":{"type":"string"},"baseAvatarId":{"type":["string","null"]},"headItemId":{"type":["string","null"]},"faceItemId":{"type":["string","null"]},"bodyItemId":{"type":["string","null"]},"accessoryItemId":{"type":["string","null"]},"backgroundId":{"type":["string","null"]},"primaryColor":{"type":"string"},"updatedAt":{"type":"number"}},"required":["id","profileId","baseAvatarId","headItemId","faceItemId","bodyItemId","accessoryItemId","backgroundId","primaryColor","updatedAt"]},"UpdateOutfitResponse":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"},"outfit":{"$ref":"#/components/schemas/Outfit"}},"required":["success","outfit"]},"UpdateOutfitRequest":{"type":"object","properties":{"baseAvatarId":{"type":["string","null"]},"headItemId":{"type":["string","null"]},"faceItemId":{"type":["string","null"]},"bodyItemId":{"type":["string","null"]},"accessoryItemId":{"type":["string","null"]},"backgroundId":{"type":["string","null"]},"primaryColor":{"type":"string"}}},"GetUserLevelResponse":{"type":"object","properties":{"success":{"type":"boolean"},"level":{"$ref":"#/components/schemas/UserLevel"},"currentLevelDef":{"$ref":"#/components/schemas/LevelDefinition"},"nextLevelDef":{"$ref":"#/components/schemas/LevelDefinition"},"xpToNextLevel":{"type":["number","null"]},"progressPercent":{"type":["number","null"]}},"required":["success","level","currentLevelDef","nextLevelDef","xpToNextLevel","progressPercent"]},"UserLevel":{"type":["object","null"],"properties":{"id":{"type":"string"},"userId":{"type":"string"},"currentLevel":{"type":"number"},"currentXp":{"type":"number"},"totalXp":{"type":"number"},"currentStreak":{"type":"number"},"longestStreak":{"type":"number"},"lastActivityDate":{"type":["string","null"]},"createdAt":{"type":"number"},"updatedAt":{"type":"number"}},"required":["id","userId","currentLevel","currentXp","totalXp","currentStreak","longestStreak","lastActivityDate","createdAt","updatedAt"]},"LevelDefinition":{"type":["object","null"],"properties":{"level":{"type":"number"},"xpRequired":{"type":"number"},"title":{"type":"string"},"unlocks":{"type":["array","null"],"items":{"type":"string"}}},"required":["level","xpRequired","title","unlocks"]},"GetXpHistoryResponse":{"type":"object","properties":{"success":{"type":"boolean"},"entries":{"type":"array","items":{"$ref":"#/components/schemas/XpLedgerEntry"}},"totalToday":{"type":"number"}},"required":["success","entries","totalToday"]},"XpLedgerEntry":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"actionId":{"type":"string"},"xpEarned":{"type":"number"},"entityType":{"type":["string","null"]},"entityId":{"type":["string","null"]},"createdAt":{"type":"number"},"action":{"$ref":"#/components/schemas/XpAction"}},"required":["id","userId","actionId","xpEarned","entityType","entityId","createdAt"]},"XpAction":{"type":"object","properties":{"id":{"type":"string"},"slug":{"type":"string"},"name":{"type":"string"},"description":{"type":["string","null"]},"xpValue":{"type":"number"},"dailyLimit":{"type":["number","null"]},"category":{"type":"string"},"isActive":{"type":"boolean"}},"required":["id","slug","name","description","xpValue","dailyLimit","category","isActive"]},"AwardXpResponse":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"},"xpEarned":{"type":"number"},"newTotalXp":{"type":"number"},"levelUp":{"type":"boolean"},"newLevel":{"type":["number","null"]},"achievementsUnlocked":{"type":"array","items":{"$ref":"#/components/schemas/Achievement"}}},"required":["success","xpEarned","newTotalXp","levelUp","newLevel","achievementsUnlocked"]},"Achievement":{"type":"object","properties":{"id":{"type":"string"},"slug":{"type":"string"},"name":{"type":"string"},"description":{"type":["string","null"]},"category":{"type":"string"},"rarity":{"type":"string"},"requirementType":{"type":"string"},"requirementTarget":{"type":["number","null"]},"requirementCondition":{"type":["string","null"]},"xpReward":{"type":"number"},"unlockItem":{"type":["string","null"]},"icon":{"type":["string","null"]},"isHidden":{"type":"boolean"},"isActive":{"type":"boolean"}},"required":["id","slug","name","description","category","rarity","requirementType","requirementTarget","requirementCondition","xpReward","unlockItem","icon","isHidden","isActive"]},"AwardXpRequest":{"type":"object","properties":{"actionSlug":{"type":"string","example":"ai_query"},"entityType":{"type":"string","example":"deal"},"entityId":{"type":"string","example":"deal_123"}},"required":["actionSlug"]},"GetAchievementsResponse":{"type":"object","properties":{"success":{"type":"boolean"},"achievements":{"type":"array","items":{"$ref":"#/components/schemas/Achievement"}},"userProgress":{"type":"array","items":{"$ref":"#/components/schemas/UserAchievement"}}},"required":["success","achievements","userProgress"]},"UserAchievement":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"achievementId":{"type":"string"},"progress":{"type":"number"},"isComplete":{"type":"boolean"},"completedAt":{"type":["number","null"]},"createdAt":{"type":"number"},"achievement":{"$ref":"#/components/schemas/Achievement"}},"required":["id","userId","achievementId","progress","isComplete","completedAt","createdAt"]},"GetLeaderboardResponse":{"type":"object","properties":{"success":{"type":"boolean"},"leaderboard":{"type":"array","items":{"type":"object","properties":{"userId":{"type":"string"},"displayName":{"type":["string","null"]},"totalXp":{"type":"number"},"currentLevel":{"type":"number"},"rank":{"type":"number"}},"required":["userId","displayName","totalXp","currentLevel","rank"]}},"userRank":{"type":["number","null"]}},"required":["success","leaderboard","userRank"]},"ListTeamsResponse":{"type":"object","properties":{"teams":{"type":"array","items":{"$ref":"#/components/schemas/Team"}},"total":{"type":"number"}},"required":["teams","total"]},"Team":{"type":"object","properties":{"id":{"type":"string"},"organizationId":{"type":"string"},"name":{"type":"string"},"description":{"type":["string","null"]},"slug":{"type":"string"},"color":{"type":["string","null"]},"icon":{"type":["string","null"]},"isActive":{"type":"boolean"},"memberCount":{"type":"number"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","organizationId","name","description","slug","color","icon","isActive","memberCount","createdAt","updatedAt"]},"TeamResponse":{"type":"object","properties":{"team":{"$ref":"#/components/schemas/Team"}},"required":["team"]},"CreateTeam":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100},"description":{"type":"string","maxLength":500},"slug":{"type":"string","minLength":2,"maxLength":50,"pattern":"^[a-z0-9-]+$"},"color":{"type":"string"},"icon":{"type":"string"}},"required":["name"]},"UpdateTeam":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100},"description":{"type":["string","null"],"maxLength":500},"color":{"type":["string","null"]},"icon":{"type":["string","null"]},"isActive":{"type":"boolean"}}},"TeamMembersResponse":{"type":"object","properties":{"members":{"type":"array","items":{"$ref":"#/components/schemas/TeamMember"}},"total":{"type":"number"}},"required":["members","total"]},"TeamMember":{"type":"object","properties":{"id":{"type":"string"},"teamId":{"type":"string"},"userId":{"type":"string"},"role":{"type":"string","enum":["lead","member"]},"addedBy":{"type":["string","null"]},"addedAt":{"type":"string"},"user":{"type":"object","properties":{"id":{"type":"string"},"displayName":{"type":["string","null"]},"email":{"type":"string"},"avatarUrl":{"type":["string","null"]}},"required":["id","displayName","email","avatarUrl"]}},"required":["id","teamId","userId","role","addedBy","addedAt"]},"TeamMemberResponse":{"type":"object","properties":{"member":{"$ref":"#/components/schemas/TeamMember"}},"required":["member"]},"AddTeamMember":{"type":"object","properties":{"userId":{"type":"string"},"role":{"type":"string","enum":["lead","member"],"default":"member"}},"required":["userId"]},"UpdateTeamMember":{"type":"object","properties":{"role":{"type":"string","enum":["lead","member"]}},"required":["role"]},"TwoFactorVerifyResponse":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"sessionToken":{"type":"string"},"user":{"$ref":"#/components/schemas/BaseUser"},"organizations":{"type":"array","items":{"$ref":"#/components/schemas/BaseOrganizationMembership"}}},"required":["success","sessionToken","user","organizations"]},"TwoFactorVerifyRequest":{"type":"object","properties":{"challengeToken":{"type":"string","minLength":1},"code":{"type":"string","minLength":6,"maxLength":10}},"required":["challengeToken","code"]},"TwoFactorStatusResponse":{"type":"object","properties":{"enabled":{"type":"boolean"},"method":{"type":["string","null"]},"verifiedAt":{"type":["string","null"]}},"required":["enabled","method","verifiedAt"]},"TwoFactorSetupResponse":{"type":"object","properties":{"secret":{"type":"string"},"qrCodeUrl":{"type":"string"},"backupCodes":{"type":"array","items":{"type":"string"}}},"required":["secret","qrCodeUrl","backupCodes"]},"TwoFactorEnableRequest":{"type":"object","properties":{"code":{"type":"string","minLength":6,"maxLength":6}},"required":["code"]},"TwoFactorDisableRequest":{"type":"object","properties":{"code":{"type":"string","minLength":6,"maxLength":10,"example":"123456","description":"Current TOTP code from your authenticator app (preferred)"},"password":{"type":"string","minLength":1,"example":"myPassword123","description":"Account password — accepted as fallback if no TOTP code provided"}}},"Workspace":{"type":"object","properties":{"id":{"type":"string","example":"ws_abc123"},"ownerOrgId":{"type":"string","example":"org_xyz789"},"clientOrgId":{"type":["string","null"],"example":"org_client456"},"name":{"type":"string","example":"BodyCloc - Social Media"},"slug":{"type":"string","example":"bodycloc-social-media"},"description":{"type":["string","null"],"example":"Social media content workspace"},"icon":{"type":["string","null"],"example":"📸"},"color":{"type":["string","null"],"example":"#3B82F6"},"coverImage":{"type":["string","null"],"example":null},"type":{"type":"string","enum":["general","project","social_media","brand","product","event"],"example":"general","description":"Workspace type"},"status":{"type":"string","enum":["active","archived","suspended","closed"],"example":"active","description":"Workspace status"},"visibility":{"type":"string","enum":["private","org_visible"],"example":"private"},"createdByUserId":{"type":"string","example":"usr_abc123"},"storageQuotaBytes":{"type":"number","example":5368709120},"storageUsedBytes":{"type":"number","example":0},"memberCount":{"type":"number","example":1},"fileCount":{"type":"number","example":0},"features":{"$ref":"#/components/schemas/WorkspaceFeatures"},"createdAt":{"type":"string","format":"date-time","example":"2026-01-01T00:00:00.000Z"},"updatedAt":{"type":["string","null"],"format":"date-time","example":null},"version":{"type":"number","example":1}},"required":["id","ownerOrgId","clientOrgId","name","slug","description","icon","color","coverImage","type","status","visibility","createdByUserId","storageQuotaBytes","storageUsedBytes","memberCount","fileCount","features","createdAt","updatedAt","version"]},"WorkspaceFeatures":{"type":["object","null"],"properties":{"drive":{"type":"boolean","default":true},"comments":{"type":"boolean","default":true},"approvals":{"type":"boolean","default":true},"boards":{"type":"boolean","default":false},"whiteboard":{"type":"boolean","default":false},"activity":{"type":"boolean","default":true}}},"CreateWorkspace":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100,"example":"BodyCloc - Social Media"},"slug":{"type":"string","minLength":1,"maxLength":100,"pattern":"^[a-z0-9-]+$","example":"bodycloc-social-media","description":"URL slug. Auto-generated from name if not provided."},"description":{"type":"string","maxLength":500},"icon":{"type":"string","maxLength":10},"color":{"type":"string","maxLength":20},"type":{"type":"string","enum":["general","project","social_media","brand","product","event"],"default":"general","example":"general","description":"Workspace type"},"clientOrgId":{"type":"string","example":"org_client456","description":"Client organization ID (if workspace is for a specific client)"},"features":{"$ref":"#/components/schemas/WorkspaceFeatures"}},"required":["name"]},"UpdateWorkspace":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100},"description":{"type":["string","null"],"maxLength":500},"icon":{"type":["string","null"],"maxLength":10},"color":{"type":["string","null"],"maxLength":20},"coverImage":{"type":["string","null"]},"type":{"type":"string","enum":["general","project","social_media","brand","product","event"],"example":"general","description":"Workspace type"},"status":{"type":"string","enum":["active","archived","suspended","closed"],"example":"active","description":"Workspace status"},"visibility":{"type":"string","enum":["private","org_visible"]},"features":{"$ref":"#/components/schemas/WorkspaceFeatures"}}},"WorkspaceMember":{"type":"object","properties":{"id":{"type":"string","example":"wsm_abc123"},"workspaceId":{"type":"string","example":"ws_abc123"},"userId":{"type":"string","example":"usr_xyz789"},"orgId":{"type":"string","example":"org_xyz789"},"role":{"type":"string","enum":["owner","admin","editor","commenter","viewer"],"example":"editor","description":"Workspace member role"},"status":{"type":"string","enum":["active","suspended","removed"],"example":"active","description":"Member status"},"displayName":{"type":["string","null"]},"email":{"type":["string","null"]},"avatarUrl":{"type":["string","null"]},"joinedAt":{"type":["string","null"],"format":"date-time","example":"2026-01-01T00:00:00.000Z"},"createdAt":{"type":"string","format":"date-time","example":"2026-01-01T00:00:00.000Z"}},"required":["id","workspaceId","userId","orgId","role","status","joinedAt","createdAt"]},"UpdateWorkspaceMember":{"type":"object","properties":{"role":{"type":"string","enum":["owner","admin","editor","commenter","viewer"],"example":"editor","description":"Workspace member role"},"status":{"type":"string","enum":["active","suspended","removed"],"example":"active","description":"Member status"}}},"WorkspaceInvitation":{"type":"object","properties":{"id":{"type":"string","example":"wsi_abc123"},"workspaceId":{"type":"string","example":"ws_abc123"},"email":{"type":"string","format":"email","example":"john@bodycloc.com"},"role":{"type":"string","enum":["owner","admin","editor","commenter","viewer"],"example":"editor","description":"Workspace member role"},"status":{"type":"string","enum":["pending","accepted","declined","expired","revoked"],"example":"pending","description":"Invitation status"},"message":{"type":["string","null"],"example":"Welcome to the workspace!"},"invitedBy":{"type":"string","example":"usr_abc123"},"expiresAt":{"type":["string","null"],"format":"date-time"},"createdAt":{"type":"string","format":"date-time","example":"2026-01-01T00:00:00.000Z"}},"required":["id","workspaceId","email","role","status","message","invitedBy","expiresAt","createdAt"]},"InviteToWorkspace":{"type":"object","properties":{"email":{"type":"string","format":"email","example":"john@bodycloc.com"},"role":{"type":"string","enum":["owner","admin","editor","commenter","viewer"],"default":"viewer","example":"editor","description":"Workspace member role"},"message":{"type":"string","maxLength":500}},"required":["email"]},"WorkspaceInvitationPreview":{"type":"object","properties":{"id":{"type":"string"},"workspaceId":{"type":"string"},"workspaceName":{"type":"string"},"workspaceSlug":{"type":"string"},"workspaceIcon":{"type":["string","null"]},"email":{"type":"string","format":"email"},"role":{"type":"string","enum":["owner","admin","editor","commenter","viewer"],"example":"editor","description":"Workspace member role"},"status":{"type":"string","enum":["pending","accepted","declined","expired","revoked"],"example":"pending","description":"Invitation status"},"message":{"type":["string","null"]},"invitedByName":{"type":["string","null"]},"expiresAt":{"type":["string","null"],"format":"date-time"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","workspaceId","workspaceName","workspaceSlug","workspaceIcon","email","role","status","message","invitedByName","expiresAt","createdAt"]},"AcceptWorkspaceInvitationResponse":{"type":"object","properties":{"workspaceId":{"type":"string"},"workspaceName":{"type":"string"},"workspaceSlug":{"type":"string"},"role":{"type":"string","enum":["owner","admin","editor","commenter","viewer"],"example":"editor","description":"Workspace member role"},"memberId":{"type":"string"}},"required":["workspaceId","workspaceName","workspaceSlug","role","memberId"]},"InternalStatsResponse":{"type":"object","properties":{"users":{"type":"object","properties":{"total":{"type":"number"},"active":{"type":"number"},"suspended":{"type":"number"},"unverified":{"type":"number"},"newLast7Days":{"type":"number"},"newLast30Days":{"type":"number"}},"required":["total","active","suspended","unverified","newLast7Days","newLast30Days"]},"organizations":{"type":"object","properties":{"total":{"type":"number"},"active":{"type":"number"},"suspended":{"type":"number"}},"required":["total","active","suspended"]},"security":{"type":"object","properties":{"activeAlerts":{"type":"number"},"failedLoginsLast24h":{"type":"number"},"lockedAccounts":{"type":"number"}},"required":["activeAlerts","failedLoginsLast24h","lockedAccounts"]}},"required":["users","organizations","security"]},"ValidateRelationshipResponse":{"type":"object","properties":{"valid":{"type":"boolean"},"status":{"type":"string"},"relationshipType":{"type":"string"}},"required":["valid"]},"IsPlatformAdminResponse":{"type":"object","properties":{"isPlatformAdmin":{"type":"boolean"}},"required":["isPlatformAdmin"]},"ResolveUsersResponse":{"type":"object","properties":{"users":{"type":"object","additionalProperties":{"type":"object","properties":{"email":{"type":"string"},"displayName":{"type":["string","null"]}},"required":["email","displayName"]}}},"required":["users"]},"ResolveOrgsResponse":{"type":"object","properties":{"organizations":{"type":"object","additionalProperties":{"type":"object","properties":{"name":{"type":"string"}},"required":["name"]}}},"required":["organizations"]},"ResolveSubscriptionResponse":{"type":"object","properties":{"organizationId":{"type":"string"},"planId":{"type":["string","null"]},"status":{"type":["string","null"]}},"required":["organizationId","planId","status"]},"OrgsOnPlanResponse":{"type":"object","properties":{"planId":{"type":"string"},"organizationIds":{"type":"array","items":{"type":"string"}}},"required":["planId","organizationIds"]},"HasPermissionsResponse":{"type":"object","properties":{"userId":{"type":"string"},"permissions":{"type":"object","additionalProperties":{"type":"boolean"}}},"required":["userId","permissions"]},"SendEmailResponse":{"type":"object","properties":{"success":{"type":"boolean"},"error":{"type":"string"}},"required":["success"]},"ResolveApiKeyResponse":{"type":"object","properties":{"value":{"type":"string"},"source":{"type":"string","enum":["organization","platform"]},"keyId":{"type":"string"}},"required":["value","source","keyId"]},"ResolveApiKeyRequest":{"type":"object","properties":{"provider":{"type":"string","minLength":1,"example":"openai"},"organizationId":{"type":"string","example":"org_abc123"},"environment":{"type":"string","example":"production"}},"required":["provider"]},"PublicChangelogList":{"type":"object","properties":{"entries":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"title":{"type":"string"},"description":{"type":"string"},"body":{"type":["string","null"]},"imageUrl":{"type":["string","null"]},"type":{"type":"string","enum":["feature","improvement","fix","security","breaking"]},"affectedFeatures":{"type":"array","items":{"type":"string"}},"relatedDocsUrl":{"type":["string","null"]},"version":{"type":["string","null"]},"publishedAt":{"type":["number","null"]}},"required":["id","title","description","body","imageUrl","type","affectedFeatures","relatedDocsUrl","version","publishedAt"]}},"total":{"type":"number"},"limit":{"type":"number"},"offset":{"type":"number"}},"required":["entries","total","limit","offset"]},"PublicChangelogEntry":{"type":"object","properties":{"id":{"type":"string"},"title":{"type":"string"},"description":{"type":"string"},"body":{"type":["string","null"]},"imageUrl":{"type":["string","null"]},"type":{"type":"string","enum":["feature","improvement","fix","security","breaking"]},"affectedFeatures":{"type":"array","items":{"type":"string"}},"relatedDocsUrl":{"type":["string","null"]},"version":{"type":["string","null"]},"publishedAt":{"type":["number","null"]}},"required":["id","title","description","body","imageUrl","type","affectedFeatures","relatedDocsUrl","version","publishedAt"]}},"parameters":{}},"paths":{"/api/v1/auth/login":{"post":{"operationId":"authLogin","summary":"Authenticate user and create session","description":"Authenticates a user with email/username and password, creating a new session.","tags":["Authentication"],"requestBody":{"description":"Login credentials","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LoginRequest"}}}},"responses":{"200":{"description":"User successfully logged in","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LoginResponse"}}}},"401":{"description":"Invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"429":{"description":"Too many login attempts","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/auth/logout":{"post":{"operationId":"authLogout","summary":"End current session","description":"Invalidates the current session and clears authentication cookies.","tags":["Authentication"],"responses":{"200":{"description":"User successfully logged out","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LogoutResponse"}}}}}}},"/api/v1/auth/me":{"get":{"operationId":"authMe","summary":"Get current user","description":"Returns the currently authenticated user and their organization memberships.","tags":["Authentication"],"responses":{"200":{"description":"Current user data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MeResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/auth/signup":{"post":{"operationId":"authSignup","summary":"Register a new user account","description":"Creates a new user account with email and password authentication. A verification email will be sent.","tags":["Authentication"],"requestBody":{"description":"Registration data","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SignupRequest"}}}},"responses":{"200":{"description":"User successfully registered","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SignupResponse"}}}},"409":{"description":"Email or username already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/auth/forgot-password":{"post":{"operationId":"authForgotPassword","summary":"Request password reset","description":"Sends a password reset link to the user email if account exists. Always returns success for security.","tags":["Authentication"],"requestBody":{"description":"Email address","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ForgotPasswordRequest"}}}},"responses":{"200":{"description":"Reset email sent (if account exists)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessMessageResponse"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"429":{"description":"Rate limit exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/auth/reset-password":{"post":{"operationId":"authResetPassword","summary":"Reset password with token","description":"Resets user password using a valid reset token. Returns a new session on success.","tags":["Authentication"],"requestBody":{"description":"Reset token and new password","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResetPasswordRequest"}}}},"responses":{"200":{"description":"Password reset successful","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResetPasswordResponse"}}}},"400":{"description":"Invalid or expired token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"429":{"description":"Rate limit exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/auth/change-password":{"post":{"operationId":"authChangePassword","summary":"Change password","description":"Changes password for authenticated user. Requires current password verification.","tags":["Authentication"],"security":[{"bearerAuth":[]}],"requestBody":{"description":"Current and new password","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChangePasswordRequest"}}}},"responses":{"200":{"description":"Password changed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessMessageResponse"}}}},"400":{"description":"Invalid current password","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"429":{"description":"Rate limit exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/auth/verify-email":{"post":{"operationId":"authVerifyEmail","summary":"Verify email address","description":"Confirms ownership of an email address using a verification token or code. Returns a session on success.","tags":["Authentication"],"requestBody":{"description":"Verification token or email+code","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerifyEmailRequest"}}}},"responses":{"200":{"description":"Email verified successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerifyEmailResponse"}}}},"400":{"description":"Invalid or expired token/code","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/auth/resend-verification":{"post":{"operationId":"authResendVerification","summary":"Resend verification email","description":"Sends a new verification email for unverified email addresses. Always returns success for security.","tags":["Authentication"],"requestBody":{"description":"Email address","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResendVerificationRequest"}}}},"responses":{"200":{"description":"Verification email sent (if applicable)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessMessageResponse"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"429":{"description":"Rate limit exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/auth/sessions":{"get":{"operationId":"authListSessions","summary":"List active sessions","description":"Returns all active sessions for the authenticated user. The current session is marked.","tags":["Authentication"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"List of active sessions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListSessionsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/auth/sessions/revoke":{"post":{"operationId":"authRevokeSession","summary":"Revoke a session","description":"Invalidates a specific session, logging out that device. Cannot revoke the current session.","tags":["Authentication"],"security":[{"Bearer":[]}],"requestBody":{"description":"Session ID to revoke","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RevokeSessionRequest"}}}},"responses":{"200":{"description":"Session successfully revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessMessageResponse"}}}},"400":{"description":"Cannot revoke current session","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Session not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/auth/check-username":{"get":{"operationId":"authCheckUsername","summary":"Check username availability","description":"Checks if a username is available for registration.","tags":["Authentication"],"parameters":[{"schema":{"type":"string","minLength":1,"description":"Username to check availability for","example":"johndoe"},"required":true,"description":"Username to check availability for","name":"username","in":"query"}],"responses":{"200":{"description":"Username availability status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CheckUsernameResponse"}}}}}}},"/api/v1/auth/check-email":{"get":{"operationId":"authCheckEmail","summary":"Check email availability","description":"Checks if an email address is available for registration.","tags":["Authentication"],"parameters":[{"schema":{"type":"string","format":"email","description":"Email address to check availability for","example":"user@example.com"},"required":true,"description":"Email address to check availability for","name":"email","in":"query"}],"responses":{"200":{"description":"Email availability status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CheckEmailResponse"}}}}}}},"/api/v1/auth/change-email":{"post":{"operationId":"authChangeEmail","summary":"Initiate email change","description":"Starts the email change process by sending verification to the new email. Requires password verification.","tags":["Authentication"],"security":[{"Bearer":[]}],"requestBody":{"description":"New email and current password","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChangeEmailRequest"}}}},"responses":{"200":{"description":"Email change verification sent","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChangeEmailResponse"}}}},"401":{"description":"Not authenticated or invalid password","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailChangeError"}}}},"409":{"description":"New email already in use","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailChangeError"}}}},"429":{"description":"Rate limit exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailChangeError"}}}}}}},"/api/v1/auth/verify-email-change":{"post":{"operationId":"authVerifyEmailChange","summary":"Complete email change","description":"Completes the email change by verifying the token sent to the new email.","tags":["Authentication"],"requestBody":{"description":"Verification token","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerifyEmailChangeRequest"}}}},"responses":{"200":{"description":"Email successfully changed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerifyEmailChangeResponse"}}}},"400":{"description":"Invalid or expired token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailChangeError"}}}}}}},"/api/v1/auth/cancel-email-change":{"post":{"operationId":"authCancelEmailChange","summary":"Cancel pending email change","description":"Cancels a pending email change request.","tags":["Authentication"],"requestBody":{"description":"Token from email change request","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CancelEmailChangeRequest"}}}},"responses":{"200":{"description":"Email change request cancelled","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CancelEmailChangeResponse"}}}},"400":{"description":"Invalid token or already completed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailChangeError"}}}}}}},"/api/v1/auth/impersonate":{"post":{"operationId":"startImpersonation","summary":"Start impersonating a user (admin only)","description":"Allows admins with user.impersonate permission to impersonate another user. Creates a new session for the target user with impersonation metadata. The original admin session is preserved for restoration.","tags":["Auth"],"security":[{"Bearer":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/StartImpersonationRequest"}}}},"responses":{"200":{"description":"Impersonation started successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ImpersonationResponse"}}}},"400":{"description":"Cannot impersonate self","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ImpersonationError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ImpersonationError"}}}},"404":{"description":"Target user not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ImpersonationError"}}}}}}},"/api/v1/auth/end-impersonation":{"post":{"operationId":"endImpersonation","summary":"End current impersonation session","description":"Ends the current impersonation session and restores the admin to their original session. The impersonation session is deleted and audit logged.","tags":["Auth"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Impersonation ended successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ImpersonationResponse"}}}},"400":{"description":"Not currently impersonating","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ImpersonationError"}}}}}}},"/api/v1/auth/impersonation-status":{"get":{"operationId":"getImpersonationStatus","summary":"Get current impersonation status","description":"Returns whether the current session is an impersonation session, along with details about who is impersonating whom and why.","tags":["Auth"],"responses":{"200":{"description":"Impersonation status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ImpersonationStatusResponse"}}}}}}},"/api/v1/auth/oauth/providers":{"get":{"operationId":"oauthListProviders","summary":"List available OAuth providers","description":"Returns a list of OAuth providers configured for the current app.","tags":["OAuth"],"responses":{"200":{"description":"List of available providers","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListProvidersResponse"}}}}}}},"/api/v1/auth/oauth/{provider}/initiate":{"get":{"operationId":"oauthInitiate","summary":"Start OAuth authentication flow","description":"Generates an OAuth authorization URL and returns it with a state token.","tags":["OAuth"],"parameters":[{"schema":{"$ref":"#/components/schemas/OAuthProvider"},"required":true,"name":"provider","in":"path"},{"schema":{"type":"string","format":"uri","description":"Where to redirect after successful login"},"required":false,"description":"Where to redirect after successful login","name":"redirectUrl","in":"query"},{"schema":{"type":"string","enum":["login","signup","link"],"default":"login","description":"OAuth flow mode"},"required":false,"description":"OAuth flow mode","name":"mode","in":"query"}],"responses":{"200":{"description":"OAuth authorization URL generated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InitiateResponse"}}}},"400":{"description":"Provider not configured","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OAuthError"}}}},"404":{"description":"Provider not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OAuthError"}}}}}}},"/api/v1/auth/oauth/{provider}/callback":{"get":{"operationId":"oauthCallback","summary":"Handle OAuth provider callback","description":"Processes the callback from the OAuth provider after user authorization. On success, sets a session cookie and redirects to the dashboard. On failure, redirects to the login page with an error message.","tags":["OAuth"],"parameters":[{"schema":{"$ref":"#/components/schemas/OAuthProvider"},"required":true,"name":"provider","in":"path"},{"schema":{"type":"string"},"required":false,"name":"code","in":"query"},{"schema":{"type":"string"},"required":true,"name":"state","in":"query"},{"schema":{"type":"string"},"required":false,"name":"error","in":"query"},{"schema":{"type":"string"},"required":false,"name":"error_description","in":"query"}],"responses":{"302":{"description":"Redirects to dashboard on success or login on failure"},"400":{"description":"Invalid state or code","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OAuthError"}}}},"401":{"description":"OAuth authentication failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OAuthError"}}}}}}},"/api/v1/auth/oauth/verify-link":{"post":{"operationId":"oauthVerifyLink","summary":"Verify and complete OAuth account linking","description":"Verifies the email code and completes linking an OAuth provider to an existing account. This is required when someone tries to sign in with OAuth using an email that already has an account.","tags":["OAuth"],"requestBody":{"description":"Verification details","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerifyOAuthLinkRequest"}}}},"responses":{"200":{"description":"OAuth link verified and completed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerifyOAuthLinkResponse"}}}},"400":{"description":"Invalid or expired verification code","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OAuthError"}}}},"401":{"description":"Verification failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OAuthError"}}}}}}},"/api/v1/auth/oauth/link":{"post":{"operationId":"oauthLinkProvider","summary":"Link OAuth provider to existing account","description":"Links an OAuth provider to the currently authenticated user account.","tags":["OAuth"],"requestBody":{"description":"Provider linking details","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LinkProviderRequest"}}}},"responses":{"200":{"description":"Provider linked successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LinkedProvidersResponse"}}}},"400":{"description":"Provider already linked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OAuthError"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OAuthError"}}}},"409":{"description":"Provider already linked to another account","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OAuthError"}}}}}}},"/api/v1/auth/oauth/unlink":{"post":{"operationId":"oauthUnlinkProvider","summary":"Unlink OAuth provider from account","description":"Removes an OAuth provider link from the currently authenticated user account.","tags":["OAuth"],"requestBody":{"description":"Provider to unlink","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnlinkProviderRequest"}}}},"responses":{"200":{"description":"Provider unlinked successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LinkedProvidersResponse"}}}},"400":{"description":"Cannot unlink last authentication method","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OAuthError"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OAuthError"}}}},"404":{"description":"Provider not linked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OAuthError"}}}}}}},"/api/v1/auth/oauth/linked":{"get":{"operationId":"oauthGetLinkedProviders","summary":"Get linked OAuth providers","description":"Returns a list of OAuth providers linked to the current user account.","tags":["OAuth"],"responses":{"200":{"description":"List of linked providers","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LinkedProvidersResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OAuthError"}}}}}}},"/api/v1/auth/admin/health":{"get":{"operationId":"adminGetSystemHealth","summary":"Get system health status","description":"Check the health status of all system components.","tags":["Admin"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"System health status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SystemHealthResponse"}}}}}}},"/api/v1/auth/admin/oauth/apps":{"get":{"operationId":"adminListOAuthApps","summary":"List all app OAuth configurations","description":"Get OAuth configuration status for all platform apps. Admin only.","tags":["Admin - OAuth"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"App OAuth configs","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListAppOAuthConfigsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}},"403":{"description":"Not an admin","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}}}}},"/api/v1/auth/admin/oauth/apps/{appId}":{"get":{"operationId":"adminGetOAuthApp","summary":"Get app OAuth configuration","description":"Get detailed OAuth configuration for a specific app. Admin only.","tags":["Admin - OAuth"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"appId","in":"path"}],"responses":{"200":{"description":"App OAuth config","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppOAuthConfig"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}},"403":{"description":"Not an admin","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}},"404":{"description":"App not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}}}}},"/api/v1/auth/admin/oauth/apps/{appId}/google":{"put":{"operationId":"adminUpdateGoogleOAuth","summary":"Update Google OAuth configuration","description":"Set or update Google OAuth credentials for an app. Admin only.","tags":["Admin - OAuth"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"appId","in":"path"}],"requestBody":{"description":"Google OAuth credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateGoogleConfig"}}}},"responses":{"200":{"description":"Config updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}},"403":{"description":"Not an admin","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}},"404":{"description":"App not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}}}},"delete":{"operationId":"adminRemoveGoogleOAuth","summary":"Remove Google OAuth configuration","description":"Remove Google OAuth credentials from an app. Admin only.","tags":["Admin - OAuth"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"appId","in":"path"}],"responses":{"200":{"description":"Config removed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}},"403":{"description":"Not an admin","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}},"404":{"description":"App not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}}}}},"/api/v1/auth/admin/oauth/apps/{appId}/apple":{"put":{"operationId":"adminUpdateAppleOAuth","summary":"Update Apple Sign-In configuration","description":"Set or update Apple Sign-In credentials for an app. Admin only.","tags":["Admin - OAuth"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"appId","in":"path"}],"requestBody":{"description":"Apple Sign-In credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateAppleConfig"}}}},"responses":{"200":{"description":"Config updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}},"403":{"description":"Not an admin","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}},"404":{"description":"App not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}}}},"delete":{"operationId":"adminRemoveAppleOAuth","summary":"Remove Apple Sign-In configuration","description":"Remove Apple Sign-In credentials from an app. Admin only.","tags":["Admin - OAuth"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"appId","in":"path"}],"responses":{"200":{"description":"Config removed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}},"403":{"description":"Not an admin","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}},"404":{"description":"App not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}}}}},"/api/v1/auth/admin/oauth/apps/{appId}/google/test":{"post":{"operationId":"adminTestGoogleOAuth","summary":"Test Google OAuth configuration","description":"Validate Google OAuth credentials are properly configured. Admin only.","tags":["Admin - OAuth"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"appId","in":"path"}],"responses":{"200":{"description":"Test result","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TestOAuthResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}},"403":{"description":"Not an admin","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}},"404":{"description":"App not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}}}}},"/api/v1/auth/admin/users":{"get":{"operationId":"adminGetUserList","summary":"List all users with filtering and pagination","description":"Retrieve a paginated list of all users with comprehensive filtering options.","tags":["Admin"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"integer","exclusiveMinimum":0,"default":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"integer","exclusiveMinimum":0,"maximum":100,"default":20},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","enum":["asc","desc"],"default":"desc"},"required":false,"name":"sortOrder","in":"query"},{"schema":{"type":"string"},"required":false,"name":"search","in":"query"},{"schema":{"type":"string","enum":["active","inactive","suspended","banned"]},"required":false,"name":"status","in":"query"},{"schema":{"type":["boolean","null"]},"required":false,"name":"emailVerified","in":"query"},{"schema":{"type":"string"},"required":false,"name":"organizationId","in":"query"},{"schema":{"type":["boolean","null"]},"required":false,"name":"hasOrganization","in":"query"},{"schema":{"type":"string","enum":["createdAt","email","name","lastSeenAt"],"default":"createdAt"},"required":false,"name":"sortBy","in":"query"}],"responses":{"200":{"description":"Paginated user list","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserListResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Platform operator access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/auth/admin/users/bulk":{"post":{"operationId":"adminBulkUserOperation","summary":"Perform bulk operations on multiple users","description":"Execute the same action on multiple user accounts at once.","tags":["Admin"],"security":[{"Bearer":[]}],"requestBody":{"description":"Bulk operation details","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkUserOperationRequest"}}}},"responses":{"200":{"description":"Bulk operation result","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkUserOperationResponse"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Platform operator access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/auth/admin/users/export":{"get":{"operationId":"adminExportUsers","summary":"Export user data to CSV or JSON","description":"Export user data with the same filters as the list endpoint.","tags":["Admin"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"integer","exclusiveMinimum":0,"default":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"integer","exclusiveMinimum":0,"maximum":100,"default":20},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","enum":["asc","desc"],"default":"desc"},"required":false,"name":"sortOrder","in":"query"},{"schema":{"type":"string"},"required":false,"name":"search","in":"query"},{"schema":{"type":"string","enum":["active","inactive","suspended","banned"]},"required":false,"name":"status","in":"query"},{"schema":{"type":["boolean","null"]},"required":false,"name":"emailVerified","in":"query"},{"schema":{"type":"string"},"required":false,"name":"organizationId","in":"query"},{"schema":{"type":["boolean","null"]},"required":false,"name":"hasOrganization","in":"query"},{"schema":{"type":"string","enum":["createdAt","email","name","lastSeenAt"],"default":"createdAt"},"required":false,"name":"sortBy","in":"query"},{"schema":{"type":"string","enum":["csv","json"],"default":"csv"},"required":false,"name":"format","in":"query"}],"responses":{"200":{"description":"User export file","content":{"text/csv":{"schema":{"type":"string"}},"application/json":{"schema":{"$ref":"#/components/schemas/UserListResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Platform operator access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/auth/admin/users/{id}":{"get":{"operationId":"adminGetUserDetail","summary":"Get detailed user information","description":"Retrieve comprehensive information about a specific user.","tags":["Admin"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"user_123"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"User details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserDetailResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Platform operator access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"User not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/auth/admin/users/{id}/suspend":{"post":{"operationId":"adminSuspendUser","summary":"Suspend a user account","description":"Suspend a user account, preventing login and API access.","tags":["Admin"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"user_123"},"required":true,"name":"id","in":"path"}],"requestBody":{"description":"Suspension details","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuspendUserRequest"}}}},"responses":{"200":{"description":"User suspended successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuspendUserResponse"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Platform operator access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"User not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/auth/admin/users/{id}/unsuspend":{"post":{"operationId":"adminUnsuspendUser","summary":"Restore a suspended user account","description":"Restore access to a previously suspended user account.","tags":["Admin"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"user_123"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"User unsuspended successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuspendUserResponse"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Platform operator access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"User not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/auth/admin/users/{id}/lock":{"post":{"operationId":"adminLockUser","summary":"Lock a user account","description":"Administratively lock a user account, preventing login. Unlike suspension (which sets a status flag), locking sets a lockedUntil timestamp in user metadata. Supports a configurable duration or permanent lock. All active sessions are revoked immediately.","tags":["Admin"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"user_123"},"required":true,"name":"id","in":"path"}],"requestBody":{"description":"Lock details","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LockUserRequest"}}}},"responses":{"200":{"description":"Account locked successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LockUserResponse"}}}},"400":{"description":"Cannot lock your own account","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Platform operator access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"User not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/auth/admin/users/{id}/unlock":{"post":{"operationId":"adminUnlockUser","summary":"Unlock a locked user account","description":"Remove an administrative or automatic lockout from a user account, restoring their ability to log in. Does not restore suspended accounts — use /unsuspend for that.","tags":["Admin"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"user_123"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Account unlocked successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LockUserResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Platform operator access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"User not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/auth/admin/users/{userId}/devices":{"get":{"operationId":"adminGetUserDevices","summary":"Get devices for a specific user","description":"Retrieve a list of devices associated with a user.","tags":["Admin"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"user_123"},"required":true,"name":"userId","in":"path"},{"schema":{"type":"integer","exclusiveMinimum":0,"default":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"integer","exclusiveMinimum":0,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"User devices list","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserDevicesListResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Platform operator access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"User not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/auth/admin/users/{userId}/devices/{deviceId}":{"delete":{"operationId":"adminRevokeUserDevice","summary":"Revoke a specific device for a user","description":"Revoke access for a specific device belonging to a user.","tags":["Admin"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"user_123"},"required":true,"name":"userId","in":"path"},{"schema":{"type":"string","example":"device_456"},"required":true,"name":"deviceId","in":"path"}],"responses":{"200":{"description":"Device revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RevokeUserDeviceResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Platform operator access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"User or device not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/auth/admin/users/{userId}/security-events":{"get":{"operationId":"adminGetUserSecurityEvents","summary":"Get security events for a specific user","description":"Retrieve security events associated with a user.","tags":["Admin"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"user_123"},"required":true,"name":"userId","in":"path"},{"schema":{"type":"integer","exclusiveMinimum":0,"default":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"integer","exclusiveMinimum":0,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","enum":["low","medium","high","critical"]},"required":false,"name":"severity","in":"query"}],"responses":{"200":{"description":"User security events list","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserSecurityEventsListResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Platform operator access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"User not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/auth/admin/users/{userId}/sessions/revoke":{"post":{"operationId":"adminRevokeUserSessions","summary":"Revoke all sessions for a user","description":"Revoke all active sessions for a user, forcing them to re-authenticate.","tags":["Admin"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"user_123"},"required":true,"name":"userId","in":"path"}],"responses":{"200":{"description":"Sessions revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RevokeUserSessionsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Platform operator access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"User not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/auth/admin/rbac/roles":{"get":{"operationId":"listAdminRoles","summary":"List roles","description":"List all roles with filtering and pagination (super admin only)","tags":["Admin","RBAC"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"integer","exclusiveMinimum":0,"default":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string"},"required":false,"name":"search","in":"query"},{"schema":{"type":["boolean","null"],"default":true},"required":false,"name":"includeSystem","in":"query"},{"schema":{"type":"string"},"required":false,"name":"organizationId","in":"query"}],"responses":{"200":{"description":"Roles retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListRolesResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"post":{"operationId":"createAdminRole","summary":"Create role","description":"Create a new role (super admin only)","tags":["Admin","RBAC"],"security":[{"Bearer":[]}],"requestBody":{"description":"Role details","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateRoleRequest"}}}},"responses":{"201":{"description":"Role created successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateRoleResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"409":{"description":"Resource already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/auth/admin/rbac/roles/{roleId}":{"get":{"operationId":"getAdminRole","summary":"Get role details","description":"Get a single role by ID with permissions (super admin only)","tags":["Admin","RBAC"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"role_abc123"},"required":true,"name":"roleId","in":"path"}],"responses":{"200":{"description":"Role retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetRoleResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"patch":{"operationId":"updateAdminRole","summary":"Update role","description":"Update an existing role (super admin only)","tags":["Admin","RBAC"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"role_abc123"},"required":true,"name":"roleId","in":"path"}],"requestBody":{"description":"Updated role details","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateRoleRequest"}}}},"responses":{"200":{"description":"Role updated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateRoleResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"delete":{"operationId":"deleteAdminRole","summary":"Delete role","description":"Delete a role (super admin only, cannot delete system roles)","tags":["Admin","RBAC"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"role_abc123"},"required":true,"name":"roleId","in":"path"}],"responses":{"200":{"description":"Role deleted successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeleteRoleResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/auth/admin/rbac/permissions":{"get":{"operationId":"listAdminPermissions","summary":"List permissions","description":"List all available permissions (super admin only)","tags":["Admin","RBAC"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string"},"required":false,"name":"resource","in":"query"},{"schema":{"type":"string"},"required":false,"name":"action","in":"query"}],"responses":{"200":{"description":"Permissions retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListPermissionsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/auth/admin/rbac/users/assign":{"post":{"operationId":"assignUserRole","summary":"Assign role to user","description":"Assign a role to a user (super admin only)","tags":["Admin","RBAC"],"security":[{"Bearer":[]}],"requestBody":{"description":"Role assignment details","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AssignRoleRequest"}}}},"responses":{"200":{"description":"Role assigned successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AssignRoleResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"409":{"description":"Resource already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/auth/admin/rbac/users/remove":{"post":{"operationId":"removeUserRole","summary":"Remove role from user","description":"Remove a role from a user (super admin only)","tags":["Admin","RBAC"],"security":[{"Bearer":[]}],"requestBody":{"description":"Role removal details","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RemoveRoleRequest"}}}},"responses":{"200":{"description":"Role removed successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AssignRoleResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/auth/admin/rbac/users/{userId}/roles":{"get":{"operationId":"getUserRoles","summary":"Get user roles","description":"Get all roles assigned to a user (super admin only)","tags":["Admin","RBAC"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"user_abc123"},"required":true,"name":"userId","in":"path"}],"responses":{"200":{"description":"User roles retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserRolesResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/auth/admin/organizations":{"get":{"operationId":"adminGetOrganizationList","summary":"List all organizations","description":"Retrieve a paginated list of all organizations with statistics.","tags":["Admin","Organizations"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"integer","exclusiveMinimum":0,"default":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"integer","exclusiveMinimum":0,"maximum":100,"default":20},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","enum":["asc","desc"],"default":"desc"},"required":false,"name":"sortOrder","in":"query"},{"schema":{"type":"string"},"required":false,"name":"search","in":"query"},{"schema":{"type":"string","enum":["free","starter","professional","enterprise"]},"required":false,"name":"plan","in":"query"},{"schema":{"type":"string","enum":["active","suspended","cancelled"]},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","enum":["createdAt","name","memberCount"],"default":"createdAt"},"required":false,"name":"sortBy","in":"query"}],"responses":{"200":{"description":"Paginated organization list with stats","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationListResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}},"403":{"description":"Super admin access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}}}}},"/api/v1/auth/admin/organizations/{organizationId}":{"get":{"operationId":"adminGetOrganizationDetail","summary":"Get organization details (admin)","description":"Retrieve detailed information about any organization as a platform administrator.","tags":["Admin","Organizations"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"org_123"},"required":true,"name":"organizationId","in":"path"}],"responses":{"200":{"description":"Organization details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}},"403":{"description":"Super admin access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}},"404":{"description":"Organization not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}}}},"patch":{"operationId":"adminUpdateOrganization","summary":"Update organization (admin)","description":"Update organization details as a platform administrator.","tags":["Admin","Organizations"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"org_123"},"required":true,"name":"organizationId","in":"path"}],"requestBody":{"description":"Organization updates","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminUpdateOrganizationRequest"}}}},"responses":{"200":{"description":"Organization updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminUpdateOrganizationResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}},"403":{"description":"Super admin access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}},"404":{"description":"Organization not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}}}}},"/api/v1/auth/admin/organizations/{organizationId}/status":{"patch":{"operationId":"adminUpdateOrganizationStatus","summary":"Update organization status (admin)","description":"Suspend or activate an organization as a platform administrator.","tags":["Admin","Organizations"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"org_123"},"required":true,"name":"organizationId","in":"path"}],"requestBody":{"description":"New status for organization","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminUpdateOrganizationStatusRequest"}}}},"responses":{"200":{"description":"Organization status updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminUpdateOrganizationResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}},"403":{"description":"Super admin access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}},"404":{"description":"Organization not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}}}}},"/api/v1/auth/admin/organizations/{organizationId}/byok-settings":{"get":{"operationId":"adminGetByokSettings","summary":"Get BYOK settings for organization","description":"Retrieve BYOK (Bring Your Own Key) settings for an organization as a platform administrator.","tags":["Admin","Organizations"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"org_123"},"required":true,"name":"organizationId","in":"path"}],"responses":{"200":{"description":"BYOK settings","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ByokSettingsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}},"403":{"description":"Super admin access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}},"404":{"description":"Organization not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}}}},"patch":{"operationId":"adminUpdateByokSettings","summary":"Update BYOK settings for organization","description":"Enable or disable BYOK and configure allowed providers for an organization as a platform administrator.","tags":["Admin","Organizations"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"org_123"},"required":true,"name":"organizationId","in":"path"}],"requestBody":{"description":"BYOK settings updates","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateByokSettingsRequest"}}}},"responses":{"200":{"description":"BYOK settings updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ByokSettingsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}},"403":{"description":"Super admin access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}},"404":{"description":"Organization not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}}}}},"/api/v1/auth/admin/organizations/{organizationId}/members":{"get":{"operationId":"adminGetOrganizationMembers","summary":"List organization members (admin)","description":"Retrieve a list of members for any organization as a platform administrator.","tags":["Admin","Organizations"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"org_123"},"required":true,"name":"organizationId","in":"path"},{"schema":{"type":"string"},"required":false,"name":"search","in":"query"},{"schema":{"type":"string","enum":["owner","admin","member","viewer"]},"required":false,"name":"role","in":"query"},{"schema":{"type":"number","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":["number","null"],"minimum":0,"default":0},"required":false,"name":"offset","in":"query"}],"responses":{"200":{"description":"List of organization members","content":{"application/json":{"schema":{"type":"object","properties":{"members":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"role":{"type":"string"},"permissions":{"type":["array","null"],"items":{"type":"string"}},"user":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":["string","null"]},"displayName":{"type":["string","null"]},"avatar":{"type":["string","null"]}},"required":["id","email","displayName","avatar"]},"joinedAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","role","permissions","user","joinedAt","updatedAt"]}},"total":{"type":"number"},"limit":{"type":"number"},"offset":{"type":"number"}},"required":["members","total","limit","offset"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}},"403":{"description":"Super admin access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}},"404":{"description":"Organization not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}}}}},"/api/v1/auth/admin/organizations/{organizationId}/apps":{"get":{"operationId":"adminGetOrganizationApps","summary":"List organization apps (admin)","description":"Retrieve a list of apps granted to an organization. Note: This is a stub - apps feature is not yet implemented.","tags":["Admin","Organizations"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"org_123"},"required":true,"name":"organizationId","in":"path"}],"responses":{"200":{"description":"List of organization apps","content":{"application/json":{"schema":{"type":"object","properties":{"apps":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"description":{"type":["string","null"]},"icon":{"type":["string","null"]},"grantedAt":{"type":"string"}},"required":["id","name","slug","description","icon","grantedAt"]}},"total":{"type":"number"}},"required":["apps","total"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}},"403":{"description":"Super admin access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}}}}},"/api/v1/auth/admin/service-api-keys":{"get":{"operationId":"listServiceApiKeys","summary":"List platform service API keys","description":"List all platform-level third-party service API keys (super admin only)","tags":["Admin","Service API Keys"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","enum":["openai","anthropic","google_ai","elevenlabs","playht","veo","pika","runway","sendgrid","resend","stripe","dropbox","google_drive","onedrive","box","cloudflare_stream","cloudflare_realtime","cloudflare_r2","cloudflare_images","deepgram","mapbox","custom"]},"required":false,"name":"provider","in":"query"},{"schema":{"type":"string"},"required":false,"name":"environment","in":"query"},{"schema":{"type":"string"},"required":false,"name":"isActive","in":"query"}],"responses":{"200":{"description":"Service API keys list","content":{"application/json":{"schema":{"type":"object","properties":{"keys":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"provider":{"type":"string","enum":["openai","anthropic","google_ai","elevenlabs","playht","veo","pika","runway","sendgrid","resend","stripe","dropbox","google_drive","onedrive","box","cloudflare_stream","cloudflare_realtime","cloudflare_r2","cloudflare_images","deepgram","mapbox","custom"]},"environment":{"type":["string","null"]},"name":{"type":["string","null"]},"keyPrefix":{"type":["string","null"]},"isActive":{"type":"boolean"},"lastUsedAt":{"type":["number","null"]},"lastValidatedAt":{"type":["number","null"]},"validationStatus":{"type":["string","null"]},"usageCount":{"type":"number"},"createdAt":{"type":"number"},"updatedAt":{"type":"number"}},"required":["id","provider","environment","name","keyPrefix","isActive","lastUsedAt","lastValidatedAt","validationStatus","usageCount","createdAt","updatedAt"]}},"total":{"type":"number"}},"required":["keys","total"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Super admin access required","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}},"post":{"operationId":"createServiceApiKey","summary":"Create platform service API key","description":"Create a new platform-level service API key. The key value is encrypted.","tags":["Admin","Service API Keys"],"security":[{"Bearer":[]}],"requestBody":{"description":"Service API key data","required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"provider":{"type":"string","enum":["openai","anthropic","google_ai","elevenlabs","playht","veo","pika","runway","sendgrid","resend","stripe","dropbox","google_drive","onedrive","box","cloudflare_stream","cloudflare_realtime","cloudflare_r2","cloudflare_images","deepgram","mapbox","custom"]},"value":{"type":"string","minLength":1},"environment":{"type":"string"},"name":{"type":"string","maxLength":100},"metadata":{"type":"object","additionalProperties":{}}},"required":["provider","value"]}}}},"responses":{"201":{"description":"Service API key created","content":{"application/json":{"schema":{"type":"object","properties":{"key":{"type":"object","properties":{"id":{"type":"string"},"provider":{"type":"string","enum":["openai","anthropic","google_ai","elevenlabs","playht","veo","pika","runway","sendgrid","resend","stripe","dropbox","google_drive","onedrive","box","cloudflare_stream","cloudflare_realtime","cloudflare_r2","cloudflare_images","deepgram","mapbox","custom"]},"environment":{"type":["string","null"]},"name":{"type":["string","null"]},"keyPrefix":{"type":["string","null"]},"isActive":{"type":"boolean"},"lastUsedAt":{"type":["number","null"]},"lastValidatedAt":{"type":["number","null"]},"validationStatus":{"type":["string","null"]},"usageCount":{"type":"number"},"createdAt":{"type":"number"},"updatedAt":{"type":"number"}},"required":["id","provider","environment","name","keyPrefix","isActive","lastUsedAt","lastValidatedAt","validationStatus","usageCount","createdAt","updatedAt"]},"message":{"type":"string"}},"required":["key","message"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Super admin access required","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}}},"/api/v1/auth/admin/service-api-keys/{keyId}":{"get":{"operationId":"getServiceApiKey","summary":"Get service API key","description":"Get details for a specific service API key (super admin only)","tags":["Admin","Service API Keys"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"sak_abc123"},"required":true,"name":"keyId","in":"path"}],"responses":{"200":{"description":"Service API key details","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"provider":{"type":"string","enum":["openai","anthropic","google_ai","elevenlabs","playht","veo","pika","runway","sendgrid","resend","stripe","dropbox","google_drive","onedrive","box","cloudflare_stream","cloudflare_realtime","cloudflare_r2","cloudflare_images","deepgram","mapbox","custom"]},"environment":{"type":["string","null"]},"name":{"type":["string","null"]},"keyPrefix":{"type":["string","null"]},"isActive":{"type":"boolean"},"lastUsedAt":{"type":["number","null"]},"lastValidatedAt":{"type":["number","null"]},"validationStatus":{"type":["string","null"]},"usageCount":{"type":"number"},"createdAt":{"type":"number"},"updatedAt":{"type":"number"}},"required":["id","provider","environment","name","keyPrefix","isActive","lastUsedAt","lastValidatedAt","validationStatus","usageCount","createdAt","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Super admin access required","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"404":{"description":"Key not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}},"patch":{"operationId":"updateServiceApiKey","summary":"Update service API key","description":"Update an existing service API key. Use this to rotate keys or update metadata.","tags":["Admin","Service API Keys"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"sak_abc123"},"required":true,"name":"keyId","in":"path"}],"requestBody":{"description":"Updated service API key data","required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","maxLength":100},"value":{"type":"string","minLength":1},"isActive":{"type":"boolean"},"metadata":{"type":"object","additionalProperties":{}}}}}}},"responses":{"200":{"description":"Service API key updated","content":{"application/json":{"schema":{"type":"object","properties":{"key":{"type":"object","properties":{"id":{"type":"string"},"provider":{"type":"string","enum":["openai","anthropic","google_ai","elevenlabs","playht","veo","pika","runway","sendgrid","resend","stripe","dropbox","google_drive","onedrive","box","cloudflare_stream","cloudflare_realtime","cloudflare_r2","cloudflare_images","deepgram","mapbox","custom"]},"environment":{"type":["string","null"]},"name":{"type":["string","null"]},"keyPrefix":{"type":["string","null"]},"isActive":{"type":"boolean"},"lastUsedAt":{"type":["number","null"]},"lastValidatedAt":{"type":["number","null"]},"validationStatus":{"type":["string","null"]},"usageCount":{"type":"number"},"createdAt":{"type":"number"},"updatedAt":{"type":"number"}},"required":["id","provider","environment","name","keyPrefix","isActive","lastUsedAt","lastValidatedAt","validationStatus","usageCount","createdAt","updatedAt"]},"message":{"type":"string"}},"required":["key","message"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Super admin access required","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"404":{"description":"Key not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}},"delete":{"operationId":"deleteServiceApiKey","summary":"Delete service API key","description":"Permanently delete a platform service API key","tags":["Admin","Service API Keys"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"sak_abc123"},"required":true,"name":"keyId","in":"path"}],"responses":{"200":{"description":"Service API key deleted","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"}},"required":["success","message"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Super admin access required","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"404":{"description":"Key not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}}},"/api/v1/auth/admin/service-api-keys/{keyId}/validate":{"post":{"operationId":"validateServiceApiKey","summary":"Validate service API key","description":"Test a service API key against the provider to verify it works","tags":["Admin","Service API Keys"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"sak_abc123"},"required":true,"name":"keyId","in":"path"}],"responses":{"200":{"description":"Validation result","content":{"application/json":{"schema":{"type":"object","properties":{"isValid":{"type":"boolean"},"error":{"type":["string","null"]},"validatedAt":{"type":["string","null"]},"canValidate":{"type":"boolean"},"message":{"type":["string","null"]}},"required":["isValid","error","validatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Super admin access required","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"404":{"description":"Key not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}}},"/api/v1/auth/admin/reserved-names/export":{"get":{"operationId":"exportReservedNames","summary":"Export reserved names","description":"Export all reserved names as JSON or CSV","tags":["Admin","Reserved Names"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","enum":["json","csv"],"default":"json"},"required":false,"name":"format","in":"query"}],"responses":{"200":{"description":"Export data","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"normalizedName":{"type":"string"},"type":{"type":"string","enum":["username","organization","project","subdomain","slug","all"]},"category":{"type":"string","enum":["system","offensive","brand","legal","security","custom"]},"matchType":{"type":"string","enum":["exact","prefix","suffix","contains","regex"]},"regexPattern":{"type":["string","null"]},"reason":{"type":"string"},"severity":{"type":"string","enum":["block","warn"]},"isActive":{"type":"boolean"},"organizationId":{"type":["string","null"]},"effectiveFrom":{"type":["number","null"]},"expiresAt":{"type":["number","null"]},"blockCount":{"type":"number"},"createdBy":{"type":"string"},"createdAt":{"type":"number"},"updatedBy":{"type":["string","null"]},"updatedAt":{"type":["number","null"]}},"required":["id","name","normalizedName","type","category","matchType","regexPattern","reason","severity","isActive","organizationId","effectiveFrom","expiresAt","blockCount","createdBy","createdAt","updatedBy","updatedAt"]}}},"text/csv":{"schema":{"type":"string"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}}},"/api/v1/auth/admin/reserved-names/bulk":{"post":{"operationId":"bulkImportReservedNames","summary":"Bulk import reserved names","description":"Import multiple reserved names at once","tags":["Admin","Reserved Names"],"security":[{"Bearer":[]}],"requestBody":{"description":"Import data","required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100,"description":"The name or pattern to reserve"},"type":{"type":"string","enum":["username","organization","project","subdomain","slug","all"],"description":"What type of name this applies to"},"category":{"type":"string","enum":["system","offensive","brand","legal","security","custom"],"default":"custom","description":"Category for organization"},"matchType":{"type":"string","enum":["exact","prefix","suffix","contains","regex"],"default":"exact","description":"How to match the name"},"reason":{"type":"string","minLength":1,"maxLength":500,"description":"Why this name is reserved (required for audit)"},"severity":{"type":"string","enum":["block","warn"],"default":"block","description":"Action to take when matched"},"effectiveFrom":{"type":["number","null"],"description":"Unix timestamp when this rule becomes effective"},"expiresAt":{"type":["number","null"],"description":"Unix timestamp when this rule expires"}},"required":["name","type","reason"]},"minItems":1,"maxItems":1000,"description":"Items to import"},"skipDuplicates":{"type":"boolean","default":true,"description":"Skip duplicates instead of failing"}},"required":["items"]}}}},"responses":{"200":{"description":"Import results","content":{"application/json":{"schema":{"type":"object","properties":{"imported":{"type":"number"},"skipped":{"type":"number"},"errors":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"error":{"type":"string"}},"required":["name","error"]}}},"required":["imported","skipped","errors"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}},"delete":{"operationId":"bulkDeleteReservedNames","summary":"Bulk delete reserved names","description":"Delete multiple reserved names at once","tags":["Admin","Reserved Names"],"security":[{"Bearer":[]}],"requestBody":{"description":"Delete data","required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"ids":{"type":"array","items":{"type":"string"},"minItems":1,"maxItems":100,"description":"IDs to delete"},"reason":{"type":"string","description":"Reason for deletion"}},"required":["ids"]}}}},"responses":{"200":{"description":"Delete results","content":{"application/json":{"schema":{"type":"object","properties":{"deleted":{"type":"number"}},"required":["deleted"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}}},"/api/v1/auth/admin/reserved-names/validate":{"post":{"operationId":"validateReservedName","summary":"Validate a name","description":"Check if a name is reserved and get suggestions","tags":["Admin","Reserved Names"],"security":[{"Bearer":[]}],"requestBody":{"description":"Name to validate","required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"description":"Name to validate"},"type":{"type":"string","enum":["username","organization","project","subdomain","slug","all"],"description":"Type of name being validated"},"organizationId":{"type":"string","description":"Organization context"}},"required":["name","type"]}}}},"responses":{"200":{"description":"Validation result","content":{"application/json":{"schema":{"type":"object","properties":{"isReserved":{"type":"boolean"},"reason":{"type":"string"},"matchedRule":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"category":{"type":"string"},"matchType":{"type":"string"}},"required":["id","name","category","matchType"]},"warnings":{"type":"array","items":{"type":"string"}},"normalized":{"type":"string"},"suggestions":{"type":"array","items":{"type":"string"}}},"required":["isReserved"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}}},"/api/v1/auth/admin/reserved-names/analytics/dashboard":{"get":{"operationId":"getReservedNamesDashboardStats","summary":"Get dashboard statistics","description":"Get statistics for the reserved names dashboard","tags":["Admin","Reserved Names"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Dashboard statistics","content":{"application/json":{"schema":{"type":"object","properties":{"totalReserved":{"type":"number"},"activeReserved":{"type":"number"},"categoryBreakdown":{"type":"object","additionalProperties":{"type":"number"}},"blockedAttempts":{"type":"object","properties":{"today":{"type":"number"},"thisWeek":{"type":"number"},"thisMonth":{"type":"number"}},"required":["today","thisWeek","thisMonth"]},"topBlocked":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"count":{"type":"number"},"category":{"type":["string","null"]}},"required":["name","count","category"]}},"recentAttempts":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"attemptedName":{"type":"string"},"normalizedName":{"type":"string"},"nameType":{"type":"string"},"matchedCategory":{"type":["string","null"]},"ipAddress":{"type":["string","null"]},"blockedAt":{"type":"number"}},"required":["id","attemptedName","normalizedName","nameType","matchedCategory","ipAddress","blockedAt"]}}},"required":["totalReserved","activeReserved","categoryBreakdown","blockedAttempts","topBlocked","recentAttempts"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}}},"/api/v1/auth/admin/reserved-names/analytics/blocked":{"get":{"operationId":"getBlockedAttempts","summary":"Get blocked attempts","description":"Get a paginated list of blocked name attempts","tags":["Admin","Reserved Names"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":["number","null"]},"required":false,"name":"startDate","in":"query"},{"schema":{"type":["number","null"]},"required":false,"name":"endDate","in":"query"},{"schema":{"type":"string"},"required":false,"name":"category","in":"query"},{"schema":{"type":"string"},"required":false,"name":"nameType","in":"query"},{"schema":{"type":"string"},"required":false,"name":"search","in":"query"},{"schema":{"type":"number","minimum":1,"default":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"number","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"Blocked attempts list","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"attemptedName":{"type":"string"},"normalizedName":{"type":"string"},"nameType":{"type":"string"},"matchedRuleId":{"type":["string","null"]},"matchedRuleName":{"type":["string","null"]},"matchedCategory":{"type":["string","null"]},"matchType":{"type":["string","null"]},"ipAddress":{"type":["string","null"]},"userAgent":{"type":["string","null"]},"userId":{"type":["string","null"]},"containsHomoglyphs":{"type":"boolean"},"containsLeetspeak":{"type":"boolean"},"blockedAt":{"type":"number"}},"required":["id","attemptedName","normalizedName","nameType","matchedRuleId","matchedRuleName","matchedCategory","matchType","ipAddress","userAgent","userId","containsHomoglyphs","containsLeetspeak","blockedAt"]}},"total":{"type":"number"},"page":{"type":"number"},"limit":{"type":"number"}},"required":["items","total","page","limit"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}}},"/api/v1/auth/admin/reserved-names/analytics/timeseries":{"get":{"operationId":"getReservedNamesTimeseries","summary":"Get blocked attempts time series","description":"Get time series data for blocked attempts","tags":["Admin","Reserved Names"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":["number","null"]},"required":false,"name":"startDate","in":"query"},{"schema":{"type":["number","null"]},"required":false,"name":"endDate","in":"query"},{"schema":{"type":"string","enum":["hour","day","week"],"default":"day"},"required":false,"name":"interval","in":"query"}],"responses":{"200":{"description":"Time series data","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","properties":{"period":{"type":"string"},"count":{"type":"number"}},"required":["period","count"]}}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}}},"/api/v1/auth/admin/reserved-names/analytics/attacks":{"get":{"operationId":"getAttackPatterns","summary":"Get attack pattern analysis","description":"Analyze attack patterns from blocked attempts","tags":["Admin","Reserved Names"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Attack pattern analysis","content":{"application/json":{"schema":{"type":"object","properties":{"suspiciousIps":{"type":"array","items":{"type":"object","properties":{"ipAddress":{"type":["string","null"]},"attemptCount":{"type":"number"},"uniqueNames":{"type":"number"},"firstSeen":{"type":"number"},"lastSeen":{"type":"number"}},"required":["ipAddress","attemptCount","uniqueNames","firstSeen","lastSeen"]}},"obfuscationAttempts":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string"},"count":{"type":"number"}},"required":["type","count"]}}},"required":["suspiciousIps","obfuscationAttempts"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}}},"/api/v1/auth/admin/reserved-names/analytics/export":{"get":{"operationId":"exportBlockedAttempts","summary":"Export blocked attempts","description":"Export blocked attempts as CSV or JSON","tags":["Admin","Reserved Names"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":["number","null"]},"required":false,"name":"startDate","in":"query"},{"schema":{"type":["number","null"]},"required":false,"name":"endDate","in":"query"},{"schema":{"type":"string","enum":["csv","json"],"default":"csv"},"required":false,"name":"format","in":"query"}],"responses":{"200":{"description":"Export data","content":{"application/json":{"schema":{"type":"array","items":{}}},"text/csv":{"schema":{"type":"string"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}}},"/api/v1/auth/admin/reserved-names":{"get":{"operationId":"listReservedNames","summary":"List reserved names","description":"Get a paginated list of reserved names with filtering and sorting","tags":["Admin","Reserved Names"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","description":"Search by name"},"required":false,"description":"Search by name","name":"search","in":"query"},{"schema":{"type":"string","enum":["username","organization","project","subdomain","slug","all"],"description":"Filter by type"},"required":false,"description":"Filter by type","name":"type","in":"query"},{"schema":{"type":"string","enum":["system","offensive","brand","legal","security","custom"],"description":"Filter by category"},"required":false,"description":"Filter by category","name":"category","in":"query"},{"schema":{"type":["boolean","null"],"description":"Filter by active status"},"required":false,"description":"Filter by active status","name":"isActive","in":"query"},{"schema":{"type":"number","minimum":1,"default":1,"description":"Page number"},"required":false,"description":"Page number","name":"page","in":"query"},{"schema":{"type":"number","minimum":1,"maximum":100,"default":50,"description":"Items per page"},"required":false,"description":"Items per page","name":"limit","in":"query"},{"schema":{"type":"string","enum":["name","createdAt","blockCount"],"default":"name","description":"Sort field"},"required":false,"description":"Sort field","name":"sortBy","in":"query"},{"schema":{"type":"string","enum":["asc","desc"],"default":"asc","description":"Sort order"},"required":false,"description":"Sort order","name":"sortOrder","in":"query"}],"responses":{"200":{"description":"Reserved names list","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"normalizedName":{"type":"string"},"type":{"type":"string","enum":["username","organization","project","subdomain","slug","all"]},"category":{"type":"string","enum":["system","offensive","brand","legal","security","custom"]},"matchType":{"type":"string","enum":["exact","prefix","suffix","contains","regex"]},"regexPattern":{"type":["string","null"]},"reason":{"type":"string"},"severity":{"type":"string","enum":["block","warn"]},"isActive":{"type":"boolean"},"organizationId":{"type":["string","null"]},"effectiveFrom":{"type":["number","null"]},"expiresAt":{"type":["number","null"]},"blockCount":{"type":"number"},"createdBy":{"type":"string"},"createdAt":{"type":"number"},"updatedBy":{"type":["string","null"]},"updatedAt":{"type":["number","null"]}},"required":["id","name","normalizedName","type","category","matchType","regexPattern","reason","severity","isActive","organizationId","effectiveFrom","expiresAt","blockCount","createdBy","createdAt","updatedBy","updatedAt"]}},"total":{"type":"number"},"page":{"type":"number"},"limit":{"type":"number"},"hasMore":{"type":"boolean"}},"required":["items","total","page","limit","hasMore"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}},"post":{"operationId":"createReservedName","summary":"Create reserved name","description":"Create a new reserved name rule","tags":["Admin","Reserved Names"],"security":[{"Bearer":[]}],"requestBody":{"description":"Reserved name data","required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100,"description":"The name or pattern to reserve"},"type":{"type":"string","enum":["username","organization","project","subdomain","slug","all"],"description":"What type of name this applies to"},"category":{"type":"string","enum":["system","offensive","brand","legal","security","custom"],"default":"custom","description":"Category for organization"},"matchType":{"type":"string","enum":["exact","prefix","suffix","contains","regex"],"default":"exact","description":"How to match the name"},"reason":{"type":"string","minLength":1,"maxLength":500,"description":"Why this name is reserved (required for audit)"},"severity":{"type":"string","enum":["block","warn"],"default":"block","description":"Action to take when matched"},"effectiveFrom":{"type":["number","null"],"description":"Unix timestamp when this rule becomes effective"},"expiresAt":{"type":["number","null"],"description":"Unix timestamp when this rule expires"}},"required":["name","type","reason"]}}}},"responses":{"201":{"description":"Reserved name created","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"normalizedName":{"type":"string"},"type":{"type":"string","enum":["username","organization","project","subdomain","slug","all"]},"category":{"type":"string","enum":["system","offensive","brand","legal","security","custom"]},"matchType":{"type":"string","enum":["exact","prefix","suffix","contains","regex"]},"regexPattern":{"type":["string","null"]},"reason":{"type":"string"},"severity":{"type":"string","enum":["block","warn"]},"isActive":{"type":"boolean"},"organizationId":{"type":["string","null"]},"effectiveFrom":{"type":["number","null"]},"expiresAt":{"type":["number","null"]},"blockCount":{"type":"number"},"createdBy":{"type":"string"},"createdAt":{"type":"number"},"updatedBy":{"type":["string","null"]},"updatedAt":{"type":["number","null"]}},"required":["id","name","normalizedName","type","category","matchType","regexPattern","reason","severity","isActive","organizationId","effectiveFrom","expiresAt","blockCount","createdBy","createdAt","updatedBy","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"409":{"description":"Resource already exists","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}}},"/api/v1/auth/admin/reserved-names/{id}":{"get":{"operationId":"getReservedName","summary":"Get reserved name","description":"Get details for a specific reserved name","tags":["Admin","Reserved Names"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"rsv_abc123"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Reserved name details","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"normalizedName":{"type":"string"},"type":{"type":"string","enum":["username","organization","project","subdomain","slug","all"]},"category":{"type":"string","enum":["system","offensive","brand","legal","security","custom"]},"matchType":{"type":"string","enum":["exact","prefix","suffix","contains","regex"]},"regexPattern":{"type":["string","null"]},"reason":{"type":"string"},"severity":{"type":"string","enum":["block","warn"]},"isActive":{"type":"boolean"},"organizationId":{"type":["string","null"]},"effectiveFrom":{"type":["number","null"]},"expiresAt":{"type":["number","null"]},"blockCount":{"type":"number"},"createdBy":{"type":"string"},"createdAt":{"type":"number"},"updatedBy":{"type":["string","null"]},"updatedAt":{"type":["number","null"]}},"required":["id","name","normalizedName","type","category","matchType","regexPattern","reason","severity","isActive","organizationId","effectiveFrom","expiresAt","blockCount","createdBy","createdAt","updatedBy","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}},"patch":{"operationId":"updateReservedName","summary":"Update reserved name","description":"Update an existing reserved name rule","tags":["Admin","Reserved Names"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"rsv_abc123"},"required":true,"name":"id","in":"path"}],"requestBody":{"description":"Updated reserved name data","required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100,"description":"The name or pattern to reserve"},"type":{"type":"string","enum":["username","organization","project","subdomain","slug","all"],"description":"What type of name this applies to"},"category":{"type":"string","enum":["system","offensive","brand","legal","security","custom"],"default":"custom","description":"Category for organization"},"matchType":{"type":"string","enum":["exact","prefix","suffix","contains","regex"],"default":"exact","description":"How to match the name"},"reason":{"type":"string","minLength":1,"maxLength":500,"description":"Why this name is reserved (required for audit)"},"severity":{"type":"string","enum":["block","warn"],"default":"block","description":"Action to take when matched"},"effectiveFrom":{"type":["number","null"],"description":"Unix timestamp when this rule becomes effective"},"expiresAt":{"type":["number","null"],"description":"Unix timestamp when this rule expires"},"isActive":{"type":"boolean","description":"Whether this rule is active"}}}}}},"responses":{"200":{"description":"Reserved name updated","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"normalizedName":{"type":"string"},"type":{"type":"string","enum":["username","organization","project","subdomain","slug","all"]},"category":{"type":"string","enum":["system","offensive","brand","legal","security","custom"]},"matchType":{"type":"string","enum":["exact","prefix","suffix","contains","regex"]},"regexPattern":{"type":["string","null"]},"reason":{"type":"string"},"severity":{"type":"string","enum":["block","warn"]},"isActive":{"type":"boolean"},"organizationId":{"type":["string","null"]},"effectiveFrom":{"type":["number","null"]},"expiresAt":{"type":["number","null"]},"blockCount":{"type":"number"},"createdBy":{"type":"string"},"createdAt":{"type":"number"},"updatedBy":{"type":["string","null"]},"updatedAt":{"type":["number","null"]}},"required":["id","name","normalizedName","type","category","matchType","regexPattern","reason","severity","isActive","organizationId","effectiveFrom","expiresAt","blockCount","createdBy","createdAt","updatedBy","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}},"delete":{"operationId":"deleteReservedName","summary":"Delete reserved name","description":"Soft delete a reserved name rule","tags":["Admin","Reserved Names"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"rsv_abc123"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Reserved name deleted","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"}},"required":["success"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}}},"/api/v1/auth/admin/reserved-names/{id}/audit":{"get":{"operationId":"getReservedNameAuditLog","summary":"Get audit log","description":"Get the audit log for a specific reserved name","tags":["Admin","Reserved Names"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"rsv_abc123"},"required":true,"name":"id","in":"path"},{"schema":{"type":"number","minimum":1,"default":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"number","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"Audit log entries","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"reservedNameId":{"type":"string"},"action":{"type":"string","enum":["created","updated","deleted","restored","activated","deactivated","bulk_imported","bulk_deleted"]},"previousValues":{"type":["object","null"],"additionalProperties":{}},"newValues":{"type":["object","null"],"additionalProperties":{}},"changedFields":{"type":["array","null"],"items":{"type":"string"}},"performedBy":{"type":"string"},"performedAt":{"type":"number"},"ipAddress":{"type":["string","null"]},"userAgent":{"type":["string","null"]},"reason":{"type":["string","null"]},"requestId":{"type":["string","null"]}},"required":["id","reservedNameId","action","previousValues","newValues","changedFields","performedBy","performedAt","ipAddress","userAgent","reason","requestId"]}},"total":{"type":"number"}},"required":["items","total"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}}},"/api/v1/auth/admin/reserved-names/{id}/exceptions":{"get":{"operationId":"listReservedNameExceptions","summary":"List exceptions","description":"Get exceptions for a reserved name","tags":["Admin","Reserved Names"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"rsv_abc123"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Exceptions list","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"reservedNameId":{"type":["string","null"]},"userId":{"type":["string","null"]},"organizationId":{"type":["string","null"]},"specificValue":{"type":["string","null"]},"reason":{"type":"string"},"approvedBy":{"type":"string"},"approvedAt":{"type":"number"},"expiresAt":{"type":["number","null"]},"isActive":{"type":"boolean"},"createdAt":{"type":"number"}},"required":["id","reservedNameId","userId","organizationId","specificValue","reason","approvedBy","approvedAt","expiresAt","isActive","createdAt"]}},"total":{"type":"number"}},"required":["items","total"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}},"post":{"operationId":"createReservedNameException","summary":"Create exception","description":"Create an exception for a reserved name","tags":["Admin","Reserved Names"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"rsv_abc123"},"required":true,"name":"id","in":"path"}],"requestBody":{"description":"Exception data","required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"userId":{"type":"string","description":"User to grant exception to"},"organizationId":{"type":"string","description":"Organization to grant exception to"},"specificValue":{"type":"string","description":"Specific value to allow"},"reason":{"type":"string","minLength":1,"description":"Reason for exception"},"expiresAt":{"type":"number","description":"When exception expires"}},"required":["reason"]}}}},"responses":{"201":{"description":"Exception created","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"reservedNameId":{"type":["string","null"]},"userId":{"type":["string","null"]},"organizationId":{"type":["string","null"]},"specificValue":{"type":["string","null"]},"reason":{"type":"string"},"approvedBy":{"type":"string"},"approvedAt":{"type":"number"},"expiresAt":{"type":["number","null"]},"isActive":{"type":"boolean"},"createdAt":{"type":"number"}},"required":["id","reservedNameId","userId","organizationId","specificValue","reason","approvedBy","approvedAt","expiresAt","isActive","createdAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}}},"/api/v1/auth/admin/reserved-names/{id}/exceptions/{exceptionId}":{"delete":{"operationId":"deleteReservedNameException","summary":"Delete exception","description":"Delete an exception","tags":["Admin","Reserved Names"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"rsv_abc123"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","example":"exc_abc123"},"required":true,"name":"exceptionId","in":"path"}],"responses":{"200":{"description":"Exception deleted","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"}},"required":["success"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}}},"/api/v1/auth/admin/sessions/revoke-all":{"post":{"operationId":"adminRevokeAllPlatformSessions","summary":"Force logout all users (platform)","description":"Immediately invalidates every active session across the entire platform. Requires platform operator (system.manage) permission. Sessions are evicted from KV on next request — no token list needed.","tags":["Admin","Sessions"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"All sessions revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminRevokeAllSessionsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminSessionsError"}}}},"403":{"description":"Platform operator access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminSessionsError"}}}}}}},"/api/v1/auth/admin/organizations/{organizationId}/sessions/revoke":{"post":{"operationId":"adminRevokeOrgSessions","summary":"Force logout all members of an organization","description":"Immediately invalidates all active sessions for every member of the specified organization. Requires platform operator or organization admin access.","tags":["Admin","Sessions"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"organizationId","in":"path"}],"responses":{"200":{"description":"Org sessions revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminRevokeOrgSessionsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminSessionsError"}}}},"403":{"description":"Platform operator or org admin access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminSessionsError"}}}},"404":{"description":"Organization not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminSessionsError"}}}}}}},"/api/v1/auth/admin/oauth-clients":{"get":{"tags":["Admin: OAuth Clients"],"security":[{"Bearer":[]}],"summary":"List registered OAuth clients","responses":{"200":{"description":"List of clients","content":{"application/json":{"schema":{"type":"object","properties":{"clients":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"clientId":{"type":"string"},"redirectUris":{"type":"array","items":{"type":"string"}},"allowedScopes":{"type":"array","items":{"type":"string"}},"allowedGrantTypes":{"type":"array","items":{"type":"string"}},"isFirstParty":{"type":"boolean"},"brandToken":{"type":"string"},"authHostname":{"type":["string","null"]},"archivedAt":{"type":["number","null"]},"createdAt":{"type":"number"},"updatedAt":{"type":"number"}},"required":["id","name","clientId","redirectUris","allowedScopes","allowedGrantTypes","isFirstParty","brandToken","authHostname","archivedAt","createdAt","updatedAt"]}},"total":{"type":"number"}},"required":["clients","total"]}}}}}},"post":{"tags":["Admin: OAuth Clients"],"security":[{"Bearer":[]}],"summary":"Register a new OAuth client","description":"Creates a new OIDC client. Returns the plaintext client_secret ONCE — store it now; we never expose it again.","requestBody":{"description":"New client config","required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":255,"example":"SIY Launchpad"},"redirectUris":{"type":"array","items":{"type":"string","format":"uri"},"minItems":1,"example":["https://app.siy.live/auth/callback"]},"allowedScopes":{"type":"array","items":{"type":"string"},"minItems":1,"example":["openid","profile","email","offline_access"]},"allowedGrantTypes":{"type":"array","items":{"type":"string","enum":["authorization_code","refresh_token"]},"example":["authorization_code","refresh_token"]},"isFirstParty":{"type":"boolean","example":true},"brandToken":{"type":"string","enum":["liveone","siy"],"default":"liveone","example":"siy"},"authHostname":{"type":"string","example":"auth.siy.live"}},"required":["name","redirectUris"]}}}},"responses":{"201":{"description":"Client created — capture the client_secret","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"clientId":{"type":"string"},"redirectUris":{"type":"array","items":{"type":"string"}},"allowedScopes":{"type":"array","items":{"type":"string"}},"allowedGrantTypes":{"type":"array","items":{"type":"string"}},"isFirstParty":{"type":"boolean"},"brandToken":{"type":"string"},"authHostname":{"type":["string","null"]},"archivedAt":{"type":["number","null"]},"createdAt":{"type":"number"},"updatedAt":{"type":"number"},"clientSecret":{"type":"string","description":"Plaintext client_secret — shown ONCE. Store in 1Password / Pages env immediately; not retrievable."}},"required":["id","name","clientId","redirectUris","allowedScopes","allowedGrantTypes","isFirstParty","brandToken","authHostname","archivedAt","createdAt","updatedAt","clientSecret"]}}}}}}},"/api/v1/auth/admin/oauth-clients/{clientId}":{"get":{"tags":["Admin: OAuth Clients"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"oc_abc123"},"required":true,"name":"clientId","in":"path"}],"responses":{"200":{"description":"Client","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"clientId":{"type":"string"},"redirectUris":{"type":"array","items":{"type":"string"}},"allowedScopes":{"type":"array","items":{"type":"string"}},"allowedGrantTypes":{"type":"array","items":{"type":"string"}},"isFirstParty":{"type":"boolean"},"brandToken":{"type":"string"},"authHostname":{"type":["string","null"]},"archivedAt":{"type":["number","null"]},"createdAt":{"type":"number"},"updatedAt":{"type":"number"}},"required":["id","name","clientId","redirectUris","allowedScopes","allowedGrantTypes","isFirstParty","brandToken","authHostname","archivedAt","createdAt","updatedAt"]}}}},"404":{"description":"Client not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}},"required":["error"]}}}}}},"patch":{"tags":["Admin: OAuth Clients"],"security":[{"Bearer":[]}],"summary":"Update OAuth client config","parameters":[{"schema":{"type":"string","example":"oc_abc123"},"required":true,"name":"clientId","in":"path"}],"requestBody":{"description":"Patch","required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":255,"example":"SIY Launchpad"},"redirectUris":{"type":"array","items":{"type":"string","format":"uri"},"minItems":1,"example":["https://app.siy.live/auth/callback"]},"allowedScopes":{"type":"array","items":{"type":"string"},"minItems":1,"example":["openid","profile","email","offline_access"]},"allowedGrantTypes":{"type":"array","items":{"type":"string","enum":["authorization_code","refresh_token"]},"example":["authorization_code","refresh_token"]},"isFirstParty":{"type":"boolean","example":true},"authHostname":{"type":"string","example":"auth.siy.live"},"brandToken":{"type":"string","enum":["liveone","siy"]}}}}}},"responses":{"200":{"description":"Updated client","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"clientId":{"type":"string"},"redirectUris":{"type":"array","items":{"type":"string"}},"allowedScopes":{"type":"array","items":{"type":"string"}},"allowedGrantTypes":{"type":"array","items":{"type":"string"}},"isFirstParty":{"type":"boolean"},"brandToken":{"type":"string"},"authHostname":{"type":["string","null"]},"archivedAt":{"type":["number","null"]},"createdAt":{"type":"number"},"updatedAt":{"type":"number"}},"required":["id","name","clientId","redirectUris","allowedScopes","allowedGrantTypes","isFirstParty","brandToken","authHostname","archivedAt","createdAt","updatedAt"]}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}},"required":["error"]}}}}}},"delete":{"tags":["Admin: OAuth Clients"],"security":[{"Bearer":[]}],"summary":"Soft-archive a client (revokes outstanding tokens)","parameters":[{"schema":{"type":"string","example":"oc_abc123"},"required":true,"name":"clientId","in":"path"}],"responses":{"200":{"description":"Archived client","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"clientId":{"type":"string"},"redirectUris":{"type":"array","items":{"type":"string"}},"allowedScopes":{"type":"array","items":{"type":"string"}},"allowedGrantTypes":{"type":"array","items":{"type":"string"}},"isFirstParty":{"type":"boolean"},"brandToken":{"type":"string"},"authHostname":{"type":["string","null"]},"archivedAt":{"type":["number","null"]},"createdAt":{"type":"number"},"updatedAt":{"type":"number"}},"required":["id","name","clientId","redirectUris","allowedScopes","allowedGrantTypes","isFirstParty","brandToken","authHostname","archivedAt","createdAt","updatedAt"]}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}},"required":["error"]}}}}}}},"/api/v1/auth/admin/oauth-clients/{clientId}/rotate-secret":{"post":{"tags":["Admin: OAuth Clients"],"security":[{"Bearer":[]}],"summary":"Issue a new client_secret, invalidating the previous one","parameters":[{"schema":{"type":"string","example":"oc_abc123"},"required":true,"name":"clientId","in":"path"}],"responses":{"200":{"description":"New client_secret — store now; not retrievable","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"clientId":{"type":"string"},"redirectUris":{"type":"array","items":{"type":"string"}},"allowedScopes":{"type":"array","items":{"type":"string"}},"allowedGrantTypes":{"type":"array","items":{"type":"string"}},"isFirstParty":{"type":"boolean"},"brandToken":{"type":"string"},"authHostname":{"type":["string","null"]},"archivedAt":{"type":["number","null"]},"createdAt":{"type":"number"},"updatedAt":{"type":"number"},"clientSecret":{"type":"string","description":"Plaintext client_secret — shown ONCE. Store in 1Password / Pages env immediately; not retrievable."}},"required":["id","name","clientId","redirectUris","allowedScopes","allowedGrantTypes","isFirstParty","brandToken","authHostname","archivedAt","createdAt","updatedAt","clientSecret"]}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}},"required":["error"]}}}}}}},"/api/v1/organizations/settings":{"get":{"operationId":"getCurrentOrganizationSettings","summary":"Get current organization settings","description":"Get settings for the currently active organization.","tags":["Organizations"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Organization settings","content":{"application/json":{"schema":{"type":"object","properties":{"settings":{"$ref":"#/components/schemas/OrganizationSettings"}},"required":["settings"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error"]}}}},"404":{"description":"No active organization","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error"]}}}}}},"patch":{"operationId":"updateCurrentOrganizationSettings","summary":"Update current organization settings","description":"Update settings for the currently active organization. Requires admin/owner role.","tags":["Organizations"],"security":[{"Bearer":[]}],"requestBody":{"description":"Settings updates","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateCurrentSettings"}}}},"responses":{"200":{"description":"Updated settings","content":{"application/json":{"schema":{"type":"object","properties":{"settings":{"$ref":"#/components/schemas/OrganizationSettings"}},"required":["settings"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error"]}}}},"403":{"description":"Admin access required","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error"]}}}},"404":{"description":"No active organization","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error"]}}}}}}},"/api/v1/organizations/members":{"get":{"operationId":"getCurrentOrganizationMembers","summary":"Get current organization members","description":"Get all members of the currently active organization.","tags":["Organizations"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Organization members","content":{"application/json":{"schema":{"type":"object","properties":{"members":{"type":"array","items":{"$ref":"#/components/schemas/OrganizationMember"}}},"required":["members"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error"]}}}},"404":{"description":"No active organization","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error"]}}}}}}},"/api/v1/organizations/invitations":{"get":{"operationId":"getCurrentOrganizationInvitations","summary":"Get current organization invitations","description":"Get all pending invitations for the currently active organization.","tags":["Organizations"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Organization invitations","content":{"application/json":{"schema":{"type":"object","properties":{"invitations":{"type":"array","items":{"$ref":"#/components/schemas/OrganizationInvitation"}}},"required":["invitations"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error"]}}}},"404":{"description":"No active organization","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error"]}}}}}}},"/api/v1/organizations/upgrade-to-agency":{"post":{"operationId":"upgradeOrganizationToAgency","summary":"Upgrade organization to agency","description":"Upgrade the current organization to an agency type, enabling multi-client management.","tags":["Organizations"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Upgraded organization","content":{"application/json":{"schema":{"type":"object","properties":{"organization":{"$ref":"#/components/schemas/Organization"}},"required":["organization"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error"]}}}},"403":{"description":"Admin access required","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error"]}}}},"404":{"description":"No active organization","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error"]}}}},"409":{"description":"Organization is already an agency","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error"]}}}}}}},"/api/v1/organizations/current":{"get":{"tags":["Current Organization"],"summary":"Get current organization","description":"Get details of the currently active organization from the session.","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Current organization details","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"organization":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"type":{"type":"string","enum":["personal","team","agency","enterprise"]},"description":{"type":["string","null"]},"website":{"type":["string","null"]},"logo":{"type":["string","null"]},"industry":{"type":["string","null"]},"size":{"type":["string","null"],"enum":["1-10","11-50","51-200","201-500","501-1000","1001+",null]},"billingEmail":{"type":["string","null"]},"supportEmail":{"type":["string","null"]},"phoneNumber":{"type":["string","null"]},"memberCount":{"type":"number"},"settings":{"type":["object","null"],"additionalProperties":{}},"createdAt":{"type":"string"},"updatedAt":{"type":"string"},"memberRole":{"type":"string"},"memberJoinedAt":{"type":"string"}},"required":["id","name","slug","type","description","website","logo","industry","size","memberCount","settings","createdAt","updatedAt"]}},"required":["success","organization"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"patch":{"tags":["Current Organization"],"summary":"Update current organization","description":"Update the currently active organization. Requires admin role.","security":[{"bearerAuth":[]}],"requestBody":{"description":"Organization updates","content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100},"description":{"type":["string","null"],"maxLength":500},"website":{"type":["string","null"],"format":"uri"},"logo":{"type":["string","null"],"format":"uri"},"industry":{"type":["string","null"]},"size":{"type":["string","null"],"enum":["1-10","11-50","51-200","201-500","501-1000","1001+",null]},"billingEmail":{"type":["string","null"],"format":"email"},"supportEmail":{"type":["string","null"],"format":"email"},"phoneNumber":{"type":["string","null"]},"taxIdNumber":{"type":["string","null"]},"addressLine1":{"type":["string","null"]},"addressLine2":{"type":["string","null"]},"city":{"type":["string","null"]},"state":{"type":["string","null"]},"postalCode":{"type":["string","null"]},"country":{"type":["string","null"]},"settings":{"type":"object","additionalProperties":{}}}}}}},"responses":{"200":{"description":"Updated organization","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"type":{"type":"string","enum":["personal","team","agency","enterprise"]},"description":{"type":["string","null"]},"website":{"type":["string","null"]},"logo":{"type":["string","null"]},"industry":{"type":["string","null"]},"size":{"type":["string","null"],"enum":["1-10","11-50","51-200","201-500","501-1000","1001+",null]},"billingEmail":{"type":["string","null"]},"supportEmail":{"type":["string","null"]},"phoneNumber":{"type":["string","null"]},"memberCount":{"type":"number"},"settings":{"type":["object","null"],"additionalProperties":{}},"createdAt":{"type":"string"},"updatedAt":{"type":"string"},"memberRole":{"type":"string"},"memberJoinedAt":{"type":"string"}},"required":["id","name","slug","type","description","website","logo","industry","size","memberCount","settings","createdAt","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/organizations/switch":{"post":{"tags":["Current Organization"],"summary":"Switch organization","description":"Switch the active organization in the current session.","security":[{"bearerAuth":[]}],"requestBody":{"description":"Organization to switch to","content":{"application/json":{"schema":{"type":"object","properties":{"organizationId":{"type":"string"}},"required":["organizationId"]}}}},"responses":{"200":{"description":"Switched organization details","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"organization":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"type":{"type":"string","enum":["personal","team","agency","enterprise"]},"description":{"type":["string","null"]},"website":{"type":["string","null"]},"logo":{"type":["string","null"]},"industry":{"type":["string","null"]},"size":{"type":["string","null"],"enum":["1-10","11-50","51-200","201-500","501-1000","1001+",null]},"billingEmail":{"type":["string","null"]},"supportEmail":{"type":["string","null"]},"phoneNumber":{"type":["string","null"]},"memberCount":{"type":"number"},"settings":{"type":["object","null"],"additionalProperties":{}},"createdAt":{"type":"string"},"updatedAt":{"type":"string"},"memberRole":{"type":"string"},"memberJoinedAt":{"type":"string"}},"required":["id","name","slug","type","description","website","logo","industry","size","memberCount","settings","createdAt","updatedAt"]}},"required":["success","organization"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/organizations/current/me":{"get":{"tags":["Current Organization"],"summary":"Get my membership","description":"Get the current user membership details in the active organization.","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Membership details","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"organizationId":{"type":"string"},"userId":{"type":"string"},"role":{"type":"string"},"permissions":{"type":["array","null"],"items":{"type":"string"}},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","organizationId","userId","role","permissions","createdAt","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/organizations/current/byok-settings":{"get":{"tags":["Organization API Keys"],"summary":"Get BYOK settings","description":"Get the BYOK (Bring Your Own Key) settings for the current organization.","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"BYOK settings","content":{"application/json":{"schema":{"type":"object","properties":{"byokEnabled":{"type":"boolean"},"byokProviders":{"type":"array","items":{"type":"string"}},"availableProviders":{"type":"array","items":{"type":"object","properties":{"provider":{"type":"string"},"name":{"type":"string"},"category":{"type":"string"},"hasOrgKey":{"type":"boolean"},"hasPlatformKey":{"type":"boolean"}},"required":["provider","name","category","hasOrgKey","hasPlatformKey"]}}},"required":["byokEnabled","byokProviders","availableProviders"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"patch":{"tags":["Organization API Keys"],"summary":"Update BYOK settings","description":"Update BYOK settings for the current organization. Requires admin role.","security":[{"bearerAuth":[]}],"requestBody":{"description":"BYOK settings update","content":{"application/json":{"schema":{"type":"object","properties":{"byokEnabled":{"type":"boolean"},"byokProviders":{"type":"array","items":{"type":"string","enum":["openai","anthropic","google_ai","elevenlabs","playht","veo","pika","runway"]}}}}}}},"responses":{"200":{"description":"Updated BYOK settings","content":{"application/json":{"schema":{"type":"object","properties":{"byokEnabled":{"type":"boolean"},"byokProviders":{"type":"array","items":{"type":"string"}},"availableProviders":{"type":"array","items":{"type":"object","properties":{"provider":{"type":"string"},"name":{"type":"string"},"category":{"type":"string"},"hasOrgKey":{"type":"boolean"},"hasPlatformKey":{"type":"boolean"}},"required":["provider","name","category","hasOrgKey","hasPlatformKey"]}}},"required":["byokEnabled","byokProviders","availableProviders"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/organizations/current/api-keys":{"get":{"tags":["Organization API Keys"],"summary":"List organization API keys","description":"List all API keys configured for the current organization.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","enum":["production","staging","development"]},"required":false,"name":"environment","in":"query"},{"schema":{"type":"string"},"required":false,"name":"category","in":"query"}],"responses":{"200":{"description":"List of organization API keys","content":{"application/json":{"schema":{"type":"object","properties":{"keys":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"provider":{"type":"string","enum":["openai","anthropic","google_ai","elevenlabs","playht","veo","pika","runway"]},"environment":{"type":"string","enum":["production","staging","development"]},"description":{"type":["string","null"]},"keyPrefix":{"type":["string","null"]},"isEnabled":{"type":"boolean"},"isValidated":{"type":"boolean"},"lastValidatedAt":{"type":["string","null"]},"lastUsedAt":{"type":["string","null"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","provider","environment","description","keyPrefix","isEnabled","isValidated","lastValidatedAt","lastUsedAt","createdAt","updatedAt"]}},"total":{"type":"number"}},"required":["keys","total"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"post":{"tags":["Organization API Keys"],"summary":"Create organization API key","description":"Create a new API key for the current organization. Requires admin role.","security":[{"bearerAuth":[]}],"requestBody":{"description":"API key details","content":{"application/json":{"schema":{"type":"object","properties":{"provider":{"type":"string","enum":["openai","anthropic","google_ai","elevenlabs","playht","veo","pika","runway"]},"encryptedValue":{"type":"string","minLength":1},"environment":{"type":"string","enum":["production","staging","development"]},"description":{"type":"string"}},"required":["provider","encryptedValue","environment"]}}}},"responses":{"201":{"description":"Created API key","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"provider":{"type":"string","enum":["openai","anthropic","google_ai","elevenlabs","playht","veo","pika","runway"]},"environment":{"type":"string","enum":["production","staging","development"]},"description":{"type":["string","null"]},"keyPrefix":{"type":["string","null"]},"isEnabled":{"type":"boolean"},"isValidated":{"type":"boolean"},"lastValidatedAt":{"type":["string","null"]},"lastUsedAt":{"type":["string","null"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","provider","environment","description","keyPrefix","isEnabled","isValidated","lastValidatedAt","lastUsedAt","createdAt","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"409":{"description":"Resource already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/organizations/current/api-keys/{keyId}":{"get":{"tags":["Organization API Keys"],"summary":"Get organization API key","description":"Get details of a specific organization API key.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"keyId","in":"path"}],"responses":{"200":{"description":"Organization API key details","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"provider":{"type":"string","enum":["openai","anthropic","google_ai","elevenlabs","playht","veo","pika","runway"]},"environment":{"type":"string","enum":["production","staging","development"]},"description":{"type":["string","null"]},"keyPrefix":{"type":["string","null"]},"isEnabled":{"type":"boolean"},"isValidated":{"type":"boolean"},"lastValidatedAt":{"type":["string","null"]},"lastUsedAt":{"type":["string","null"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","provider","environment","description","keyPrefix","isEnabled","isValidated","lastValidatedAt","lastUsedAt","createdAt","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"patch":{"tags":["Organization API Keys"],"summary":"Update organization API key","description":"Update an existing organization API key. Requires admin role.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"keyId","in":"path"}],"requestBody":{"description":"API key updates","content":{"application/json":{"schema":{"type":"object","properties":{"encryptedValue":{"type":"string","minLength":1},"environment":{"type":"string","enum":["production","staging","development"]},"description":{"type":["string","null"]},"isEnabled":{"type":"boolean"}}}}}},"responses":{"200":{"description":"Updated API key","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"provider":{"type":"string","enum":["openai","anthropic","google_ai","elevenlabs","playht","veo","pika","runway"]},"environment":{"type":"string","enum":["production","staging","development"]},"description":{"type":["string","null"]},"keyPrefix":{"type":["string","null"]},"isEnabled":{"type":"boolean"},"isValidated":{"type":"boolean"},"lastValidatedAt":{"type":["string","null"]},"lastUsedAt":{"type":["string","null"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","provider","environment","description","keyPrefix","isEnabled","isValidated","lastValidatedAt","lastUsedAt","createdAt","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"delete":{"tags":["Organization API Keys"],"summary":"Delete organization API key","description":"Delete an organization API key. Requires admin role.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"keyId","in":"path"}],"responses":{"204":{"description":"API key deleted successfully"},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/organizations/current/api-keys/{keyId}/validate":{"post":{"tags":["Organization API Keys"],"summary":"Validate organization API key","description":"Validate that an organization API key works with its provider.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"keyId","in":"path"}],"responses":{"200":{"description":"Validation result","content":{"application/json":{"schema":{"type":"object","properties":{"provider":{"type":"string"},"isValid":{"type":"boolean"},"error":{"type":["string","null"]}},"required":["provider","isValid","error"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/organizations/current/apps":{"get":{"tags":["Organization Apps"],"summary":"List organization apps","description":"List all app entitlements for the current organization.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":false,"name":"category","in":"query"},{"schema":{"type":"string","enum":["true","false"]},"required":false,"name":"enabled","in":"query"}],"responses":{"200":{"description":"List of organization app entitlements","content":{"application/json":{"schema":{"type":"object","properties":{"apps":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"appId":{"type":"string"},"appKey":{"type":"string"},"name":{"type":"string"},"description":{"type":["string","null"]},"category":{"type":"string"},"isEnabled":{"type":"boolean"},"plan":{"type":"string"},"defaultMemberAccess":{"type":"string"},"logoUrl":{"type":["string","null"]},"memberStats":{"type":"object","properties":{"total":{"type":"number"},"granted":{"type":"number"},"denied":{"type":"number"}},"required":["total","granted","denied"]},"createdAt":{"anyOf":[{"type":"string"},{"type":"number"},{"type":"null"}]},"updatedAt":{"anyOf":[{"type":"string"},{"type":"number"},{"type":"null"}]}},"required":["id","appKey","name","description","category","isEnabled","plan","memberStats","createdAt","updatedAt"]}},"total":{"type":"number"}},"required":["apps","total"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/organizations/current/apps/{appId}":{"get":{"tags":["Organization Apps"],"summary":"Get organization app","description":"Get a specific app entitlement for the current organization.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"appId","in":"path"}],"responses":{"200":{"description":"Organization app entitlement","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"appId":{"type":"string"},"appKey":{"type":"string"},"name":{"type":"string"},"description":{"type":["string","null"]},"category":{"type":"string"},"isEnabled":{"type":"boolean"},"plan":{"type":"string"},"defaultMemberAccess":{"type":"string"},"logoUrl":{"type":["string","null"]},"memberStats":{"type":"object","properties":{"total":{"type":"number"},"granted":{"type":"number"},"denied":{"type":"number"}},"required":["total","granted","denied"]},"createdAt":{"anyOf":[{"type":"string"},{"type":"number"},{"type":"null"}]},"updatedAt":{"anyOf":[{"type":"string"},{"type":"number"},{"type":"null"}]}},"required":["id","appKey","name","description","category","isEnabled","plan","memberStats","createdAt","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"patch":{"tags":["Organization Apps"],"summary":"Update organization app","description":"Update app entitlement settings for the current organization. Requires admin role.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"appId","in":"path"}],"requestBody":{"description":"App entitlement updates","content":{"application/json":{"schema":{"type":"object","properties":{"isEnabled":{"type":"boolean"}}}}}},"responses":{"200":{"description":"Updated app entitlement","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"appId":{"type":"string"},"appKey":{"type":"string"},"name":{"type":"string"},"description":{"type":["string","null"]},"category":{"type":"string"},"isEnabled":{"type":"boolean"},"plan":{"type":"string"},"defaultMemberAccess":{"type":"string"},"logoUrl":{"type":["string","null"]},"memberStats":{"type":"object","properties":{"total":{"type":"number"},"granted":{"type":"number"},"denied":{"type":"number"}},"required":["total","granted","denied"]},"createdAt":{"anyOf":[{"type":"string"},{"type":"number"},{"type":"null"}]},"updatedAt":{"anyOf":[{"type":"string"},{"type":"number"},{"type":"null"}]}},"required":["id","appKey","name","description","category","isEnabled","plan","memberStats","createdAt","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/organizations/current/apps/defaults":{"post":{"tags":["Organization Apps"],"summary":"Set default apps","description":"Initialize default app entitlements based on subscription tier. Requires admin role.","security":[{"bearerAuth":[]}],"requestBody":{"description":"Default apps configuration","content":{"application/json":{"schema":{"type":"object","properties":{"tier":{"type":"string","enum":["free","starter","professional","enterprise"]}}}}}},"responses":{"200":{"description":"Updated app entitlements","content":{"application/json":{"schema":{"type":"object","properties":{"apps":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"appId":{"type":"string"},"appKey":{"type":"string"},"name":{"type":"string"},"description":{"type":["string","null"]},"category":{"type":"string"},"isEnabled":{"type":"boolean"},"plan":{"type":"string"},"defaultMemberAccess":{"type":"string"},"logoUrl":{"type":["string","null"]},"memberStats":{"type":"object","properties":{"total":{"type":"number"},"granted":{"type":"number"},"denied":{"type":"number"}},"required":["total","granted","denied"]},"createdAt":{"anyOf":[{"type":"string"},{"type":"number"},{"type":"null"}]},"updatedAt":{"anyOf":[{"type":"string"},{"type":"number"},{"type":"null"}]}},"required":["id","appKey","name","description","category","isEnabled","plan","memberStats","createdAt","updatedAt"]}},"total":{"type":"number"}},"required":["apps","total"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/organizations/current/apps/{appId}/members":{"get":{"tags":["Organization Apps"],"summary":"List app members","description":"List all members with access to a specific app in the organization.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"appId","in":"path"},{"schema":{"type":"string"},"required":false,"name":"search","in":"query"},{"schema":{"type":"string","enum":["all","granted","denied"]},"required":false,"name":"accessFilter","in":"query"},{"schema":{"type":["number","null"]},"required":false,"name":"limit","in":"query"},{"schema":{"type":["number","null"]},"required":false,"name":"offset","in":"query"}],"responses":{"200":{"description":"App members","content":{"application/json":{"schema":{"type":"object","properties":{"members":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"appId":{"type":"string"},"role":{"type":"string"},"isActive":{"type":"boolean"},"accessSource":{"type":"string","enum":["explicit","inherited","role"]},"displayName":{"type":["string","null"]},"email":{"type":["string","null"]},"avatarUrl":{"type":["string","null"]},"createdAt":{"type":"string"}},"required":["id","userId","appId","role","createdAt"]}},"total":{"type":"number"},"defaultAccess":{"type":"string"}},"required":["members","total"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"post":{"tags":["Organization Apps"],"summary":"Add app member","description":"Grant a user access to a specific app.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"appId","in":"path"}],"requestBody":{"description":"Member to add","content":{"application/json":{"schema":{"type":"object","properties":{"userIds":{"type":"array","items":{"type":"string"}},"userId":{"type":"string"},"role":{"type":"string"}}}}}},"responses":{"201":{"description":"Member added","content":{"application/json":{"schema":{"type":"object","properties":{"member":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"appId":{"type":"string"},"role":{"type":"string"},"isActive":{"type":"boolean"},"accessSource":{"type":"string","enum":["explicit","inherited","role"]},"displayName":{"type":["string","null"]},"email":{"type":["string","null"]},"avatarUrl":{"type":["string","null"]},"createdAt":{"type":"string"}},"required":["id","userId","appId","role","createdAt"]},"members":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"appId":{"type":"string"},"role":{"type":"string"},"isActive":{"type":"boolean"},"accessSource":{"type":"string","enum":["explicit","inherited","role"]},"displayName":{"type":["string","null"]},"email":{"type":["string","null"]},"avatarUrl":{"type":["string","null"]},"createdAt":{"type":"string"}},"required":["id","userId","appId","role","createdAt"]}}}}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/organizations/current/apps/{appId}/members/{userId}":{"patch":{"tags":["Organization Apps"],"summary":"Update app member","description":"Update a member's role for a specific app.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"appId","in":"path"},{"schema":{"type":"string"},"required":true,"name":"userId","in":"path"}],"requestBody":{"description":"Role update","content":{"application/json":{"schema":{"type":"object","properties":{"role":{"type":"string"},"isActive":{"type":"boolean"}}}}}},"responses":{"200":{"description":"Member updated","content":{"application/json":{"schema":{"type":"object","properties":{"member":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"appId":{"type":"string"},"role":{"type":"string"},"isActive":{"type":"boolean"},"accessSource":{"type":"string","enum":["explicit","inherited","role"]},"displayName":{"type":["string","null"]},"email":{"type":["string","null"]},"avatarUrl":{"type":["string","null"]},"createdAt":{"type":"string"}},"required":["id","userId","appId","role","createdAt"]}},"required":["member"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"delete":{"tags":["Organization Apps"],"summary":"Remove app member","description":"Remove a user's access from a specific app.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"appId","in":"path"},{"schema":{"type":"string"},"required":true,"name":"userId","in":"path"}],"responses":{"200":{"description":"Member removed","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"}},"required":["success"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/organizations/current/apps/{appId}/settings":{"patch":{"tags":["Organization Apps"],"summary":"Update app settings","description":"Update organization-specific settings for an app.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"appId","in":"path"}],"requestBody":{"description":"App settings","content":{"application/json":{"schema":{"type":"object","properties":{"settings":{"type":"object","additionalProperties":{}},"defaultMemberAccess":{"type":"string","enum":["all","none","explicit"]}}}}}},"responses":{"200":{"description":"Settings updated","content":{"application/json":{"schema":{"type":"object","properties":{"settings":{"type":"object","additionalProperties":{}}},"required":["settings"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/organizations/current/invitations":{"get":{"tags":["Organization Invitations"],"summary":"List invitations","description":"List all pending invitations for the current organization.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","enum":["pending","accepted","expired","revoked"]},"required":false,"name":"status","in":"query"},{"schema":{"type":"string"},"required":false,"name":"search","in":"query"},{"schema":{"type":"number","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":["number","null"],"minimum":0,"default":0},"required":false,"name":"offset","in":"query"}],"responses":{"200":{"description":"List of invitations","content":{"application/json":{"schema":{"type":"object","properties":{"invitations":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string"},"role":{"type":"string"},"status":{"type":"string","enum":["pending","accepted","expired","revoked"]},"message":{"type":["string","null"]},"expiresAt":{"type":"string"},"invitedBy":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":["string","null"]},"email":{"type":["string","null"]}},"required":["id","name","email"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","email","role","status","message","expiresAt","invitedBy","createdAt","updatedAt"]}},"total":{"type":"number"},"limit":{"type":"number"},"offset":{"type":"number"}},"required":["invitations","total","limit","offset"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"post":{"tags":["Organization Invitations"],"summary":"Create invitation","description":"Invite a new member to the organization. Requires admin role.","security":[{"bearerAuth":[]}],"requestBody":{"description":"Invitation details","content":{"application/json":{"schema":{"type":"object","properties":{"email":{"type":"string","format":"email"},"role":{"type":"string","enum":["admin","member","viewer"],"default":"member"},"message":{"type":"string","maxLength":500},"expiresInDays":{"type":"number","minimum":1,"maximum":30,"default":7}},"required":["email"]}}}},"responses":{"201":{"description":"Created invitation","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string"},"role":{"type":"string"},"status":{"type":"string","enum":["pending","accepted","expired","revoked"]},"message":{"type":["string","null"]},"expiresAt":{"type":"string"},"invitedBy":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":["string","null"]},"email":{"type":["string","null"]}},"required":["id","name","email"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","email","role","status","message","expiresAt","invitedBy","createdAt","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"409":{"description":"Resource already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/organizations/current/invitations/{invitationId}":{"get":{"tags":["Organization Invitations"],"summary":"Get invitation","description":"Get details of a specific invitation.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"invitationId","in":"path"}],"responses":{"200":{"description":"Invitation details","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string"},"role":{"type":"string"},"status":{"type":"string","enum":["pending","accepted","expired","revoked"]},"message":{"type":["string","null"]},"expiresAt":{"type":"string"},"invitedBy":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":["string","null"]},"email":{"type":["string","null"]}},"required":["id","name","email"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","email","role","status","message","expiresAt","invitedBy","createdAt","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"delete":{"tags":["Organization Invitations"],"summary":"Revoke invitation","description":"Revoke a pending invitation. Requires admin role.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"invitationId","in":"path"}],"responses":{"204":{"description":"Invitation revoked successfully"},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/organizations/current/invitations/{invitationId}/resend":{"post":{"tags":["Organization Invitations"],"summary":"Resend invitation","description":"Resend an invitation email. Requires admin role.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"invitationId","in":"path"}],"responses":{"200":{"description":"Resent invitation","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string"},"role":{"type":"string"},"status":{"type":"string","enum":["pending","accepted","expired","revoked"]},"message":{"type":["string","null"]},"expiresAt":{"type":"string"},"invitedBy":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":["string","null"]},"email":{"type":["string","null"]}},"required":["id","name","email"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","email","role","status","message","expiresAt","invitedBy","createdAt","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/invitations/accept":{"post":{"tags":["Organization Invitations"],"summary":"Accept invitation","description":"Accept an invitation using a token. The authenticated user joins the organization.","security":[{"bearerAuth":[]}],"requestBody":{"description":"Invitation token","content":{"application/json":{"schema":{"type":"object","properties":{"token":{"type":"string"}},"required":["token"]}}}},"responses":{"200":{"description":"Accepted invitation result","content":{"application/json":{"schema":{"type":"object","properties":{"organizationId":{"type":"string"},"organizationName":{"type":"string"},"role":{"type":"string"},"message":{"type":"string"}},"required":["organizationId","organizationName","role","message"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"409":{"description":"Resource already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/invitations/{token}":{"get":{"tags":["Organization Invitations"],"summary":"Get invitation by token","description":"Get invitation details by token (for preview before accepting).","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"token","in":"path"}],"responses":{"200":{"description":"Invitation preview","content":{"application/json":{"schema":{"type":"object","properties":{"email":{"type":"string"},"organizationName":{"type":"string"},"organizationLogo":{"type":["string","null"]},"role":{"type":"string"},"invitedBy":{"type":["string","null"]},"expiresAt":{"type":"string"},"isExpired":{"type":"boolean"}},"required":["email","organizationName","organizationLogo","role","invitedBy","expiresAt","isExpired"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/organizations/current/members":{"get":{"tags":["Organization Members"],"summary":"List members","description":"List all members of the current organization.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":false,"name":"search","in":"query"},{"schema":{"type":"string","enum":["owner","admin","member","viewer"]},"required":false,"name":"role","in":"query"},{"schema":{"type":"number","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":["number","null"],"minimum":0,"default":0},"required":false,"name":"offset","in":"query"}],"responses":{"200":{"description":"List of organization members","content":{"application/json":{"schema":{"type":"object","properties":{"members":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"role":{"type":"string"},"permissions":{"type":["array","null"],"items":{"type":"string"}},"user":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":["string","null"]},"displayName":{"type":["string","null"]},"avatar":{"type":["string","null"]}},"required":["id","email","displayName","avatar"]},"joinedAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","role","permissions","user","joinedAt","updatedAt"]}},"total":{"type":"number"},"limit":{"type":"number"},"offset":{"type":"number"}},"required":["members","total","limit","offset"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/organizations/current/members/{memberId}":{"get":{"tags":["Organization Members"],"summary":"Get member","description":"Get details of a specific organization member.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"memberId","in":"path"}],"responses":{"200":{"description":"Member details","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"role":{"type":"string"},"permissions":{"type":["array","null"],"items":{"type":"string"}},"user":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":["string","null"]},"displayName":{"type":["string","null"]},"avatar":{"type":["string","null"]}},"required":["id","email","displayName","avatar"]},"joinedAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","role","permissions","user","joinedAt","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"patch":{"tags":["Organization Members"],"summary":"Update member","description":"Update a member role or permissions. Owners can change roles, admins can change permissions.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"memberId","in":"path"}],"requestBody":{"description":"Member updates","content":{"application/json":{"schema":{"type":"object","properties":{"role":{"type":"string","enum":["admin","member","viewer"]},"permissions":{"type":"array","items":{"type":"string"}}}}}}},"responses":{"200":{"description":"Updated member","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"role":{"type":"string"},"permissions":{"type":["array","null"],"items":{"type":"string"}},"user":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":["string","null"]},"displayName":{"type":["string","null"]},"avatar":{"type":["string","null"]}},"required":["id","email","displayName","avatar"]},"joinedAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","role","permissions","user","joinedAt","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"delete":{"tags":["Organization Members"],"summary":"Remove member","description":"Remove a member from the organization. Users can remove themselves, admins can remove others.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"memberId","in":"path"}],"responses":{"204":{"description":"Member removed successfully"},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/organizations/clients":{"get":{"tags":["Organization Relationships"],"summary":"List clients","description":"List all client relationships for the current agency organization.","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"List of client relationships","content":{"application/json":{"schema":{"type":"object","properties":{"clients":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"clientOrgId":{"type":"string"},"status":{"type":"string"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"},"relationshipType":{"type":"string"},"notes":{"type":["string","null"]},"client":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"logo":{"type":["string","null"]},"slug":{"type":["string","null"]},"website":{"type":["string","null"]},"type":{"type":["string","null"]}},"required":["id","name","logo","slug","website","type"]},"sharedProjectCount":{"type":"number"},"pendingInvitationId":{"type":["string","null"]}},"required":["id","clientOrgId","status","createdAt","updatedAt","client"]}}},"required":["clients"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"post":{"tags":["Organization Relationships"],"summary":"Add existing client","description":"Add an existing organization as a client by their organizationId.","security":[{"bearerAuth":[]}],"requestBody":{"description":"Client details","content":{"application/json":{"schema":{"type":"object","properties":{"clientOrgId":{"type":"string","description":"The ID of the existing organization to add as a client"},"notes":{"type":"string","description":"Optional notes about the relationship"}},"required":["clientOrgId"]}}}},"responses":{"201":{"description":"Client relationship created","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"clientOrgId":{"type":"string"},"status":{"type":"string"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"},"relationshipType":{"type":"string"},"notes":{"type":["string","null"]},"client":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"logo":{"type":["string","null"]},"slug":{"type":["string","null"]},"website":{"type":["string","null"]},"type":{"type":["string","null"]}},"required":["id","name","logo","slug","website","type"]},"sharedProjectCount":{"type":"number"},"pendingInvitationId":{"type":["string","null"]}},"required":["id","clientOrgId","status","createdAt","updatedAt","client"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"409":{"description":"Resource already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/organizations/clients/{clientOrgId}":{"get":{"tags":["Organization Relationships"],"summary":"Get client relationship","description":"Get details of a specific client relationship by client org ID.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"clientOrgId","in":"path"}],"responses":{"200":{"description":"Client relationship details","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"clientOrgId":{"type":"string"},"status":{"type":"string"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"},"relationshipType":{"type":"string"},"notes":{"type":["string","null"]},"client":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"logo":{"type":["string","null"]},"slug":{"type":["string","null"]},"website":{"type":["string","null"]},"type":{"type":["string","null"]}},"required":["id","name","logo","slug","website","type"]},"sharedProjectCount":{"type":"number"},"pendingInvitationId":{"type":["string","null"]}},"required":["id","clientOrgId","status","createdAt","updatedAt","client"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"delete":{"tags":["Organization Relationships"],"summary":"Remove client","description":"Terminate the agency-client relationship by client org ID. Does not delete the client organization.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"clientOrgId","in":"path"}],"responses":{"204":{"description":"Client relationship terminated successfully"},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/organizations/current/relationships":{"get":{"tags":["Organization Relationships"],"summary":"List relationships","description":"List all agency-client relationships for the current organization.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","enum":["agency","client"]},"required":false,"name":"type","in":"query"},{"schema":{"type":"string","enum":["pending","active","suspended","terminated"]},"required":false,"name":"status","in":"query"},{"schema":{"type":"string"},"required":false,"name":"search","in":"query"},{"schema":{"type":"number","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":["number","null"],"minimum":0,"default":0},"required":false,"name":"offset","in":"query"}],"responses":{"200":{"description":"List of relationships","content":{"application/json":{"schema":{"type":"object","properties":{"relationships":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"agencyOrganizationId":{"type":"string"},"clientOrganizationId":{"type":"string"},"agencyOrganization":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"logo":{"type":["string","null"]}},"required":["id","name","logo"]},"clientOrganization":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"logo":{"type":["string","null"]}},"required":["id","name","logo"]},"type":{"type":"string"},"status":{"type":"string"},"permissions":{"type":["array","null"],"items":{"type":"string"}},"metadata":{"type":["object","null"],"additionalProperties":{}},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","agencyOrganizationId","clientOrganizationId","agencyOrganization","clientOrganization","type","status","permissions","metadata","createdAt","updatedAt"]}},"total":{"type":"number"},"limit":{"type":"number"},"offset":{"type":"number"}},"required":["relationships","total","limit","offset"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"post":{"tags":["Organization Relationships"],"summary":"Create relationship","description":"Create a new agency-client relationship. Requires admin role.","security":[{"bearerAuth":[]}],"requestBody":{"description":"Relationship details","content":{"application/json":{"schema":{"type":"object","properties":{"clientOrganizationId":{"type":"string"},"type":{"type":"string","enum":["full_service","project_based","reseller"],"default":"full_service"},"permissions":{"type":"array","items":{"type":"string"}},"metadata":{"type":"object","additionalProperties":{}}},"required":["clientOrganizationId"]}}}},"responses":{"201":{"description":"Created relationship","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"agencyOrganizationId":{"type":"string"},"clientOrganizationId":{"type":"string"},"agencyOrganization":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"logo":{"type":["string","null"]}},"required":["id","name","logo"]},"clientOrganization":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"logo":{"type":["string","null"]}},"required":["id","name","logo"]},"type":{"type":"string"},"status":{"type":"string"},"permissions":{"type":["array","null"],"items":{"type":"string"}},"metadata":{"type":["object","null"],"additionalProperties":{}},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","agencyOrganizationId","clientOrganizationId","agencyOrganization","clientOrganization","type","status","permissions","metadata","createdAt","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"409":{"description":"Resource already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/organizations/current/relationships/{relationshipId}":{"get":{"tags":["Organization Relationships"],"summary":"Get relationship","description":"Get details of a specific relationship.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"relationshipId","in":"path"}],"responses":{"200":{"description":"Relationship details","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"agencyOrganizationId":{"type":"string"},"clientOrganizationId":{"type":"string"},"agencyOrganization":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"logo":{"type":["string","null"]}},"required":["id","name","logo"]},"clientOrganization":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"logo":{"type":["string","null"]}},"required":["id","name","logo"]},"type":{"type":"string"},"status":{"type":"string"},"permissions":{"type":["array","null"],"items":{"type":"string"}},"metadata":{"type":["object","null"],"additionalProperties":{}},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","agencyOrganizationId","clientOrganizationId","agencyOrganization","clientOrganization","type","status","permissions","metadata","createdAt","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"patch":{"tags":["Organization Relationships"],"summary":"Update relationship","description":"Update a relationship. Requires admin role.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"relationshipId","in":"path"}],"requestBody":{"description":"Relationship updates","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","enum":["active","suspended"]},"type":{"type":"string","enum":["full_service","project_based","reseller"]},"permissions":{"type":"array","items":{"type":"string"}},"metadata":{"type":"object","additionalProperties":{}}}}}}},"responses":{"200":{"description":"Updated relationship","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"agencyOrganizationId":{"type":"string"},"clientOrganizationId":{"type":"string"},"agencyOrganization":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"logo":{"type":["string","null"]}},"required":["id","name","logo"]},"clientOrganization":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"logo":{"type":["string","null"]}},"required":["id","name","logo"]},"type":{"type":"string"},"status":{"type":"string"},"permissions":{"type":["array","null"],"items":{"type":"string"}},"metadata":{"type":["object","null"],"additionalProperties":{}},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","agencyOrganizationId","clientOrganizationId","agencyOrganization","clientOrganization","type","status","permissions","metadata","createdAt","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"delete":{"tags":["Organization Relationships"],"summary":"Terminate relationship","description":"Terminate an agency-client relationship. Requires admin role.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"relationshipId","in":"path"}],"responses":{"204":{"description":"Relationship terminated successfully"},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/organizations/clients/onboard":{"post":{"tags":["Organization Relationships"],"summary":"Onboard new client","description":"Create a new client organization and establish agency relationship. The client owner will receive an invitation email.","security":[{"bearerAuth":[]}],"requestBody":{"description":"Client onboarding details","content":{"application/json":{"schema":{"type":"object","properties":{"clientName":{"type":"string","minLength":1,"maxLength":255},"clientSlug":{"type":"string","minLength":2,"maxLength":50},"clientWebsite":{"type":"string","format":"uri"},"clientIndustry":{"type":"string","maxLength":100},"ownerEmail":{"type":"string","format":"email"},"ownerName":{"type":"string","maxLength":255},"invitationMessage":{"type":"string","maxLength":1000},"relationshipNotes":{"type":"string","maxLength":2000}},"required":["clientName","ownerEmail"]}}}},"responses":{"201":{"description":"Client onboarded successfully","content":{"application/json":{"schema":{"type":"object","properties":{"organizationId":{"type":"string"},"relationshipId":{"type":"string"},"invitationSent":{"type":"boolean"},"message":{"type":"string"}},"required":["organizationId","relationshipId","invitationSent","message"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"409":{"description":"Resource already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/organizations/current/settings":{"get":{"tags":["Organization Settings"],"summary":"Get organization settings","description":"Get general settings for the current organization.","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Organization settings","content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"slug":{"type":"string"},"website":{"type":["string","null"]},"industry":{"type":["string","null"]},"size":{"type":["string","null"]},"timezone":{"type":["string","null"]},"locale":{"type":["string","null"]},"defaultCurrency":{"type":["string","null"]},"billingEmail":{"type":["string","null"]}},"required":["name","slug","website","industry","size","timezone","locale","defaultCurrency","billingEmail"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"patch":{"tags":["Organization Settings"],"summary":"Update organization settings","description":"Update general settings. Requires admin role.","security":[{"bearerAuth":[]}],"requestBody":{"description":"Settings updates","content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100},"slug":{"type":"string","minLength":2,"maxLength":50,"pattern":"^[a-z0-9-]+$"},"website":{"type":["string","null"],"maxLength":200,"format":"uri"},"industry":{"type":["string","null"],"maxLength":100},"size":{"type":["string","null"],"enum":["1-10","11-50","51-200","201-500","500+",null]},"timezone":{"type":["string","null"],"maxLength":50},"locale":{"type":["string","null"],"maxLength":10},"defaultCurrency":{"type":["string","null"],"minLength":3,"maxLength":3},"billingEmail":{"type":["string","null"],"format":"email"}}}}}},"responses":{"200":{"description":"Updated settings","content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"slug":{"type":"string"},"website":{"type":["string","null"]},"industry":{"type":["string","null"]},"size":{"type":["string","null"]},"timezone":{"type":["string","null"]},"locale":{"type":["string","null"]},"defaultCurrency":{"type":["string","null"]},"billingEmail":{"type":["string","null"]}},"required":["name","slug","website","industry","size","timezone","locale","defaultCurrency","billingEmail"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/organizations/current/settings/branding":{"get":{"tags":["Organization Settings"],"summary":"Get branding settings","description":"Get branding and customization settings.","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Branding settings","content":{"application/json":{"schema":{"type":"object","properties":{"logo":{"type":["string","null"]},"favicon":{"type":["string","null"]},"themeUrl":{"type":["string","null"]},"themeVersion":{"type":"number"},"primaryColor":{"type":["string","null"]},"secondaryColor":{"type":["string","null"]},"textColor":{"type":["string","null"]},"secondaryTextColor":{"type":["string","null"]},"primaryColorDark":{"type":["string","null"]},"secondaryColorDark":{"type":["string","null"]},"textColorDark":{"type":["string","null"]},"secondaryTextColorDark":{"type":["string","null"]}},"required":["logo","favicon","themeUrl","themeVersion","primaryColor","secondaryColor","textColor","secondaryTextColor","primaryColorDark","secondaryColorDark","textColorDark","secondaryTextColorDark"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"patch":{"tags":["Organization Settings"],"summary":"Update branding settings","description":"Update branding and customization settings. Requires admin role.","security":[{"bearerAuth":[]}],"requestBody":{"description":"Branding updates","content":{"application/json":{"schema":{"type":"object","properties":{"logo":{"type":["string","null"],"format":"uri"},"favicon":{"type":["string","null"],"format":"uri"},"themeUrl":{"type":["string","null"],"maxLength":500},"primaryColor":{"type":["string","null"],"pattern":"^#[0-9a-fA-F]{6}$"},"secondaryColor":{"type":["string","null"],"pattern":"^#[0-9a-fA-F]{6}$"},"textColor":{"type":["string","null"],"pattern":"^#[0-9a-fA-F]{6}$"},"secondaryTextColor":{"type":["string","null"],"pattern":"^#[0-9a-fA-F]{6}$"},"primaryColorDark":{"type":["string","null"],"pattern":"^#[0-9a-fA-F]{6}$"},"secondaryColorDark":{"type":["string","null"],"pattern":"^#[0-9a-fA-F]{6}$"},"textColorDark":{"type":["string","null"],"pattern":"^#[0-9a-fA-F]{6}$"},"secondaryTextColorDark":{"type":["string","null"],"pattern":"^#[0-9a-fA-F]{6}$"}}}}}},"responses":{"200":{"description":"Updated branding settings","content":{"application/json":{"schema":{"type":"object","properties":{"logo":{"type":["string","null"]},"favicon":{"type":["string","null"]},"themeUrl":{"type":["string","null"]},"themeVersion":{"type":"number"},"primaryColor":{"type":["string","null"]},"secondaryColor":{"type":["string","null"]},"textColor":{"type":["string","null"]},"secondaryTextColor":{"type":["string","null"]},"primaryColorDark":{"type":["string","null"]},"secondaryColorDark":{"type":["string","null"]},"textColorDark":{"type":["string","null"]},"secondaryTextColorDark":{"type":["string","null"]}},"required":["logo","favicon","themeUrl","themeVersion","primaryColor","secondaryColor","textColor","secondaryTextColor","primaryColorDark","secondaryColorDark","textColorDark","secondaryTextColorDark"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/organizations/current/settings/branding/theme/upload":{"post":{"tags":["Organization Settings"],"summary":"Upload custom theme CSS","description":"Upload sanitized CSS for the org theme. Sanitizer runs server-side. Returns the new theme URL and version. Requires admin role.","security":[{"bearerAuth":[]}],"requestBody":{"description":"Theme CSS + builder source spec","content":{"application/json":{"schema":{"type":"object","properties":{"css":{"type":"string","minLength":1,"maxLength":200000},"source":{}},"required":["css"]}}}},"responses":{"200":{"description":"Uploaded theme","content":{"application/json":{"schema":{"type":"object","properties":{"themeUrl":{"type":"string","format":"uri"},"themeVersion":{"type":"number"},"warnings":{"type":"array","items":{"type":"string"}}},"required":["themeUrl","themeVersion","warnings"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/organizations/current/settings/security":{"get":{"tags":["Organization Settings"],"summary":"Get security settings","description":"Get security and compliance settings. Requires admin role.","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Security settings","content":{"application/json":{"schema":{"type":"object","properties":{"requireMfa":{"type":"boolean"},"allowedAuthMethods":{"type":"array","items":{"type":"string"}},"sessionTimeoutMinutes":{"type":"number"},"allowedIpRanges":{"type":["array","null"],"items":{"type":"string"}},"passwordPolicy":{"type":["object","null"],"properties":{"minLength":{"type":"number"},"requireUppercase":{"type":"boolean"},"requireLowercase":{"type":"boolean"},"requireNumbers":{"type":"boolean"},"requireSpecialChars":{"type":"boolean"}},"required":["minLength","requireUppercase","requireLowercase","requireNumbers","requireSpecialChars"]},"auditLogRetentionDays":{"type":"number"},"dataRetentionDays":{"type":["number","null"]}},"required":["requireMfa","allowedAuthMethods","sessionTimeoutMinutes","allowedIpRanges","passwordPolicy","auditLogRetentionDays","dataRetentionDays"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"patch":{"tags":["Organization Settings"],"summary":"Update security settings","description":"Update security and compliance settings. Requires admin role.","security":[{"bearerAuth":[]}],"requestBody":{"description":"Security updates","content":{"application/json":{"schema":{"type":"object","properties":{"requireMfa":{"type":"boolean"},"allowedAuthMethods":{"type":"array","items":{"type":"string","enum":["email","google","github","saml"]}},"sessionTimeoutMinutes":{"type":"number","minimum":5,"maximum":10080},"allowedIpRanges":{"type":["array","null"],"items":{"type":"string"}},"passwordPolicy":{"type":["object","null"],"properties":{"minLength":{"type":"number","minimum":8,"maximum":128},"requireUppercase":{"type":"boolean"},"requireLowercase":{"type":"boolean"},"requireNumbers":{"type":"boolean"},"requireSpecialChars":{"type":"boolean"}},"required":["minLength","requireUppercase","requireLowercase","requireNumbers","requireSpecialChars"]},"auditLogRetentionDays":{"type":"number","minimum":30,"maximum":3650},"dataRetentionDays":{"type":["number","null"],"minimum":30,"maximum":3650}}}}}},"responses":{"200":{"description":"Updated security settings","content":{"application/json":{"schema":{"type":"object","properties":{"requireMfa":{"type":"boolean"},"allowedAuthMethods":{"type":"array","items":{"type":"string"}},"sessionTimeoutMinutes":{"type":"number"},"allowedIpRanges":{"type":["array","null"],"items":{"type":"string"}},"passwordPolicy":{"type":["object","null"],"properties":{"minLength":{"type":"number"},"requireUppercase":{"type":"boolean"},"requireLowercase":{"type":"boolean"},"requireNumbers":{"type":"boolean"},"requireSpecialChars":{"type":"boolean"}},"required":["minLength","requireUppercase","requireLowercase","requireNumbers","requireSpecialChars"]},"auditLogRetentionDays":{"type":"number"},"dataRetentionDays":{"type":["number","null"]}},"required":["requireMfa","allowedAuthMethods","sessionTimeoutMinutes","allowedIpRanges","passwordPolicy","auditLogRetentionDays","dataRetentionDays"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/organizations/check-slug":{"get":{"tags":["Organizations"],"summary":"Check slug availability","description":"Check if an organization slug is available.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","minLength":2,"maxLength":100},"required":true,"name":"slug","in":"query"}],"responses":{"200":{"description":"Slug availability status","content":{"application/json":{"schema":{"type":"object","properties":{"available":{"type":"boolean"},"slug":{"type":"string"},"suggestion":{"type":"string"}},"required":["available","slug"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/organizations":{"get":{"tags":["Organizations"],"summary":"List organizations","description":"List all organizations the current user has access to.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":false,"name":"search","in":"query"},{"schema":{"type":"string","enum":["personal","team","agency","enterprise"]},"required":false,"name":"type","in":"query"},{"schema":{"type":"number","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":["number","null"],"minimum":0,"default":0},"required":false,"name":"offset","in":"query"}],"responses":{"200":{"description":"List of organizations","content":{"application/json":{"schema":{"type":"object","properties":{"organizations":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"type":{"type":"string","enum":["personal","team","agency","enterprise"]},"description":{"type":["string","null"]},"website":{"type":["string","null"]},"logo":{"type":["string","null"]},"industry":{"type":["string","null"]},"size":{"type":["string","null"],"enum":["1-10","11-50","51-200","201-500","501-1000","1001+",null]},"billingEmail":{"type":["string","null"]},"supportEmail":{"type":["string","null"]},"phoneNumber":{"type":["string","null"]},"memberCount":{"type":"number"},"settings":{"type":["object","null"],"additionalProperties":{}},"createdAt":{"type":"string"},"updatedAt":{"type":"string"},"memberRole":{"type":"string"},"memberJoinedAt":{"type":"string"}},"required":["id","name","slug","type","description","website","logo","industry","size","memberCount","settings","createdAt","updatedAt"]}},"total":{"type":"number"},"limit":{"type":"number"},"offset":{"type":"number"}},"required":["organizations","total","limit","offset"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"post":{"tags":["Organizations"],"summary":"Create organization","description":"Create a new organization. The current user becomes the owner.","security":[{"bearerAuth":[]}],"requestBody":{"description":"Organization details","content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100},"slug":{"type":"string","minLength":2,"maxLength":50,"pattern":"^[a-z0-9-]+$"},"type":{"type":"string","enum":["personal","team","agency","enterprise"],"default":"team"},"description":{"type":"string","maxLength":500},"website":{"type":"string","format":"uri"},"logo":{"type":"string","format":"uri"},"industry":{"type":"string"},"size":{"type":"string","enum":["1-10","11-50","51-200","201-500","500+"]}},"required":["name"]}}}},"responses":{"201":{"description":"Created organization","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"type":{"type":"string","enum":["personal","team","agency","enterprise"]},"description":{"type":["string","null"]},"website":{"type":["string","null"]},"logo":{"type":["string","null"]},"industry":{"type":["string","null"]},"size":{"type":["string","null"],"enum":["1-10","11-50","51-200","201-500","501-1000","1001+",null]},"billingEmail":{"type":["string","null"]},"supportEmail":{"type":["string","null"]},"phoneNumber":{"type":["string","null"]},"memberCount":{"type":"number"},"settings":{"type":["object","null"],"additionalProperties":{}},"createdAt":{"type":"string"},"updatedAt":{"type":"string"},"memberRole":{"type":"string"},"memberJoinedAt":{"type":"string"}},"required":["id","name","slug","type","description","website","logo","industry","size","memberCount","settings","createdAt","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"409":{"description":"Resource already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/organizations/{organizationId}":{"get":{"tags":["Organizations"],"summary":"Get organization","description":"Get details of a specific organization.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"organizationId","in":"path"}],"responses":{"200":{"description":"Organization details","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"type":{"type":"string","enum":["personal","team","agency","enterprise"]},"description":{"type":["string","null"]},"website":{"type":["string","null"]},"logo":{"type":["string","null"]},"industry":{"type":["string","null"]},"size":{"type":["string","null"],"enum":["1-10","11-50","51-200","201-500","501-1000","1001+",null]},"billingEmail":{"type":["string","null"]},"supportEmail":{"type":["string","null"]},"phoneNumber":{"type":["string","null"]},"memberCount":{"type":"number"},"settings":{"type":["object","null"],"additionalProperties":{}},"createdAt":{"type":"string"},"updatedAt":{"type":"string"},"memberRole":{"type":"string"},"memberJoinedAt":{"type":"string"}},"required":["id","name","slug","type","description","website","logo","industry","size","memberCount","settings","createdAt","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"patch":{"tags":["Organizations"],"summary":"Update organization","description":"Update organization details. Requires admin role.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"organizationId","in":"path"}],"requestBody":{"description":"Organization updates","content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100},"description":{"type":["string","null"],"maxLength":500},"website":{"type":["string","null"],"format":"uri"},"logo":{"type":["string","null"],"format":"uri"},"industry":{"type":["string","null"]},"size":{"type":["string","null"],"enum":["1-10","11-50","51-200","201-500","501-1000","1001+",null]},"billingEmail":{"type":["string","null"],"format":"email"},"supportEmail":{"type":["string","null"],"format":"email"},"phoneNumber":{"type":["string","null"]},"taxIdNumber":{"type":["string","null"]},"addressLine1":{"type":["string","null"]},"addressLine2":{"type":["string","null"]},"city":{"type":["string","null"]},"state":{"type":["string","null"]},"postalCode":{"type":["string","null"]},"country":{"type":["string","null"]},"settings":{"type":"object","additionalProperties":{}}}}}}},"responses":{"200":{"description":"Updated organization","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"type":{"type":"string","enum":["personal","team","agency","enterprise"]},"description":{"type":["string","null"]},"website":{"type":["string","null"]},"logo":{"type":["string","null"]},"industry":{"type":["string","null"]},"size":{"type":["string","null"],"enum":["1-10","11-50","51-200","201-500","501-1000","1001+",null]},"billingEmail":{"type":["string","null"]},"supportEmail":{"type":["string","null"]},"phoneNumber":{"type":["string","null"]},"memberCount":{"type":"number"},"settings":{"type":["object","null"],"additionalProperties":{}},"createdAt":{"type":"string"},"updatedAt":{"type":"string"},"memberRole":{"type":"string"},"memberJoinedAt":{"type":"string"}},"required":["id","name","slug","type","description","website","logo","industry","size","memberCount","settings","createdAt","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"delete":{"tags":["Organizations"],"summary":"Delete organization","description":"Delete an organization. Requires owner role.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"organizationId","in":"path"}],"responses":{"204":{"description":"Organization deleted successfully"},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/organizations/{organizationId}/members":{"get":{"tags":["Organizations"],"summary":"List organization members","description":"List members of a specific organization by its ID.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"organizationId","in":"path"},{"schema":{"type":["number","null"]},"required":false,"name":"limit","in":"query"},{"schema":{"type":["number","null"]},"required":false,"name":"offset","in":"query"}],"responses":{"200":{"description":"Organization members","content":{"application/json":{"schema":{"type":"object","properties":{"members":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"role":{"type":"string"},"joinedAt":{"type":"string"},"displayName":{"type":["string","null"]},"email":{"type":["string","null"]}},"required":["id","userId","role","joinedAt"]}},"total":{"type":"number"}},"required":["members","total"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/auth/switch-organization":{"post":{"operationId":"authSwitchOrganization","summary":"Switch active organization","description":"Switch the currently active organization for the authenticated user. The user must be a member of the target organization.","tags":["Organizations"],"security":[{"Bearer":[]}],"requestBody":{"description":"Organization to switch to","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SwitchOrganizationRequest"}}}},"responses":{"200":{"description":"Successfully switched organization","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SwitchOrganizationResponse"}}}},"400":{"description":"Invalid organization ID","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SwitchOrganizationError"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SwitchOrganizationError"}}}},"403":{"description":"Not a member of this organization","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SwitchOrganizationError"}}}},"404":{"description":"Organization not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SwitchOrganizationError"}}}}}}},"/api/v1/users/me":{"get":{"operationId":"getCurrentUser","summary":"Get current user profile","description":"Get the current authenticated user profile with organizations","tags":["Users"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"User profile retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserProfile"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}}},"/api/v1/users":{"patch":{"operationId":"updateUser","summary":"Update user profile","description":"Update profile fields for the current user (name, avatar, username, etc.)","tags":["Users"],"security":[{"Bearer":[]}],"requestBody":{"description":"Profile fields to update","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateUser"}}}},"responses":{"200":{"description":"Profile updated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserProfile"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"409":{"description":"Username already taken","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}},"delete":{"operationId":"deleteUser","summary":"Delete user account","description":"Permanently delete the current user account. Requires password confirmation.","tags":["Users"],"security":[{"Bearer":[]}],"requestBody":{"description":"Account deletion confirmation","required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"password":{"type":"string"},"confirmPhrase":{"type":"string"}}}}}},"responses":{"200":{"description":"Account deleted","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"}},"required":["success"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}}},"/api/v1/users/emails":{"get":{"operationId":"getUserEmails","summary":"Get user email addresses","description":"Get all email addresses associated with the current user","tags":["Users"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Emails retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetEmailsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}},"post":{"operationId":"addUserEmail","summary":"Add email address","description":"Add a new email address to the current user account","tags":["Users"],"security":[{"Bearer":[]}],"requestBody":{"description":"Email address to add","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddEmail"}}}},"responses":{"201":{"description":"Email added successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddEmailResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"409":{"description":"Email already exists","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}}},"/api/v1/users/emails/{emailId}":{"delete":{"operationId":"deleteUserEmail","summary":"Remove email address","description":"Remove an email address from the current user account. Cannot remove primary email.","tags":["Users"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"emailId","in":"path"}],"responses":{"200":{"description":"Email removed successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeleteEmailResponse"}}}},"400":{"description":"Cannot remove primary email","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"404":{"description":"Email not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}}},"/api/v1/users/emails/{emailId}/verify-code":{"post":{"operationId":"verifyEmailCode","summary":"Verify email with code","description":"Verify an email address using a verification code.","tags":["Users"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"emailId","in":"path"}],"requestBody":{"description":"Verification code","required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string","description":"6-digit verification code"}},"required":["code"]}}}},"responses":{"200":{"description":"Email verified","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"}},"required":["success"]}}}},"400":{"description":"Invalid or expired code","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"404":{"description":"Email not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}}},"/api/v1/users/me/organizations":{"get":{"operationId":"getUserOrganizations","summary":"Get user organizations","description":"Get all organizations the current user is a member of","tags":["Users"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Organizations retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetUserOrganizationsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}}},"/api/v1/users/me/active-organization":{"post":{"operationId":"setActiveOrganization","summary":"Set active organization","description":"Sets the active organization for the current session. User must be an active member.","tags":["Users"],"security":[{"Bearer":[]}],"requestBody":{"description":"Organization to activate","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SetActiveOrganizationRequest"}}}},"responses":{"200":{"description":"Active organization set","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SetActiveOrganizationResponse"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"403":{"description":"Not a member of the organization","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}}},"/api/v1/users/preferences":{"get":{"operationId":"getUserPreferences","summary":"Get user preferences","description":"Get user preferences (theme, language, notifications, etc.)","tags":["Users"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Preferences retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetPreferencesResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}},"patch":{"operationId":"updateUserPreferences","summary":"Update user preferences","description":"Update user preferences (theme, language, notifications, etc.)","tags":["Users"],"security":[{"Bearer":[]}],"requestBody":{"description":"Preferences to update","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdatePreferences"}}}},"responses":{"200":{"description":"Preferences updated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetPreferencesResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}}},"/api/v1/users/dashboard":{"get":{"operationId":"getUserDashboard","summary":"Get personal dashboard data","description":"Retrieve comprehensive data for the user's personal dashboard including stats, organizations, recent activity, and chart data.","tags":["Users"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Personal dashboard data","content":{"application/json":{"schema":{"type":"object","properties":{"stats":{"type":"object","properties":{"totalOrganizations":{"type":"number"},"teamOrganizations":{"type":"number"},"totalLogins":{"type":"number"},"loginsLast7Days":{"type":"number"},"loginsLast30Days":{"type":"number"},"activeDevices":{"type":"number"},"unresolvedAlerts":{"type":"number"},"accountAge":{"type":"number"},"emailVerified":{"type":"boolean"},"twoFactorEnabled":{"type":"boolean"}},"required":["totalOrganizations","teamOrganizations","totalLogins","loginsLast7Days","loginsLast30Days","activeDevices","unresolvedAlerts","accountAge","emailVerified","twoFactorEnabled"]},"organizations":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":["string","null"]},"type":{"type":"string","enum":["personal","organization"]},"logo":{"type":["string","null"]},"role":{"type":"string"},"memberCount":{"type":"number"},"isActive":{"type":"boolean"}},"required":["id","name","slug","type","logo","role","memberCount","isActive"]}},"recentActivity":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string"},"title":{"type":"string"},"description":{"type":["string","null"]},"severity":{"type":["string","null"],"enum":["info","warning","critical","low","medium","high",null]},"createdAt":{"type":"string"},"ipAddress":{"type":["string","null"]},"location":{"type":["string","null"]}},"required":["id","type","title","description","severity","createdAt","ipAddress","location"]}},"activityChart":{"type":"array","items":{"type":"object","properties":{"date":{"type":"string"},"logins":{"type":"number"},"events":{"type":"number"}},"required":["date","logins","events"]}}},"required":["stats","organizations","recentActivity","activityChart"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}},"required":["error"]}}}}}}},"/api/v1/users/devices":{"get":{"tags":["Devices"],"summary":"List trusted devices","description":"Get all trusted devices for the current user","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"List of trusted devices","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetDevicesResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"delete":{"tags":["Devices"],"summary":"Revoke all devices","description":"Remove all devices from trusted devices","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"All devices revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessCountResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/users/devices/trust":{"post":{"tags":["Devices"],"summary":"Trust a device","description":"Mark the current device as trusted","security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TrustDeviceRequest"}}}},"responses":{"200":{"description":"Device trusted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TrustDeviceResponse"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/users/devices/{deviceId}":{"patch":{"tags":["Devices"],"summary":"Rename a device","description":"Update the name of a trusted device","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","example":"device_abc123"},"required":true,"name":"deviceId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RenameDeviceRequest"}}}},"responses":{"200":{"description":"Device renamed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Device not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"delete":{"tags":["Devices"],"summary":"Revoke a device","description":"Remove a device from trusted devices","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","example":"device_abc123"},"required":true,"name":"deviceId","in":"path"}],"responses":{"200":{"description":"Device revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Device not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/users/notifications":{"get":{"operationId":"listNotifications","tags":["Notifications"],"summary":"List my notifications","description":"List notifications for the current user","security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"default":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":100,"default":20},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string"},"required":false,"name":"unreadOnly","in":"query"},{"schema":{"type":"string","enum":["system","billing","security","feature","marketing","support","job"]},"required":false,"name":"type","in":"query"}],"responses":{"200":{"description":"Notifications list","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListNotificationsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/users/notifications/unread-count":{"get":{"operationId":"getUnreadCount","tags":["Notifications"],"summary":"Get unread notification count","description":"Get the count of unread notifications for the current user","security":[{"Bearer":[]}],"responses":{"200":{"description":"Unread count","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnreadCountResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/users/notifications/mark-read":{"post":{"operationId":"markNotificationsRead","tags":["Notifications"],"summary":"Mark notifications as read","description":"Mark specific notifications as read","security":[{"Bearer":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"notificationIds":{"type":"array","items":{"type":"string"},"minItems":1,"maxItems":100}},"required":["notificationIds"]}}}},"responses":{"200":{"description":"Notifications marked as read","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MarkReadResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/users/notifications/mark-all-read":{"post":{"operationId":"markAllNotificationsRead","tags":["Notifications"],"summary":"Mark all notifications as read","description":"Mark all notifications as read for the current user","security":[{"Bearer":[]}],"responses":{"200":{"description":"All notifications marked as read","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MarkReadResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/users/notifications/{notificationId}/dismiss":{"post":{"operationId":"dismissNotification","tags":["Notifications"],"summary":"Dismiss a notification","description":"Dismiss a notification (hides it from the list)","security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"notificationId","in":"path"}],"responses":{"200":{"description":"Notification dismissed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Notification"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Notification not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/users/test-notification":{"post":{"operationId":"sendTestNotification","tags":["Users"],"summary":"Send test notification","description":"Send a test email to verify email notifications are working","security":[{"Bearer":[]}],"responses":{"200":{"description":"Test notification sent successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TestNotificationResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"500":{"description":"Failed to send email","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/users/security-alerts":{"get":{"operationId":"getUnreadAlerts","summary":"Get security alerts","description":"Get all unread and non-dismissed security alerts for the current user","tags":["Users","Security"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Alerts retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserSecurityAlertsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/users/security-alerts/count":{"get":{"operationId":"getUnreadAlertCount","summary":"Get unread alert count","description":"Get the count of unread security alerts for the current user","tags":["Users","Security"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Count retrieved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetAlertCountResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/users/security-alerts/{alertId}/read":{"post":{"operationId":"markAlertAsRead","summary":"Mark alert as read","description":"Mark a specific security alert as read","tags":["Users","Security"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"alert_abc123"},"required":true,"name":"alertId","in":"path"}],"responses":{"200":{"description":"Alert marked as read","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Alert not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/users/security-alerts/read-all":{"post":{"operationId":"markAllAlertsAsRead","summary":"Mark all alerts as read","description":"Mark all security alerts as read for the current user","tags":["Users","Security"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"All alerts marked as read","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessCountResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/users/security-alerts/{alertId}/dismiss":{"post":{"operationId":"dismissAlert","summary":"Dismiss alert","description":"Dismiss a security alert (will no longer appear in unread list)","tags":["Users","Security"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"alert_abc123"},"required":true,"name":"alertId","in":"path"}],"responses":{"200":{"description":"Alert dismissed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Alert not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/users/security-alerts/dismiss-all":{"post":{"operationId":"dismissAllAlerts","summary":"Dismiss all alerts","description":"Dismiss all security alerts for the current user","tags":["Users","Security"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"All alerts dismissed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessCountResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/users/security-events":{"get":{"tags":["Users"],"summary":"Get security events","description":"Get recent security events for the current user with pagination","security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","default":"10","example":"10"},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","default":"0","example":"0"},"required":false,"name":"offset","in":"query"},{"schema":{"type":"string","example":"login"},"required":false,"name":"eventType","in":"query"}],"responses":{"200":{"description":"Security events retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SecurityEventsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/users/export":{"post":{"tags":["Users"],"summary":"Export user data","description":"Export all user data in a GDPR-compliant format (JSON)","security":[{"Bearer":[]}],"responses":{"200":{"description":"User data exported successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExportUserDataResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/users/companion/profile":{"get":{"operationId":"getCompanionProfile","summary":"Get companion profile","description":"Get the AI companion profile for the current user, including personality traits","tags":["Companion"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Companion profile retrieved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetCompanionProfileResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"patch":{"operationId":"updateCompanionProfile","summary":"Update companion profile","description":"Update the AI companion name, pronouns, or personality preset","tags":["Companion"],"security":[{"Bearer":[]}],"requestBody":{"description":"Profile updates","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateCompanionProfileRequest"}}}},"responses":{"200":{"description":"Companion profile updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateCompanionProfileResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/users/companion/personality-presets":{"get":{"operationId":"getPersonalityPresets","summary":"Get personality presets","description":"Get all available personality presets for companion customization","tags":["Companion"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Personality presets retrieved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetPersonalityPresetsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/users/companion/personality-traits":{"get":{"operationId":"getPersonalityTraits","summary":"Get personality traits","description":"Get the detailed personality trait configuration for the companion","tags":["Companion"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Personality traits retrieved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetPersonalityTraitsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"patch":{"operationId":"updatePersonalityTraits","summary":"Update personality traits","description":"Update individual personality trait values for fine-grained control","tags":["Companion"],"security":[{"Bearer":[]}],"requestBody":{"description":"Trait updates","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdatePersonalityTraitsRequest"}}}},"responses":{"200":{"description":"Personality traits updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdatePersonalityTraitsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/users/companion/onboarding":{"get":{"operationId":"getCompanionOnboarding","summary":"Get onboarding progress","description":"Get the current onboarding progress for companion setup","tags":["Companion"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Onboarding progress retrieved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetOnboardingResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"patch":{"operationId":"updateCompanionOnboarding","summary":"Update onboarding progress","description":"Update the onboarding step or complete/skip onboarding","tags":["Companion"],"security":[{"Bearer":[]}],"requestBody":{"description":"Onboarding updates","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateOnboardingRequest"}}}},"responses":{"200":{"description":"Onboarding progress updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateOnboardingResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/users/companion/avatars":{"get":{"operationId":"getCompanionAvatars","summary":"Get available avatars","description":"Get all avatar bases with unlock status for the current user","tags":["Companion"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Avatars retrieved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetAvatarsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/users/companion/items":{"get":{"operationId":"getCompanionItems","summary":"Get available items","description":"Get all cosmetic items with optional category filter","tags":["Companion"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","description":"Filter by category (head, face, body, accessory, background)","example":"head"},"required":false,"description":"Filter by category (head, face, body, accessory, background)","name":"category","in":"query"}],"responses":{"200":{"description":"Items retrieved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetItemsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/users/companion/inventory":{"get":{"operationId":"getCompanionInventory","summary":"Get user inventory","description":"Get all items owned by the current user","tags":["Companion"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Inventory retrieved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetInventoryResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/users/companion/outfit":{"get":{"operationId":"getCompanionOutfit","summary":"Get current outfit","description":"Get the currently equipped avatar and items","tags":["Companion"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Outfit retrieved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetOutfitResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"patch":{"operationId":"updateCompanionOutfit","summary":"Update outfit","description":"Equip or unequip avatar and items","tags":["Companion"],"security":[{"Bearer":[]}],"requestBody":{"description":"Outfit updates","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateOutfitRequest"}}}},"responses":{"200":{"description":"Outfit updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateOutfitResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/users/companion/context":{"get":{"tags":["Companion - Context"],"summary":"Get user context items","description":"Retrieves all active context items for the companion to use.","parameters":[{"schema":{"type":"string","enum":["user_preference","workflow","project","relationship","general"]},"required":false,"name":"type","in":"query"}],"responses":{"200":{"description":"Context items retrieved successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"contexts":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"contextType":{"type":"string","enum":["user_preference","workflow","project","relationship","general","settings","timezone","work_hours","weather","location"]},"key":{"type":"string"},"value":{"type":"string"},"confidence":{"type":"number","minimum":0,"maximum":1},"source":{"type":"string","enum":["explicit","inferred","system"]},"lastUsed":{"type":["string","null"]},"expiresAt":{"type":["string","null"]},"isActive":{"type":"boolean"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","contextType","key","value","confidence","source","lastUsed","expiresAt","isActive","createdAt","updatedAt"]}}},"required":["success","contexts"]}}}}}},"post":{"tags":["Companion - Context"],"summary":"Add a context item","description":"Adds a new context item for the companion to remember.","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"contextType":{"type":"string","enum":["user_preference","workflow","project","relationship","general","settings","timezone","work_hours","weather","location"]},"key":{"type":"string","minLength":1,"maxLength":100},"value":{"type":"string","minLength":1,"maxLength":5000},"confidence":{"type":"number","minimum":0,"maximum":1,"default":1},"source":{"type":"string","enum":["explicit","inferred","system"],"default":"explicit"},"expiresAt":{"type":["string","null"]}},"required":["contextType","key","value"]}}}},"responses":{"201":{"description":"Context item added successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"context":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"contextType":{"type":"string","enum":["user_preference","workflow","project","relationship","general","settings","timezone","work_hours","weather","location"]},"key":{"type":"string"},"value":{"type":"string"},"confidence":{"type":"number","minimum":0,"maximum":1},"source":{"type":"string","enum":["explicit","inferred","system"]},"lastUsed":{"type":["string","null"]},"expiresAt":{"type":["string","null"]},"isActive":{"type":"boolean"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","contextType","key","value","confidence","source","lastUsed","expiresAt","isActive","createdAt","updatedAt"]}},"required":["success","context"]}}}}}}},"/api/v1/users/companion/context/{contextId}":{"delete":{"tags":["Companion - Context"],"summary":"Delete a context item","description":"Removes a context item.","parameters":[{"schema":{"type":"string"},"required":true,"name":"contextId","in":"path"}],"responses":{"200":{"description":"Context item deleted successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"}},"required":["success"]}}}}}}},"/api/v1/users/companion/memories":{"get":{"tags":["Companion - Context"],"summary":"Get companion memories","description":"Retrieves memory items the companion has stored.","parameters":[{"schema":{"type":"string","enum":["fact","preference","interaction","milestone"]},"required":false,"name":"type","in":"query"},{"schema":{"type":"string"},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"Memories retrieved successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"memories":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string","enum":["fact","preference","interaction","milestone"]},"content":{"type":"string"},"importance":{"type":"string","enum":["low","medium","high","critical"]},"relatedEntity":{"type":["string","null"]},"createdAt":{"type":"string"}},"required":["id","type","content","importance","relatedEntity","createdAt"]}}},"required":["success","memories"]}}}}}},"post":{"tags":["Companion - Context"],"summary":"Add a memory","description":"Adds a new memory item for the companion.","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"type":{"type":"string","enum":["fact","preference","interaction","milestone"]},"content":{"type":"string","minLength":1,"maxLength":5000},"importance":{"type":"string","enum":["low","medium","high","critical"],"default":"medium"},"relatedEntity":{"type":["string","null"]}},"required":["type","content"]}}}},"responses":{"201":{"description":"Memory added successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"memory":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string","enum":["fact","preference","interaction","milestone"]},"content":{"type":"string"},"importance":{"type":"string","enum":["low","medium","high","critical"]},"relatedEntity":{"type":["string","null"]},"createdAt":{"type":"string"}},"required":["id","type","content","importance","relatedEntity","createdAt"]}},"required":["success","memory"]}}}}}}},"/api/v1/users/companion/greeting":{"get":{"tags":["Companion - Context"],"summary":"Get contextual greeting","description":"Returns a personalized greeting based on time, streak, and recent activity.","responses":{"200":{"description":"Greeting generated successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"greeting":{"type":"string"},"timeOfDay":{"type":"string","enum":["morning","afternoon","evening","night"]},"streak":{"type":"number"},"recentActivity":{"type":["string","null"]}},"required":["success","greeting","timeOfDay","streak","recentActivity"]}}}}}}},"/api/v1/users/companion/context-prompt":{"get":{"tags":["Companion - Context"],"summary":"Build context prompt for AI","description":"Builds a context-aware prompt section for use in AI system prompts.","responses":{"200":{"description":"Context prompt built successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"prompt":{"type":"string"},"contextItems":{"type":"number"}},"required":["success","prompt","contextItems"]}}}}}}},"/api/v1/users/companion/level":{"get":{"operationId":"getCompanionUserLevel","summary":"Get user level","description":"Get current XP, level, and progress to next level","tags":["Companion"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"User level retrieved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetUserLevelResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/users/companion/xp/history":{"get":{"operationId":"getCompanionXpHistory","summary":"Get XP history","description":"Get recent XP earning history","tags":["Companion"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"20"},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"XP history retrieved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetXpHistoryResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/users/companion/xp/award":{"post":{"operationId":"awardCompanionXp","summary":"Award XP","description":"Award XP for an action (internal use)","tags":["Companion"],"security":[{"Bearer":[]}],"requestBody":{"description":"XP award request","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AwardXpRequest"}}}},"responses":{"200":{"description":"XP awarded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AwardXpResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/users/companion/achievements":{"get":{"operationId":"getCompanionAchievements","summary":"Get achievements","description":"Get all achievements with user progress","tags":["Companion"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"streaks"},"required":false,"name":"category","in":"query"}],"responses":{"200":{"description":"Achievements retrieved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetAchievementsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/users/companion/leaderboard":{"get":{"operationId":"getCompanionLeaderboard","summary":"Get leaderboard","description":"Get organization XP leaderboard","tags":["Companion"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"10"},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"Leaderboard retrieved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetLeaderboardResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/users/companion/voice/options":{"get":{"tags":["Companion - Voice"],"summary":"Get available voice options","description":"Retrieves all available voice options for the companion.","parameters":[{"schema":{"type":"string","enum":["masculine","feminine","neutral"]},"required":false,"name":"gender","in":"query"},{"schema":{"type":"string"},"required":false,"name":"provider","in":"query"}],"responses":{"200":{"description":"Voice options retrieved successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"voices":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"slug":{"type":"string"},"name":{"type":"string"},"description":{"type":["string","null"]},"provider":{"type":"string","enum":["elevenlabs","openai","azure","google","system"]},"voiceId":{"type":"string"},"gender":{"type":"string","enum":["masculine","feminine","neutral"]},"accent":{"type":["string","null"]},"style":{"type":["string","null"]},"sampleUrl":{"type":["string","null"]},"isPremium":{"type":"boolean"},"isActive":{"type":"boolean"}},"required":["id","slug","name","description","provider","voiceId","gender","accent","style","sampleUrl","isPremium","isActive"]}}},"required":["success","voices"]}}}}}}},"/api/v1/users/companion/voice":{"get":{"tags":["Companion - Voice"],"summary":"Get user voice preference","description":"Retrieves the user's current voice preference for the companion.","responses":{"200":{"description":"Voice preference retrieved successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"preference":{"type":["object","null"],"properties":{"id":{"type":"string"},"userId":{"type":"string"},"voiceId":{"type":"string"},"pitch":{"type":"number","minimum":-50,"maximum":50},"speed":{"type":"number","minimum":0.5,"maximum":2},"volume":{"type":"number","minimum":0,"maximum":100},"isEnabled":{"type":"boolean"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","voiceId","pitch","speed","volume","isEnabled","createdAt","updatedAt"]},"voice":{"type":["object","null"],"properties":{"id":{"type":"string"},"slug":{"type":"string"},"name":{"type":"string"},"description":{"type":["string","null"]},"provider":{"type":"string","enum":["elevenlabs","openai","azure","google","system"]},"voiceId":{"type":"string"},"gender":{"type":"string","enum":["masculine","feminine","neutral"]},"accent":{"type":["string","null"]},"style":{"type":["string","null"]},"sampleUrl":{"type":["string","null"]},"isPremium":{"type":"boolean"},"isActive":{"type":"boolean"}},"required":["id","slug","name","description","provider","voiceId","gender","accent","style","sampleUrl","isPremium","isActive"]}},"required":["success","preference","voice"]}}}}}},"patch":{"tags":["Companion - Voice"],"summary":"Update user voice preference","description":"Updates the user's voice preference for the companion.","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"voiceId":{"type":"string"},"pitch":{"type":"number","minimum":-50,"maximum":50},"speed":{"type":"number","minimum":0.5,"maximum":2},"volume":{"type":"number","minimum":0,"maximum":100},"isEnabled":{"type":"boolean"}}}}}},"responses":{"200":{"description":"Voice preference updated successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"preference":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"voiceId":{"type":"string"},"pitch":{"type":"number","minimum":-50,"maximum":50},"speed":{"type":"number","minimum":0.5,"maximum":2},"volume":{"type":"number","minimum":0,"maximum":100},"isEnabled":{"type":"boolean"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","voiceId","pitch","speed","volume","isEnabled","createdAt","updatedAt"]}},"required":["success","preference"]}}}}}}},"/api/v1/users/companion/voice/test":{"post":{"tags":["Companion - Voice"],"summary":"Test a voice","description":"Generates a sample audio clip to test a specific voice.","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"voiceId":{"type":"string"},"text":{"type":"string","minLength":1,"maxLength":500}},"required":["voiceId"]}}}},"responses":{"200":{"description":"Voice test audio generated successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"audioUrl":{"type":"string"},"duration":{"type":"number"}},"required":["success","audioUrl","duration"]}}}}}}},"/api/v1/users/companion/voice/synthesize":{"post":{"tags":["Companion - Voice"],"summary":"Synthesize speech","description":"Converts text to speech using the user's preferred voice.","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"text":{"type":"string","minLength":1,"maxLength":5000},"voiceId":{"type":"string"}},"required":["text"]}}}},"responses":{"200":{"description":"Speech synthesized successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"audioUrl":{"type":"string"},"duration":{"type":"number"},"charactersUsed":{"type":"number"}},"required":["success","audioUrl","duration","charactersUsed"]}}}}}}},"/api/v1/users/companion/pets":{"get":{"tags":["Companion - Advanced"],"summary":"Get pets","description":"Retrieves available pets and user's adopted pets.","responses":{"200":{"description":"Pets retrieved successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"availablePets":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"slug":{"type":"string"},"name":{"type":"string"},"description":{"type":["string","null"]},"type":{"type":"string","enum":["cat","dog","bird","dragon","robot","magical"]},"rarity":{"type":"string","enum":["common","uncommon","rare","epic","legendary"]},"requiredLevel":{"type":"number"},"unlockCondition":{"type":["string","null"]},"animationUrl":{"type":["string","null"]},"soundUrl":{"type":["string","null"]},"isActive":{"type":"boolean"}},"required":["id","slug","name","description","type","rarity","requiredLevel","unlockCondition","animationUrl","soundUrl","isActive"]}},"userPets":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"petId":{"type":"string"},"customName":{"type":["string","null"]},"affection":{"type":"number","minimum":0,"maximum":100},"lastInteraction":{"type":["string","null"]},"isActive":{"type":"boolean"},"unlockedAt":{"type":"string"}},"required":["id","userId","petId","customName","affection","lastInteraction","isActive","unlockedAt"]}}},"required":["success","availablePets","userPets"]}}}}}},"post":{"tags":["Companion - Advanced"],"summary":"Adopt a pet","description":"Adopts a new pet for the companion.","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"petId":{"type":"string"},"customName":{"type":"string","maxLength":50}},"required":["petId"]}}}},"responses":{"201":{"description":"Pet adopted successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"userPet":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"petId":{"type":"string"},"customName":{"type":["string","null"]},"affection":{"type":"number","minimum":0,"maximum":100},"lastInteraction":{"type":["string","null"]},"isActive":{"type":"boolean"},"unlockedAt":{"type":"string"}},"required":["id","userId","petId","customName","affection","lastInteraction","isActive","unlockedAt"]}},"required":["success","userPet"]}}}}}}},"/api/v1/users/companion/pets/{petId}/interact":{"post":{"tags":["Companion - Advanced"],"summary":"Interact with pet","description":"Interacts with an adopted pet to increase affection.","parameters":[{"schema":{"type":"string"},"required":true,"name":"petId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"action":{"type":"string","enum":["pet","feed","play","walk"]}},"required":["action"]}}}},"responses":{"200":{"description":"Interaction successful","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"affectionGained":{"type":"number"},"newAffection":{"type":"number"},"message":{"type":"string"}},"required":["success","affectionGained","newAffection","message"]}}}}}}},"/api/v1/users/companion/seasonal":{"get":{"tags":["Companion - Advanced"],"summary":"Get seasonal events","description":"Retrieves current and upcoming seasonal events.","responses":{"200":{"description":"Seasonal events retrieved successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"currentEvent":{"type":["object","null"],"properties":{"id":{"type":"string"},"slug":{"type":"string"},"name":{"type":"string"},"description":{"type":["string","null"]},"theme":{"type":"string"},"startDate":{"type":"string"},"endDate":{"type":"string"},"specialItems":{"type":["array","null"],"items":{"type":"string"}},"specialAvatars":{"type":["array","null"],"items":{"type":"string"}},"xpMultiplier":{"type":"number"},"isActive":{"type":"boolean"}},"required":["id","slug","name","description","theme","startDate","endDate","specialItems","specialAvatars","xpMultiplier","isActive"]},"upcomingEvents":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"slug":{"type":"string"},"name":{"type":"string"},"description":{"type":["string","null"]},"theme":{"type":"string"},"startDate":{"type":"string"},"endDate":{"type":"string"},"specialItems":{"type":["array","null"],"items":{"type":"string"}},"specialAvatars":{"type":["array","null"],"items":{"type":"string"}},"xpMultiplier":{"type":"number"},"isActive":{"type":"boolean"}},"required":["id","slug","name","description","theme","startDate","endDate","specialItems","specialAvatars","xpMultiplier","isActive"]}}},"required":["success","currentEvent","upcomingEvents"]}}}}}}},"/api/v1/users/companion/terminology":{"get":{"tags":["Companion - Advanced"],"summary":"Get taught terminology","description":"Retrieves terms the user has taught the companion.","parameters":[{"schema":{"type":"string"},"required":false,"name":"category","in":"query"}],"responses":{"200":{"description":"Terminology retrieved successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"terms":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"term":{"type":"string"},"definition":{"type":"string"},"category":{"type":["string","null"]},"examples":{"type":["array","null"],"items":{"type":"string"}},"isActive":{"type":"boolean"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","term","definition","category","examples","isActive","createdAt","updatedAt"]}}},"required":["success","terms"]}}}}}},"post":{"tags":["Companion - Advanced"],"summary":"Teach a term","description":"Teaches the companion a new term or concept.","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"term":{"type":"string","minLength":1,"maxLength":100},"definition":{"type":"string","minLength":1,"maxLength":2000},"category":{"type":"string","maxLength":50},"examples":{"type":"array","items":{"type":"string","maxLength":500}}},"required":["term","definition"]}}}},"responses":{"201":{"description":"Term taught successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"terminology":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"term":{"type":"string"},"definition":{"type":"string"},"category":{"type":["string","null"]},"examples":{"type":["array","null"],"items":{"type":"string"}},"isActive":{"type":"boolean"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","term","definition","category","examples","isActive","createdAt","updatedAt"]}},"required":["success","terminology"]}}}}}}},"/api/v1/users/companion/terminology/{termId}":{"delete":{"tags":["Companion - Advanced"],"summary":"Delete a term","description":"Removes a taught term from the companion.","parameters":[{"schema":{"type":"string"},"required":true,"name":"termId","in":"path"}],"responses":{"200":{"description":"Term deleted successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"}},"required":["success"]}}}}}}},"/api/v1/users/companion/easter-eggs":{"get":{"tags":["Companion - Advanced"],"summary":"Get discovered easter eggs","description":"Retrieves easter eggs the user has discovered.","responses":{"200":{"description":"Easter eggs retrieved successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"discovered":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"trigger":{"type":"string"},"response":{"type":"string"},"category":{"type":"string"},"xpReward":{"type":"number"},"isDiscovered":{"type":"boolean"}},"required":["id","trigger","response","category","xpReward","isDiscovered"]}},"totalCount":{"type":"number"},"discoveredCount":{"type":"number"}},"required":["success","discovered","totalCount","discoveredCount"]}}}}}}},"/api/v1/users/companion/easter-eggs/trigger":{"post":{"tags":["Companion - Advanced"],"summary":"Trigger an easter egg","description":"Attempts to trigger an easter egg with a phrase or action.","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"trigger":{"type":"string"}},"required":["trigger"]}}}},"responses":{"200":{"description":"Easter egg check completed","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"found":{"type":"boolean"},"easterEgg":{"type":["object","null"],"properties":{"id":{"type":"string"},"trigger":{"type":"string"},"response":{"type":"string"},"category":{"type":"string"},"xpReward":{"type":"number"},"isDiscovered":{"type":"boolean"}},"required":["id","trigger","response","category","xpReward","isDiscovered"]},"xpAwarded":{"type":"number"},"message":{"type":["string","null"]}},"required":["success","found","easterEgg","xpAwarded","message"]}}}}}}},"/api/v1/teams":{"get":{"operationId":"listTeams","summary":"List organization teams","description":"Get all teams in the current organization","tags":["Teams"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Teams retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListTeamsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}},"post":{"operationId":"createTeam","summary":"Create a team","description":"Create a new team in the organization","tags":["Teams"],"security":[{"Bearer":[]}],"requestBody":{"description":"Team details","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateTeam"}}}},"responses":{"201":{"description":"Team created successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TeamResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"409":{"description":"Team slug already exists","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}}},"/api/v1/teams/{teamId}":{"get":{"operationId":"getTeam","summary":"Get team details","description":"Get details of a specific team","tags":["Teams"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"team_abc123"},"required":true,"name":"teamId","in":"path"}],"responses":{"200":{"description":"Team retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TeamResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"404":{"description":"Team not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}},"patch":{"operationId":"updateTeam","summary":"Update team","description":"Update team details","tags":["Teams"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"team_abc123"},"required":true,"name":"teamId","in":"path"}],"requestBody":{"description":"Team fields to update","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateTeam"}}}},"responses":{"200":{"description":"Team updated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TeamResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"404":{"description":"Team not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}},"delete":{"operationId":"deleteTeam","summary":"Delete team","description":"Soft delete a team","tags":["Teams"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"team_abc123"},"required":true,"name":"teamId","in":"path"}],"responses":{"200":{"description":"Team deleted successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]}},"required":["success"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"404":{"description":"Team not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}}},"/api/v1/teams/{teamId}/members":{"get":{"operationId":"listTeamMembers","summary":"List team members","description":"Get all members of a team","tags":["Teams"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"team_abc123"},"required":true,"name":"teamId","in":"path"}],"responses":{"200":{"description":"Members retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TeamMembersResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"404":{"description":"Team not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}},"post":{"operationId":"addTeamMember","summary":"Add team member","description":"Add a user to a team","tags":["Teams"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"team_abc123"},"required":true,"name":"teamId","in":"path"}],"requestBody":{"description":"Member details","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddTeamMember"}}}},"responses":{"201":{"description":"Member added successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TeamMemberResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"404":{"description":"Team or user not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"409":{"description":"User is already a member","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}}},"/api/v1/teams/{teamId}/members/{memberId}":{"patch":{"operationId":"updateTeamMember","summary":"Update team member","description":"Update a team member role","tags":["Teams"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"team_abc123"},"required":true,"name":"teamId","in":"path"},{"schema":{"type":"string","example":"tm_xyz789"},"required":true,"name":"memberId","in":"path"}],"requestBody":{"description":"Member fields to update","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateTeamMember"}}}},"responses":{"200":{"description":"Member updated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TeamMemberResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"404":{"description":"Team member not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}},"delete":{"operationId":"removeTeamMember","summary":"Remove team member","description":"Remove a user from a team","tags":["Teams"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"team_abc123"},"required":true,"name":"teamId","in":"path"},{"schema":{"type":"string","example":"tm_xyz789"},"required":true,"name":"memberId","in":"path"}],"responses":{"200":{"description":"Member removed successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]}},"required":["success"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"404":{"description":"Team member not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}}},"/api/v1/auth/2fa/verify":{"post":{"operationId":"twoFactorVerify","summary":"Complete 2FA challenge","description":"Submit a TOTP code or backup code to complete authentication after a 2FA challenge.","tags":["Two-Factor Authentication"],"requestBody":{"description":"2FA verification payload","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TwoFactorVerifyRequest"}}}},"responses":{"200":{"description":"Authentication complete","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TwoFactorVerifyResponse"}}}},"401":{"description":"Invalid code or expired challenge","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TwoFactorVerifyRequest"}}}}}}},"/api/v1/auth/2fa/status":{"get":{"operationId":"twoFactorStatus","summary":"Get 2FA status","description":"Returns whether two-factor authentication is enabled for the authenticated user.","tags":["Two-Factor Authentication"],"responses":{"200":{"description":"2FA status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TwoFactorStatusResponse"}}}}}}},"/api/v1/auth/2fa/setup":{"post":{"operationId":"twoFactorSetup","summary":"Begin 2FA setup","description":"Generates a new TOTP secret and backup codes. Call /enable after scanning the QR code.","tags":["Two-Factor Authentication"],"responses":{"200":{"description":"TOTP setup data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TwoFactorSetupResponse"}}}}}}},"/api/v1/auth/2fa/enable":{"post":{"operationId":"twoFactorEnable","summary":"Enable 2FA","description":"Verify the TOTP code from the authenticator app and enable two-factor authentication.","tags":["Two-Factor Authentication"],"requestBody":{"description":"TOTP verification code","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TwoFactorEnableRequest"}}}},"responses":{"200":{"description":"2FA enabled successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TwoFactorStatusResponse"}}}},"401":{"description":"Invalid TOTP code","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TwoFactorVerifyRequest"}}}}}}},"/api/v1/auth/2fa":{"delete":{"operationId":"twoFactorDisable","summary":"Disable 2FA","description":"Disables two-factor authentication. Requires either the current TOTP code or account password to prevent a stolen session from disabling MFA.","tags":["Two-Factor Authentication"],"requestBody":{"description":"Confirmation credential","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TwoFactorDisableRequest"}}}},"responses":{"200":{"description":"2FA disabled","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TwoFactorStatusResponse"}}}},"401":{"description":"Invalid code or password","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TwoFactorStatusResponse"}}}}}}},"/api/v1/workspaces":{"get":{"operationId":"listWorkspaces","summary":"List workspaces","description":"List all workspaces the authenticated user has access to (as owner or member).","tags":["Workspaces"],"parameters":[{"schema":{"type":"string","enum":["active","archived","suspended","closed"]},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","enum":["general","project","social_media","brand","product","event"]},"required":false,"name":"type","in":"query"}],"responses":{"200":{"description":"List of workspaces","content":{"application/json":{"schema":{"type":"object","properties":{"workspaces":{"type":"array","items":{"$ref":"#/components/schemas/Workspace"}},"total":{"type":"number"}},"required":["workspaces","total"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"post":{"operationId":"createWorkspace","summary":"Create a workspace","description":"Create a new workspace. The authenticated user becomes the owner. Workspace is scoped to their current organization.","tags":["Workspaces"],"requestBody":{"description":"Workspace details","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateWorkspace"}}}},"responses":{"201":{"description":"Workspace created","content":{"application/json":{"schema":{"type":"object","properties":{"workspace":{"$ref":"#/components/schemas/Workspace"}},"required":["workspace"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"409":{"description":"Resource already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/workspaces/{workspaceId}":{"get":{"operationId":"getWorkspace","summary":"Get workspace details","description":"Get a workspace by ID. Requires workspace membership.","tags":["Workspaces"],"parameters":[{"schema":{"type":"string","example":"ws_abc123","description":"Workspace ID"},"required":true,"description":"Workspace ID","name":"workspaceId","in":"path"}],"responses":{"200":{"description":"Workspace details","content":{"application/json":{"schema":{"type":"object","properties":{"workspace":{"$ref":"#/components/schemas/Workspace"}},"required":["workspace"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"patch":{"operationId":"updateWorkspace","summary":"Update a workspace","description":"Update workspace settings. Requires owner or admin role.","tags":["Workspaces"],"parameters":[{"schema":{"type":"string","example":"ws_abc123","description":"Workspace ID"},"required":true,"description":"Workspace ID","name":"workspaceId","in":"path"}],"requestBody":{"description":"Workspace updates","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateWorkspace"}}}},"responses":{"200":{"description":"Updated workspace","content":{"application/json":{"schema":{"type":"object","properties":{"workspace":{"$ref":"#/components/schemas/Workspace"}},"required":["workspace"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"delete":{"operationId":"deleteWorkspace","summary":"Delete a workspace","description":"Soft-delete a workspace. Requires owner role.","tags":["Workspaces"],"parameters":[{"schema":{"type":"string","example":"ws_abc123","description":"Workspace ID"},"required":true,"description":"Workspace ID","name":"workspaceId","in":"path"}],"responses":{"200":{"description":"Workspace deleted","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}},"required":["message"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/workspaces/{workspaceId}/members":{"get":{"operationId":"listWorkspaceMembers","summary":"List workspace members","description":"List all members of a workspace. Requires workspace membership.","tags":["Workspaces"],"parameters":[{"schema":{"type":"string","example":"ws_abc123","description":"Workspace ID"},"required":true,"description":"Workspace ID","name":"workspaceId","in":"path"}],"responses":{"200":{"description":"Workspace members","content":{"application/json":{"schema":{"type":"object","properties":{"members":{"type":"array","items":{"$ref":"#/components/schemas/WorkspaceMember"}}},"required":["members"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/workspaces/{workspaceId}/members/{memberId}":{"patch":{"operationId":"updateWorkspaceMember","summary":"Update workspace member","description":"Update a member role or status. Requires admin/owner role.","tags":["Workspaces"],"parameters":[{"schema":{"type":"string","example":"ws_abc123","description":"Workspace ID"},"required":true,"description":"Workspace ID","name":"workspaceId","in":"path"},{"schema":{"type":"string","example":"wsm_xyz789","description":"Workspace member ID"},"required":true,"description":"Workspace member ID","name":"memberId","in":"path"}],"requestBody":{"description":"Member updates","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateWorkspaceMember"}}}},"responses":{"200":{"description":"Updated member","content":{"application/json":{"schema":{"type":"object","properties":{"member":{"$ref":"#/components/schemas/WorkspaceMember"}},"required":["member"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"delete":{"operationId":"removeWorkspaceMember","summary":"Remove workspace member","description":"Remove a member from a workspace. Requires admin/owner role.","tags":["Workspaces"],"parameters":[{"schema":{"type":"string","example":"ws_abc123","description":"Workspace ID"},"required":true,"description":"Workspace ID","name":"workspaceId","in":"path"},{"schema":{"type":"string","example":"wsm_xyz789","description":"Workspace member ID"},"required":true,"description":"Workspace member ID","name":"memberId","in":"path"}],"responses":{"200":{"description":"Member removed","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}},"required":["message"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/workspaces/{workspaceId}/invitations":{"get":{"operationId":"listWorkspaceInvitations","summary":"List workspace invitations","description":"List all pending invitations for a workspace. Requires admin/owner role.","tags":["Workspaces"],"parameters":[{"schema":{"type":"string","example":"ws_abc123","description":"Workspace ID"},"required":true,"description":"Workspace ID","name":"workspaceId","in":"path"}],"responses":{"200":{"description":"Workspace invitations","content":{"application/json":{"schema":{"type":"object","properties":{"invitations":{"type":"array","items":{"$ref":"#/components/schemas/WorkspaceInvitation"}}},"required":["invitations"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"post":{"operationId":"inviteToWorkspace","summary":"Invite to workspace","description":"Invite a user by email to join a workspace. They can be from any organization. Requires admin/owner role.","tags":["Workspaces"],"parameters":[{"schema":{"type":"string","example":"ws_abc123","description":"Workspace ID"},"required":true,"description":"Workspace ID","name":"workspaceId","in":"path"}],"requestBody":{"description":"Invitation details","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InviteToWorkspace"}}}},"responses":{"201":{"description":"Invitation created","content":{"application/json":{"schema":{"type":"object","properties":{"invitation":{"$ref":"#/components/schemas/WorkspaceInvitation"}},"required":["invitation"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"409":{"description":"Resource already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/workspaces/{workspaceId}/invitations/{invitationId}":{"delete":{"operationId":"revokeWorkspaceInvitation","summary":"Revoke workspace invitation","description":"Cancel a pending workspace invitation. Requires admin/owner role.","tags":["Workspaces"],"parameters":[{"schema":{"type":"string","example":"ws_abc123","description":"Workspace ID"},"required":true,"description":"Workspace ID","name":"workspaceId","in":"path"},{"schema":{"type":"string","example":"wsi_def456","description":"Workspace invitation ID"},"required":true,"description":"Workspace invitation ID","name":"invitationId","in":"path"}],"responses":{"200":{"description":"Invitation revoked","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}},"required":["message"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/workspaces/invitations/{token}":{"get":{"operationId":"getWorkspaceInvitationByToken","summary":"Get workspace invitation by token","description":"Preview a workspace invitation without accepting it. Requires authentication.","tags":["Workspaces"],"parameters":[{"schema":{"type":"string","minLength":1,"example":"abc123xyz","description":"Invitation token from email link"},"required":true,"description":"Invitation token from email link","name":"token","in":"path"}],"responses":{"200":{"description":"Invitation details","content":{"application/json":{"schema":{"type":"object","properties":{"invitation":{"$ref":"#/components/schemas/WorkspaceInvitationPreview"}},"required":["invitation"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/workspaces/invitations/{token}/accept":{"post":{"operationId":"acceptWorkspaceInvitation","summary":"Accept workspace invitation","description":"Accept a workspace invitation using its token. The authenticated user's email must match the invitation target.","tags":["Workspaces"],"parameters":[{"schema":{"type":"string","minLength":1,"example":"abc123xyz","description":"Invitation token from email link"},"required":true,"description":"Invitation token from email link","name":"token","in":"path"}],"responses":{"200":{"description":"Invitation accepted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AcceptWorkspaceInvitationResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Invitation not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"409":{"description":"Already a member","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"410":{"description":"Invitation has expired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/auth/internal/stats":{"get":{"operationId":"getInternalStats","tags":["Internal"],"security":[],"summary":"Get platform statistics (internal)","description":"Service-to-service endpoint for platform-wide statistics. Authenticated via X-Internal-Key header.","responses":{"200":{"description":"Platform statistics","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalStatsResponse"}}}},"401":{"description":"Invalid or missing internal service key"}}}},"/api/v1/auth/internal/validate-relationship":{"get":{"operationId":"validateRelationship","tags":["Internal"],"security":[],"summary":"Validate agency-client relationship (internal)","description":"Service-to-service endpoint to check if an active agency-client relationship exists. Authenticated via internal service key.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"agencyOrgId","in":"query"},{"schema":{"type":"string","minLength":1},"required":true,"name":"clientOrgId","in":"query"}],"responses":{"200":{"description":"Relationship validation result","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidateRelationshipResponse"}}}},"401":{"description":"Invalid or missing internal service key"}}}},"/api/v1/auth/internal/is-platform-admin":{"get":{"operationId":"isPlatformAdmin","tags":["Internal"],"security":[],"summary":"Check if user is platform admin (internal)","description":"Service-to-service endpoint to check if a user has the system.manage permission. Authenticated via internal service key.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"userId","in":"query"}],"responses":{"200":{"description":"Platform admin check result","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IsPlatformAdminResponse"}}}}}}},"/api/v1/auth/internal/resolve-users":{"post":{"operationId":"resolveUsers","tags":["Internal"],"security":[],"summary":"Resolve user IDs to profile info (internal)","description":"Service-to-service endpoint to resolve user IDs to email and display name. Authenticated via internal service key.","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"userIds":{"type":"array","items":{"type":"string"},"minItems":1,"maxItems":100}},"required":["userIds"]}}}},"responses":{"200":{"description":"Resolved user info keyed by userId","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResolveUsersResponse"}}}}}}},"/api/v1/auth/internal/resolve-organizations":{"post":{"operationId":"resolveOrganizations","tags":["Internal"],"security":[],"summary":"Resolve organization IDs to names (internal)","description":"Service-to-service endpoint to resolve organization IDs to their display names. Authenticated via internal service key.","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"organizationIds":{"type":"array","items":{"type":"string"},"minItems":1,"maxItems":100}},"required":["organizationIds"]}}}},"responses":{"200":{"description":"Resolved org info keyed by organizationId","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResolveOrgsResponse"}}}}}}},"/api/v1/auth/internal/orgs/{organizationId}/subscription":{"get":{"operationId":"resolveOrgSubscription","tags":["Internal"],"security":[],"summary":"Get an org's active subscription plan id (internal)","description":"Service-to-service endpoint. Authenticated via internal service key. Returns the most recent active subscription, or null fields when none exists.","parameters":[{"schema":{"type":"string"},"required":true,"name":"organizationId","in":"path"}],"responses":{"200":{"description":"Active subscription (or null)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResolveSubscriptionResponse"}}}}}}},"/api/v1/auth/internal/plans/{planId}/orgs":{"get":{"operationId":"listOrgsOnPlan","tags":["Internal"],"security":[],"summary":"List organization ids subscribed to the given plan (internal)","description":"Returns active + trialing subscriptions for the plan. Authenticated via internal service key. Used by platform pricing for targeted cache invalidation.","parameters":[{"schema":{"type":"string"},"required":true,"name":"planId","in":"path"}],"responses":{"200":{"description":"Subscribers","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrgsOnPlanResponse"}}}}}}},"/api/v1/auth/internal/users/has-permissions":{"post":{"operationId":"internalHasPermissions","tags":["Internal"],"security":[],"summary":"Bulk check whether a user holds the given permissions","description":"Returns true/false for each requested permission. Authenticated via INTERNAL_SERVICE_KEY.","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"userId":{"type":"string"},"permissions":{"type":"array","items":{"type":"string"},"minItems":1,"maxItems":50},"organizationId":{"type":"string"}},"required":["userId","permissions"]}}}},"responses":{"200":{"description":"Permission map","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HasPermissionsResponse"}}}}}}},"/api/v1/auth/internal/send-email":{"post":{"operationId":"internalSendEmail","tags":["Internal"],"security":[],"summary":"Send email via centralized provider (internal)","description":"Service-to-service endpoint for sending emails through identity's email provider. Authenticated via internal service key.","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"to":{"type":"string","format":"email"},"toUserId":{"type":"string"},"toName":{"type":"string"},"subject":{"type":"string","minLength":1},"html":{"type":"string","minLength":1},"text":{"type":"string","minLength":1}},"required":["subject","html","text"]}}}},"responses":{"200":{"description":"Email sent successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendEmailResponse"}}}},"401":{"description":"Invalid or missing internal service key"},"500":{"description":"Email sending failed"}}}},"/api/v1/auth/internal/resolve-api-key":{"post":{"operationId":"resolveApiKey","tags":["Internal"],"security":[],"summary":"Resolve a decrypted API key (internal)","description":"Service-to-service endpoint to resolve and decrypt a service API key. Identity handles decryption internally so callers never need ENCRYPTION_SECRET. Authenticated via internal service key.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResolveApiKeyRequest"}}}},"responses":{"200":{"description":"Resolved API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResolveApiKeyResponse"}}}},"404":{"description":"No key configured for the requested provider","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}},"required":["message"]}}}}}}},"/v1/auth/login":{"post":{"operationId":"authLogin","summary":"Authenticate user and create session","description":"Authenticates a user with email/username and password, creating a new session.","tags":["Authentication"],"requestBody":{"description":"Login credentials","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LoginRequest"}}}},"responses":{"200":{"description":"User successfully logged in","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LoginResponse"}}}},"401":{"description":"Invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"429":{"description":"Too many login attempts","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/auth/logout":{"post":{"operationId":"authLogout","summary":"End current session","description":"Invalidates the current session and clears authentication cookies.","tags":["Authentication"],"responses":{"200":{"description":"User successfully logged out","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LogoutResponse"}}}}}}},"/v1/auth/me":{"get":{"operationId":"authMe","summary":"Get current user","description":"Returns the currently authenticated user and their organization memberships.","tags":["Authentication"],"responses":{"200":{"description":"Current user data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MeResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/auth/signup":{"post":{"operationId":"authSignup","summary":"Register a new user account","description":"Creates a new user account with email and password authentication. A verification email will be sent.","tags":["Authentication"],"requestBody":{"description":"Registration data","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SignupRequest"}}}},"responses":{"200":{"description":"User successfully registered","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SignupResponse"}}}},"409":{"description":"Email or username already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/auth/forgot-password":{"post":{"operationId":"authForgotPassword","summary":"Request password reset","description":"Sends a password reset link to the user email if account exists. Always returns success for security.","tags":["Authentication"],"requestBody":{"description":"Email address","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ForgotPasswordRequest"}}}},"responses":{"200":{"description":"Reset email sent (if account exists)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessMessageResponse"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"429":{"description":"Rate limit exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/auth/reset-password":{"post":{"operationId":"authResetPassword","summary":"Reset password with token","description":"Resets user password using a valid reset token. Returns a new session on success.","tags":["Authentication"],"requestBody":{"description":"Reset token and new password","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResetPasswordRequest"}}}},"responses":{"200":{"description":"Password reset successful","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResetPasswordResponse"}}}},"400":{"description":"Invalid or expired token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"429":{"description":"Rate limit exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/auth/change-password":{"post":{"operationId":"authChangePassword","summary":"Change password","description":"Changes password for authenticated user. Requires current password verification.","tags":["Authentication"],"security":[{"bearerAuth":[]}],"requestBody":{"description":"Current and new password","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChangePasswordRequest"}}}},"responses":{"200":{"description":"Password changed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessMessageResponse"}}}},"400":{"description":"Invalid current password","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"429":{"description":"Rate limit exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/auth/verify-email":{"post":{"operationId":"authVerifyEmail","summary":"Verify email address","description":"Confirms ownership of an email address using a verification token or code. Returns a session on success.","tags":["Authentication"],"requestBody":{"description":"Verification token or email+code","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerifyEmailRequest"}}}},"responses":{"200":{"description":"Email verified successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerifyEmailResponse"}}}},"400":{"description":"Invalid or expired token/code","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/auth/resend-verification":{"post":{"operationId":"authResendVerification","summary":"Resend verification email","description":"Sends a new verification email for unverified email addresses. Always returns success for security.","tags":["Authentication"],"requestBody":{"description":"Email address","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResendVerificationRequest"}}}},"responses":{"200":{"description":"Verification email sent (if applicable)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessMessageResponse"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"429":{"description":"Rate limit exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/auth/sessions":{"get":{"operationId":"authListSessions","summary":"List active sessions","description":"Returns all active sessions for the authenticated user. The current session is marked.","tags":["Authentication"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"List of active sessions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListSessionsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/auth/sessions/revoke":{"post":{"operationId":"authRevokeSession","summary":"Revoke a session","description":"Invalidates a specific session, logging out that device. Cannot revoke the current session.","tags":["Authentication"],"security":[{"Bearer":[]}],"requestBody":{"description":"Session ID to revoke","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RevokeSessionRequest"}}}},"responses":{"200":{"description":"Session successfully revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessMessageResponse"}}}},"400":{"description":"Cannot revoke current session","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Session not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/auth/check-username":{"get":{"operationId":"authCheckUsername","summary":"Check username availability","description":"Checks if a username is available for registration.","tags":["Authentication"],"parameters":[{"schema":{"type":"string","minLength":1,"description":"Username to check availability for","example":"johndoe"},"required":true,"description":"Username to check availability for","name":"username","in":"query"}],"responses":{"200":{"description":"Username availability status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CheckUsernameResponse"}}}}}}},"/v1/auth/check-email":{"get":{"operationId":"authCheckEmail","summary":"Check email availability","description":"Checks if an email address is available for registration.","tags":["Authentication"],"parameters":[{"schema":{"type":"string","format":"email","description":"Email address to check availability for","example":"user@example.com"},"required":true,"description":"Email address to check availability for","name":"email","in":"query"}],"responses":{"200":{"description":"Email availability status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CheckEmailResponse"}}}}}}},"/v1/auth/change-email":{"post":{"operationId":"authChangeEmail","summary":"Initiate email change","description":"Starts the email change process by sending verification to the new email. Requires password verification.","tags":["Authentication"],"security":[{"Bearer":[]}],"requestBody":{"description":"New email and current password","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChangeEmailRequest"}}}},"responses":{"200":{"description":"Email change verification sent","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChangeEmailResponse"}}}},"401":{"description":"Not authenticated or invalid password","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailChangeError"}}}},"409":{"description":"New email already in use","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailChangeError"}}}},"429":{"description":"Rate limit exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailChangeError"}}}}}}},"/v1/auth/verify-email-change":{"post":{"operationId":"authVerifyEmailChange","summary":"Complete email change","description":"Completes the email change by verifying the token sent to the new email.","tags":["Authentication"],"requestBody":{"description":"Verification token","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerifyEmailChangeRequest"}}}},"responses":{"200":{"description":"Email successfully changed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerifyEmailChangeResponse"}}}},"400":{"description":"Invalid or expired token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailChangeError"}}}}}}},"/v1/auth/cancel-email-change":{"post":{"operationId":"authCancelEmailChange","summary":"Cancel pending email change","description":"Cancels a pending email change request.","tags":["Authentication"],"requestBody":{"description":"Token from email change request","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CancelEmailChangeRequest"}}}},"responses":{"200":{"description":"Email change request cancelled","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CancelEmailChangeResponse"}}}},"400":{"description":"Invalid token or already completed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailChangeError"}}}}}}},"/v1/auth/impersonate":{"post":{"operationId":"startImpersonation","summary":"Start impersonating a user (admin only)","description":"Allows admins with user.impersonate permission to impersonate another user. Creates a new session for the target user with impersonation metadata. The original admin session is preserved for restoration.","tags":["Auth"],"security":[{"Bearer":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/StartImpersonationRequest"}}}},"responses":{"200":{"description":"Impersonation started successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ImpersonationResponse"}}}},"400":{"description":"Cannot impersonate self","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ImpersonationError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ImpersonationError"}}}},"404":{"description":"Target user not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ImpersonationError"}}}}}}},"/v1/auth/end-impersonation":{"post":{"operationId":"endImpersonation","summary":"End current impersonation session","description":"Ends the current impersonation session and restores the admin to their original session. The impersonation session is deleted and audit logged.","tags":["Auth"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Impersonation ended successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ImpersonationResponse"}}}},"400":{"description":"Not currently impersonating","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ImpersonationError"}}}}}}},"/v1/auth/impersonation-status":{"get":{"operationId":"getImpersonationStatus","summary":"Get current impersonation status","description":"Returns whether the current session is an impersonation session, along with details about who is impersonating whom and why.","tags":["Auth"],"responses":{"200":{"description":"Impersonation status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ImpersonationStatusResponse"}}}}}}},"/v1/auth/oauth/providers":{"get":{"operationId":"oauthListProviders","summary":"List available OAuth providers","description":"Returns a list of OAuth providers configured for the current app.","tags":["OAuth"],"responses":{"200":{"description":"List of available providers","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListProvidersResponse"}}}}}}},"/v1/auth/oauth/{provider}/initiate":{"get":{"operationId":"oauthInitiate","summary":"Start OAuth authentication flow","description":"Generates an OAuth authorization URL and returns it with a state token.","tags":["OAuth"],"parameters":[{"schema":{"$ref":"#/components/schemas/OAuthProvider"},"required":true,"name":"provider","in":"path"},{"schema":{"type":"string","format":"uri","description":"Where to redirect after successful login"},"required":false,"description":"Where to redirect after successful login","name":"redirectUrl","in":"query"},{"schema":{"type":"string","enum":["login","signup","link"],"default":"login","description":"OAuth flow mode"},"required":false,"description":"OAuth flow mode","name":"mode","in":"query"}],"responses":{"200":{"description":"OAuth authorization URL generated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InitiateResponse"}}}},"400":{"description":"Provider not configured","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OAuthError"}}}},"404":{"description":"Provider not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OAuthError"}}}}}}},"/v1/auth/oauth/{provider}/callback":{"get":{"operationId":"oauthCallback","summary":"Handle OAuth provider callback","description":"Processes the callback from the OAuth provider after user authorization. On success, sets a session cookie and redirects to the dashboard. On failure, redirects to the login page with an error message.","tags":["OAuth"],"parameters":[{"schema":{"$ref":"#/components/schemas/OAuthProvider"},"required":true,"name":"provider","in":"path"},{"schema":{"type":"string"},"required":false,"name":"code","in":"query"},{"schema":{"type":"string"},"required":true,"name":"state","in":"query"},{"schema":{"type":"string"},"required":false,"name":"error","in":"query"},{"schema":{"type":"string"},"required":false,"name":"error_description","in":"query"}],"responses":{"302":{"description":"Redirects to dashboard on success or login on failure"},"400":{"description":"Invalid state or code","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OAuthError"}}}},"401":{"description":"OAuth authentication failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OAuthError"}}}}}}},"/v1/auth/oauth/verify-link":{"post":{"operationId":"oauthVerifyLink","summary":"Verify and complete OAuth account linking","description":"Verifies the email code and completes linking an OAuth provider to an existing account. This is required when someone tries to sign in with OAuth using an email that already has an account.","tags":["OAuth"],"requestBody":{"description":"Verification details","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerifyOAuthLinkRequest"}}}},"responses":{"200":{"description":"OAuth link verified and completed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerifyOAuthLinkResponse"}}}},"400":{"description":"Invalid or expired verification code","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OAuthError"}}}},"401":{"description":"Verification failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OAuthError"}}}}}}},"/v1/auth/oauth/link":{"post":{"operationId":"oauthLinkProvider","summary":"Link OAuth provider to existing account","description":"Links an OAuth provider to the currently authenticated user account.","tags":["OAuth"],"requestBody":{"description":"Provider linking details","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LinkProviderRequest"}}}},"responses":{"200":{"description":"Provider linked successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LinkedProvidersResponse"}}}},"400":{"description":"Provider already linked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OAuthError"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OAuthError"}}}},"409":{"description":"Provider already linked to another account","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OAuthError"}}}}}}},"/v1/auth/oauth/unlink":{"post":{"operationId":"oauthUnlinkProvider","summary":"Unlink OAuth provider from account","description":"Removes an OAuth provider link from the currently authenticated user account.","tags":["OAuth"],"requestBody":{"description":"Provider to unlink","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnlinkProviderRequest"}}}},"responses":{"200":{"description":"Provider unlinked successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LinkedProvidersResponse"}}}},"400":{"description":"Cannot unlink last authentication method","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OAuthError"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OAuthError"}}}},"404":{"description":"Provider not linked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OAuthError"}}}}}}},"/v1/auth/oauth/linked":{"get":{"operationId":"oauthGetLinkedProviders","summary":"Get linked OAuth providers","description":"Returns a list of OAuth providers linked to the current user account.","tags":["OAuth"],"responses":{"200":{"description":"List of linked providers","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LinkedProvidersResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OAuthError"}}}}}}},"/v1/auth/admin/health":{"get":{"operationId":"adminGetSystemHealth","summary":"Get system health status","description":"Check the health status of all system components.","tags":["Admin"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"System health status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SystemHealthResponse"}}}}}}},"/v1/auth/admin/oauth/apps":{"get":{"operationId":"adminListOAuthApps","summary":"List all app OAuth configurations","description":"Get OAuth configuration status for all platform apps. Admin only.","tags":["Admin - OAuth"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"App OAuth configs","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListAppOAuthConfigsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}},"403":{"description":"Not an admin","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}}}}},"/v1/auth/admin/oauth/apps/{appId}":{"get":{"operationId":"adminGetOAuthApp","summary":"Get app OAuth configuration","description":"Get detailed OAuth configuration for a specific app. Admin only.","tags":["Admin - OAuth"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"appId","in":"path"}],"responses":{"200":{"description":"App OAuth config","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppOAuthConfig"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}},"403":{"description":"Not an admin","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}},"404":{"description":"App not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}}}}},"/v1/auth/admin/oauth/apps/{appId}/google":{"put":{"operationId":"adminUpdateGoogleOAuth","summary":"Update Google OAuth configuration","description":"Set or update Google OAuth credentials for an app. Admin only.","tags":["Admin - OAuth"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"appId","in":"path"}],"requestBody":{"description":"Google OAuth credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateGoogleConfig"}}}},"responses":{"200":{"description":"Config updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}},"403":{"description":"Not an admin","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}},"404":{"description":"App not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}}}},"delete":{"operationId":"adminRemoveGoogleOAuth","summary":"Remove Google OAuth configuration","description":"Remove Google OAuth credentials from an app. Admin only.","tags":["Admin - OAuth"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"appId","in":"path"}],"responses":{"200":{"description":"Config removed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}},"403":{"description":"Not an admin","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}},"404":{"description":"App not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}}}}},"/v1/auth/admin/oauth/apps/{appId}/apple":{"put":{"operationId":"adminUpdateAppleOAuth","summary":"Update Apple Sign-In configuration","description":"Set or update Apple Sign-In credentials for an app. Admin only.","tags":["Admin - OAuth"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"appId","in":"path"}],"requestBody":{"description":"Apple Sign-In credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateAppleConfig"}}}},"responses":{"200":{"description":"Config updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}},"403":{"description":"Not an admin","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}},"404":{"description":"App not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}}}},"delete":{"operationId":"adminRemoveAppleOAuth","summary":"Remove Apple Sign-In configuration","description":"Remove Apple Sign-In credentials from an app. Admin only.","tags":["Admin - OAuth"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"appId","in":"path"}],"responses":{"200":{"description":"Config removed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}},"403":{"description":"Not an admin","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}},"404":{"description":"App not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}}}}},"/v1/auth/admin/oauth/apps/{appId}/google/test":{"post":{"operationId":"adminTestGoogleOAuth","summary":"Test Google OAuth configuration","description":"Validate Google OAuth credentials are properly configured. Admin only.","tags":["Admin - OAuth"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"appId","in":"path"}],"responses":{"200":{"description":"Test result","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TestOAuthResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}},"403":{"description":"Not an admin","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}},"404":{"description":"App not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminError"}}}}}}},"/v1/auth/admin/users":{"get":{"operationId":"adminGetUserList","summary":"List all users with filtering and pagination","description":"Retrieve a paginated list of all users with comprehensive filtering options.","tags":["Admin"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"integer","exclusiveMinimum":0,"default":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"integer","exclusiveMinimum":0,"maximum":100,"default":20},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","enum":["asc","desc"],"default":"desc"},"required":false,"name":"sortOrder","in":"query"},{"schema":{"type":"string"},"required":false,"name":"search","in":"query"},{"schema":{"type":"string","enum":["active","inactive","suspended","banned"]},"required":false,"name":"status","in":"query"},{"schema":{"type":["boolean","null"]},"required":false,"name":"emailVerified","in":"query"},{"schema":{"type":"string"},"required":false,"name":"organizationId","in":"query"},{"schema":{"type":["boolean","null"]},"required":false,"name":"hasOrganization","in":"query"},{"schema":{"type":"string","enum":["createdAt","email","name","lastSeenAt"],"default":"createdAt"},"required":false,"name":"sortBy","in":"query"}],"responses":{"200":{"description":"Paginated user list","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserListResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Platform operator access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/auth/admin/users/bulk":{"post":{"operationId":"adminBulkUserOperation","summary":"Perform bulk operations on multiple users","description":"Execute the same action on multiple user accounts at once.","tags":["Admin"],"security":[{"Bearer":[]}],"requestBody":{"description":"Bulk operation details","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkUserOperationRequest"}}}},"responses":{"200":{"description":"Bulk operation result","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkUserOperationResponse"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Platform operator access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/auth/admin/users/export":{"get":{"operationId":"adminExportUsers","summary":"Export user data to CSV or JSON","description":"Export user data with the same filters as the list endpoint.","tags":["Admin"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"integer","exclusiveMinimum":0,"default":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"integer","exclusiveMinimum":0,"maximum":100,"default":20},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","enum":["asc","desc"],"default":"desc"},"required":false,"name":"sortOrder","in":"query"},{"schema":{"type":"string"},"required":false,"name":"search","in":"query"},{"schema":{"type":"string","enum":["active","inactive","suspended","banned"]},"required":false,"name":"status","in":"query"},{"schema":{"type":["boolean","null"]},"required":false,"name":"emailVerified","in":"query"},{"schema":{"type":"string"},"required":false,"name":"organizationId","in":"query"},{"schema":{"type":["boolean","null"]},"required":false,"name":"hasOrganization","in":"query"},{"schema":{"type":"string","enum":["createdAt","email","name","lastSeenAt"],"default":"createdAt"},"required":false,"name":"sortBy","in":"query"},{"schema":{"type":"string","enum":["csv","json"],"default":"csv"},"required":false,"name":"format","in":"query"}],"responses":{"200":{"description":"User export file","content":{"text/csv":{"schema":{"type":"string"}},"application/json":{"schema":{"$ref":"#/components/schemas/UserListResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Platform operator access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/auth/admin/users/{id}":{"get":{"operationId":"adminGetUserDetail","summary":"Get detailed user information","description":"Retrieve comprehensive information about a specific user.","tags":["Admin"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"user_123"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"User details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserDetailResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Platform operator access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"User not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/auth/admin/users/{id}/suspend":{"post":{"operationId":"adminSuspendUser","summary":"Suspend a user account","description":"Suspend a user account, preventing login and API access.","tags":["Admin"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"user_123"},"required":true,"name":"id","in":"path"}],"requestBody":{"description":"Suspension details","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuspendUserRequest"}}}},"responses":{"200":{"description":"User suspended successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuspendUserResponse"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Platform operator access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"User not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/auth/admin/users/{id}/unsuspend":{"post":{"operationId":"adminUnsuspendUser","summary":"Restore a suspended user account","description":"Restore access to a previously suspended user account.","tags":["Admin"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"user_123"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"User unsuspended successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuspendUserResponse"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Platform operator access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"User not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/auth/admin/users/{id}/lock":{"post":{"operationId":"adminLockUser","summary":"Lock a user account","description":"Administratively lock a user account, preventing login. Unlike suspension (which sets a status flag), locking sets a lockedUntil timestamp in user metadata. Supports a configurable duration or permanent lock. All active sessions are revoked immediately.","tags":["Admin"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"user_123"},"required":true,"name":"id","in":"path"}],"requestBody":{"description":"Lock details","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LockUserRequest"}}}},"responses":{"200":{"description":"Account locked successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LockUserResponse"}}}},"400":{"description":"Cannot lock your own account","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Platform operator access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"User not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/auth/admin/users/{id}/unlock":{"post":{"operationId":"adminUnlockUser","summary":"Unlock a locked user account","description":"Remove an administrative or automatic lockout from a user account, restoring their ability to log in. Does not restore suspended accounts — use /unsuspend for that.","tags":["Admin"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"user_123"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Account unlocked successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LockUserResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Platform operator access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"User not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/auth/admin/users/{userId}/devices":{"get":{"operationId":"adminGetUserDevices","summary":"Get devices for a specific user","description":"Retrieve a list of devices associated with a user.","tags":["Admin"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"user_123"},"required":true,"name":"userId","in":"path"},{"schema":{"type":"integer","exclusiveMinimum":0,"default":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"integer","exclusiveMinimum":0,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"User devices list","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserDevicesListResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Platform operator access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"User not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/auth/admin/users/{userId}/devices/{deviceId}":{"delete":{"operationId":"adminRevokeUserDevice","summary":"Revoke a specific device for a user","description":"Revoke access for a specific device belonging to a user.","tags":["Admin"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"user_123"},"required":true,"name":"userId","in":"path"},{"schema":{"type":"string","example":"device_456"},"required":true,"name":"deviceId","in":"path"}],"responses":{"200":{"description":"Device revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RevokeUserDeviceResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Platform operator access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"User or device not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/auth/admin/users/{userId}/security-events":{"get":{"operationId":"adminGetUserSecurityEvents","summary":"Get security events for a specific user","description":"Retrieve security events associated with a user.","tags":["Admin"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"user_123"},"required":true,"name":"userId","in":"path"},{"schema":{"type":"integer","exclusiveMinimum":0,"default":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"integer","exclusiveMinimum":0,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","enum":["low","medium","high","critical"]},"required":false,"name":"severity","in":"query"}],"responses":{"200":{"description":"User security events list","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserSecurityEventsListResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Platform operator access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"User not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/auth/admin/users/{userId}/sessions/revoke":{"post":{"operationId":"adminRevokeUserSessions","summary":"Revoke all sessions for a user","description":"Revoke all active sessions for a user, forcing them to re-authenticate.","tags":["Admin"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"user_123"},"required":true,"name":"userId","in":"path"}],"responses":{"200":{"description":"Sessions revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RevokeUserSessionsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Platform operator access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"User not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/auth/admin/rbac/roles":{"get":{"operationId":"listAdminRoles","summary":"List roles","description":"List all roles with filtering and pagination (super admin only)","tags":["Admin","RBAC"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"integer","exclusiveMinimum":0,"default":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string"},"required":false,"name":"search","in":"query"},{"schema":{"type":["boolean","null"],"default":true},"required":false,"name":"includeSystem","in":"query"},{"schema":{"type":"string"},"required":false,"name":"organizationId","in":"query"}],"responses":{"200":{"description":"Roles retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListRolesResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"post":{"operationId":"createAdminRole","summary":"Create role","description":"Create a new role (super admin only)","tags":["Admin","RBAC"],"security":[{"Bearer":[]}],"requestBody":{"description":"Role details","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateRoleRequest"}}}},"responses":{"201":{"description":"Role created successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateRoleResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"409":{"description":"Resource already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/auth/admin/rbac/roles/{roleId}":{"get":{"operationId":"getAdminRole","summary":"Get role details","description":"Get a single role by ID with permissions (super admin only)","tags":["Admin","RBAC"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"role_abc123"},"required":true,"name":"roleId","in":"path"}],"responses":{"200":{"description":"Role retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetRoleResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"patch":{"operationId":"updateAdminRole","summary":"Update role","description":"Update an existing role (super admin only)","tags":["Admin","RBAC"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"role_abc123"},"required":true,"name":"roleId","in":"path"}],"requestBody":{"description":"Updated role details","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateRoleRequest"}}}},"responses":{"200":{"description":"Role updated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateRoleResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"delete":{"operationId":"deleteAdminRole","summary":"Delete role","description":"Delete a role (super admin only, cannot delete system roles)","tags":["Admin","RBAC"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"role_abc123"},"required":true,"name":"roleId","in":"path"}],"responses":{"200":{"description":"Role deleted successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeleteRoleResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/auth/admin/rbac/permissions":{"get":{"operationId":"listAdminPermissions","summary":"List permissions","description":"List all available permissions (super admin only)","tags":["Admin","RBAC"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string"},"required":false,"name":"resource","in":"query"},{"schema":{"type":"string"},"required":false,"name":"action","in":"query"}],"responses":{"200":{"description":"Permissions retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListPermissionsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/auth/admin/rbac/users/assign":{"post":{"operationId":"assignUserRole","summary":"Assign role to user","description":"Assign a role to a user (super admin only)","tags":["Admin","RBAC"],"security":[{"Bearer":[]}],"requestBody":{"description":"Role assignment details","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AssignRoleRequest"}}}},"responses":{"200":{"description":"Role assigned successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AssignRoleResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"409":{"description":"Resource already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/auth/admin/rbac/users/remove":{"post":{"operationId":"removeUserRole","summary":"Remove role from user","description":"Remove a role from a user (super admin only)","tags":["Admin","RBAC"],"security":[{"Bearer":[]}],"requestBody":{"description":"Role removal details","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RemoveRoleRequest"}}}},"responses":{"200":{"description":"Role removed successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AssignRoleResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/auth/admin/rbac/users/{userId}/roles":{"get":{"operationId":"getUserRoles","summary":"Get user roles","description":"Get all roles assigned to a user (super admin only)","tags":["Admin","RBAC"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"user_abc123"},"required":true,"name":"userId","in":"path"}],"responses":{"200":{"description":"User roles retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserRolesResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/auth/admin/organizations":{"get":{"operationId":"adminGetOrganizationList","summary":"List all organizations","description":"Retrieve a paginated list of all organizations with statistics.","tags":["Admin","Organizations"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"integer","exclusiveMinimum":0,"default":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"integer","exclusiveMinimum":0,"maximum":100,"default":20},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","enum":["asc","desc"],"default":"desc"},"required":false,"name":"sortOrder","in":"query"},{"schema":{"type":"string"},"required":false,"name":"search","in":"query"},{"schema":{"type":"string","enum":["free","starter","professional","enterprise"]},"required":false,"name":"plan","in":"query"},{"schema":{"type":"string","enum":["active","suspended","cancelled"]},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","enum":["createdAt","name","memberCount"],"default":"createdAt"},"required":false,"name":"sortBy","in":"query"}],"responses":{"200":{"description":"Paginated organization list with stats","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationListResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}},"403":{"description":"Super admin access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}}}}},"/v1/auth/admin/organizations/{organizationId}":{"get":{"operationId":"adminGetOrganizationDetail","summary":"Get organization details (admin)","description":"Retrieve detailed information about any organization as a platform administrator.","tags":["Admin","Organizations"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"org_123"},"required":true,"name":"organizationId","in":"path"}],"responses":{"200":{"description":"Organization details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}},"403":{"description":"Super admin access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}},"404":{"description":"Organization not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}}}},"patch":{"operationId":"adminUpdateOrganization","summary":"Update organization (admin)","description":"Update organization details as a platform administrator.","tags":["Admin","Organizations"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"org_123"},"required":true,"name":"organizationId","in":"path"}],"requestBody":{"description":"Organization updates","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminUpdateOrganizationRequest"}}}},"responses":{"200":{"description":"Organization updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminUpdateOrganizationResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}},"403":{"description":"Super admin access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}},"404":{"description":"Organization not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}}}}},"/v1/auth/admin/organizations/{organizationId}/status":{"patch":{"operationId":"adminUpdateOrganizationStatus","summary":"Update organization status (admin)","description":"Suspend or activate an organization as a platform administrator.","tags":["Admin","Organizations"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"org_123"},"required":true,"name":"organizationId","in":"path"}],"requestBody":{"description":"New status for organization","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminUpdateOrganizationStatusRequest"}}}},"responses":{"200":{"description":"Organization status updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminUpdateOrganizationResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}},"403":{"description":"Super admin access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}},"404":{"description":"Organization not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}}}}},"/v1/auth/admin/organizations/{organizationId}/byok-settings":{"get":{"operationId":"adminGetByokSettings","summary":"Get BYOK settings for organization","description":"Retrieve BYOK (Bring Your Own Key) settings for an organization as a platform administrator.","tags":["Admin","Organizations"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"org_123"},"required":true,"name":"organizationId","in":"path"}],"responses":{"200":{"description":"BYOK settings","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ByokSettingsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}},"403":{"description":"Super admin access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}},"404":{"description":"Organization not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}}}},"patch":{"operationId":"adminUpdateByokSettings","summary":"Update BYOK settings for organization","description":"Enable or disable BYOK and configure allowed providers for an organization as a platform administrator.","tags":["Admin","Organizations"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"org_123"},"required":true,"name":"organizationId","in":"path"}],"requestBody":{"description":"BYOK settings updates","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateByokSettingsRequest"}}}},"responses":{"200":{"description":"BYOK settings updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ByokSettingsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}},"403":{"description":"Super admin access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}},"404":{"description":"Organization not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}}}}},"/v1/auth/admin/organizations/{organizationId}/members":{"get":{"operationId":"adminGetOrganizationMembers","summary":"List organization members (admin)","description":"Retrieve a list of members for any organization as a platform administrator.","tags":["Admin","Organizations"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"org_123"},"required":true,"name":"organizationId","in":"path"},{"schema":{"type":"string"},"required":false,"name":"search","in":"query"},{"schema":{"type":"string","enum":["owner","admin","member","viewer"]},"required":false,"name":"role","in":"query"},{"schema":{"type":"number","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":["number","null"],"minimum":0,"default":0},"required":false,"name":"offset","in":"query"}],"responses":{"200":{"description":"List of organization members","content":{"application/json":{"schema":{"type":"object","properties":{"members":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"role":{"type":"string"},"permissions":{"type":["array","null"],"items":{"type":"string"}},"user":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":["string","null"]},"displayName":{"type":["string","null"]},"avatar":{"type":["string","null"]}},"required":["id","email","displayName","avatar"]},"joinedAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","role","permissions","user","joinedAt","updatedAt"]}},"total":{"type":"number"},"limit":{"type":"number"},"offset":{"type":"number"}},"required":["members","total","limit","offset"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}},"403":{"description":"Super admin access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}},"404":{"description":"Organization not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}}}}},"/v1/auth/admin/organizations/{organizationId}/apps":{"get":{"operationId":"adminGetOrganizationApps","summary":"List organization apps (admin)","description":"Retrieve a list of apps granted to an organization. Note: This is a stub - apps feature is not yet implemented.","tags":["Admin","Organizations"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"org_123"},"required":true,"name":"organizationId","in":"path"}],"responses":{"200":{"description":"List of organization apps","content":{"application/json":{"schema":{"type":"object","properties":{"apps":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"description":{"type":["string","null"]},"icon":{"type":["string","null"]},"grantedAt":{"type":"string"}},"required":["id","name","slug","description","icon","grantedAt"]}},"total":{"type":"number"}},"required":["apps","total"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}},"403":{"description":"Super admin access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrganizationsError"}}}}}}},"/v1/auth/admin/service-api-keys":{"get":{"operationId":"listServiceApiKeys","summary":"List platform service API keys","description":"List all platform-level third-party service API keys (super admin only)","tags":["Admin","Service API Keys"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","enum":["openai","anthropic","google_ai","elevenlabs","playht","veo","pika","runway","sendgrid","resend","stripe","dropbox","google_drive","onedrive","box","cloudflare_stream","cloudflare_realtime","cloudflare_r2","cloudflare_images","deepgram","mapbox","custom"]},"required":false,"name":"provider","in":"query"},{"schema":{"type":"string"},"required":false,"name":"environment","in":"query"},{"schema":{"type":"string"},"required":false,"name":"isActive","in":"query"}],"responses":{"200":{"description":"Service API keys list","content":{"application/json":{"schema":{"type":"object","properties":{"keys":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"provider":{"type":"string","enum":["openai","anthropic","google_ai","elevenlabs","playht","veo","pika","runway","sendgrid","resend","stripe","dropbox","google_drive","onedrive","box","cloudflare_stream","cloudflare_realtime","cloudflare_r2","cloudflare_images","deepgram","mapbox","custom"]},"environment":{"type":["string","null"]},"name":{"type":["string","null"]},"keyPrefix":{"type":["string","null"]},"isActive":{"type":"boolean"},"lastUsedAt":{"type":["number","null"]},"lastValidatedAt":{"type":["number","null"]},"validationStatus":{"type":["string","null"]},"usageCount":{"type":"number"},"createdAt":{"type":"number"},"updatedAt":{"type":"number"}},"required":["id","provider","environment","name","keyPrefix","isActive","lastUsedAt","lastValidatedAt","validationStatus","usageCount","createdAt","updatedAt"]}},"total":{"type":"number"}},"required":["keys","total"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Super admin access required","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}},"post":{"operationId":"createServiceApiKey","summary":"Create platform service API key","description":"Create a new platform-level service API key. The key value is encrypted.","tags":["Admin","Service API Keys"],"security":[{"Bearer":[]}],"requestBody":{"description":"Service API key data","required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"provider":{"type":"string","enum":["openai","anthropic","google_ai","elevenlabs","playht","veo","pika","runway","sendgrid","resend","stripe","dropbox","google_drive","onedrive","box","cloudflare_stream","cloudflare_realtime","cloudflare_r2","cloudflare_images","deepgram","mapbox","custom"]},"value":{"type":"string","minLength":1},"environment":{"type":"string"},"name":{"type":"string","maxLength":100},"metadata":{"type":"object","additionalProperties":{}}},"required":["provider","value"]}}}},"responses":{"201":{"description":"Service API key created","content":{"application/json":{"schema":{"type":"object","properties":{"key":{"type":"object","properties":{"id":{"type":"string"},"provider":{"type":"string","enum":["openai","anthropic","google_ai","elevenlabs","playht","veo","pika","runway","sendgrid","resend","stripe","dropbox","google_drive","onedrive","box","cloudflare_stream","cloudflare_realtime","cloudflare_r2","cloudflare_images","deepgram","mapbox","custom"]},"environment":{"type":["string","null"]},"name":{"type":["string","null"]},"keyPrefix":{"type":["string","null"]},"isActive":{"type":"boolean"},"lastUsedAt":{"type":["number","null"]},"lastValidatedAt":{"type":["number","null"]},"validationStatus":{"type":["string","null"]},"usageCount":{"type":"number"},"createdAt":{"type":"number"},"updatedAt":{"type":"number"}},"required":["id","provider","environment","name","keyPrefix","isActive","lastUsedAt","lastValidatedAt","validationStatus","usageCount","createdAt","updatedAt"]},"message":{"type":"string"}},"required":["key","message"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Super admin access required","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}}},"/v1/auth/admin/service-api-keys/{keyId}":{"get":{"operationId":"getServiceApiKey","summary":"Get service API key","description":"Get details for a specific service API key (super admin only)","tags":["Admin","Service API Keys"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"sak_abc123"},"required":true,"name":"keyId","in":"path"}],"responses":{"200":{"description":"Service API key details","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"provider":{"type":"string","enum":["openai","anthropic","google_ai","elevenlabs","playht","veo","pika","runway","sendgrid","resend","stripe","dropbox","google_drive","onedrive","box","cloudflare_stream","cloudflare_realtime","cloudflare_r2","cloudflare_images","deepgram","mapbox","custom"]},"environment":{"type":["string","null"]},"name":{"type":["string","null"]},"keyPrefix":{"type":["string","null"]},"isActive":{"type":"boolean"},"lastUsedAt":{"type":["number","null"]},"lastValidatedAt":{"type":["number","null"]},"validationStatus":{"type":["string","null"]},"usageCount":{"type":"number"},"createdAt":{"type":"number"},"updatedAt":{"type":"number"}},"required":["id","provider","environment","name","keyPrefix","isActive","lastUsedAt","lastValidatedAt","validationStatus","usageCount","createdAt","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Super admin access required","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"404":{"description":"Key not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}},"patch":{"operationId":"updateServiceApiKey","summary":"Update service API key","description":"Update an existing service API key. Use this to rotate keys or update metadata.","tags":["Admin","Service API Keys"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"sak_abc123"},"required":true,"name":"keyId","in":"path"}],"requestBody":{"description":"Updated service API key data","required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","maxLength":100},"value":{"type":"string","minLength":1},"isActive":{"type":"boolean"},"metadata":{"type":"object","additionalProperties":{}}}}}}},"responses":{"200":{"description":"Service API key updated","content":{"application/json":{"schema":{"type":"object","properties":{"key":{"type":"object","properties":{"id":{"type":"string"},"provider":{"type":"string","enum":["openai","anthropic","google_ai","elevenlabs","playht","veo","pika","runway","sendgrid","resend","stripe","dropbox","google_drive","onedrive","box","cloudflare_stream","cloudflare_realtime","cloudflare_r2","cloudflare_images","deepgram","mapbox","custom"]},"environment":{"type":["string","null"]},"name":{"type":["string","null"]},"keyPrefix":{"type":["string","null"]},"isActive":{"type":"boolean"},"lastUsedAt":{"type":["number","null"]},"lastValidatedAt":{"type":["number","null"]},"validationStatus":{"type":["string","null"]},"usageCount":{"type":"number"},"createdAt":{"type":"number"},"updatedAt":{"type":"number"}},"required":["id","provider","environment","name","keyPrefix","isActive","lastUsedAt","lastValidatedAt","validationStatus","usageCount","createdAt","updatedAt"]},"message":{"type":"string"}},"required":["key","message"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Super admin access required","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"404":{"description":"Key not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}},"delete":{"operationId":"deleteServiceApiKey","summary":"Delete service API key","description":"Permanently delete a platform service API key","tags":["Admin","Service API Keys"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"sak_abc123"},"required":true,"name":"keyId","in":"path"}],"responses":{"200":{"description":"Service API key deleted","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"}},"required":["success","message"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Super admin access required","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"404":{"description":"Key not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}}},"/v1/auth/admin/service-api-keys/{keyId}/validate":{"post":{"operationId":"validateServiceApiKey","summary":"Validate service API key","description":"Test a service API key against the provider to verify it works","tags":["Admin","Service API Keys"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"sak_abc123"},"required":true,"name":"keyId","in":"path"}],"responses":{"200":{"description":"Validation result","content":{"application/json":{"schema":{"type":"object","properties":{"isValid":{"type":"boolean"},"error":{"type":["string","null"]},"validatedAt":{"type":["string","null"]},"canValidate":{"type":"boolean"},"message":{"type":["string","null"]}},"required":["isValid","error","validatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Super admin access required","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"404":{"description":"Key not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}}},"/v1/auth/admin/reserved-names/export":{"get":{"operationId":"exportReservedNames","summary":"Export reserved names","description":"Export all reserved names as JSON or CSV","tags":["Admin","Reserved Names"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","enum":["json","csv"],"default":"json"},"required":false,"name":"format","in":"query"}],"responses":{"200":{"description":"Export data","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"normalizedName":{"type":"string"},"type":{"type":"string","enum":["username","organization","project","subdomain","slug","all"]},"category":{"type":"string","enum":["system","offensive","brand","legal","security","custom"]},"matchType":{"type":"string","enum":["exact","prefix","suffix","contains","regex"]},"regexPattern":{"type":["string","null"]},"reason":{"type":"string"},"severity":{"type":"string","enum":["block","warn"]},"isActive":{"type":"boolean"},"organizationId":{"type":["string","null"]},"effectiveFrom":{"type":["number","null"]},"expiresAt":{"type":["number","null"]},"blockCount":{"type":"number"},"createdBy":{"type":"string"},"createdAt":{"type":"number"},"updatedBy":{"type":["string","null"]},"updatedAt":{"type":["number","null"]}},"required":["id","name","normalizedName","type","category","matchType","regexPattern","reason","severity","isActive","organizationId","effectiveFrom","expiresAt","blockCount","createdBy","createdAt","updatedBy","updatedAt"]}}},"text/csv":{"schema":{"type":"string"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}}},"/v1/auth/admin/reserved-names/bulk":{"post":{"operationId":"bulkImportReservedNames","summary":"Bulk import reserved names","description":"Import multiple reserved names at once","tags":["Admin","Reserved Names"],"security":[{"Bearer":[]}],"requestBody":{"description":"Import data","required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100,"description":"The name or pattern to reserve"},"type":{"type":"string","enum":["username","organization","project","subdomain","slug","all"],"description":"What type of name this applies to"},"category":{"type":"string","enum":["system","offensive","brand","legal","security","custom"],"default":"custom","description":"Category for organization"},"matchType":{"type":"string","enum":["exact","prefix","suffix","contains","regex"],"default":"exact","description":"How to match the name"},"reason":{"type":"string","minLength":1,"maxLength":500,"description":"Why this name is reserved (required for audit)"},"severity":{"type":"string","enum":["block","warn"],"default":"block","description":"Action to take when matched"},"effectiveFrom":{"type":["number","null"],"description":"Unix timestamp when this rule becomes effective"},"expiresAt":{"type":["number","null"],"description":"Unix timestamp when this rule expires"}},"required":["name","type","reason"]},"minItems":1,"maxItems":1000,"description":"Items to import"},"skipDuplicates":{"type":"boolean","default":true,"description":"Skip duplicates instead of failing"}},"required":["items"]}}}},"responses":{"200":{"description":"Import results","content":{"application/json":{"schema":{"type":"object","properties":{"imported":{"type":"number"},"skipped":{"type":"number"},"errors":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"error":{"type":"string"}},"required":["name","error"]}}},"required":["imported","skipped","errors"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}},"delete":{"operationId":"bulkDeleteReservedNames","summary":"Bulk delete reserved names","description":"Delete multiple reserved names at once","tags":["Admin","Reserved Names"],"security":[{"Bearer":[]}],"requestBody":{"description":"Delete data","required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"ids":{"type":"array","items":{"type":"string"},"minItems":1,"maxItems":100,"description":"IDs to delete"},"reason":{"type":"string","description":"Reason for deletion"}},"required":["ids"]}}}},"responses":{"200":{"description":"Delete results","content":{"application/json":{"schema":{"type":"object","properties":{"deleted":{"type":"number"}},"required":["deleted"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}}},"/v1/auth/admin/reserved-names/validate":{"post":{"operationId":"validateReservedName","summary":"Validate a name","description":"Check if a name is reserved and get suggestions","tags":["Admin","Reserved Names"],"security":[{"Bearer":[]}],"requestBody":{"description":"Name to validate","required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"description":"Name to validate"},"type":{"type":"string","enum":["username","organization","project","subdomain","slug","all"],"description":"Type of name being validated"},"organizationId":{"type":"string","description":"Organization context"}},"required":["name","type"]}}}},"responses":{"200":{"description":"Validation result","content":{"application/json":{"schema":{"type":"object","properties":{"isReserved":{"type":"boolean"},"reason":{"type":"string"},"matchedRule":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"category":{"type":"string"},"matchType":{"type":"string"}},"required":["id","name","category","matchType"]},"warnings":{"type":"array","items":{"type":"string"}},"normalized":{"type":"string"},"suggestions":{"type":"array","items":{"type":"string"}}},"required":["isReserved"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}}},"/v1/auth/admin/reserved-names/analytics/dashboard":{"get":{"operationId":"getReservedNamesDashboardStats","summary":"Get dashboard statistics","description":"Get statistics for the reserved names dashboard","tags":["Admin","Reserved Names"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Dashboard statistics","content":{"application/json":{"schema":{"type":"object","properties":{"totalReserved":{"type":"number"},"activeReserved":{"type":"number"},"categoryBreakdown":{"type":"object","additionalProperties":{"type":"number"}},"blockedAttempts":{"type":"object","properties":{"today":{"type":"number"},"thisWeek":{"type":"number"},"thisMonth":{"type":"number"}},"required":["today","thisWeek","thisMonth"]},"topBlocked":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"count":{"type":"number"},"category":{"type":["string","null"]}},"required":["name","count","category"]}},"recentAttempts":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"attemptedName":{"type":"string"},"normalizedName":{"type":"string"},"nameType":{"type":"string"},"matchedCategory":{"type":["string","null"]},"ipAddress":{"type":["string","null"]},"blockedAt":{"type":"number"}},"required":["id","attemptedName","normalizedName","nameType","matchedCategory","ipAddress","blockedAt"]}}},"required":["totalReserved","activeReserved","categoryBreakdown","blockedAttempts","topBlocked","recentAttempts"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}}},"/v1/auth/admin/reserved-names/analytics/blocked":{"get":{"operationId":"getBlockedAttempts","summary":"Get blocked attempts","description":"Get a paginated list of blocked name attempts","tags":["Admin","Reserved Names"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":["number","null"]},"required":false,"name":"startDate","in":"query"},{"schema":{"type":["number","null"]},"required":false,"name":"endDate","in":"query"},{"schema":{"type":"string"},"required":false,"name":"category","in":"query"},{"schema":{"type":"string"},"required":false,"name":"nameType","in":"query"},{"schema":{"type":"string"},"required":false,"name":"search","in":"query"},{"schema":{"type":"number","minimum":1,"default":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"number","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"Blocked attempts list","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"attemptedName":{"type":"string"},"normalizedName":{"type":"string"},"nameType":{"type":"string"},"matchedRuleId":{"type":["string","null"]},"matchedRuleName":{"type":["string","null"]},"matchedCategory":{"type":["string","null"]},"matchType":{"type":["string","null"]},"ipAddress":{"type":["string","null"]},"userAgent":{"type":["string","null"]},"userId":{"type":["string","null"]},"containsHomoglyphs":{"type":"boolean"},"containsLeetspeak":{"type":"boolean"},"blockedAt":{"type":"number"}},"required":["id","attemptedName","normalizedName","nameType","matchedRuleId","matchedRuleName","matchedCategory","matchType","ipAddress","userAgent","userId","containsHomoglyphs","containsLeetspeak","blockedAt"]}},"total":{"type":"number"},"page":{"type":"number"},"limit":{"type":"number"}},"required":["items","total","page","limit"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}}},"/v1/auth/admin/reserved-names/analytics/timeseries":{"get":{"operationId":"getReservedNamesTimeseries","summary":"Get blocked attempts time series","description":"Get time series data for blocked attempts","tags":["Admin","Reserved Names"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":["number","null"]},"required":false,"name":"startDate","in":"query"},{"schema":{"type":["number","null"]},"required":false,"name":"endDate","in":"query"},{"schema":{"type":"string","enum":["hour","day","week"],"default":"day"},"required":false,"name":"interval","in":"query"}],"responses":{"200":{"description":"Time series data","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","properties":{"period":{"type":"string"},"count":{"type":"number"}},"required":["period","count"]}}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}}},"/v1/auth/admin/reserved-names/analytics/attacks":{"get":{"operationId":"getAttackPatterns","summary":"Get attack pattern analysis","description":"Analyze attack patterns from blocked attempts","tags":["Admin","Reserved Names"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Attack pattern analysis","content":{"application/json":{"schema":{"type":"object","properties":{"suspiciousIps":{"type":"array","items":{"type":"object","properties":{"ipAddress":{"type":["string","null"]},"attemptCount":{"type":"number"},"uniqueNames":{"type":"number"},"firstSeen":{"type":"number"},"lastSeen":{"type":"number"}},"required":["ipAddress","attemptCount","uniqueNames","firstSeen","lastSeen"]}},"obfuscationAttempts":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string"},"count":{"type":"number"}},"required":["type","count"]}}},"required":["suspiciousIps","obfuscationAttempts"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}}},"/v1/auth/admin/reserved-names/analytics/export":{"get":{"operationId":"exportBlockedAttempts","summary":"Export blocked attempts","description":"Export blocked attempts as CSV or JSON","tags":["Admin","Reserved Names"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":["number","null"]},"required":false,"name":"startDate","in":"query"},{"schema":{"type":["number","null"]},"required":false,"name":"endDate","in":"query"},{"schema":{"type":"string","enum":["csv","json"],"default":"csv"},"required":false,"name":"format","in":"query"}],"responses":{"200":{"description":"Export data","content":{"application/json":{"schema":{"type":"array","items":{}}},"text/csv":{"schema":{"type":"string"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}}},"/v1/auth/admin/reserved-names":{"get":{"operationId":"listReservedNames","summary":"List reserved names","description":"Get a paginated list of reserved names with filtering and sorting","tags":["Admin","Reserved Names"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","description":"Search by name"},"required":false,"description":"Search by name","name":"search","in":"query"},{"schema":{"type":"string","enum":["username","organization","project","subdomain","slug","all"],"description":"Filter by type"},"required":false,"description":"Filter by type","name":"type","in":"query"},{"schema":{"type":"string","enum":["system","offensive","brand","legal","security","custom"],"description":"Filter by category"},"required":false,"description":"Filter by category","name":"category","in":"query"},{"schema":{"type":["boolean","null"],"description":"Filter by active status"},"required":false,"description":"Filter by active status","name":"isActive","in":"query"},{"schema":{"type":"number","minimum":1,"default":1,"description":"Page number"},"required":false,"description":"Page number","name":"page","in":"query"},{"schema":{"type":"number","minimum":1,"maximum":100,"default":50,"description":"Items per page"},"required":false,"description":"Items per page","name":"limit","in":"query"},{"schema":{"type":"string","enum":["name","createdAt","blockCount"],"default":"name","description":"Sort field"},"required":false,"description":"Sort field","name":"sortBy","in":"query"},{"schema":{"type":"string","enum":["asc","desc"],"default":"asc","description":"Sort order"},"required":false,"description":"Sort order","name":"sortOrder","in":"query"}],"responses":{"200":{"description":"Reserved names list","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"normalizedName":{"type":"string"},"type":{"type":"string","enum":["username","organization","project","subdomain","slug","all"]},"category":{"type":"string","enum":["system","offensive","brand","legal","security","custom"]},"matchType":{"type":"string","enum":["exact","prefix","suffix","contains","regex"]},"regexPattern":{"type":["string","null"]},"reason":{"type":"string"},"severity":{"type":"string","enum":["block","warn"]},"isActive":{"type":"boolean"},"organizationId":{"type":["string","null"]},"effectiveFrom":{"type":["number","null"]},"expiresAt":{"type":["number","null"]},"blockCount":{"type":"number"},"createdBy":{"type":"string"},"createdAt":{"type":"number"},"updatedBy":{"type":["string","null"]},"updatedAt":{"type":["number","null"]}},"required":["id","name","normalizedName","type","category","matchType","regexPattern","reason","severity","isActive","organizationId","effectiveFrom","expiresAt","blockCount","createdBy","createdAt","updatedBy","updatedAt"]}},"total":{"type":"number"},"page":{"type":"number"},"limit":{"type":"number"},"hasMore":{"type":"boolean"}},"required":["items","total","page","limit","hasMore"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}},"post":{"operationId":"createReservedName","summary":"Create reserved name","description":"Create a new reserved name rule","tags":["Admin","Reserved Names"],"security":[{"Bearer":[]}],"requestBody":{"description":"Reserved name data","required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100,"description":"The name or pattern to reserve"},"type":{"type":"string","enum":["username","organization","project","subdomain","slug","all"],"description":"What type of name this applies to"},"category":{"type":"string","enum":["system","offensive","brand","legal","security","custom"],"default":"custom","description":"Category for organization"},"matchType":{"type":"string","enum":["exact","prefix","suffix","contains","regex"],"default":"exact","description":"How to match the name"},"reason":{"type":"string","minLength":1,"maxLength":500,"description":"Why this name is reserved (required for audit)"},"severity":{"type":"string","enum":["block","warn"],"default":"block","description":"Action to take when matched"},"effectiveFrom":{"type":["number","null"],"description":"Unix timestamp when this rule becomes effective"},"expiresAt":{"type":["number","null"],"description":"Unix timestamp when this rule expires"}},"required":["name","type","reason"]}}}},"responses":{"201":{"description":"Reserved name created","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"normalizedName":{"type":"string"},"type":{"type":"string","enum":["username","organization","project","subdomain","slug","all"]},"category":{"type":"string","enum":["system","offensive","brand","legal","security","custom"]},"matchType":{"type":"string","enum":["exact","prefix","suffix","contains","regex"]},"regexPattern":{"type":["string","null"]},"reason":{"type":"string"},"severity":{"type":"string","enum":["block","warn"]},"isActive":{"type":"boolean"},"organizationId":{"type":["string","null"]},"effectiveFrom":{"type":["number","null"]},"expiresAt":{"type":["number","null"]},"blockCount":{"type":"number"},"createdBy":{"type":"string"},"createdAt":{"type":"number"},"updatedBy":{"type":["string","null"]},"updatedAt":{"type":["number","null"]}},"required":["id","name","normalizedName","type","category","matchType","regexPattern","reason","severity","isActive","organizationId","effectiveFrom","expiresAt","blockCount","createdBy","createdAt","updatedBy","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"409":{"description":"Resource already exists","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}}},"/v1/auth/admin/reserved-names/{id}":{"get":{"operationId":"getReservedName","summary":"Get reserved name","description":"Get details for a specific reserved name","tags":["Admin","Reserved Names"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"rsv_abc123"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Reserved name details","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"normalizedName":{"type":"string"},"type":{"type":"string","enum":["username","organization","project","subdomain","slug","all"]},"category":{"type":"string","enum":["system","offensive","brand","legal","security","custom"]},"matchType":{"type":"string","enum":["exact","prefix","suffix","contains","regex"]},"regexPattern":{"type":["string","null"]},"reason":{"type":"string"},"severity":{"type":"string","enum":["block","warn"]},"isActive":{"type":"boolean"},"organizationId":{"type":["string","null"]},"effectiveFrom":{"type":["number","null"]},"expiresAt":{"type":["number","null"]},"blockCount":{"type":"number"},"createdBy":{"type":"string"},"createdAt":{"type":"number"},"updatedBy":{"type":["string","null"]},"updatedAt":{"type":["number","null"]}},"required":["id","name","normalizedName","type","category","matchType","regexPattern","reason","severity","isActive","organizationId","effectiveFrom","expiresAt","blockCount","createdBy","createdAt","updatedBy","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}},"patch":{"operationId":"updateReservedName","summary":"Update reserved name","description":"Update an existing reserved name rule","tags":["Admin","Reserved Names"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"rsv_abc123"},"required":true,"name":"id","in":"path"}],"requestBody":{"description":"Updated reserved name data","required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100,"description":"The name or pattern to reserve"},"type":{"type":"string","enum":["username","organization","project","subdomain","slug","all"],"description":"What type of name this applies to"},"category":{"type":"string","enum":["system","offensive","brand","legal","security","custom"],"default":"custom","description":"Category for organization"},"matchType":{"type":"string","enum":["exact","prefix","suffix","contains","regex"],"default":"exact","description":"How to match the name"},"reason":{"type":"string","minLength":1,"maxLength":500,"description":"Why this name is reserved (required for audit)"},"severity":{"type":"string","enum":["block","warn"],"default":"block","description":"Action to take when matched"},"effectiveFrom":{"type":["number","null"],"description":"Unix timestamp when this rule becomes effective"},"expiresAt":{"type":["number","null"],"description":"Unix timestamp when this rule expires"},"isActive":{"type":"boolean","description":"Whether this rule is active"}}}}}},"responses":{"200":{"description":"Reserved name updated","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"normalizedName":{"type":"string"},"type":{"type":"string","enum":["username","organization","project","subdomain","slug","all"]},"category":{"type":"string","enum":["system","offensive","brand","legal","security","custom"]},"matchType":{"type":"string","enum":["exact","prefix","suffix","contains","regex"]},"regexPattern":{"type":["string","null"]},"reason":{"type":"string"},"severity":{"type":"string","enum":["block","warn"]},"isActive":{"type":"boolean"},"organizationId":{"type":["string","null"]},"effectiveFrom":{"type":["number","null"]},"expiresAt":{"type":["number","null"]},"blockCount":{"type":"number"},"createdBy":{"type":"string"},"createdAt":{"type":"number"},"updatedBy":{"type":["string","null"]},"updatedAt":{"type":["number","null"]}},"required":["id","name","normalizedName","type","category","matchType","regexPattern","reason","severity","isActive","organizationId","effectiveFrom","expiresAt","blockCount","createdBy","createdAt","updatedBy","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}},"delete":{"operationId":"deleteReservedName","summary":"Delete reserved name","description":"Soft delete a reserved name rule","tags":["Admin","Reserved Names"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"rsv_abc123"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Reserved name deleted","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"}},"required":["success"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}}},"/v1/auth/admin/reserved-names/{id}/audit":{"get":{"operationId":"getReservedNameAuditLog","summary":"Get audit log","description":"Get the audit log for a specific reserved name","tags":["Admin","Reserved Names"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"rsv_abc123"},"required":true,"name":"id","in":"path"},{"schema":{"type":"number","minimum":1,"default":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"number","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"Audit log entries","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"reservedNameId":{"type":"string"},"action":{"type":"string","enum":["created","updated","deleted","restored","activated","deactivated","bulk_imported","bulk_deleted"]},"previousValues":{"type":["object","null"],"additionalProperties":{}},"newValues":{"type":["object","null"],"additionalProperties":{}},"changedFields":{"type":["array","null"],"items":{"type":"string"}},"performedBy":{"type":"string"},"performedAt":{"type":"number"},"ipAddress":{"type":["string","null"]},"userAgent":{"type":["string","null"]},"reason":{"type":["string","null"]},"requestId":{"type":["string","null"]}},"required":["id","reservedNameId","action","previousValues","newValues","changedFields","performedBy","performedAt","ipAddress","userAgent","reason","requestId"]}},"total":{"type":"number"}},"required":["items","total"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}}},"/v1/auth/admin/reserved-names/{id}/exceptions":{"get":{"operationId":"listReservedNameExceptions","summary":"List exceptions","description":"Get exceptions for a reserved name","tags":["Admin","Reserved Names"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"rsv_abc123"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Exceptions list","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"reservedNameId":{"type":["string","null"]},"userId":{"type":["string","null"]},"organizationId":{"type":["string","null"]},"specificValue":{"type":["string","null"]},"reason":{"type":"string"},"approvedBy":{"type":"string"},"approvedAt":{"type":"number"},"expiresAt":{"type":["number","null"]},"isActive":{"type":"boolean"},"createdAt":{"type":"number"}},"required":["id","reservedNameId","userId","organizationId","specificValue","reason","approvedBy","approvedAt","expiresAt","isActive","createdAt"]}},"total":{"type":"number"}},"required":["items","total"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}},"post":{"operationId":"createReservedNameException","summary":"Create exception","description":"Create an exception for a reserved name","tags":["Admin","Reserved Names"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"rsv_abc123"},"required":true,"name":"id","in":"path"}],"requestBody":{"description":"Exception data","required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"userId":{"type":"string","description":"User to grant exception to"},"organizationId":{"type":"string","description":"Organization to grant exception to"},"specificValue":{"type":"string","description":"Specific value to allow"},"reason":{"type":"string","minLength":1,"description":"Reason for exception"},"expiresAt":{"type":"number","description":"When exception expires"}},"required":["reason"]}}}},"responses":{"201":{"description":"Exception created","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"reservedNameId":{"type":["string","null"]},"userId":{"type":["string","null"]},"organizationId":{"type":["string","null"]},"specificValue":{"type":["string","null"]},"reason":{"type":"string"},"approvedBy":{"type":"string"},"approvedAt":{"type":"number"},"expiresAt":{"type":["number","null"]},"isActive":{"type":"boolean"},"createdAt":{"type":"number"}},"required":["id","reservedNameId","userId","organizationId","specificValue","reason","approvedBy","approvedAt","expiresAt","isActive","createdAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}}},"/v1/auth/admin/reserved-names/{id}/exceptions/{exceptionId}":{"delete":{"operationId":"deleteReservedNameException","summary":"Delete exception","description":"Delete an exception","tags":["Admin","Reserved Names"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"rsv_abc123"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","example":"exc_abc123"},"required":true,"name":"exceptionId","in":"path"}],"responses":{"200":{"description":"Exception deleted","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"}},"required":["success"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error","code"]}}}}}}},"/v1/auth/admin/sessions/revoke-all":{"post":{"operationId":"adminRevokeAllPlatformSessions","summary":"Force logout all users (platform)","description":"Immediately invalidates every active session across the entire platform. Requires platform operator (system.manage) permission. Sessions are evicted from KV on next request — no token list needed.","tags":["Admin","Sessions"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"All sessions revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminRevokeAllSessionsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminSessionsError"}}}},"403":{"description":"Platform operator access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminSessionsError"}}}}}}},"/v1/auth/admin/organizations/{organizationId}/sessions/revoke":{"post":{"operationId":"adminRevokeOrgSessions","summary":"Force logout all members of an organization","description":"Immediately invalidates all active sessions for every member of the specified organization. Requires platform operator or organization admin access.","tags":["Admin","Sessions"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"organizationId","in":"path"}],"responses":{"200":{"description":"Org sessions revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminRevokeOrgSessionsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminSessionsError"}}}},"403":{"description":"Platform operator or org admin access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminSessionsError"}}}},"404":{"description":"Organization not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminSessionsError"}}}}}}},"/v1/auth/admin/oauth-clients":{"get":{"tags":["Admin: OAuth Clients"],"security":[{"Bearer":[]}],"summary":"List registered OAuth clients","responses":{"200":{"description":"List of clients","content":{"application/json":{"schema":{"type":"object","properties":{"clients":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"clientId":{"type":"string"},"redirectUris":{"type":"array","items":{"type":"string"}},"allowedScopes":{"type":"array","items":{"type":"string"}},"allowedGrantTypes":{"type":"array","items":{"type":"string"}},"isFirstParty":{"type":"boolean"},"brandToken":{"type":"string"},"authHostname":{"type":["string","null"]},"archivedAt":{"type":["number","null"]},"createdAt":{"type":"number"},"updatedAt":{"type":"number"}},"required":["id","name","clientId","redirectUris","allowedScopes","allowedGrantTypes","isFirstParty","brandToken","authHostname","archivedAt","createdAt","updatedAt"]}},"total":{"type":"number"}},"required":["clients","total"]}}}}}},"post":{"tags":["Admin: OAuth Clients"],"security":[{"Bearer":[]}],"summary":"Register a new OAuth client","description":"Creates a new OIDC client. Returns the plaintext client_secret ONCE — store it now; we never expose it again.","requestBody":{"description":"New client config","required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":255,"example":"SIY Launchpad"},"redirectUris":{"type":"array","items":{"type":"string","format":"uri"},"minItems":1,"example":["https://app.siy.live/auth/callback"]},"allowedScopes":{"type":"array","items":{"type":"string"},"minItems":1,"example":["openid","profile","email","offline_access"]},"allowedGrantTypes":{"type":"array","items":{"type":"string","enum":["authorization_code","refresh_token"]},"example":["authorization_code","refresh_token"]},"isFirstParty":{"type":"boolean","example":true},"brandToken":{"type":"string","enum":["liveone","siy"],"default":"liveone","example":"siy"},"authHostname":{"type":"string","example":"auth.siy.live"}},"required":["name","redirectUris"]}}}},"responses":{"201":{"description":"Client created — capture the client_secret","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"clientId":{"type":"string"},"redirectUris":{"type":"array","items":{"type":"string"}},"allowedScopes":{"type":"array","items":{"type":"string"}},"allowedGrantTypes":{"type":"array","items":{"type":"string"}},"isFirstParty":{"type":"boolean"},"brandToken":{"type":"string"},"authHostname":{"type":["string","null"]},"archivedAt":{"type":["number","null"]},"createdAt":{"type":"number"},"updatedAt":{"type":"number"},"clientSecret":{"type":"string","description":"Plaintext client_secret — shown ONCE. Store in 1Password / Pages env immediately; not retrievable."}},"required":["id","name","clientId","redirectUris","allowedScopes","allowedGrantTypes","isFirstParty","brandToken","authHostname","archivedAt","createdAt","updatedAt","clientSecret"]}}}}}}},"/v1/auth/admin/oauth-clients/{clientId}":{"get":{"tags":["Admin: OAuth Clients"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"oc_abc123"},"required":true,"name":"clientId","in":"path"}],"responses":{"200":{"description":"Client","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"clientId":{"type":"string"},"redirectUris":{"type":"array","items":{"type":"string"}},"allowedScopes":{"type":"array","items":{"type":"string"}},"allowedGrantTypes":{"type":"array","items":{"type":"string"}},"isFirstParty":{"type":"boolean"},"brandToken":{"type":"string"},"authHostname":{"type":["string","null"]},"archivedAt":{"type":["number","null"]},"createdAt":{"type":"number"},"updatedAt":{"type":"number"}},"required":["id","name","clientId","redirectUris","allowedScopes","allowedGrantTypes","isFirstParty","brandToken","authHostname","archivedAt","createdAt","updatedAt"]}}}},"404":{"description":"Client not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}},"required":["error"]}}}}}},"patch":{"tags":["Admin: OAuth Clients"],"security":[{"Bearer":[]}],"summary":"Update OAuth client config","parameters":[{"schema":{"type":"string","example":"oc_abc123"},"required":true,"name":"clientId","in":"path"}],"requestBody":{"description":"Patch","required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":255,"example":"SIY Launchpad"},"redirectUris":{"type":"array","items":{"type":"string","format":"uri"},"minItems":1,"example":["https://app.siy.live/auth/callback"]},"allowedScopes":{"type":"array","items":{"type":"string"},"minItems":1,"example":["openid","profile","email","offline_access"]},"allowedGrantTypes":{"type":"array","items":{"type":"string","enum":["authorization_code","refresh_token"]},"example":["authorization_code","refresh_token"]},"isFirstParty":{"type":"boolean","example":true},"authHostname":{"type":"string","example":"auth.siy.live"},"brandToken":{"type":"string","enum":["liveone","siy"]}}}}}},"responses":{"200":{"description":"Updated client","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"clientId":{"type":"string"},"redirectUris":{"type":"array","items":{"type":"string"}},"allowedScopes":{"type":"array","items":{"type":"string"}},"allowedGrantTypes":{"type":"array","items":{"type":"string"}},"isFirstParty":{"type":"boolean"},"brandToken":{"type":"string"},"authHostname":{"type":["string","null"]},"archivedAt":{"type":["number","null"]},"createdAt":{"type":"number"},"updatedAt":{"type":"number"}},"required":["id","name","clientId","redirectUris","allowedScopes","allowedGrantTypes","isFirstParty","brandToken","authHostname","archivedAt","createdAt","updatedAt"]}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}},"required":["error"]}}}}}},"delete":{"tags":["Admin: OAuth Clients"],"security":[{"Bearer":[]}],"summary":"Soft-archive a client (revokes outstanding tokens)","parameters":[{"schema":{"type":"string","example":"oc_abc123"},"required":true,"name":"clientId","in":"path"}],"responses":{"200":{"description":"Archived client","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"clientId":{"type":"string"},"redirectUris":{"type":"array","items":{"type":"string"}},"allowedScopes":{"type":"array","items":{"type":"string"}},"allowedGrantTypes":{"type":"array","items":{"type":"string"}},"isFirstParty":{"type":"boolean"},"brandToken":{"type":"string"},"authHostname":{"type":["string","null"]},"archivedAt":{"type":["number","null"]},"createdAt":{"type":"number"},"updatedAt":{"type":"number"}},"required":["id","name","clientId","redirectUris","allowedScopes","allowedGrantTypes","isFirstParty","brandToken","authHostname","archivedAt","createdAt","updatedAt"]}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}},"required":["error"]}}}}}}},"/v1/auth/admin/oauth-clients/{clientId}/rotate-secret":{"post":{"tags":["Admin: OAuth Clients"],"security":[{"Bearer":[]}],"summary":"Issue a new client_secret, invalidating the previous one","parameters":[{"schema":{"type":"string","example":"oc_abc123"},"required":true,"name":"clientId","in":"path"}],"responses":{"200":{"description":"New client_secret — store now; not retrievable","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"clientId":{"type":"string"},"redirectUris":{"type":"array","items":{"type":"string"}},"allowedScopes":{"type":"array","items":{"type":"string"}},"allowedGrantTypes":{"type":"array","items":{"type":"string"}},"isFirstParty":{"type":"boolean"},"brandToken":{"type":"string"},"authHostname":{"type":["string","null"]},"archivedAt":{"type":["number","null"]},"createdAt":{"type":"number"},"updatedAt":{"type":"number"},"clientSecret":{"type":"string","description":"Plaintext client_secret — shown ONCE. Store in 1Password / Pages env immediately; not retrievable."}},"required":["id","name","clientId","redirectUris","allowedScopes","allowedGrantTypes","isFirstParty","brandToken","authHostname","archivedAt","createdAt","updatedAt","clientSecret"]}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}},"required":["error"]}}}}}}},"/v1/organizations/settings":{"get":{"operationId":"getCurrentOrganizationSettings","summary":"Get current organization settings","description":"Get settings for the currently active organization.","tags":["Organizations"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Organization settings","content":{"application/json":{"schema":{"type":"object","properties":{"settings":{"$ref":"#/components/schemas/OrganizationSettings"}},"required":["settings"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error"]}}}},"404":{"description":"No active organization","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error"]}}}}}},"patch":{"operationId":"updateCurrentOrganizationSettings","summary":"Update current organization settings","description":"Update settings for the currently active organization. Requires admin/owner role.","tags":["Organizations"],"security":[{"Bearer":[]}],"requestBody":{"description":"Settings updates","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateCurrentSettings"}}}},"responses":{"200":{"description":"Updated settings","content":{"application/json":{"schema":{"type":"object","properties":{"settings":{"$ref":"#/components/schemas/OrganizationSettings"}},"required":["settings"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error"]}}}},"403":{"description":"Admin access required","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error"]}}}},"404":{"description":"No active organization","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error"]}}}}}}},"/v1/organizations/members":{"get":{"operationId":"getCurrentOrganizationMembers","summary":"Get current organization members","description":"Get all members of the currently active organization.","tags":["Organizations"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Organization members","content":{"application/json":{"schema":{"type":"object","properties":{"members":{"type":"array","items":{"$ref":"#/components/schemas/OrganizationMember"}}},"required":["members"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error"]}}}},"404":{"description":"No active organization","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error"]}}}}}}},"/v1/organizations/invitations":{"get":{"operationId":"getCurrentOrganizationInvitations","summary":"Get current organization invitations","description":"Get all pending invitations for the currently active organization.","tags":["Organizations"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Organization invitations","content":{"application/json":{"schema":{"type":"object","properties":{"invitations":{"type":"array","items":{"$ref":"#/components/schemas/OrganizationInvitation"}}},"required":["invitations"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error"]}}}},"404":{"description":"No active organization","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error"]}}}}}}},"/v1/organizations/upgrade-to-agency":{"post":{"operationId":"upgradeOrganizationToAgency","summary":"Upgrade organization to agency","description":"Upgrade the current organization to an agency type, enabling multi-client management.","tags":["Organizations"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Upgraded organization","content":{"application/json":{"schema":{"type":"object","properties":{"organization":{"$ref":"#/components/schemas/Organization"}},"required":["organization"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error"]}}}},"403":{"description":"Admin access required","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error"]}}}},"404":{"description":"No active organization","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error"]}}}},"409":{"description":"Organization is already an agency","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error"]}}}}}}},"/v1/organizations/current":{"get":{"tags":["Current Organization"],"summary":"Get current organization","description":"Get details of the currently active organization from the session.","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Current organization details","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"organization":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"type":{"type":"string","enum":["personal","team","agency","enterprise"]},"description":{"type":["string","null"]},"website":{"type":["string","null"]},"logo":{"type":["string","null"]},"industry":{"type":["string","null"]},"size":{"type":["string","null"],"enum":["1-10","11-50","51-200","201-500","501-1000","1001+",null]},"billingEmail":{"type":["string","null"]},"supportEmail":{"type":["string","null"]},"phoneNumber":{"type":["string","null"]},"memberCount":{"type":"number"},"settings":{"type":["object","null"],"additionalProperties":{}},"createdAt":{"type":"string"},"updatedAt":{"type":"string"},"memberRole":{"type":"string"},"memberJoinedAt":{"type":"string"}},"required":["id","name","slug","type","description","website","logo","industry","size","memberCount","settings","createdAt","updatedAt"]}},"required":["success","organization"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"patch":{"tags":["Current Organization"],"summary":"Update current organization","description":"Update the currently active organization. Requires admin role.","security":[{"bearerAuth":[]}],"requestBody":{"description":"Organization updates","content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100},"description":{"type":["string","null"],"maxLength":500},"website":{"type":["string","null"],"format":"uri"},"logo":{"type":["string","null"],"format":"uri"},"industry":{"type":["string","null"]},"size":{"type":["string","null"],"enum":["1-10","11-50","51-200","201-500","501-1000","1001+",null]},"billingEmail":{"type":["string","null"],"format":"email"},"supportEmail":{"type":["string","null"],"format":"email"},"phoneNumber":{"type":["string","null"]},"taxIdNumber":{"type":["string","null"]},"addressLine1":{"type":["string","null"]},"addressLine2":{"type":["string","null"]},"city":{"type":["string","null"]},"state":{"type":["string","null"]},"postalCode":{"type":["string","null"]},"country":{"type":["string","null"]},"settings":{"type":"object","additionalProperties":{}}}}}}},"responses":{"200":{"description":"Updated organization","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"type":{"type":"string","enum":["personal","team","agency","enterprise"]},"description":{"type":["string","null"]},"website":{"type":["string","null"]},"logo":{"type":["string","null"]},"industry":{"type":["string","null"]},"size":{"type":["string","null"],"enum":["1-10","11-50","51-200","201-500","501-1000","1001+",null]},"billingEmail":{"type":["string","null"]},"supportEmail":{"type":["string","null"]},"phoneNumber":{"type":["string","null"]},"memberCount":{"type":"number"},"settings":{"type":["object","null"],"additionalProperties":{}},"createdAt":{"type":"string"},"updatedAt":{"type":"string"},"memberRole":{"type":"string"},"memberJoinedAt":{"type":"string"}},"required":["id","name","slug","type","description","website","logo","industry","size","memberCount","settings","createdAt","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/organizations/switch":{"post":{"tags":["Current Organization"],"summary":"Switch organization","description":"Switch the active organization in the current session.","security":[{"bearerAuth":[]}],"requestBody":{"description":"Organization to switch to","content":{"application/json":{"schema":{"type":"object","properties":{"organizationId":{"type":"string"}},"required":["organizationId"]}}}},"responses":{"200":{"description":"Switched organization details","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"organization":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"type":{"type":"string","enum":["personal","team","agency","enterprise"]},"description":{"type":["string","null"]},"website":{"type":["string","null"]},"logo":{"type":["string","null"]},"industry":{"type":["string","null"]},"size":{"type":["string","null"],"enum":["1-10","11-50","51-200","201-500","501-1000","1001+",null]},"billingEmail":{"type":["string","null"]},"supportEmail":{"type":["string","null"]},"phoneNumber":{"type":["string","null"]},"memberCount":{"type":"number"},"settings":{"type":["object","null"],"additionalProperties":{}},"createdAt":{"type":"string"},"updatedAt":{"type":"string"},"memberRole":{"type":"string"},"memberJoinedAt":{"type":"string"}},"required":["id","name","slug","type","description","website","logo","industry","size","memberCount","settings","createdAt","updatedAt"]}},"required":["success","organization"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/organizations/current/me":{"get":{"tags":["Current Organization"],"summary":"Get my membership","description":"Get the current user membership details in the active organization.","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Membership details","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"organizationId":{"type":"string"},"userId":{"type":"string"},"role":{"type":"string"},"permissions":{"type":["array","null"],"items":{"type":"string"}},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","organizationId","userId","role","permissions","createdAt","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/organizations/current/byok-settings":{"get":{"tags":["Organization API Keys"],"summary":"Get BYOK settings","description":"Get the BYOK (Bring Your Own Key) settings for the current organization.","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"BYOK settings","content":{"application/json":{"schema":{"type":"object","properties":{"byokEnabled":{"type":"boolean"},"byokProviders":{"type":"array","items":{"type":"string"}},"availableProviders":{"type":"array","items":{"type":"object","properties":{"provider":{"type":"string"},"name":{"type":"string"},"category":{"type":"string"},"hasOrgKey":{"type":"boolean"},"hasPlatformKey":{"type":"boolean"}},"required":["provider","name","category","hasOrgKey","hasPlatformKey"]}}},"required":["byokEnabled","byokProviders","availableProviders"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"patch":{"tags":["Organization API Keys"],"summary":"Update BYOK settings","description":"Update BYOK settings for the current organization. Requires admin role.","security":[{"bearerAuth":[]}],"requestBody":{"description":"BYOK settings update","content":{"application/json":{"schema":{"type":"object","properties":{"byokEnabled":{"type":"boolean"},"byokProviders":{"type":"array","items":{"type":"string","enum":["openai","anthropic","google_ai","elevenlabs","playht","veo","pika","runway"]}}}}}}},"responses":{"200":{"description":"Updated BYOK settings","content":{"application/json":{"schema":{"type":"object","properties":{"byokEnabled":{"type":"boolean"},"byokProviders":{"type":"array","items":{"type":"string"}},"availableProviders":{"type":"array","items":{"type":"object","properties":{"provider":{"type":"string"},"name":{"type":"string"},"category":{"type":"string"},"hasOrgKey":{"type":"boolean"},"hasPlatformKey":{"type":"boolean"}},"required":["provider","name","category","hasOrgKey","hasPlatformKey"]}}},"required":["byokEnabled","byokProviders","availableProviders"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/organizations/current/api-keys":{"get":{"tags":["Organization API Keys"],"summary":"List organization API keys","description":"List all API keys configured for the current organization.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","enum":["production","staging","development"]},"required":false,"name":"environment","in":"query"},{"schema":{"type":"string"},"required":false,"name":"category","in":"query"}],"responses":{"200":{"description":"List of organization API keys","content":{"application/json":{"schema":{"type":"object","properties":{"keys":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"provider":{"type":"string","enum":["openai","anthropic","google_ai","elevenlabs","playht","veo","pika","runway"]},"environment":{"type":"string","enum":["production","staging","development"]},"description":{"type":["string","null"]},"keyPrefix":{"type":["string","null"]},"isEnabled":{"type":"boolean"},"isValidated":{"type":"boolean"},"lastValidatedAt":{"type":["string","null"]},"lastUsedAt":{"type":["string","null"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","provider","environment","description","keyPrefix","isEnabled","isValidated","lastValidatedAt","lastUsedAt","createdAt","updatedAt"]}},"total":{"type":"number"}},"required":["keys","total"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"post":{"tags":["Organization API Keys"],"summary":"Create organization API key","description":"Create a new API key for the current organization. Requires admin role.","security":[{"bearerAuth":[]}],"requestBody":{"description":"API key details","content":{"application/json":{"schema":{"type":"object","properties":{"provider":{"type":"string","enum":["openai","anthropic","google_ai","elevenlabs","playht","veo","pika","runway"]},"encryptedValue":{"type":"string","minLength":1},"environment":{"type":"string","enum":["production","staging","development"]},"description":{"type":"string"}},"required":["provider","encryptedValue","environment"]}}}},"responses":{"201":{"description":"Created API key","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"provider":{"type":"string","enum":["openai","anthropic","google_ai","elevenlabs","playht","veo","pika","runway"]},"environment":{"type":"string","enum":["production","staging","development"]},"description":{"type":["string","null"]},"keyPrefix":{"type":["string","null"]},"isEnabled":{"type":"boolean"},"isValidated":{"type":"boolean"},"lastValidatedAt":{"type":["string","null"]},"lastUsedAt":{"type":["string","null"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","provider","environment","description","keyPrefix","isEnabled","isValidated","lastValidatedAt","lastUsedAt","createdAt","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"409":{"description":"Resource already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/organizations/current/api-keys/{keyId}":{"get":{"tags":["Organization API Keys"],"summary":"Get organization API key","description":"Get details of a specific organization API key.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"keyId","in":"path"}],"responses":{"200":{"description":"Organization API key details","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"provider":{"type":"string","enum":["openai","anthropic","google_ai","elevenlabs","playht","veo","pika","runway"]},"environment":{"type":"string","enum":["production","staging","development"]},"description":{"type":["string","null"]},"keyPrefix":{"type":["string","null"]},"isEnabled":{"type":"boolean"},"isValidated":{"type":"boolean"},"lastValidatedAt":{"type":["string","null"]},"lastUsedAt":{"type":["string","null"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","provider","environment","description","keyPrefix","isEnabled","isValidated","lastValidatedAt","lastUsedAt","createdAt","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"patch":{"tags":["Organization API Keys"],"summary":"Update organization API key","description":"Update an existing organization API key. Requires admin role.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"keyId","in":"path"}],"requestBody":{"description":"API key updates","content":{"application/json":{"schema":{"type":"object","properties":{"encryptedValue":{"type":"string","minLength":1},"environment":{"type":"string","enum":["production","staging","development"]},"description":{"type":["string","null"]},"isEnabled":{"type":"boolean"}}}}}},"responses":{"200":{"description":"Updated API key","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"provider":{"type":"string","enum":["openai","anthropic","google_ai","elevenlabs","playht","veo","pika","runway"]},"environment":{"type":"string","enum":["production","staging","development"]},"description":{"type":["string","null"]},"keyPrefix":{"type":["string","null"]},"isEnabled":{"type":"boolean"},"isValidated":{"type":"boolean"},"lastValidatedAt":{"type":["string","null"]},"lastUsedAt":{"type":["string","null"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","provider","environment","description","keyPrefix","isEnabled","isValidated","lastValidatedAt","lastUsedAt","createdAt","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"delete":{"tags":["Organization API Keys"],"summary":"Delete organization API key","description":"Delete an organization API key. Requires admin role.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"keyId","in":"path"}],"responses":{"204":{"description":"API key deleted successfully"},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/organizations/current/api-keys/{keyId}/validate":{"post":{"tags":["Organization API Keys"],"summary":"Validate organization API key","description":"Validate that an organization API key works with its provider.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"keyId","in":"path"}],"responses":{"200":{"description":"Validation result","content":{"application/json":{"schema":{"type":"object","properties":{"provider":{"type":"string"},"isValid":{"type":"boolean"},"error":{"type":["string","null"]}},"required":["provider","isValid","error"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/organizations/current/apps":{"get":{"tags":["Organization Apps"],"summary":"List organization apps","description":"List all app entitlements for the current organization.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":false,"name":"category","in":"query"},{"schema":{"type":"string","enum":["true","false"]},"required":false,"name":"enabled","in":"query"}],"responses":{"200":{"description":"List of organization app entitlements","content":{"application/json":{"schema":{"type":"object","properties":{"apps":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"appId":{"type":"string"},"appKey":{"type":"string"},"name":{"type":"string"},"description":{"type":["string","null"]},"category":{"type":"string"},"isEnabled":{"type":"boolean"},"plan":{"type":"string"},"defaultMemberAccess":{"type":"string"},"logoUrl":{"type":["string","null"]},"memberStats":{"type":"object","properties":{"total":{"type":"number"},"granted":{"type":"number"},"denied":{"type":"number"}},"required":["total","granted","denied"]},"createdAt":{"anyOf":[{"type":"string"},{"type":"number"},{"type":"null"}]},"updatedAt":{"anyOf":[{"type":"string"},{"type":"number"},{"type":"null"}]}},"required":["id","appKey","name","description","category","isEnabled","plan","memberStats","createdAt","updatedAt"]}},"total":{"type":"number"}},"required":["apps","total"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/organizations/current/apps/{appId}":{"get":{"tags":["Organization Apps"],"summary":"Get organization app","description":"Get a specific app entitlement for the current organization.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"appId","in":"path"}],"responses":{"200":{"description":"Organization app entitlement","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"appId":{"type":"string"},"appKey":{"type":"string"},"name":{"type":"string"},"description":{"type":["string","null"]},"category":{"type":"string"},"isEnabled":{"type":"boolean"},"plan":{"type":"string"},"defaultMemberAccess":{"type":"string"},"logoUrl":{"type":["string","null"]},"memberStats":{"type":"object","properties":{"total":{"type":"number"},"granted":{"type":"number"},"denied":{"type":"number"}},"required":["total","granted","denied"]},"createdAt":{"anyOf":[{"type":"string"},{"type":"number"},{"type":"null"}]},"updatedAt":{"anyOf":[{"type":"string"},{"type":"number"},{"type":"null"}]}},"required":["id","appKey","name","description","category","isEnabled","plan","memberStats","createdAt","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"patch":{"tags":["Organization Apps"],"summary":"Update organization app","description":"Update app entitlement settings for the current organization. Requires admin role.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"appId","in":"path"}],"requestBody":{"description":"App entitlement updates","content":{"application/json":{"schema":{"type":"object","properties":{"isEnabled":{"type":"boolean"}}}}}},"responses":{"200":{"description":"Updated app entitlement","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"appId":{"type":"string"},"appKey":{"type":"string"},"name":{"type":"string"},"description":{"type":["string","null"]},"category":{"type":"string"},"isEnabled":{"type":"boolean"},"plan":{"type":"string"},"defaultMemberAccess":{"type":"string"},"logoUrl":{"type":["string","null"]},"memberStats":{"type":"object","properties":{"total":{"type":"number"},"granted":{"type":"number"},"denied":{"type":"number"}},"required":["total","granted","denied"]},"createdAt":{"anyOf":[{"type":"string"},{"type":"number"},{"type":"null"}]},"updatedAt":{"anyOf":[{"type":"string"},{"type":"number"},{"type":"null"}]}},"required":["id","appKey","name","description","category","isEnabled","plan","memberStats","createdAt","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/organizations/current/apps/defaults":{"post":{"tags":["Organization Apps"],"summary":"Set default apps","description":"Initialize default app entitlements based on subscription tier. Requires admin role.","security":[{"bearerAuth":[]}],"requestBody":{"description":"Default apps configuration","content":{"application/json":{"schema":{"type":"object","properties":{"tier":{"type":"string","enum":["free","starter","professional","enterprise"]}}}}}},"responses":{"200":{"description":"Updated app entitlements","content":{"application/json":{"schema":{"type":"object","properties":{"apps":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"appId":{"type":"string"},"appKey":{"type":"string"},"name":{"type":"string"},"description":{"type":["string","null"]},"category":{"type":"string"},"isEnabled":{"type":"boolean"},"plan":{"type":"string"},"defaultMemberAccess":{"type":"string"},"logoUrl":{"type":["string","null"]},"memberStats":{"type":"object","properties":{"total":{"type":"number"},"granted":{"type":"number"},"denied":{"type":"number"}},"required":["total","granted","denied"]},"createdAt":{"anyOf":[{"type":"string"},{"type":"number"},{"type":"null"}]},"updatedAt":{"anyOf":[{"type":"string"},{"type":"number"},{"type":"null"}]}},"required":["id","appKey","name","description","category","isEnabled","plan","memberStats","createdAt","updatedAt"]}},"total":{"type":"number"}},"required":["apps","total"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/organizations/current/apps/{appId}/members":{"get":{"tags":["Organization Apps"],"summary":"List app members","description":"List all members with access to a specific app in the organization.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"appId","in":"path"},{"schema":{"type":"string"},"required":false,"name":"search","in":"query"},{"schema":{"type":"string","enum":["all","granted","denied"]},"required":false,"name":"accessFilter","in":"query"},{"schema":{"type":["number","null"]},"required":false,"name":"limit","in":"query"},{"schema":{"type":["number","null"]},"required":false,"name":"offset","in":"query"}],"responses":{"200":{"description":"App members","content":{"application/json":{"schema":{"type":"object","properties":{"members":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"appId":{"type":"string"},"role":{"type":"string"},"isActive":{"type":"boolean"},"accessSource":{"type":"string","enum":["explicit","inherited","role"]},"displayName":{"type":["string","null"]},"email":{"type":["string","null"]},"avatarUrl":{"type":["string","null"]},"createdAt":{"type":"string"}},"required":["id","userId","appId","role","createdAt"]}},"total":{"type":"number"},"defaultAccess":{"type":"string"}},"required":["members","total"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"post":{"tags":["Organization Apps"],"summary":"Add app member","description":"Grant a user access to a specific app.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"appId","in":"path"}],"requestBody":{"description":"Member to add","content":{"application/json":{"schema":{"type":"object","properties":{"userIds":{"type":"array","items":{"type":"string"}},"userId":{"type":"string"},"role":{"type":"string"}}}}}},"responses":{"201":{"description":"Member added","content":{"application/json":{"schema":{"type":"object","properties":{"member":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"appId":{"type":"string"},"role":{"type":"string"},"isActive":{"type":"boolean"},"accessSource":{"type":"string","enum":["explicit","inherited","role"]},"displayName":{"type":["string","null"]},"email":{"type":["string","null"]},"avatarUrl":{"type":["string","null"]},"createdAt":{"type":"string"}},"required":["id","userId","appId","role","createdAt"]},"members":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"appId":{"type":"string"},"role":{"type":"string"},"isActive":{"type":"boolean"},"accessSource":{"type":"string","enum":["explicit","inherited","role"]},"displayName":{"type":["string","null"]},"email":{"type":["string","null"]},"avatarUrl":{"type":["string","null"]},"createdAt":{"type":"string"}},"required":["id","userId","appId","role","createdAt"]}}}}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/organizations/current/apps/{appId}/members/{userId}":{"patch":{"tags":["Organization Apps"],"summary":"Update app member","description":"Update a member's role for a specific app.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"appId","in":"path"},{"schema":{"type":"string"},"required":true,"name":"userId","in":"path"}],"requestBody":{"description":"Role update","content":{"application/json":{"schema":{"type":"object","properties":{"role":{"type":"string"},"isActive":{"type":"boolean"}}}}}},"responses":{"200":{"description":"Member updated","content":{"application/json":{"schema":{"type":"object","properties":{"member":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"appId":{"type":"string"},"role":{"type":"string"},"isActive":{"type":"boolean"},"accessSource":{"type":"string","enum":["explicit","inherited","role"]},"displayName":{"type":["string","null"]},"email":{"type":["string","null"]},"avatarUrl":{"type":["string","null"]},"createdAt":{"type":"string"}},"required":["id","userId","appId","role","createdAt"]}},"required":["member"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"delete":{"tags":["Organization Apps"],"summary":"Remove app member","description":"Remove a user's access from a specific app.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"appId","in":"path"},{"schema":{"type":"string"},"required":true,"name":"userId","in":"path"}],"responses":{"200":{"description":"Member removed","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"}},"required":["success"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/organizations/current/apps/{appId}/settings":{"patch":{"tags":["Organization Apps"],"summary":"Update app settings","description":"Update organization-specific settings for an app.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"appId","in":"path"}],"requestBody":{"description":"App settings","content":{"application/json":{"schema":{"type":"object","properties":{"settings":{"type":"object","additionalProperties":{}},"defaultMemberAccess":{"type":"string","enum":["all","none","explicit"]}}}}}},"responses":{"200":{"description":"Settings updated","content":{"application/json":{"schema":{"type":"object","properties":{"settings":{"type":"object","additionalProperties":{}}},"required":["settings"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/organizations/current/invitations":{"get":{"tags":["Organization Invitations"],"summary":"List invitations","description":"List all pending invitations for the current organization.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","enum":["pending","accepted","expired","revoked"]},"required":false,"name":"status","in":"query"},{"schema":{"type":"string"},"required":false,"name":"search","in":"query"},{"schema":{"type":"number","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":["number","null"],"minimum":0,"default":0},"required":false,"name":"offset","in":"query"}],"responses":{"200":{"description":"List of invitations","content":{"application/json":{"schema":{"type":"object","properties":{"invitations":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string"},"role":{"type":"string"},"status":{"type":"string","enum":["pending","accepted","expired","revoked"]},"message":{"type":["string","null"]},"expiresAt":{"type":"string"},"invitedBy":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":["string","null"]},"email":{"type":["string","null"]}},"required":["id","name","email"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","email","role","status","message","expiresAt","invitedBy","createdAt","updatedAt"]}},"total":{"type":"number"},"limit":{"type":"number"},"offset":{"type":"number"}},"required":["invitations","total","limit","offset"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"post":{"tags":["Organization Invitations"],"summary":"Create invitation","description":"Invite a new member to the organization. Requires admin role.","security":[{"bearerAuth":[]}],"requestBody":{"description":"Invitation details","content":{"application/json":{"schema":{"type":"object","properties":{"email":{"type":"string","format":"email"},"role":{"type":"string","enum":["admin","member","viewer"],"default":"member"},"message":{"type":"string","maxLength":500},"expiresInDays":{"type":"number","minimum":1,"maximum":30,"default":7}},"required":["email"]}}}},"responses":{"201":{"description":"Created invitation","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string"},"role":{"type":"string"},"status":{"type":"string","enum":["pending","accepted","expired","revoked"]},"message":{"type":["string","null"]},"expiresAt":{"type":"string"},"invitedBy":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":["string","null"]},"email":{"type":["string","null"]}},"required":["id","name","email"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","email","role","status","message","expiresAt","invitedBy","createdAt","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"409":{"description":"Resource already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/organizations/current/invitations/{invitationId}":{"get":{"tags":["Organization Invitations"],"summary":"Get invitation","description":"Get details of a specific invitation.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"invitationId","in":"path"}],"responses":{"200":{"description":"Invitation details","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string"},"role":{"type":"string"},"status":{"type":"string","enum":["pending","accepted","expired","revoked"]},"message":{"type":["string","null"]},"expiresAt":{"type":"string"},"invitedBy":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":["string","null"]},"email":{"type":["string","null"]}},"required":["id","name","email"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","email","role","status","message","expiresAt","invitedBy","createdAt","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"delete":{"tags":["Organization Invitations"],"summary":"Revoke invitation","description":"Revoke a pending invitation. Requires admin role.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"invitationId","in":"path"}],"responses":{"204":{"description":"Invitation revoked successfully"},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/organizations/current/invitations/{invitationId}/resend":{"post":{"tags":["Organization Invitations"],"summary":"Resend invitation","description":"Resend an invitation email. Requires admin role.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"invitationId","in":"path"}],"responses":{"200":{"description":"Resent invitation","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string"},"role":{"type":"string"},"status":{"type":"string","enum":["pending","accepted","expired","revoked"]},"message":{"type":["string","null"]},"expiresAt":{"type":"string"},"invitedBy":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":["string","null"]},"email":{"type":["string","null"]}},"required":["id","name","email"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","email","role","status","message","expiresAt","invitedBy","createdAt","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/invitations/accept":{"post":{"tags":["Organization Invitations"],"summary":"Accept invitation","description":"Accept an invitation using a token. The authenticated user joins the organization.","security":[{"bearerAuth":[]}],"requestBody":{"description":"Invitation token","content":{"application/json":{"schema":{"type":"object","properties":{"token":{"type":"string"}},"required":["token"]}}}},"responses":{"200":{"description":"Accepted invitation result","content":{"application/json":{"schema":{"type":"object","properties":{"organizationId":{"type":"string"},"organizationName":{"type":"string"},"role":{"type":"string"},"message":{"type":"string"}},"required":["organizationId","organizationName","role","message"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"409":{"description":"Resource already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/invitations/{token}":{"get":{"tags":["Organization Invitations"],"summary":"Get invitation by token","description":"Get invitation details by token (for preview before accepting).","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"token","in":"path"}],"responses":{"200":{"description":"Invitation preview","content":{"application/json":{"schema":{"type":"object","properties":{"email":{"type":"string"},"organizationName":{"type":"string"},"organizationLogo":{"type":["string","null"]},"role":{"type":"string"},"invitedBy":{"type":["string","null"]},"expiresAt":{"type":"string"},"isExpired":{"type":"boolean"}},"required":["email","organizationName","organizationLogo","role","invitedBy","expiresAt","isExpired"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/organizations/current/members":{"get":{"tags":["Organization Members"],"summary":"List members","description":"List all members of the current organization.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":false,"name":"search","in":"query"},{"schema":{"type":"string","enum":["owner","admin","member","viewer"]},"required":false,"name":"role","in":"query"},{"schema":{"type":"number","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":["number","null"],"minimum":0,"default":0},"required":false,"name":"offset","in":"query"}],"responses":{"200":{"description":"List of organization members","content":{"application/json":{"schema":{"type":"object","properties":{"members":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"role":{"type":"string"},"permissions":{"type":["array","null"],"items":{"type":"string"}},"user":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":["string","null"]},"displayName":{"type":["string","null"]},"avatar":{"type":["string","null"]}},"required":["id","email","displayName","avatar"]},"joinedAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","role","permissions","user","joinedAt","updatedAt"]}},"total":{"type":"number"},"limit":{"type":"number"},"offset":{"type":"number"}},"required":["members","total","limit","offset"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/organizations/current/members/{memberId}":{"get":{"tags":["Organization Members"],"summary":"Get member","description":"Get details of a specific organization member.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"memberId","in":"path"}],"responses":{"200":{"description":"Member details","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"role":{"type":"string"},"permissions":{"type":["array","null"],"items":{"type":"string"}},"user":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":["string","null"]},"displayName":{"type":["string","null"]},"avatar":{"type":["string","null"]}},"required":["id","email","displayName","avatar"]},"joinedAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","role","permissions","user","joinedAt","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"patch":{"tags":["Organization Members"],"summary":"Update member","description":"Update a member role or permissions. Owners can change roles, admins can change permissions.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"memberId","in":"path"}],"requestBody":{"description":"Member updates","content":{"application/json":{"schema":{"type":"object","properties":{"role":{"type":"string","enum":["admin","member","viewer"]},"permissions":{"type":"array","items":{"type":"string"}}}}}}},"responses":{"200":{"description":"Updated member","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"role":{"type":"string"},"permissions":{"type":["array","null"],"items":{"type":"string"}},"user":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":["string","null"]},"displayName":{"type":["string","null"]},"avatar":{"type":["string","null"]}},"required":["id","email","displayName","avatar"]},"joinedAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","role","permissions","user","joinedAt","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"delete":{"tags":["Organization Members"],"summary":"Remove member","description":"Remove a member from the organization. Users can remove themselves, admins can remove others.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"memberId","in":"path"}],"responses":{"204":{"description":"Member removed successfully"},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/organizations/clients":{"get":{"tags":["Organization Relationships"],"summary":"List clients","description":"List all client relationships for the current agency organization.","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"List of client relationships","content":{"application/json":{"schema":{"type":"object","properties":{"clients":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"clientOrgId":{"type":"string"},"status":{"type":"string"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"},"relationshipType":{"type":"string"},"notes":{"type":["string","null"]},"client":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"logo":{"type":["string","null"]},"slug":{"type":["string","null"]},"website":{"type":["string","null"]},"type":{"type":["string","null"]}},"required":["id","name","logo","slug","website","type"]},"sharedProjectCount":{"type":"number"},"pendingInvitationId":{"type":["string","null"]}},"required":["id","clientOrgId","status","createdAt","updatedAt","client"]}}},"required":["clients"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"post":{"tags":["Organization Relationships"],"summary":"Add existing client","description":"Add an existing organization as a client by their organizationId.","security":[{"bearerAuth":[]}],"requestBody":{"description":"Client details","content":{"application/json":{"schema":{"type":"object","properties":{"clientOrgId":{"type":"string","description":"The ID of the existing organization to add as a client"},"notes":{"type":"string","description":"Optional notes about the relationship"}},"required":["clientOrgId"]}}}},"responses":{"201":{"description":"Client relationship created","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"clientOrgId":{"type":"string"},"status":{"type":"string"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"},"relationshipType":{"type":"string"},"notes":{"type":["string","null"]},"client":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"logo":{"type":["string","null"]},"slug":{"type":["string","null"]},"website":{"type":["string","null"]},"type":{"type":["string","null"]}},"required":["id","name","logo","slug","website","type"]},"sharedProjectCount":{"type":"number"},"pendingInvitationId":{"type":["string","null"]}},"required":["id","clientOrgId","status","createdAt","updatedAt","client"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"409":{"description":"Resource already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/organizations/clients/{clientOrgId}":{"get":{"tags":["Organization Relationships"],"summary":"Get client relationship","description":"Get details of a specific client relationship by client org ID.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"clientOrgId","in":"path"}],"responses":{"200":{"description":"Client relationship details","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"clientOrgId":{"type":"string"},"status":{"type":"string"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"},"relationshipType":{"type":"string"},"notes":{"type":["string","null"]},"client":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"logo":{"type":["string","null"]},"slug":{"type":["string","null"]},"website":{"type":["string","null"]},"type":{"type":["string","null"]}},"required":["id","name","logo","slug","website","type"]},"sharedProjectCount":{"type":"number"},"pendingInvitationId":{"type":["string","null"]}},"required":["id","clientOrgId","status","createdAt","updatedAt","client"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"delete":{"tags":["Organization Relationships"],"summary":"Remove client","description":"Terminate the agency-client relationship by client org ID. Does not delete the client organization.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"clientOrgId","in":"path"}],"responses":{"204":{"description":"Client relationship terminated successfully"},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/organizations/current/relationships":{"get":{"tags":["Organization Relationships"],"summary":"List relationships","description":"List all agency-client relationships for the current organization.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","enum":["agency","client"]},"required":false,"name":"type","in":"query"},{"schema":{"type":"string","enum":["pending","active","suspended","terminated"]},"required":false,"name":"status","in":"query"},{"schema":{"type":"string"},"required":false,"name":"search","in":"query"},{"schema":{"type":"number","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":["number","null"],"minimum":0,"default":0},"required":false,"name":"offset","in":"query"}],"responses":{"200":{"description":"List of relationships","content":{"application/json":{"schema":{"type":"object","properties":{"relationships":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"agencyOrganizationId":{"type":"string"},"clientOrganizationId":{"type":"string"},"agencyOrganization":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"logo":{"type":["string","null"]}},"required":["id","name","logo"]},"clientOrganization":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"logo":{"type":["string","null"]}},"required":["id","name","logo"]},"type":{"type":"string"},"status":{"type":"string"},"permissions":{"type":["array","null"],"items":{"type":"string"}},"metadata":{"type":["object","null"],"additionalProperties":{}},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","agencyOrganizationId","clientOrganizationId","agencyOrganization","clientOrganization","type","status","permissions","metadata","createdAt","updatedAt"]}},"total":{"type":"number"},"limit":{"type":"number"},"offset":{"type":"number"}},"required":["relationships","total","limit","offset"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"post":{"tags":["Organization Relationships"],"summary":"Create relationship","description":"Create a new agency-client relationship. Requires admin role.","security":[{"bearerAuth":[]}],"requestBody":{"description":"Relationship details","content":{"application/json":{"schema":{"type":"object","properties":{"clientOrganizationId":{"type":"string"},"type":{"type":"string","enum":["full_service","project_based","reseller"],"default":"full_service"},"permissions":{"type":"array","items":{"type":"string"}},"metadata":{"type":"object","additionalProperties":{}}},"required":["clientOrganizationId"]}}}},"responses":{"201":{"description":"Created relationship","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"agencyOrganizationId":{"type":"string"},"clientOrganizationId":{"type":"string"},"agencyOrganization":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"logo":{"type":["string","null"]}},"required":["id","name","logo"]},"clientOrganization":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"logo":{"type":["string","null"]}},"required":["id","name","logo"]},"type":{"type":"string"},"status":{"type":"string"},"permissions":{"type":["array","null"],"items":{"type":"string"}},"metadata":{"type":["object","null"],"additionalProperties":{}},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","agencyOrganizationId","clientOrganizationId","agencyOrganization","clientOrganization","type","status","permissions","metadata","createdAt","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"409":{"description":"Resource already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/organizations/current/relationships/{relationshipId}":{"get":{"tags":["Organization Relationships"],"summary":"Get relationship","description":"Get details of a specific relationship.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"relationshipId","in":"path"}],"responses":{"200":{"description":"Relationship details","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"agencyOrganizationId":{"type":"string"},"clientOrganizationId":{"type":"string"},"agencyOrganization":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"logo":{"type":["string","null"]}},"required":["id","name","logo"]},"clientOrganization":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"logo":{"type":["string","null"]}},"required":["id","name","logo"]},"type":{"type":"string"},"status":{"type":"string"},"permissions":{"type":["array","null"],"items":{"type":"string"}},"metadata":{"type":["object","null"],"additionalProperties":{}},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","agencyOrganizationId","clientOrganizationId","agencyOrganization","clientOrganization","type","status","permissions","metadata","createdAt","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"patch":{"tags":["Organization Relationships"],"summary":"Update relationship","description":"Update a relationship. Requires admin role.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"relationshipId","in":"path"}],"requestBody":{"description":"Relationship updates","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","enum":["active","suspended"]},"type":{"type":"string","enum":["full_service","project_based","reseller"]},"permissions":{"type":"array","items":{"type":"string"}},"metadata":{"type":"object","additionalProperties":{}}}}}}},"responses":{"200":{"description":"Updated relationship","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"agencyOrganizationId":{"type":"string"},"clientOrganizationId":{"type":"string"},"agencyOrganization":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"logo":{"type":["string","null"]}},"required":["id","name","logo"]},"clientOrganization":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"logo":{"type":["string","null"]}},"required":["id","name","logo"]},"type":{"type":"string"},"status":{"type":"string"},"permissions":{"type":["array","null"],"items":{"type":"string"}},"metadata":{"type":["object","null"],"additionalProperties":{}},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","agencyOrganizationId","clientOrganizationId","agencyOrganization","clientOrganization","type","status","permissions","metadata","createdAt","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"delete":{"tags":["Organization Relationships"],"summary":"Terminate relationship","description":"Terminate an agency-client relationship. Requires admin role.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"relationshipId","in":"path"}],"responses":{"204":{"description":"Relationship terminated successfully"},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/organizations/clients/onboard":{"post":{"tags":["Organization Relationships"],"summary":"Onboard new client","description":"Create a new client organization and establish agency relationship. The client owner will receive an invitation email.","security":[{"bearerAuth":[]}],"requestBody":{"description":"Client onboarding details","content":{"application/json":{"schema":{"type":"object","properties":{"clientName":{"type":"string","minLength":1,"maxLength":255},"clientSlug":{"type":"string","minLength":2,"maxLength":50},"clientWebsite":{"type":"string","format":"uri"},"clientIndustry":{"type":"string","maxLength":100},"ownerEmail":{"type":"string","format":"email"},"ownerName":{"type":"string","maxLength":255},"invitationMessage":{"type":"string","maxLength":1000},"relationshipNotes":{"type":"string","maxLength":2000}},"required":["clientName","ownerEmail"]}}}},"responses":{"201":{"description":"Client onboarded successfully","content":{"application/json":{"schema":{"type":"object","properties":{"organizationId":{"type":"string"},"relationshipId":{"type":"string"},"invitationSent":{"type":"boolean"},"message":{"type":"string"}},"required":["organizationId","relationshipId","invitationSent","message"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"409":{"description":"Resource already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/organizations/current/settings":{"get":{"tags":["Organization Settings"],"summary":"Get organization settings","description":"Get general settings for the current organization.","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Organization settings","content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"slug":{"type":"string"},"website":{"type":["string","null"]},"industry":{"type":["string","null"]},"size":{"type":["string","null"]},"timezone":{"type":["string","null"]},"locale":{"type":["string","null"]},"defaultCurrency":{"type":["string","null"]},"billingEmail":{"type":["string","null"]}},"required":["name","slug","website","industry","size","timezone","locale","defaultCurrency","billingEmail"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"patch":{"tags":["Organization Settings"],"summary":"Update organization settings","description":"Update general settings. Requires admin role.","security":[{"bearerAuth":[]}],"requestBody":{"description":"Settings updates","content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100},"slug":{"type":"string","minLength":2,"maxLength":50,"pattern":"^[a-z0-9-]+$"},"website":{"type":["string","null"],"maxLength":200,"format":"uri"},"industry":{"type":["string","null"],"maxLength":100},"size":{"type":["string","null"],"enum":["1-10","11-50","51-200","201-500","500+",null]},"timezone":{"type":["string","null"],"maxLength":50},"locale":{"type":["string","null"],"maxLength":10},"defaultCurrency":{"type":["string","null"],"minLength":3,"maxLength":3},"billingEmail":{"type":["string","null"],"format":"email"}}}}}},"responses":{"200":{"description":"Updated settings","content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"slug":{"type":"string"},"website":{"type":["string","null"]},"industry":{"type":["string","null"]},"size":{"type":["string","null"]},"timezone":{"type":["string","null"]},"locale":{"type":["string","null"]},"defaultCurrency":{"type":["string","null"]},"billingEmail":{"type":["string","null"]}},"required":["name","slug","website","industry","size","timezone","locale","defaultCurrency","billingEmail"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/organizations/current/settings/branding":{"get":{"tags":["Organization Settings"],"summary":"Get branding settings","description":"Get branding and customization settings.","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Branding settings","content":{"application/json":{"schema":{"type":"object","properties":{"logo":{"type":["string","null"]},"favicon":{"type":["string","null"]},"themeUrl":{"type":["string","null"]},"themeVersion":{"type":"number"},"primaryColor":{"type":["string","null"]},"secondaryColor":{"type":["string","null"]},"textColor":{"type":["string","null"]},"secondaryTextColor":{"type":["string","null"]},"primaryColorDark":{"type":["string","null"]},"secondaryColorDark":{"type":["string","null"]},"textColorDark":{"type":["string","null"]},"secondaryTextColorDark":{"type":["string","null"]}},"required":["logo","favicon","themeUrl","themeVersion","primaryColor","secondaryColor","textColor","secondaryTextColor","primaryColorDark","secondaryColorDark","textColorDark","secondaryTextColorDark"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"patch":{"tags":["Organization Settings"],"summary":"Update branding settings","description":"Update branding and customization settings. Requires admin role.","security":[{"bearerAuth":[]}],"requestBody":{"description":"Branding updates","content":{"application/json":{"schema":{"type":"object","properties":{"logo":{"type":["string","null"],"format":"uri"},"favicon":{"type":["string","null"],"format":"uri"},"themeUrl":{"type":["string","null"],"maxLength":500},"primaryColor":{"type":["string","null"],"pattern":"^#[0-9a-fA-F]{6}$"},"secondaryColor":{"type":["string","null"],"pattern":"^#[0-9a-fA-F]{6}$"},"textColor":{"type":["string","null"],"pattern":"^#[0-9a-fA-F]{6}$"},"secondaryTextColor":{"type":["string","null"],"pattern":"^#[0-9a-fA-F]{6}$"},"primaryColorDark":{"type":["string","null"],"pattern":"^#[0-9a-fA-F]{6}$"},"secondaryColorDark":{"type":["string","null"],"pattern":"^#[0-9a-fA-F]{6}$"},"textColorDark":{"type":["string","null"],"pattern":"^#[0-9a-fA-F]{6}$"},"secondaryTextColorDark":{"type":["string","null"],"pattern":"^#[0-9a-fA-F]{6}$"}}}}}},"responses":{"200":{"description":"Updated branding settings","content":{"application/json":{"schema":{"type":"object","properties":{"logo":{"type":["string","null"]},"favicon":{"type":["string","null"]},"themeUrl":{"type":["string","null"]},"themeVersion":{"type":"number"},"primaryColor":{"type":["string","null"]},"secondaryColor":{"type":["string","null"]},"textColor":{"type":["string","null"]},"secondaryTextColor":{"type":["string","null"]},"primaryColorDark":{"type":["string","null"]},"secondaryColorDark":{"type":["string","null"]},"textColorDark":{"type":["string","null"]},"secondaryTextColorDark":{"type":["string","null"]}},"required":["logo","favicon","themeUrl","themeVersion","primaryColor","secondaryColor","textColor","secondaryTextColor","primaryColorDark","secondaryColorDark","textColorDark","secondaryTextColorDark"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/organizations/current/settings/branding/theme/upload":{"post":{"tags":["Organization Settings"],"summary":"Upload custom theme CSS","description":"Upload sanitized CSS for the org theme. Sanitizer runs server-side. Returns the new theme URL and version. Requires admin role.","security":[{"bearerAuth":[]}],"requestBody":{"description":"Theme CSS + builder source spec","content":{"application/json":{"schema":{"type":"object","properties":{"css":{"type":"string","minLength":1,"maxLength":200000},"source":{}},"required":["css"]}}}},"responses":{"200":{"description":"Uploaded theme","content":{"application/json":{"schema":{"type":"object","properties":{"themeUrl":{"type":"string","format":"uri"},"themeVersion":{"type":"number"},"warnings":{"type":"array","items":{"type":"string"}}},"required":["themeUrl","themeVersion","warnings"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/organizations/current/settings/security":{"get":{"tags":["Organization Settings"],"summary":"Get security settings","description":"Get security and compliance settings. Requires admin role.","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Security settings","content":{"application/json":{"schema":{"type":"object","properties":{"requireMfa":{"type":"boolean"},"allowedAuthMethods":{"type":"array","items":{"type":"string"}},"sessionTimeoutMinutes":{"type":"number"},"allowedIpRanges":{"type":["array","null"],"items":{"type":"string"}},"passwordPolicy":{"type":["object","null"],"properties":{"minLength":{"type":"number"},"requireUppercase":{"type":"boolean"},"requireLowercase":{"type":"boolean"},"requireNumbers":{"type":"boolean"},"requireSpecialChars":{"type":"boolean"}},"required":["minLength","requireUppercase","requireLowercase","requireNumbers","requireSpecialChars"]},"auditLogRetentionDays":{"type":"number"},"dataRetentionDays":{"type":["number","null"]}},"required":["requireMfa","allowedAuthMethods","sessionTimeoutMinutes","allowedIpRanges","passwordPolicy","auditLogRetentionDays","dataRetentionDays"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"patch":{"tags":["Organization Settings"],"summary":"Update security settings","description":"Update security and compliance settings. Requires admin role.","security":[{"bearerAuth":[]}],"requestBody":{"description":"Security updates","content":{"application/json":{"schema":{"type":"object","properties":{"requireMfa":{"type":"boolean"},"allowedAuthMethods":{"type":"array","items":{"type":"string","enum":["email","google","github","saml"]}},"sessionTimeoutMinutes":{"type":"number","minimum":5,"maximum":10080},"allowedIpRanges":{"type":["array","null"],"items":{"type":"string"}},"passwordPolicy":{"type":["object","null"],"properties":{"minLength":{"type":"number","minimum":8,"maximum":128},"requireUppercase":{"type":"boolean"},"requireLowercase":{"type":"boolean"},"requireNumbers":{"type":"boolean"},"requireSpecialChars":{"type":"boolean"}},"required":["minLength","requireUppercase","requireLowercase","requireNumbers","requireSpecialChars"]},"auditLogRetentionDays":{"type":"number","minimum":30,"maximum":3650},"dataRetentionDays":{"type":["number","null"],"minimum":30,"maximum":3650}}}}}},"responses":{"200":{"description":"Updated security settings","content":{"application/json":{"schema":{"type":"object","properties":{"requireMfa":{"type":"boolean"},"allowedAuthMethods":{"type":"array","items":{"type":"string"}},"sessionTimeoutMinutes":{"type":"number"},"allowedIpRanges":{"type":["array","null"],"items":{"type":"string"}},"passwordPolicy":{"type":["object","null"],"properties":{"minLength":{"type":"number"},"requireUppercase":{"type":"boolean"},"requireLowercase":{"type":"boolean"},"requireNumbers":{"type":"boolean"},"requireSpecialChars":{"type":"boolean"}},"required":["minLength","requireUppercase","requireLowercase","requireNumbers","requireSpecialChars"]},"auditLogRetentionDays":{"type":"number"},"dataRetentionDays":{"type":["number","null"]}},"required":["requireMfa","allowedAuthMethods","sessionTimeoutMinutes","allowedIpRanges","passwordPolicy","auditLogRetentionDays","dataRetentionDays"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/organizations/check-slug":{"get":{"tags":["Organizations"],"summary":"Check slug availability","description":"Check if an organization slug is available.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","minLength":2,"maxLength":100},"required":true,"name":"slug","in":"query"}],"responses":{"200":{"description":"Slug availability status","content":{"application/json":{"schema":{"type":"object","properties":{"available":{"type":"boolean"},"slug":{"type":"string"},"suggestion":{"type":"string"}},"required":["available","slug"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/organizations":{"get":{"tags":["Organizations"],"summary":"List organizations","description":"List all organizations the current user has access to.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":false,"name":"search","in":"query"},{"schema":{"type":"string","enum":["personal","team","agency","enterprise"]},"required":false,"name":"type","in":"query"},{"schema":{"type":"number","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":["number","null"],"minimum":0,"default":0},"required":false,"name":"offset","in":"query"}],"responses":{"200":{"description":"List of organizations","content":{"application/json":{"schema":{"type":"object","properties":{"organizations":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"type":{"type":"string","enum":["personal","team","agency","enterprise"]},"description":{"type":["string","null"]},"website":{"type":["string","null"]},"logo":{"type":["string","null"]},"industry":{"type":["string","null"]},"size":{"type":["string","null"],"enum":["1-10","11-50","51-200","201-500","501-1000","1001+",null]},"billingEmail":{"type":["string","null"]},"supportEmail":{"type":["string","null"]},"phoneNumber":{"type":["string","null"]},"memberCount":{"type":"number"},"settings":{"type":["object","null"],"additionalProperties":{}},"createdAt":{"type":"string"},"updatedAt":{"type":"string"},"memberRole":{"type":"string"},"memberJoinedAt":{"type":"string"}},"required":["id","name","slug","type","description","website","logo","industry","size","memberCount","settings","createdAt","updatedAt"]}},"total":{"type":"number"},"limit":{"type":"number"},"offset":{"type":"number"}},"required":["organizations","total","limit","offset"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"post":{"tags":["Organizations"],"summary":"Create organization","description":"Create a new organization. The current user becomes the owner.","security":[{"bearerAuth":[]}],"requestBody":{"description":"Organization details","content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100},"slug":{"type":"string","minLength":2,"maxLength":50,"pattern":"^[a-z0-9-]+$"},"type":{"type":"string","enum":["personal","team","agency","enterprise"],"default":"team"},"description":{"type":"string","maxLength":500},"website":{"type":"string","format":"uri"},"logo":{"type":"string","format":"uri"},"industry":{"type":"string"},"size":{"type":"string","enum":["1-10","11-50","51-200","201-500","500+"]}},"required":["name"]}}}},"responses":{"201":{"description":"Created organization","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"type":{"type":"string","enum":["personal","team","agency","enterprise"]},"description":{"type":["string","null"]},"website":{"type":["string","null"]},"logo":{"type":["string","null"]},"industry":{"type":["string","null"]},"size":{"type":["string","null"],"enum":["1-10","11-50","51-200","201-500","501-1000","1001+",null]},"billingEmail":{"type":["string","null"]},"supportEmail":{"type":["string","null"]},"phoneNumber":{"type":["string","null"]},"memberCount":{"type":"number"},"settings":{"type":["object","null"],"additionalProperties":{}},"createdAt":{"type":"string"},"updatedAt":{"type":"string"},"memberRole":{"type":"string"},"memberJoinedAt":{"type":"string"}},"required":["id","name","slug","type","description","website","logo","industry","size","memberCount","settings","createdAt","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"409":{"description":"Resource already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/organizations/{organizationId}":{"get":{"tags":["Organizations"],"summary":"Get organization","description":"Get details of a specific organization.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"organizationId","in":"path"}],"responses":{"200":{"description":"Organization details","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"type":{"type":"string","enum":["personal","team","agency","enterprise"]},"description":{"type":["string","null"]},"website":{"type":["string","null"]},"logo":{"type":["string","null"]},"industry":{"type":["string","null"]},"size":{"type":["string","null"],"enum":["1-10","11-50","51-200","201-500","501-1000","1001+",null]},"billingEmail":{"type":["string","null"]},"supportEmail":{"type":["string","null"]},"phoneNumber":{"type":["string","null"]},"memberCount":{"type":"number"},"settings":{"type":["object","null"],"additionalProperties":{}},"createdAt":{"type":"string"},"updatedAt":{"type":"string"},"memberRole":{"type":"string"},"memberJoinedAt":{"type":"string"}},"required":["id","name","slug","type","description","website","logo","industry","size","memberCount","settings","createdAt","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"patch":{"tags":["Organizations"],"summary":"Update organization","description":"Update organization details. Requires admin role.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"organizationId","in":"path"}],"requestBody":{"description":"Organization updates","content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100},"description":{"type":["string","null"],"maxLength":500},"website":{"type":["string","null"],"format":"uri"},"logo":{"type":["string","null"],"format":"uri"},"industry":{"type":["string","null"]},"size":{"type":["string","null"],"enum":["1-10","11-50","51-200","201-500","501-1000","1001+",null]},"billingEmail":{"type":["string","null"],"format":"email"},"supportEmail":{"type":["string","null"],"format":"email"},"phoneNumber":{"type":["string","null"]},"taxIdNumber":{"type":["string","null"]},"addressLine1":{"type":["string","null"]},"addressLine2":{"type":["string","null"]},"city":{"type":["string","null"]},"state":{"type":["string","null"]},"postalCode":{"type":["string","null"]},"country":{"type":["string","null"]},"settings":{"type":"object","additionalProperties":{}}}}}}},"responses":{"200":{"description":"Updated organization","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"type":{"type":"string","enum":["personal","team","agency","enterprise"]},"description":{"type":["string","null"]},"website":{"type":["string","null"]},"logo":{"type":["string","null"]},"industry":{"type":["string","null"]},"size":{"type":["string","null"],"enum":["1-10","11-50","51-200","201-500","501-1000","1001+",null]},"billingEmail":{"type":["string","null"]},"supportEmail":{"type":["string","null"]},"phoneNumber":{"type":["string","null"]},"memberCount":{"type":"number"},"settings":{"type":["object","null"],"additionalProperties":{}},"createdAt":{"type":"string"},"updatedAt":{"type":"string"},"memberRole":{"type":"string"},"memberJoinedAt":{"type":"string"}},"required":["id","name","slug","type","description","website","logo","industry","size","memberCount","settings","createdAt","updatedAt"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"delete":{"tags":["Organizations"],"summary":"Delete organization","description":"Delete an organization. Requires owner role.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"organizationId","in":"path"}],"responses":{"204":{"description":"Organization deleted successfully"},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/organizations/{organizationId}/members":{"get":{"tags":["Organizations"],"summary":"List organization members","description":"List members of a specific organization by its ID.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"organizationId","in":"path"},{"schema":{"type":["number","null"]},"required":false,"name":"limit","in":"query"},{"schema":{"type":["number","null"]},"required":false,"name":"offset","in":"query"}],"responses":{"200":{"description":"Organization members","content":{"application/json":{"schema":{"type":"object","properties":{"members":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"role":{"type":"string"},"joinedAt":{"type":"string"},"displayName":{"type":["string","null"]},"email":{"type":["string","null"]}},"required":["id","userId","role","joinedAt"]}},"total":{"type":"number"}},"required":["members","total"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/auth/switch-organization":{"post":{"operationId":"authSwitchOrganization","summary":"Switch active organization","description":"Switch the currently active organization for the authenticated user. The user must be a member of the target organization.","tags":["Organizations"],"security":[{"Bearer":[]}],"requestBody":{"description":"Organization to switch to","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SwitchOrganizationRequest"}}}},"responses":{"200":{"description":"Successfully switched organization","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SwitchOrganizationResponse"}}}},"400":{"description":"Invalid organization ID","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SwitchOrganizationError"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SwitchOrganizationError"}}}},"403":{"description":"Not a member of this organization","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SwitchOrganizationError"}}}},"404":{"description":"Organization not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SwitchOrganizationError"}}}}}}},"/v1/users/me":{"get":{"operationId":"getCurrentUser","summary":"Get current user profile","description":"Get the current authenticated user profile with organizations","tags":["Users"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"User profile retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserProfile"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}}},"/v1/users":{"patch":{"operationId":"updateUser","summary":"Update user profile","description":"Update profile fields for the current user (name, avatar, username, etc.)","tags":["Users"],"security":[{"Bearer":[]}],"requestBody":{"description":"Profile fields to update","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateUser"}}}},"responses":{"200":{"description":"Profile updated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserProfile"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"409":{"description":"Username already taken","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}},"delete":{"operationId":"deleteUser","summary":"Delete user account","description":"Permanently delete the current user account. Requires password confirmation.","tags":["Users"],"security":[{"Bearer":[]}],"requestBody":{"description":"Account deletion confirmation","required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"password":{"type":"string"},"confirmPhrase":{"type":"string"}}}}}},"responses":{"200":{"description":"Account deleted","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"}},"required":["success"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}}},"/v1/users/emails":{"get":{"operationId":"getUserEmails","summary":"Get user email addresses","description":"Get all email addresses associated with the current user","tags":["Users"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Emails retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetEmailsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}},"post":{"operationId":"addUserEmail","summary":"Add email address","description":"Add a new email address to the current user account","tags":["Users"],"security":[{"Bearer":[]}],"requestBody":{"description":"Email address to add","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddEmail"}}}},"responses":{"201":{"description":"Email added successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddEmailResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"409":{"description":"Email already exists","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}}},"/v1/users/emails/{emailId}":{"delete":{"operationId":"deleteUserEmail","summary":"Remove email address","description":"Remove an email address from the current user account. Cannot remove primary email.","tags":["Users"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"emailId","in":"path"}],"responses":{"200":{"description":"Email removed successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeleteEmailResponse"}}}},"400":{"description":"Cannot remove primary email","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"404":{"description":"Email not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}}},"/v1/users/emails/{emailId}/verify-code":{"post":{"operationId":"verifyEmailCode","summary":"Verify email with code","description":"Verify an email address using a verification code.","tags":["Users"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"emailId","in":"path"}],"requestBody":{"description":"Verification code","required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string","description":"6-digit verification code"}},"required":["code"]}}}},"responses":{"200":{"description":"Email verified","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"}},"required":["success"]}}}},"400":{"description":"Invalid or expired code","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"404":{"description":"Email not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}}},"/v1/users/me/organizations":{"get":{"operationId":"getUserOrganizations","summary":"Get user organizations","description":"Get all organizations the current user is a member of","tags":["Users"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Organizations retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetUserOrganizationsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}}},"/v1/users/me/active-organization":{"post":{"operationId":"setActiveOrganization","summary":"Set active organization","description":"Sets the active organization for the current session. User must be an active member.","tags":["Users"],"security":[{"Bearer":[]}],"requestBody":{"description":"Organization to activate","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SetActiveOrganizationRequest"}}}},"responses":{"200":{"description":"Active organization set","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SetActiveOrganizationResponse"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"403":{"description":"Not a member of the organization","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}}},"/v1/users/preferences":{"get":{"operationId":"getUserPreferences","summary":"Get user preferences","description":"Get user preferences (theme, language, notifications, etc.)","tags":["Users"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Preferences retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetPreferencesResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}},"patch":{"operationId":"updateUserPreferences","summary":"Update user preferences","description":"Update user preferences (theme, language, notifications, etc.)","tags":["Users"],"security":[{"Bearer":[]}],"requestBody":{"description":"Preferences to update","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdatePreferences"}}}},"responses":{"200":{"description":"Preferences updated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetPreferencesResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}}},"/v1/users/dashboard":{"get":{"operationId":"getUserDashboard","summary":"Get personal dashboard data","description":"Retrieve comprehensive data for the user's personal dashboard including stats, organizations, recent activity, and chart data.","tags":["Users"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Personal dashboard data","content":{"application/json":{"schema":{"type":"object","properties":{"stats":{"type":"object","properties":{"totalOrganizations":{"type":"number"},"teamOrganizations":{"type":"number"},"totalLogins":{"type":"number"},"loginsLast7Days":{"type":"number"},"loginsLast30Days":{"type":"number"},"activeDevices":{"type":"number"},"unresolvedAlerts":{"type":"number"},"accountAge":{"type":"number"},"emailVerified":{"type":"boolean"},"twoFactorEnabled":{"type":"boolean"}},"required":["totalOrganizations","teamOrganizations","totalLogins","loginsLast7Days","loginsLast30Days","activeDevices","unresolvedAlerts","accountAge","emailVerified","twoFactorEnabled"]},"organizations":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":["string","null"]},"type":{"type":"string","enum":["personal","organization"]},"logo":{"type":["string","null"]},"role":{"type":"string"},"memberCount":{"type":"number"},"isActive":{"type":"boolean"}},"required":["id","name","slug","type","logo","role","memberCount","isActive"]}},"recentActivity":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string"},"title":{"type":"string"},"description":{"type":["string","null"]},"severity":{"type":["string","null"],"enum":["info","warning","critical","low","medium","high",null]},"createdAt":{"type":"string"},"ipAddress":{"type":["string","null"]},"location":{"type":["string","null"]}},"required":["id","type","title","description","severity","createdAt","ipAddress","location"]}},"activityChart":{"type":"array","items":{"type":"object","properties":{"date":{"type":"string"},"logins":{"type":"number"},"events":{"type":"number"}},"required":["date","logins","events"]}}},"required":["stats","organizations","recentActivity","activityChart"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}},"required":["error"]}}}}}}},"/v1/users/devices":{"get":{"tags":["Devices"],"summary":"List trusted devices","description":"Get all trusted devices for the current user","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"List of trusted devices","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetDevicesResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"delete":{"tags":["Devices"],"summary":"Revoke all devices","description":"Remove all devices from trusted devices","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"All devices revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessCountResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/users/devices/trust":{"post":{"tags":["Devices"],"summary":"Trust a device","description":"Mark the current device as trusted","security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TrustDeviceRequest"}}}},"responses":{"200":{"description":"Device trusted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TrustDeviceResponse"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/users/devices/{deviceId}":{"patch":{"tags":["Devices"],"summary":"Rename a device","description":"Update the name of a trusted device","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","example":"device_abc123"},"required":true,"name":"deviceId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RenameDeviceRequest"}}}},"responses":{"200":{"description":"Device renamed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Device not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"delete":{"tags":["Devices"],"summary":"Revoke a device","description":"Remove a device from trusted devices","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","example":"device_abc123"},"required":true,"name":"deviceId","in":"path"}],"responses":{"200":{"description":"Device revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Device not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/users/notifications":{"get":{"operationId":"listNotifications","tags":["Notifications"],"summary":"List my notifications","description":"List notifications for the current user","security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"default":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":100,"default":20},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string"},"required":false,"name":"unreadOnly","in":"query"},{"schema":{"type":"string","enum":["system","billing","security","feature","marketing","support","job"]},"required":false,"name":"type","in":"query"}],"responses":{"200":{"description":"Notifications list","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListNotificationsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/users/notifications/unread-count":{"get":{"operationId":"getUnreadCount","tags":["Notifications"],"summary":"Get unread notification count","description":"Get the count of unread notifications for the current user","security":[{"Bearer":[]}],"responses":{"200":{"description":"Unread count","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnreadCountResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/users/notifications/mark-read":{"post":{"operationId":"markNotificationsRead","tags":["Notifications"],"summary":"Mark notifications as read","description":"Mark specific notifications as read","security":[{"Bearer":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"notificationIds":{"type":"array","items":{"type":"string"},"minItems":1,"maxItems":100}},"required":["notificationIds"]}}}},"responses":{"200":{"description":"Notifications marked as read","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MarkReadResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/users/notifications/mark-all-read":{"post":{"operationId":"markAllNotificationsRead","tags":["Notifications"],"summary":"Mark all notifications as read","description":"Mark all notifications as read for the current user","security":[{"Bearer":[]}],"responses":{"200":{"description":"All notifications marked as read","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MarkReadResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/users/notifications/{notificationId}/dismiss":{"post":{"operationId":"dismissNotification","tags":["Notifications"],"summary":"Dismiss a notification","description":"Dismiss a notification (hides it from the list)","security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"notificationId","in":"path"}],"responses":{"200":{"description":"Notification dismissed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Notification"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Notification not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/users/test-notification":{"post":{"operationId":"sendTestNotification","tags":["Users"],"summary":"Send test notification","description":"Send a test email to verify email notifications are working","security":[{"Bearer":[]}],"responses":{"200":{"description":"Test notification sent successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TestNotificationResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"500":{"description":"Failed to send email","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/users/security-alerts":{"get":{"operationId":"getUnreadAlerts","summary":"Get security alerts","description":"Get all unread and non-dismissed security alerts for the current user","tags":["Users","Security"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Alerts retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserSecurityAlertsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/users/security-alerts/count":{"get":{"operationId":"getUnreadAlertCount","summary":"Get unread alert count","description":"Get the count of unread security alerts for the current user","tags":["Users","Security"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Count retrieved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetAlertCountResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/users/security-alerts/{alertId}/read":{"post":{"operationId":"markAlertAsRead","summary":"Mark alert as read","description":"Mark a specific security alert as read","tags":["Users","Security"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"alert_abc123"},"required":true,"name":"alertId","in":"path"}],"responses":{"200":{"description":"Alert marked as read","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Alert not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/users/security-alerts/read-all":{"post":{"operationId":"markAllAlertsAsRead","summary":"Mark all alerts as read","description":"Mark all security alerts as read for the current user","tags":["Users","Security"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"All alerts marked as read","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessCountResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/users/security-alerts/{alertId}/dismiss":{"post":{"operationId":"dismissAlert","summary":"Dismiss alert","description":"Dismiss a security alert (will no longer appear in unread list)","tags":["Users","Security"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"alert_abc123"},"required":true,"name":"alertId","in":"path"}],"responses":{"200":{"description":"Alert dismissed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Alert not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/users/security-alerts/dismiss-all":{"post":{"operationId":"dismissAllAlerts","summary":"Dismiss all alerts","description":"Dismiss all security alerts for the current user","tags":["Users","Security"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"All alerts dismissed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessCountResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/users/security-events":{"get":{"tags":["Users"],"summary":"Get security events","description":"Get recent security events for the current user with pagination","security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","default":"10","example":"10"},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","default":"0","example":"0"},"required":false,"name":"offset","in":"query"},{"schema":{"type":"string","example":"login"},"required":false,"name":"eventType","in":"query"}],"responses":{"200":{"description":"Security events retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SecurityEventsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/users/export":{"post":{"tags":["Users"],"summary":"Export user data","description":"Export all user data in a GDPR-compliant format (JSON)","security":[{"Bearer":[]}],"responses":{"200":{"description":"User data exported successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExportUserDataResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/users/companion/profile":{"get":{"operationId":"getCompanionProfile","summary":"Get companion profile","description":"Get the AI companion profile for the current user, including personality traits","tags":["Companion"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Companion profile retrieved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetCompanionProfileResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"patch":{"operationId":"updateCompanionProfile","summary":"Update companion profile","description":"Update the AI companion name, pronouns, or personality preset","tags":["Companion"],"security":[{"Bearer":[]}],"requestBody":{"description":"Profile updates","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateCompanionProfileRequest"}}}},"responses":{"200":{"description":"Companion profile updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateCompanionProfileResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/users/companion/personality-presets":{"get":{"operationId":"getPersonalityPresets","summary":"Get personality presets","description":"Get all available personality presets for companion customization","tags":["Companion"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Personality presets retrieved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetPersonalityPresetsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/users/companion/personality-traits":{"get":{"operationId":"getPersonalityTraits","summary":"Get personality traits","description":"Get the detailed personality trait configuration for the companion","tags":["Companion"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Personality traits retrieved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetPersonalityTraitsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"patch":{"operationId":"updatePersonalityTraits","summary":"Update personality traits","description":"Update individual personality trait values for fine-grained control","tags":["Companion"],"security":[{"Bearer":[]}],"requestBody":{"description":"Trait updates","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdatePersonalityTraitsRequest"}}}},"responses":{"200":{"description":"Personality traits updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdatePersonalityTraitsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/users/companion/onboarding":{"get":{"operationId":"getCompanionOnboarding","summary":"Get onboarding progress","description":"Get the current onboarding progress for companion setup","tags":["Companion"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Onboarding progress retrieved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetOnboardingResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"patch":{"operationId":"updateCompanionOnboarding","summary":"Update onboarding progress","description":"Update the onboarding step or complete/skip onboarding","tags":["Companion"],"security":[{"Bearer":[]}],"requestBody":{"description":"Onboarding updates","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateOnboardingRequest"}}}},"responses":{"200":{"description":"Onboarding progress updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateOnboardingResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/users/companion/avatars":{"get":{"operationId":"getCompanionAvatars","summary":"Get available avatars","description":"Get all avatar bases with unlock status for the current user","tags":["Companion"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Avatars retrieved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetAvatarsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/users/companion/items":{"get":{"operationId":"getCompanionItems","summary":"Get available items","description":"Get all cosmetic items with optional category filter","tags":["Companion"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","description":"Filter by category (head, face, body, accessory, background)","example":"head"},"required":false,"description":"Filter by category (head, face, body, accessory, background)","name":"category","in":"query"}],"responses":{"200":{"description":"Items retrieved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetItemsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/users/companion/inventory":{"get":{"operationId":"getCompanionInventory","summary":"Get user inventory","description":"Get all items owned by the current user","tags":["Companion"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Inventory retrieved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetInventoryResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/users/companion/outfit":{"get":{"operationId":"getCompanionOutfit","summary":"Get current outfit","description":"Get the currently equipped avatar and items","tags":["Companion"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Outfit retrieved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetOutfitResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"patch":{"operationId":"updateCompanionOutfit","summary":"Update outfit","description":"Equip or unequip avatar and items","tags":["Companion"],"security":[{"Bearer":[]}],"requestBody":{"description":"Outfit updates","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateOutfitRequest"}}}},"responses":{"200":{"description":"Outfit updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateOutfitResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/users/companion/context":{"get":{"tags":["Companion - Context"],"summary":"Get user context items","description":"Retrieves all active context items for the companion to use.","parameters":[{"schema":{"type":"string","enum":["user_preference","workflow","project","relationship","general"]},"required":false,"name":"type","in":"query"}],"responses":{"200":{"description":"Context items retrieved successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"contexts":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"contextType":{"type":"string","enum":["user_preference","workflow","project","relationship","general","settings","timezone","work_hours","weather","location"]},"key":{"type":"string"},"value":{"type":"string"},"confidence":{"type":"number","minimum":0,"maximum":1},"source":{"type":"string","enum":["explicit","inferred","system"]},"lastUsed":{"type":["string","null"]},"expiresAt":{"type":["string","null"]},"isActive":{"type":"boolean"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","contextType","key","value","confidence","source","lastUsed","expiresAt","isActive","createdAt","updatedAt"]}}},"required":["success","contexts"]}}}}}},"post":{"tags":["Companion - Context"],"summary":"Add a context item","description":"Adds a new context item for the companion to remember.","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"contextType":{"type":"string","enum":["user_preference","workflow","project","relationship","general","settings","timezone","work_hours","weather","location"]},"key":{"type":"string","minLength":1,"maxLength":100},"value":{"type":"string","minLength":1,"maxLength":5000},"confidence":{"type":"number","minimum":0,"maximum":1,"default":1},"source":{"type":"string","enum":["explicit","inferred","system"],"default":"explicit"},"expiresAt":{"type":["string","null"]}},"required":["contextType","key","value"]}}}},"responses":{"201":{"description":"Context item added successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"context":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"contextType":{"type":"string","enum":["user_preference","workflow","project","relationship","general","settings","timezone","work_hours","weather","location"]},"key":{"type":"string"},"value":{"type":"string"},"confidence":{"type":"number","minimum":0,"maximum":1},"source":{"type":"string","enum":["explicit","inferred","system"]},"lastUsed":{"type":["string","null"]},"expiresAt":{"type":["string","null"]},"isActive":{"type":"boolean"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","contextType","key","value","confidence","source","lastUsed","expiresAt","isActive","createdAt","updatedAt"]}},"required":["success","context"]}}}}}}},"/v1/users/companion/context/{contextId}":{"delete":{"tags":["Companion - Context"],"summary":"Delete a context item","description":"Removes a context item.","parameters":[{"schema":{"type":"string"},"required":true,"name":"contextId","in":"path"}],"responses":{"200":{"description":"Context item deleted successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"}},"required":["success"]}}}}}}},"/v1/users/companion/memories":{"get":{"tags":["Companion - Context"],"summary":"Get companion memories","description":"Retrieves memory items the companion has stored.","parameters":[{"schema":{"type":"string","enum":["fact","preference","interaction","milestone"]},"required":false,"name":"type","in":"query"},{"schema":{"type":"string"},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"Memories retrieved successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"memories":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string","enum":["fact","preference","interaction","milestone"]},"content":{"type":"string"},"importance":{"type":"string","enum":["low","medium","high","critical"]},"relatedEntity":{"type":["string","null"]},"createdAt":{"type":"string"}},"required":["id","type","content","importance","relatedEntity","createdAt"]}}},"required":["success","memories"]}}}}}},"post":{"tags":["Companion - Context"],"summary":"Add a memory","description":"Adds a new memory item for the companion.","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"type":{"type":"string","enum":["fact","preference","interaction","milestone"]},"content":{"type":"string","minLength":1,"maxLength":5000},"importance":{"type":"string","enum":["low","medium","high","critical"],"default":"medium"},"relatedEntity":{"type":["string","null"]}},"required":["type","content"]}}}},"responses":{"201":{"description":"Memory added successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"memory":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string","enum":["fact","preference","interaction","milestone"]},"content":{"type":"string"},"importance":{"type":"string","enum":["low","medium","high","critical"]},"relatedEntity":{"type":["string","null"]},"createdAt":{"type":"string"}},"required":["id","type","content","importance","relatedEntity","createdAt"]}},"required":["success","memory"]}}}}}}},"/v1/users/companion/greeting":{"get":{"tags":["Companion - Context"],"summary":"Get contextual greeting","description":"Returns a personalized greeting based on time, streak, and recent activity.","responses":{"200":{"description":"Greeting generated successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"greeting":{"type":"string"},"timeOfDay":{"type":"string","enum":["morning","afternoon","evening","night"]},"streak":{"type":"number"},"recentActivity":{"type":["string","null"]}},"required":["success","greeting","timeOfDay","streak","recentActivity"]}}}}}}},"/v1/users/companion/context-prompt":{"get":{"tags":["Companion - Context"],"summary":"Build context prompt for AI","description":"Builds a context-aware prompt section for use in AI system prompts.","responses":{"200":{"description":"Context prompt built successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"prompt":{"type":"string"},"contextItems":{"type":"number"}},"required":["success","prompt","contextItems"]}}}}}}},"/v1/users/companion/level":{"get":{"operationId":"getCompanionUserLevel","summary":"Get user level","description":"Get current XP, level, and progress to next level","tags":["Companion"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"User level retrieved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetUserLevelResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/users/companion/xp/history":{"get":{"operationId":"getCompanionXpHistory","summary":"Get XP history","description":"Get recent XP earning history","tags":["Companion"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"20"},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"XP history retrieved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetXpHistoryResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/users/companion/xp/award":{"post":{"operationId":"awardCompanionXp","summary":"Award XP","description":"Award XP for an action (internal use)","tags":["Companion"],"security":[{"Bearer":[]}],"requestBody":{"description":"XP award request","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AwardXpRequest"}}}},"responses":{"200":{"description":"XP awarded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AwardXpResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/users/companion/achievements":{"get":{"operationId":"getCompanionAchievements","summary":"Get achievements","description":"Get all achievements with user progress","tags":["Companion"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"streaks"},"required":false,"name":"category","in":"query"}],"responses":{"200":{"description":"Achievements retrieved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetAchievementsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/users/companion/leaderboard":{"get":{"operationId":"getCompanionLeaderboard","summary":"Get leaderboard","description":"Get organization XP leaderboard","tags":["Companion"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"10"},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"Leaderboard retrieved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetLeaderboardResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/users/companion/voice/options":{"get":{"tags":["Companion - Voice"],"summary":"Get available voice options","description":"Retrieves all available voice options for the companion.","parameters":[{"schema":{"type":"string","enum":["masculine","feminine","neutral"]},"required":false,"name":"gender","in":"query"},{"schema":{"type":"string"},"required":false,"name":"provider","in":"query"}],"responses":{"200":{"description":"Voice options retrieved successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"voices":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"slug":{"type":"string"},"name":{"type":"string"},"description":{"type":["string","null"]},"provider":{"type":"string","enum":["elevenlabs","openai","azure","google","system"]},"voiceId":{"type":"string"},"gender":{"type":"string","enum":["masculine","feminine","neutral"]},"accent":{"type":["string","null"]},"style":{"type":["string","null"]},"sampleUrl":{"type":["string","null"]},"isPremium":{"type":"boolean"},"isActive":{"type":"boolean"}},"required":["id","slug","name","description","provider","voiceId","gender","accent","style","sampleUrl","isPremium","isActive"]}}},"required":["success","voices"]}}}}}}},"/v1/users/companion/voice":{"get":{"tags":["Companion - Voice"],"summary":"Get user voice preference","description":"Retrieves the user's current voice preference for the companion.","responses":{"200":{"description":"Voice preference retrieved successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"preference":{"type":["object","null"],"properties":{"id":{"type":"string"},"userId":{"type":"string"},"voiceId":{"type":"string"},"pitch":{"type":"number","minimum":-50,"maximum":50},"speed":{"type":"number","minimum":0.5,"maximum":2},"volume":{"type":"number","minimum":0,"maximum":100},"isEnabled":{"type":"boolean"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","voiceId","pitch","speed","volume","isEnabled","createdAt","updatedAt"]},"voice":{"type":["object","null"],"properties":{"id":{"type":"string"},"slug":{"type":"string"},"name":{"type":"string"},"description":{"type":["string","null"]},"provider":{"type":"string","enum":["elevenlabs","openai","azure","google","system"]},"voiceId":{"type":"string"},"gender":{"type":"string","enum":["masculine","feminine","neutral"]},"accent":{"type":["string","null"]},"style":{"type":["string","null"]},"sampleUrl":{"type":["string","null"]},"isPremium":{"type":"boolean"},"isActive":{"type":"boolean"}},"required":["id","slug","name","description","provider","voiceId","gender","accent","style","sampleUrl","isPremium","isActive"]}},"required":["success","preference","voice"]}}}}}},"patch":{"tags":["Companion - Voice"],"summary":"Update user voice preference","description":"Updates the user's voice preference for the companion.","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"voiceId":{"type":"string"},"pitch":{"type":"number","minimum":-50,"maximum":50},"speed":{"type":"number","minimum":0.5,"maximum":2},"volume":{"type":"number","minimum":0,"maximum":100},"isEnabled":{"type":"boolean"}}}}}},"responses":{"200":{"description":"Voice preference updated successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"preference":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"voiceId":{"type":"string"},"pitch":{"type":"number","minimum":-50,"maximum":50},"speed":{"type":"number","minimum":0.5,"maximum":2},"volume":{"type":"number","minimum":0,"maximum":100},"isEnabled":{"type":"boolean"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","voiceId","pitch","speed","volume","isEnabled","createdAt","updatedAt"]}},"required":["success","preference"]}}}}}}},"/v1/users/companion/voice/test":{"post":{"tags":["Companion - Voice"],"summary":"Test a voice","description":"Generates a sample audio clip to test a specific voice.","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"voiceId":{"type":"string"},"text":{"type":"string","minLength":1,"maxLength":500}},"required":["voiceId"]}}}},"responses":{"200":{"description":"Voice test audio generated successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"audioUrl":{"type":"string"},"duration":{"type":"number"}},"required":["success","audioUrl","duration"]}}}}}}},"/v1/users/companion/voice/synthesize":{"post":{"tags":["Companion - Voice"],"summary":"Synthesize speech","description":"Converts text to speech using the user's preferred voice.","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"text":{"type":"string","minLength":1,"maxLength":5000},"voiceId":{"type":"string"}},"required":["text"]}}}},"responses":{"200":{"description":"Speech synthesized successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"audioUrl":{"type":"string"},"duration":{"type":"number"},"charactersUsed":{"type":"number"}},"required":["success","audioUrl","duration","charactersUsed"]}}}}}}},"/v1/users/companion/pets":{"get":{"tags":["Companion - Advanced"],"summary":"Get pets","description":"Retrieves available pets and user's adopted pets.","responses":{"200":{"description":"Pets retrieved successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"availablePets":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"slug":{"type":"string"},"name":{"type":"string"},"description":{"type":["string","null"]},"type":{"type":"string","enum":["cat","dog","bird","dragon","robot","magical"]},"rarity":{"type":"string","enum":["common","uncommon","rare","epic","legendary"]},"requiredLevel":{"type":"number"},"unlockCondition":{"type":["string","null"]},"animationUrl":{"type":["string","null"]},"soundUrl":{"type":["string","null"]},"isActive":{"type":"boolean"}},"required":["id","slug","name","description","type","rarity","requiredLevel","unlockCondition","animationUrl","soundUrl","isActive"]}},"userPets":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"petId":{"type":"string"},"customName":{"type":["string","null"]},"affection":{"type":"number","minimum":0,"maximum":100},"lastInteraction":{"type":["string","null"]},"isActive":{"type":"boolean"},"unlockedAt":{"type":"string"}},"required":["id","userId","petId","customName","affection","lastInteraction","isActive","unlockedAt"]}}},"required":["success","availablePets","userPets"]}}}}}},"post":{"tags":["Companion - Advanced"],"summary":"Adopt a pet","description":"Adopts a new pet for the companion.","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"petId":{"type":"string"},"customName":{"type":"string","maxLength":50}},"required":["petId"]}}}},"responses":{"201":{"description":"Pet adopted successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"userPet":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"petId":{"type":"string"},"customName":{"type":["string","null"]},"affection":{"type":"number","minimum":0,"maximum":100},"lastInteraction":{"type":["string","null"]},"isActive":{"type":"boolean"},"unlockedAt":{"type":"string"}},"required":["id","userId","petId","customName","affection","lastInteraction","isActive","unlockedAt"]}},"required":["success","userPet"]}}}}}}},"/v1/users/companion/pets/{petId}/interact":{"post":{"tags":["Companion - Advanced"],"summary":"Interact with pet","description":"Interacts with an adopted pet to increase affection.","parameters":[{"schema":{"type":"string"},"required":true,"name":"petId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"action":{"type":"string","enum":["pet","feed","play","walk"]}},"required":["action"]}}}},"responses":{"200":{"description":"Interaction successful","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"affectionGained":{"type":"number"},"newAffection":{"type":"number"},"message":{"type":"string"}},"required":["success","affectionGained","newAffection","message"]}}}}}}},"/v1/users/companion/seasonal":{"get":{"tags":["Companion - Advanced"],"summary":"Get seasonal events","description":"Retrieves current and upcoming seasonal events.","responses":{"200":{"description":"Seasonal events retrieved successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"currentEvent":{"type":["object","null"],"properties":{"id":{"type":"string"},"slug":{"type":"string"},"name":{"type":"string"},"description":{"type":["string","null"]},"theme":{"type":"string"},"startDate":{"type":"string"},"endDate":{"type":"string"},"specialItems":{"type":["array","null"],"items":{"type":"string"}},"specialAvatars":{"type":["array","null"],"items":{"type":"string"}},"xpMultiplier":{"type":"number"},"isActive":{"type":"boolean"}},"required":["id","slug","name","description","theme","startDate","endDate","specialItems","specialAvatars","xpMultiplier","isActive"]},"upcomingEvents":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"slug":{"type":"string"},"name":{"type":"string"},"description":{"type":["string","null"]},"theme":{"type":"string"},"startDate":{"type":"string"},"endDate":{"type":"string"},"specialItems":{"type":["array","null"],"items":{"type":"string"}},"specialAvatars":{"type":["array","null"],"items":{"type":"string"}},"xpMultiplier":{"type":"number"},"isActive":{"type":"boolean"}},"required":["id","slug","name","description","theme","startDate","endDate","specialItems","specialAvatars","xpMultiplier","isActive"]}}},"required":["success","currentEvent","upcomingEvents"]}}}}}}},"/v1/users/companion/terminology":{"get":{"tags":["Companion - Advanced"],"summary":"Get taught terminology","description":"Retrieves terms the user has taught the companion.","parameters":[{"schema":{"type":"string"},"required":false,"name":"category","in":"query"}],"responses":{"200":{"description":"Terminology retrieved successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"terms":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"term":{"type":"string"},"definition":{"type":"string"},"category":{"type":["string","null"]},"examples":{"type":["array","null"],"items":{"type":"string"}},"isActive":{"type":"boolean"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","term","definition","category","examples","isActive","createdAt","updatedAt"]}}},"required":["success","terms"]}}}}}},"post":{"tags":["Companion - Advanced"],"summary":"Teach a term","description":"Teaches the companion a new term or concept.","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"term":{"type":"string","minLength":1,"maxLength":100},"definition":{"type":"string","minLength":1,"maxLength":2000},"category":{"type":"string","maxLength":50},"examples":{"type":"array","items":{"type":"string","maxLength":500}}},"required":["term","definition"]}}}},"responses":{"201":{"description":"Term taught successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"terminology":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"term":{"type":"string"},"definition":{"type":"string"},"category":{"type":["string","null"]},"examples":{"type":["array","null"],"items":{"type":"string"}},"isActive":{"type":"boolean"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","term","definition","category","examples","isActive","createdAt","updatedAt"]}},"required":["success","terminology"]}}}}}}},"/v1/users/companion/terminology/{termId}":{"delete":{"tags":["Companion - Advanced"],"summary":"Delete a term","description":"Removes a taught term from the companion.","parameters":[{"schema":{"type":"string"},"required":true,"name":"termId","in":"path"}],"responses":{"200":{"description":"Term deleted successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"}},"required":["success"]}}}}}}},"/v1/users/companion/easter-eggs":{"get":{"tags":["Companion - Advanced"],"summary":"Get discovered easter eggs","description":"Retrieves easter eggs the user has discovered.","responses":{"200":{"description":"Easter eggs retrieved successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"discovered":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"trigger":{"type":"string"},"response":{"type":"string"},"category":{"type":"string"},"xpReward":{"type":"number"},"isDiscovered":{"type":"boolean"}},"required":["id","trigger","response","category","xpReward","isDiscovered"]}},"totalCount":{"type":"number"},"discoveredCount":{"type":"number"}},"required":["success","discovered","totalCount","discoveredCount"]}}}}}}},"/v1/users/companion/easter-eggs/trigger":{"post":{"tags":["Companion - Advanced"],"summary":"Trigger an easter egg","description":"Attempts to trigger an easter egg with a phrase or action.","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"trigger":{"type":"string"}},"required":["trigger"]}}}},"responses":{"200":{"description":"Easter egg check completed","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"found":{"type":"boolean"},"easterEgg":{"type":["object","null"],"properties":{"id":{"type":"string"},"trigger":{"type":"string"},"response":{"type":"string"},"category":{"type":"string"},"xpReward":{"type":"number"},"isDiscovered":{"type":"boolean"}},"required":["id","trigger","response","category","xpReward","isDiscovered"]},"xpAwarded":{"type":"number"},"message":{"type":["string","null"]}},"required":["success","found","easterEgg","xpAwarded","message"]}}}}}}},"/v1/teams":{"get":{"operationId":"listTeams","summary":"List organization teams","description":"Get all teams in the current organization","tags":["Teams"],"security":[{"Bearer":[]}],"responses":{"200":{"description":"Teams retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListTeamsResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}},"post":{"operationId":"createTeam","summary":"Create a team","description":"Create a new team in the organization","tags":["Teams"],"security":[{"Bearer":[]}],"requestBody":{"description":"Team details","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateTeam"}}}},"responses":{"201":{"description":"Team created successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TeamResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"409":{"description":"Team slug already exists","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}}},"/v1/teams/{teamId}":{"get":{"operationId":"getTeam","summary":"Get team details","description":"Get details of a specific team","tags":["Teams"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"team_abc123"},"required":true,"name":"teamId","in":"path"}],"responses":{"200":{"description":"Team retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TeamResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"404":{"description":"Team not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}},"patch":{"operationId":"updateTeam","summary":"Update team","description":"Update team details","tags":["Teams"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"team_abc123"},"required":true,"name":"teamId","in":"path"}],"requestBody":{"description":"Team fields to update","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateTeam"}}}},"responses":{"200":{"description":"Team updated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TeamResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"404":{"description":"Team not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}},"delete":{"operationId":"deleteTeam","summary":"Delete team","description":"Soft delete a team","tags":["Teams"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"team_abc123"},"required":true,"name":"teamId","in":"path"}],"responses":{"200":{"description":"Team deleted successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]}},"required":["success"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"404":{"description":"Team not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}}},"/v1/teams/{teamId}/members":{"get":{"operationId":"listTeamMembers","summary":"List team members","description":"Get all members of a team","tags":["Teams"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"team_abc123"},"required":true,"name":"teamId","in":"path"}],"responses":{"200":{"description":"Members retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TeamMembersResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"404":{"description":"Team not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}},"post":{"operationId":"addTeamMember","summary":"Add team member","description":"Add a user to a team","tags":["Teams"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"team_abc123"},"required":true,"name":"teamId","in":"path"}],"requestBody":{"description":"Member details","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddTeamMember"}}}},"responses":{"201":{"description":"Member added successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TeamMemberResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"404":{"description":"Team or user not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"409":{"description":"User is already a member","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}}},"/v1/teams/{teamId}/members/{memberId}":{"patch":{"operationId":"updateTeamMember","summary":"Update team member","description":"Update a team member role","tags":["Teams"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"team_abc123"},"required":true,"name":"teamId","in":"path"},{"schema":{"type":"string","example":"tm_xyz789"},"required":true,"name":"memberId","in":"path"}],"requestBody":{"description":"Member fields to update","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateTeamMember"}}}},"responses":{"200":{"description":"Member updated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TeamMemberResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"404":{"description":"Team member not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}},"delete":{"operationId":"removeTeamMember","summary":"Remove team member","description":"Remove a user from a team","tags":["Teams"],"security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","example":"team_abc123"},"required":true,"name":"teamId","in":"path"},{"schema":{"type":"string","example":"tm_xyz789"},"required":true,"name":"memberId","in":"path"}],"responses":{"200":{"description":"Member removed successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]}},"required":["success"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}},"404":{"description":"Team member not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]}}}}}}},"/v1/auth/2fa/verify":{"post":{"operationId":"twoFactorVerify","summary":"Complete 2FA challenge","description":"Submit a TOTP code or backup code to complete authentication after a 2FA challenge.","tags":["Two-Factor Authentication"],"requestBody":{"description":"2FA verification payload","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TwoFactorVerifyRequest"}}}},"responses":{"200":{"description":"Authentication complete","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TwoFactorVerifyResponse"}}}},"401":{"description":"Invalid code or expired challenge","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TwoFactorVerifyRequest"}}}}}}},"/v1/auth/2fa/status":{"get":{"operationId":"twoFactorStatus","summary":"Get 2FA status","description":"Returns whether two-factor authentication is enabled for the authenticated user.","tags":["Two-Factor Authentication"],"responses":{"200":{"description":"2FA status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TwoFactorStatusResponse"}}}}}}},"/v1/auth/2fa/setup":{"post":{"operationId":"twoFactorSetup","summary":"Begin 2FA setup","description":"Generates a new TOTP secret and backup codes. Call /enable after scanning the QR code.","tags":["Two-Factor Authentication"],"responses":{"200":{"description":"TOTP setup data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TwoFactorSetupResponse"}}}}}}},"/v1/auth/2fa/enable":{"post":{"operationId":"twoFactorEnable","summary":"Enable 2FA","description":"Verify the TOTP code from the authenticator app and enable two-factor authentication.","tags":["Two-Factor Authentication"],"requestBody":{"description":"TOTP verification code","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TwoFactorEnableRequest"}}}},"responses":{"200":{"description":"2FA enabled successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TwoFactorStatusResponse"}}}},"401":{"description":"Invalid TOTP code","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TwoFactorVerifyRequest"}}}}}}},"/v1/auth/2fa":{"delete":{"operationId":"twoFactorDisable","summary":"Disable 2FA","description":"Disables two-factor authentication. Requires either the current TOTP code or account password to prevent a stolen session from disabling MFA.","tags":["Two-Factor Authentication"],"requestBody":{"description":"Confirmation credential","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TwoFactorDisableRequest"}}}},"responses":{"200":{"description":"2FA disabled","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TwoFactorStatusResponse"}}}},"401":{"description":"Invalid code or password","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TwoFactorStatusResponse"}}}}}}},"/v1/workspaces":{"get":{"operationId":"listWorkspaces","summary":"List workspaces","description":"List all workspaces the authenticated user has access to (as owner or member).","tags":["Workspaces"],"parameters":[{"schema":{"type":"string","enum":["active","archived","suspended","closed"]},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","enum":["general","project","social_media","brand","product","event"]},"required":false,"name":"type","in":"query"}],"responses":{"200":{"description":"List of workspaces","content":{"application/json":{"schema":{"type":"object","properties":{"workspaces":{"type":"array","items":{"$ref":"#/components/schemas/Workspace"}},"total":{"type":"number"}},"required":["workspaces","total"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"post":{"operationId":"createWorkspace","summary":"Create a workspace","description":"Create a new workspace. The authenticated user becomes the owner. Workspace is scoped to their current organization.","tags":["Workspaces"],"requestBody":{"description":"Workspace details","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateWorkspace"}}}},"responses":{"201":{"description":"Workspace created","content":{"application/json":{"schema":{"type":"object","properties":{"workspace":{"$ref":"#/components/schemas/Workspace"}},"required":["workspace"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"409":{"description":"Resource already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/workspaces/{workspaceId}":{"get":{"operationId":"getWorkspace","summary":"Get workspace details","description":"Get a workspace by ID. Requires workspace membership.","tags":["Workspaces"],"parameters":[{"schema":{"type":"string","example":"ws_abc123","description":"Workspace ID"},"required":true,"description":"Workspace ID","name":"workspaceId","in":"path"}],"responses":{"200":{"description":"Workspace details","content":{"application/json":{"schema":{"type":"object","properties":{"workspace":{"$ref":"#/components/schemas/Workspace"}},"required":["workspace"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"patch":{"operationId":"updateWorkspace","summary":"Update a workspace","description":"Update workspace settings. Requires owner or admin role.","tags":["Workspaces"],"parameters":[{"schema":{"type":"string","example":"ws_abc123","description":"Workspace ID"},"required":true,"description":"Workspace ID","name":"workspaceId","in":"path"}],"requestBody":{"description":"Workspace updates","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateWorkspace"}}}},"responses":{"200":{"description":"Updated workspace","content":{"application/json":{"schema":{"type":"object","properties":{"workspace":{"$ref":"#/components/schemas/Workspace"}},"required":["workspace"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"delete":{"operationId":"deleteWorkspace","summary":"Delete a workspace","description":"Soft-delete a workspace. Requires owner role.","tags":["Workspaces"],"parameters":[{"schema":{"type":"string","example":"ws_abc123","description":"Workspace ID"},"required":true,"description":"Workspace ID","name":"workspaceId","in":"path"}],"responses":{"200":{"description":"Workspace deleted","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}},"required":["message"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/workspaces/{workspaceId}/members":{"get":{"operationId":"listWorkspaceMembers","summary":"List workspace members","description":"List all members of a workspace. Requires workspace membership.","tags":["Workspaces"],"parameters":[{"schema":{"type":"string","example":"ws_abc123","description":"Workspace ID"},"required":true,"description":"Workspace ID","name":"workspaceId","in":"path"}],"responses":{"200":{"description":"Workspace members","content":{"application/json":{"schema":{"type":"object","properties":{"members":{"type":"array","items":{"$ref":"#/components/schemas/WorkspaceMember"}}},"required":["members"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/workspaces/{workspaceId}/members/{memberId}":{"patch":{"operationId":"updateWorkspaceMember","summary":"Update workspace member","description":"Update a member role or status. Requires admin/owner role.","tags":["Workspaces"],"parameters":[{"schema":{"type":"string","example":"ws_abc123","description":"Workspace ID"},"required":true,"description":"Workspace ID","name":"workspaceId","in":"path"},{"schema":{"type":"string","example":"wsm_xyz789","description":"Workspace member ID"},"required":true,"description":"Workspace member ID","name":"memberId","in":"path"}],"requestBody":{"description":"Member updates","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateWorkspaceMember"}}}},"responses":{"200":{"description":"Updated member","content":{"application/json":{"schema":{"type":"object","properties":{"member":{"$ref":"#/components/schemas/WorkspaceMember"}},"required":["member"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"delete":{"operationId":"removeWorkspaceMember","summary":"Remove workspace member","description":"Remove a member from a workspace. Requires admin/owner role.","tags":["Workspaces"],"parameters":[{"schema":{"type":"string","example":"ws_abc123","description":"Workspace ID"},"required":true,"description":"Workspace ID","name":"workspaceId","in":"path"},{"schema":{"type":"string","example":"wsm_xyz789","description":"Workspace member ID"},"required":true,"description":"Workspace member ID","name":"memberId","in":"path"}],"responses":{"200":{"description":"Member removed","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}},"required":["message"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/workspaces/{workspaceId}/invitations":{"get":{"operationId":"listWorkspaceInvitations","summary":"List workspace invitations","description":"List all pending invitations for a workspace. Requires admin/owner role.","tags":["Workspaces"],"parameters":[{"schema":{"type":"string","example":"ws_abc123","description":"Workspace ID"},"required":true,"description":"Workspace ID","name":"workspaceId","in":"path"}],"responses":{"200":{"description":"Workspace invitations","content":{"application/json":{"schema":{"type":"object","properties":{"invitations":{"type":"array","items":{"$ref":"#/components/schemas/WorkspaceInvitation"}}},"required":["invitations"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}},"post":{"operationId":"inviteToWorkspace","summary":"Invite to workspace","description":"Invite a user by email to join a workspace. They can be from any organization. Requires admin/owner role.","tags":["Workspaces"],"parameters":[{"schema":{"type":"string","example":"ws_abc123","description":"Workspace ID"},"required":true,"description":"Workspace ID","name":"workspaceId","in":"path"}],"requestBody":{"description":"Invitation details","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InviteToWorkspace"}}}},"responses":{"201":{"description":"Invitation created","content":{"application/json":{"schema":{"type":"object","properties":{"invitation":{"$ref":"#/components/schemas/WorkspaceInvitation"}},"required":["invitation"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"409":{"description":"Resource already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/workspaces/{workspaceId}/invitations/{invitationId}":{"delete":{"operationId":"revokeWorkspaceInvitation","summary":"Revoke workspace invitation","description":"Cancel a pending workspace invitation. Requires admin/owner role.","tags":["Workspaces"],"parameters":[{"schema":{"type":"string","example":"ws_abc123","description":"Workspace ID"},"required":true,"description":"Workspace ID","name":"workspaceId","in":"path"},{"schema":{"type":"string","example":"wsi_def456","description":"Workspace invitation ID"},"required":true,"description":"Workspace invitation ID","name":"invitationId","in":"path"}],"responses":{"200":{"description":"Invitation revoked","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}},"required":["message"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/workspaces/invitations/{token}":{"get":{"operationId":"getWorkspaceInvitationByToken","summary":"Get workspace invitation by token","description":"Preview a workspace invitation without accepting it. Requires authentication.","tags":["Workspaces"],"parameters":[{"schema":{"type":"string","minLength":1,"example":"abc123xyz","description":"Invitation token from email link"},"required":true,"description":"Invitation token from email link","name":"token","in":"path"}],"responses":{"200":{"description":"Invitation details","content":{"application/json":{"schema":{"type":"object","properties":{"invitation":{"$ref":"#/components/schemas/WorkspaceInvitationPreview"}},"required":["invitation"]}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/workspaces/invitations/{token}/accept":{"post":{"operationId":"acceptWorkspaceInvitation","summary":"Accept workspace invitation","description":"Accept a workspace invitation using its token. The authenticated user's email must match the invitation target.","tags":["Workspaces"],"parameters":[{"schema":{"type":"string","minLength":1,"example":"abc123xyz","description":"Invitation token from email link"},"required":true,"description":"Invitation token from email link","name":"token","in":"path"}],"responses":{"200":{"description":"Invitation accepted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AcceptWorkspaceInvitationResponse"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Invitation not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"409":{"description":"Already a member","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"410":{"description":"Invitation has expired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/v1/auth/internal/stats":{"get":{"operationId":"getInternalStats","tags":["Internal"],"security":[],"summary":"Get platform statistics (internal)","description":"Service-to-service endpoint for platform-wide statistics. Authenticated via X-Internal-Key header.","responses":{"200":{"description":"Platform statistics","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalStatsResponse"}}}},"401":{"description":"Invalid or missing internal service key"}}}},"/v1/auth/internal/validate-relationship":{"get":{"operationId":"validateRelationship","tags":["Internal"],"security":[],"summary":"Validate agency-client relationship (internal)","description":"Service-to-service endpoint to check if an active agency-client relationship exists. Authenticated via internal service key.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"agencyOrgId","in":"query"},{"schema":{"type":"string","minLength":1},"required":true,"name":"clientOrgId","in":"query"}],"responses":{"200":{"description":"Relationship validation result","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidateRelationshipResponse"}}}},"401":{"description":"Invalid or missing internal service key"}}}},"/v1/auth/internal/is-platform-admin":{"get":{"operationId":"isPlatformAdmin","tags":["Internal"],"security":[],"summary":"Check if user is platform admin (internal)","description":"Service-to-service endpoint to check if a user has the system.manage permission. Authenticated via internal service key.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"userId","in":"query"}],"responses":{"200":{"description":"Platform admin check result","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IsPlatformAdminResponse"}}}}}}},"/v1/auth/internal/resolve-users":{"post":{"operationId":"resolveUsers","tags":["Internal"],"security":[],"summary":"Resolve user IDs to profile info (internal)","description":"Service-to-service endpoint to resolve user IDs to email and display name. Authenticated via internal service key.","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"userIds":{"type":"array","items":{"type":"string"},"minItems":1,"maxItems":100}},"required":["userIds"]}}}},"responses":{"200":{"description":"Resolved user info keyed by userId","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResolveUsersResponse"}}}}}}},"/v1/auth/internal/resolve-organizations":{"post":{"operationId":"resolveOrganizations","tags":["Internal"],"security":[],"summary":"Resolve organization IDs to names (internal)","description":"Service-to-service endpoint to resolve organization IDs to their display names. Authenticated via internal service key.","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"organizationIds":{"type":"array","items":{"type":"string"},"minItems":1,"maxItems":100}},"required":["organizationIds"]}}}},"responses":{"200":{"description":"Resolved org info keyed by organizationId","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResolveOrgsResponse"}}}}}}},"/v1/auth/internal/orgs/{organizationId}/subscription":{"get":{"operationId":"resolveOrgSubscription","tags":["Internal"],"security":[],"summary":"Get an org's active subscription plan id (internal)","description":"Service-to-service endpoint. Authenticated via internal service key. Returns the most recent active subscription, or null fields when none exists.","parameters":[{"schema":{"type":"string"},"required":true,"name":"organizationId","in":"path"}],"responses":{"200":{"description":"Active subscription (or null)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResolveSubscriptionResponse"}}}}}}},"/v1/auth/internal/plans/{planId}/orgs":{"get":{"operationId":"listOrgsOnPlan","tags":["Internal"],"security":[],"summary":"List organization ids subscribed to the given plan (internal)","description":"Returns active + trialing subscriptions for the plan. Authenticated via internal service key. Used by platform pricing for targeted cache invalidation.","parameters":[{"schema":{"type":"string"},"required":true,"name":"planId","in":"path"}],"responses":{"200":{"description":"Subscribers","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrgsOnPlanResponse"}}}}}}},"/v1/auth/internal/users/has-permissions":{"post":{"operationId":"internalHasPermissions","tags":["Internal"],"security":[],"summary":"Bulk check whether a user holds the given permissions","description":"Returns true/false for each requested permission. Authenticated via INTERNAL_SERVICE_KEY.","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"userId":{"type":"string"},"permissions":{"type":"array","items":{"type":"string"},"minItems":1,"maxItems":50},"organizationId":{"type":"string"}},"required":["userId","permissions"]}}}},"responses":{"200":{"description":"Permission map","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HasPermissionsResponse"}}}}}}},"/v1/auth/internal/send-email":{"post":{"operationId":"internalSendEmail","tags":["Internal"],"security":[],"summary":"Send email via centralized provider (internal)","description":"Service-to-service endpoint for sending emails through identity's email provider. Authenticated via internal service key.","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"to":{"type":"string","format":"email"},"toUserId":{"type":"string"},"toName":{"type":"string"},"subject":{"type":"string","minLength":1},"html":{"type":"string","minLength":1},"text":{"type":"string","minLength":1}},"required":["subject","html","text"]}}}},"responses":{"200":{"description":"Email sent successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendEmailResponse"}}}},"401":{"description":"Invalid or missing internal service key"},"500":{"description":"Email sending failed"}}}},"/v1/auth/internal/resolve-api-key":{"post":{"operationId":"resolveApiKey","tags":["Internal"],"security":[],"summary":"Resolve a decrypted API key (internal)","description":"Service-to-service endpoint to resolve and decrypt a service API key. Identity handles decryption internally so callers never need ENCRYPTION_SECRET. Authenticated via internal service key.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResolveApiKeyRequest"}}}},"responses":{"200":{"description":"Resolved API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResolveApiKeyResponse"}}}},"404":{"description":"No key configured for the requested provider","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}},"required":["message"]}}}}}}},"/api/v1/changelog":{"get":{"tags":["Changelog"],"summary":"List published changelog entries","description":"List publicly available changelog entries (What's New)","parameters":[{"schema":{"type":"string","enum":["feature","improvement","fix","security","breaking"]},"required":false,"name":"type","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":100,"default":20},"required":false,"name":"limit","in":"query"},{"schema":{"type":["integer","null"],"minimum":0,"default":0},"required":false,"name":"offset","in":"query"}],"responses":{"200":{"description":"List of published changelog entries","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PublicChangelogList"}}}}}}},"/api/v1/changelog/{entryId}":{"get":{"tags":["Changelog"],"summary":"Get published changelog entry","description":"Get a specific published changelog entry by ID","parameters":[{"schema":{"type":"string"},"required":true,"name":"entryId","in":"path"}],"responses":{"200":{"description":"Changelog entry details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PublicChangelogEntry"}}}},"404":{"description":"Entry not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error"]}}}}}}},"/v1/changelog":{"get":{"tags":["Changelog"],"summary":"List published changelog entries","description":"List publicly available changelog entries (What's New)","parameters":[{"schema":{"type":"string","enum":["feature","improvement","fix","security","breaking"]},"required":false,"name":"type","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":100,"default":20},"required":false,"name":"limit","in":"query"},{"schema":{"type":["integer","null"],"minimum":0,"default":0},"required":false,"name":"offset","in":"query"}],"responses":{"200":{"description":"List of published changelog entries","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PublicChangelogList"}}}}}}},"/v1/changelog/{entryId}":{"get":{"tags":["Changelog"],"summary":"Get published changelog entry","description":"Get a specific published changelog entry by ID","parameters":[{"schema":{"type":"string"},"required":true,"name":"entryId","in":"path"}],"responses":{"200":{"description":"Changelog entry details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PublicChangelogEntry"}}}},"404":{"description":"Entry not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}},"required":["error"]}}}}}}},"/.well-known/openid-configuration":{"get":{"tags":["OAuth Server (OIDC)"],"summary":"OIDC discovery document","description":"Returns the per-host OIDC issuer configuration (response shape per OIDC Discovery 1.0 §3).","responses":{"200":{"description":"Discovery document","content":{"application/json":{"schema":{"type":"object","properties":{"issuer":{"type":"string","format":"uri"},"authorization_endpoint":{"type":"string","format":"uri"},"token_endpoint":{"type":"string","format":"uri"},"userinfo_endpoint":{"type":"string","format":"uri"},"jwks_uri":{"type":"string","format":"uri"},"response_types_supported":{"type":"array","items":{"type":"string"}},"subject_types_supported":{"type":"array","items":{"type":"string"}},"id_token_signing_alg_values_supported":{"type":"array","items":{"type":"string"}},"scopes_supported":{"type":"array","items":{"type":"string"}},"token_endpoint_auth_methods_supported":{"type":"array","items":{"type":"string"}},"code_challenge_methods_supported":{"type":"array","items":{"type":"string"}},"grant_types_supported":{"type":"array","items":{"type":"string"}}},"required":["issuer","authorization_endpoint","token_endpoint","userinfo_endpoint","jwks_uri","response_types_supported","subject_types_supported","id_token_signing_alg_values_supported","scopes_supported","token_endpoint_auth_methods_supported","code_challenge_methods_supported","grant_types_supported"]}}}}}}},"/jwks":{"get":{"tags":["OAuth Server (OIDC)"],"summary":"JSON Web Key Set","description":"Public RSA keys for verifying access tokens / id_tokens issued by this IdP. Per RFC 7517.","responses":{"200":{"description":"JWKS document","content":{"application/json":{"schema":{"type":"object","properties":{"keys":{"type":"array","items":{"type":"object","properties":{"kty":{"type":"string","enum":["RSA"]},"use":{"type":"string","enum":["sig"]},"alg":{"type":"string","enum":["RS256"]},"kid":{"type":"string"},"n":{"type":"string"},"e":{"type":"string"}},"required":["kty","use","alg","kid","n","e"]}}},"required":["keys"]}}}}}}},"/oauth/authorize":{"get":{"tags":["OAuth Server (OIDC)"],"summary":"Authorization endpoint","description":"Begins the OIDC authorization code + PKCE flow. Validates client, scope,\nredirect_uri, PKCE challenge. If the user has a valid identity session, issues a\nsingle-use authorization code and 302s back to redirect_uri with code+state. If the\nuser is unauthenticated (or 'prompt=login'), redirects to the branded login UI with\nthe original /authorize URL preserved as ?return_to=.","parameters":[{"schema":{"type":"string","enum":["code"]},"required":true,"name":"response_type","in":"query"},{"schema":{"type":"string","minLength":1},"required":true,"name":"client_id","in":"query"},{"schema":{"type":"string","format":"uri"},"required":true,"name":"redirect_uri","in":"query"},{"schema":{"type":"string","minLength":1},"required":true,"name":"scope","in":"query"},{"schema":{"type":"string","minLength":1},"required":true,"name":"state","in":"query"},{"schema":{"type":"string","minLength":1},"required":true,"name":"code_challenge","in":"query"},{"schema":{"type":"string","enum":["S256"]},"required":true,"name":"code_challenge_method","in":"query"},{"schema":{"type":"string"},"required":false,"name":"nonce","in":"query"},{"schema":{"type":"string","enum":["none","login"]},"required":false,"name":"prompt","in":"query"}],"responses":{"302":{"description":"Redirect to redirect_uri with ?code=…&state=…  OR  redirect to login UI with ?return_to=… preserved"},"400":{"description":"Invalid request — client_id/redirect_uri/response_type rejected before redirect","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"error_description":{"type":"string"}},"required":["error"]}}}}}}},"/oauth/token":{"post":{"tags":["OAuth Server (OIDC)"],"summary":"Token endpoint","description":"Server-to-server endpoint. Accepts authorization_code (with PKCE\nverifier) or refresh_token grant. Returns access_token (RS256 JWT, 1h) plus\noptional id_token (when scope includes openid) and refresh_token (when scope\nincludes offline_access). Refresh tokens rotate on every use.","requestBody":{"content":{"application/x-www-form-urlencoded":{"schema":{"oneOf":[{"type":"object","properties":{"grant_type":{"type":"string","enum":["authorization_code"]},"code":{"type":"string","minLength":1},"redirect_uri":{"type":"string","format":"uri"},"client_id":{"type":"string","minLength":1},"client_secret":{"type":"string"},"code_verifier":{"type":"string","minLength":43,"maxLength":128}},"required":["grant_type","code","redirect_uri","client_id","code_verifier"]},{"type":"object","properties":{"grant_type":{"type":"string","enum":["refresh_token"]},"refresh_token":{"type":"string","minLength":1},"client_id":{"type":"string","minLength":1},"client_secret":{"type":"string"},"scope":{"type":"string"}},"required":["grant_type","refresh_token","client_id"]}]}},"application/json":{"schema":{"oneOf":[{"type":"object","properties":{"grant_type":{"type":"string","enum":["authorization_code"]},"code":{"type":"string","minLength":1},"redirect_uri":{"type":"string","format":"uri"},"client_id":{"type":"string","minLength":1},"client_secret":{"type":"string"},"code_verifier":{"type":"string","minLength":43,"maxLength":128}},"required":["grant_type","code","redirect_uri","client_id","code_verifier"]},{"type":"object","properties":{"grant_type":{"type":"string","enum":["refresh_token"]},"refresh_token":{"type":"string","minLength":1},"client_id":{"type":"string","minLength":1},"client_secret":{"type":"string"},"scope":{"type":"string"}},"required":["grant_type","refresh_token","client_id"]}]}}}},"responses":{"200":{"description":"Token bundle","content":{"application/json":{"schema":{"type":"object","properties":{"access_token":{"type":"string"},"id_token":{"type":"string"},"refresh_token":{"type":"string"},"token_type":{"type":"string","enum":["Bearer"]},"expires_in":{"type":"integer","exclusiveMinimum":0},"scope":{"type":"string"}},"required":["access_token","token_type","expires_in","scope"]}}}},"400":{"description":"OAuth error response","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","enum":["invalid_request","invalid_client","invalid_grant","unauthorized_client","unsupported_grant_type","invalid_scope"]},"error_description":{"type":"string"}},"required":["error"]}}}},"401":{"description":"invalid_client","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","enum":["invalid_request","invalid_client","invalid_grant","unauthorized_client","unsupported_grant_type","invalid_scope"]},"error_description":{"type":"string"}},"required":["error"]}}}}}}},"/oauth/userinfo":{"get":{"tags":["OAuth Server (OIDC)"],"summary":"UserInfo endpoint","description":"Returns user claims (filtered by granted scope) for a valid access_token.","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"User claims","content":{"application/json":{"schema":{"type":"object","properties":{"sub":{"type":"string"},"email":{"type":"string","format":"email"},"email_verified":{"type":"boolean"},"name":{"type":"string"},"preferred_username":{"type":"string"},"picture":{"type":"string","format":"uri"}},"required":["sub"]}}}},"401":{"description":"Missing or invalid Bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}},"required":["error"]}}}}}}}},"webhooks":{}}