Documentation Index
Fetch the complete documentation index at: https://docs.gateways.app/llms.txt
Use this file to discover all available pages before exploring further.
Authentication & User Management API
Overview
The Authentication & User Management API provides endpoints for user registration, authentication, password management, profile management, two-factor authentication (2FA), and session management. For API keys (sk_…), X-API-Key / Bearer usage, WebSocket URL token=, and which routes accept keys vs session JWT, see Authentication & API access.
Base Endpoints:
/api/auth- Authentication endpoints/api/users- User management and session management endpoints
Authentication Endpoints
Signup
Register a new user account. Endpoint:POST /api/auth/signup
Authentication: Not required
Request Body:
400 Bad Request: Missing required fields, invalid email format, or weak password409 Conflict: Email already exists500 Internal Server Error: Registration failed
Login
Authenticate and create a new session. If two-factor authentication (2FA) is enabled, the response will require additional verification. Endpoint:POST /api/auth/login
Authentication: Not required
Request Body:
/api/auth/login/verify-2fa endpoint before the session is activated.
Error Responses:
400 Bad Request: Missing email or password401 Unauthorized: Invalid credentials403 Forbidden: Account is inactive500 Internal Server Error: Login failed
Verify 2FA and Complete Login
Complete login by verifying the two-factor authentication code. This endpoint is only required when 2FA is enabled for the user. Endpoint:POST /api/auth/login/verify-2fa
Authentication: Not required (uses verification token from login)
Request Body:
400 Bad Request: Missing required fields or 2FA not enabled401 Unauthorized: Invalid verification token or incorrect code404 Not Found: User or session not found500 Internal Server Error: Verification failed
Forgot Password
Request a password reset email. Endpoint:POST /api/auth/forgot-password
Authentication: Not required
Request Body:
Reset Password
Reset password using a reset token from the email. Endpoint:POST /api/auth/reset-password
Authentication: Not required
Request Body:
400 Bad Request: Missing token or newPassword, invalid/expired token, or weak password500 Internal Server Error: Password reset failed
Logout
Logout from the current session. Endpoint:POST /api/auth/logout
Authentication: Required
Example Request:
Logout All Sessions
Logout from all active sessions. Endpoint:POST /api/auth/logout-all
Authentication: Required
Example Request:
User Management Endpoints
Get Profile
Get the current user’s profile information. Endpoint:GET /api/users/profile
Authentication: Required
Example Request:
defaultWorkspaceId: ID of the user’s default workspace (null if not set). This workspace will be opened by default when the user logs in.workspaces: Array of workspaces the user is a member of, each containing:id: Workspace IDname: Workspace nameslug: Workspace slug (used in URLs)description: Workspace descriptionprofileImage: Workspace profile image URL (null if not set)planId: Current pricing plan IDisActive: Whether the workspace is activeuserRole: User’s role in this workspace (owner, admin, member, billing, dev, viewer)permissions: User’s effective permissions in this workspace (merged from role defaults and custom permissions)joinedAt: When the user joined this workspacecreatedAt: When the workspace was createdupdatedAt: When the workspace was last updated
pendingInvitationsCount: Number of pending workspace invitations (useful for notification badges)pendingInvitations: Array of pending invitation objects containing:id: Invitation IDworkspaceId: ID of the workspaceworkspaceName: Name of the workspaceworkspaceSlug: Slug of the workspaceworkspaceProfileImage: Profile image URL of the workspace (null if not set)role: Role assigned in the invitationpermissions: Custom permissions (if any)invitedByName: Name of the user who sent the invitationinvitedByEmail: Email of the user who sent the invitationexpiresAt: Expiration date of the invitationcreatedAt: When the invitation was created
Upload Profile Image
Upload a profile image file. The image is optimized (resized to max 512px, compressed as JPEG) and stored in S3; the user’sprofileImage is updated with the returned URL. Use this endpoint to set or change the profile picture; use Update Profile for name and email only.
Endpoint: POST /api/users/profile/image
Authentication: Required
Request: multipart/form-data with a single file field:
- profileImage (required): Image file (JPEG, PNG, GIF, or WebP). Max size is configurable (default 2MB; set
PROFILE_IMAGE_MAX_SIZE_MBin env, 0.5–10).
400 Bad Request: Missing file, file too large (seePROFILE_IMAGE_MAX_SIZE_MB), or invalid content type (must be image/jpeg, image/png, image/gif, or image/webp)401 Unauthorized: Missing or invalid authentication token503 Service Unavailable: Profile storage not configured (PROFILE_STORAGE_BUCKET)500 Internal Server Error: Upload or update failed
Update Profile
Update user profile information (name, email). For profile image, use Upload Profile Image instead. Endpoint:PATCH /api/users/profile
Authentication: Required
Request Body: (all fields are optional; application/json only)
400 Bad Request: Invalid email format, empty name, or no fields provided401 Unauthorized: Missing or invalid authentication token409 Conflict: Email already in use by another account500 Internal Server Error: Failed to update profile
Change Password
Change the user’s password. Endpoint:POST /api/users/change-password
Authentication: Required
Request Body:
400 Bad Request: Missing currentPassword or newPassword, weak password, or password change not available for OAuth users401 Unauthorized: Missing/invalid token or incorrect current password500 Internal Server Error: Failed to change password
Generate 2FA Secret
Generate a two-factor authentication secret and QR code for setup. Endpoint:POST /api/users/2fa/generate
Authentication: Required
Example Request:
401 Unauthorized: Missing or invalid authentication token500 Internal Server Error: Failed to generate 2FA secret
Verify and Enable 2FA
Verify the TOTP token and enable two-factor authentication. Endpoint:POST /api/users/2fa/verify
Authentication: Required
Request Body:
400 Bad Request: Missing token, invalid token, or no 2FA secret found (generate one first)401 Unauthorized: Missing or invalid authentication token500 Internal Server Error: Failed to verify 2FA
Disable 2FA
Disable two-factor authentication for the account. Endpoint:POST /api/users/2fa/disable
Authentication: Required
Request Body: (password required for email/password accounts)
400 Bad Request: Missing password (for email/password accounts)401 Unauthorized: Missing/invalid token or incorrect password500 Internal Server Error: Failed to disable 2FA
Get Sessions
Get all sessions for the current user with pagination (including past/expired sessions). Endpoint:GET /api/users/sessions
Authentication: Required
Query Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
page | integer | 1 | Page number (1-based). |
limit | integer | 10 | Items per page (max 50). |
isActive and isExpired fields to filter sessions as needed. Use pagination to request other pages.
Delete Account
Delete (deactivate) the user account. Endpoint:DELETE /api/users/account
Authentication: Required
Request Body: (password required for email/password accounts)
400 Bad Request: Missing password (for email/password accounts)401 Unauthorized: Missing/invalid token or incorrect password404 Not Found: User not found500 Internal Server Error: Failed to delete account
- This is a soft delete (account is deactivated, not permanently deleted)
- All active sessions are automatically deactivated
- Password confirmation is only required for email/password accounts
Cancel Session
Cancel/delete a specific session. Endpoint:DELETE /api/users/sessions/:sessionId
Authentication: Required
Path Parameters:
sessionId(required): The ID of the session to cancel
400 Bad Request: Invalid session ID401 Unauthorized: Missing or invalid authentication token403 Forbidden: You can only cancel your own sessions404 Not Found: Session not found500 Internal Server Error: Failed to cancel session
Password Requirements
Passwords must meet the following requirements:- Minimum 8 characters
- At least one uppercase letter
- At least one lowercase letter
- At least one number
- At least one special character (!@#$%^&*)
Two-Factor Authentication (2FA)
Two-factor authentication adds an extra layer of security to your account by requiring a time-based one-time password (TOTP) in addition to your password when logging in.How to Enable 2FA:
- Generate Secret: Call
POST /api/users/2fa/generateto get a secret and QR code - Scan QR Code: Use an authenticator app (Google Authenticator, Authy, etc.) to scan the QR code
- Verify Token: Enter a token from your authenticator app using
POST /api/users/2fa/verify - 2FA Enabled: Once verified, 2FA is enabled for your account
Login with 2FA:
When 2FA is enabled for your account, the login process requires an additional step:- Login: Call
POST /api/auth/loginwith your email and password - Check Response: If
requires2FA: trueis in the response, 2FA verification is required - Get Verification Token: The response includes a
verificationTokenthat you’ll need for the next step - Verify 2FA Code: Call
POST /api/auth/login/verify-2fawith theverificationTokenand the 6-digit code from your authenticator app - Complete Login: Upon successful verification, you’ll receive your access token and can proceed with authenticated requests
Supported Authenticator Apps:
- Google Authenticator
- Authy
- Microsoft Authenticator
- 1Password
- Any TOTP-compatible authenticator app
Manual Entry:
If you can’t scan the QR code, you can manually enter the secret key (manualEntryKey) into your authenticator app.
Plan Restrictions
All users are assigned a pricing plan that determines their resource limits. Plan restrictions are automatically enforced when creating resources. See the Pricing Plans API documentation for details. Default Plan: All new users are automatically assigned the Free plan, which includes:- 1 project
- 1 environment per project
- 3 total resources
- 1 cloud connection
403 Forbidden error with details about the limit and upgrade options.
Response Fields
User Profile Object
| Field | Type | Description |
|---|---|---|
id | number | Unique user ID |
email | string | User’s email address |
name | string | User’s display name |
profileImage | string | null | URL to user’s profile image |
authProvider | string | Authentication provider (email, google, github, etc.) |
emailVerified | boolean | Whether email is verified |
twoFactorEnabled | boolean | Whether two-factor authentication is enabled |
createdAt | string | Timestamp when account was created (ISO 8601) |
updatedAt | string | Timestamp when account was last updated (ISO 8601) |
Session Object
| Field | Type | Description |
|---|---|---|
id | number | Unique session ID |
deviceInfo | string | Device information (e.g., “Chrome on Mac”) |
ipAddress | string | null | IP address of the session |
userAgent | string | null | Browser user agent string |
isActive | boolean | Whether the session is active |
expiresAt | string | Timestamp when session expires (ISO 8601) |
lastActivity | string | null | Timestamp of last activity (ISO 8601) |
createdAt | string | Timestamp when session was created (ISO 8601) |
isCurrentSession | boolean | Whether this is the current session |
isExpired | boolean | Whether the session has expired (expiresAt < current time) |
Security Best Practices
- Strong Passwords: Use complex passwords that meet all requirements
- 2FA: Enable two-factor authentication for enhanced security
- Session Management: Regularly review and revoke unused sessions
- Password Updates: Change your password periodically
- Account Security: Use the logout-all endpoint if you suspect unauthorized access
- Email Verification: Verify your email address to enable account recovery features
Error Codes
| Status Code | Description |
|---|---|
400 | Bad Request - Invalid input or missing required fields |
401 | Unauthorized - Invalid or missing authentication token |
403 | Forbidden - Insufficient permissions |
404 | Not Found - Resource does not exist |
409 | Conflict - Resource already exists (e.g., email in use) |
500 | Internal Server Error - Server error occurred |