Passa al contenuto principale

Authentication Endpoints

Complete reference for the authentication API endpoints.

Loginโ€‹

Email/Password Loginโ€‹

POST /api/auth/login
Content-Type: application/json

Request Body:

{
"email": "admin@ever.co",
"password": "admin"
}

Response (200 OK):

{
"user": {
"id": "...",
"email": "admin@ever.co",
"firstName": "Admin",
"lastName": "User",
"tenantId": "...",
"role": {
"id": "...",
"name": "SUPER_ADMIN"
}
},
"token": "eyJhbGciOiJIUzI1NiIs...",
"refreshToken": "eyJhbGciOiJIUzI1NiIs..."
}

Magic Sign-In (Passwordless)โ€‹

Step 1 โ€” Request magic code:

POST /api/auth/send-magic-code
Content-Type: application/json

{
"email": "user@example.com",
"appMagicSignUrl": "https://app.gauzy.co/#/auth/magic-sign-in",
"appName": "Gauzy"
}

Step 2 โ€” Verify magic code:

POST /api/auth/magic-sign-in
Content-Type: application/json

{
"email": "user@example.com",
"code": "123456"
}

Response: same format as email/password login.

Registrationโ€‹

Public Registrationโ€‹

POST /api/auth/register
Content-Type: application/json

{
"user": {
"firstName": "John",
"lastName": "Doe",
"email": "john@example.com"
},
"password": "securePassword123"
}
note

Public registration creates a user without a tenant. The user must then create a tenant via POST /api/tenant to complete onboarding.

Admin-Initiated Registrationโ€‹

POST /api/auth/register
Authorization: Bearer {admin_token}
Content-Type: application/json

{
"user": {
"firstName": "Jane",
"lastName": "Smith",
"email": "jane@example.com",
"role": { "id": "role-uuid" },
"tenant": { "id": "tenant-uuid" }
},
"password": "securePassword123",
"organizationId": "org-uuid"
}

Token Managementโ€‹

Refresh Tokenโ€‹

POST /api/auth/refresh-token
Content-Type: application/json

{
"refreshToken": "eyJhbGciOiJIUzI1NiIs..."
}

Response (200 OK):

{
"token": "new-access-token...",
"refreshToken": "new-refresh-token..."
}

Password Managementโ€‹

Request Password Resetโ€‹

POST /api/auth/request-password
Content-Type: application/json

{
"email": "user@example.com"
}

Sends a password reset email with a reset link.

Reset Passwordโ€‹

POST /api/auth/reset-password
Content-Type: application/json

{
"token": "reset-token-from-email",
"password": "newSecurePassword123",
"confirmPassword": "newSecurePassword123"
}

Change Password (Authenticated)โ€‹

POST /api/auth/change-password
Authorization: Bearer {token}
Content-Type: application/json

{
"currentPassword": "oldPassword",
"newPassword": "newPassword",
"confirmPassword": "newPassword"
}

Email Verificationโ€‹

Send Verification Emailโ€‹

POST /api/auth/email/verify/send-verification-code
Authorization: Bearer {token}

Confirm Emailโ€‹

POST /api/auth/email/verify
Content-Type: application/json

{
"token": "verification-token",
"email": "user@example.com"
}

Social OAuthโ€‹

Initiate OAuth Flowโ€‹

Redirect the user to the provider's authorization URL:

ProviderEndpoint
GoogleGET /api/auth/google
GitHubGET /api/auth/github
FacebookGET /api/auth/facebook
TwitterGET /api/auth/twitter
LinkedInGET /api/auth/linkedin
MicrosoftGET /api/auth/microsoft

OAuth Callbackโ€‹

After the user authorizes, the provider redirects to:

GET /api/auth/{provider}/callback?code={auth_code}

The server exchanges the code for tokens and returns a JWT:

{
"token": "eyJhbGciOiJIUzI1NiIs...",
"refreshToken": "eyJhbGciOiJIUzI1NiIs...",
"user": { ... }
}

Current Userโ€‹

Get Current User Profileโ€‹

GET /api/user/me
Authorization: Bearer {token}

Response (200 OK):

{
"id": "...",
"email": "admin@ever.co",
"firstName": "Admin",
"lastName": "User",
"tenantId": "...",
"roleId": "...",
"role": {
"name": "SUPER_ADMIN",
"rolePermissions": [...]
},
"employee": { ... }
}

Error Responsesโ€‹

StatusErrorWhen
400Bad RequestInvalid credentials format
401UnauthorizedWrong email/password, expired token
403ForbiddenAccount disabled, email not verified
404Not FoundEmail not registered
429Too Many RequestsRate limit exceeded