Authentication

Authenticate with JWT tokens, manage sessions, update profiles, and configure SSO.

All Authentication endpoints require JWT authentication via the Authorization: Bearer <token> header.

Core Endpoints

POST /auth/login Login
Public

Authenticate with email and password to receive a JWT token.

Request Body

NameTypeRequiredDescription
email string Required User email address
password string Required User password

Response

Login successful

{
    "success": true,
    "token": "eyJhbGciOiJIUzI1NiIs...",
    "user": {
        "id": 1,
        "first_name": "...",
        "last_name": "...",
        "email": "...",
        "role": "..."
    },
    "app_version": "...",
    "app_environment": "..."
}

Code Examples

curl -X POST "https://crm.revorbit.com/api/auth/login" \
  -H "Content-Type: application/json" \
  -d '{"email":"...","password":"..."}'
const response = await fetch(
  "https://crm.revorbit.com/api/auth/login",
  {
    method: "POST",
    headers: {
      "Content-Type": "application/json"
    },
    body: JSON.stringify(
      {
          "email": "...",
          "password": "..."
      }
    )
  }
);
const data = await response.json();
POST /auth/register Register
Public

Self-service registration for a new organization and admin user.

Request Body

NameTypeRequiredDescription
organization_name string Required Name for the new organization
first_name string Required
last_name string Required
email string Required
password string Required

Response

Registration successful

{
    "success": true,
    "token": "...",
    "user": {},
    "is_new_org": true
}

Code Examples

curl -X POST "https://crm.revorbit.com/api/auth/register" \
  -H "Content-Type: application/json" \
  -d '{"organization_name":"...","first_name":"...","last_name":"...","email":"...","password":"..."}'
const response = await fetch(
  "https://crm.revorbit.com/api/auth/register",
  {
    method: "POST",
    headers: {
      "Content-Type": "application/json"
    },
    body: JSON.stringify(
      {
          "organization_name": "...",
          "first_name": "...",
          "last_name": "...",
          "email": "...",
          "password": "..."
      }
    )
  }
);
const data = await response.json();
POST /auth/refresh Refresh token
Public

Exchange an expiring JWT token for a new one.

Response

New token issued

{
    "success": true,
    "token": "...",
    "user": {}
}

Code Examples

curl -X POST "https://crm.revorbit.com/api/auth/refresh"
const response = await fetch(
  "https://crm.revorbit.com/api/auth/refresh",
  {
    method: "POST",
    headers: {
    }
  }
);
const data = await response.json();
POST /auth/forgot-password Forgot password
Public

Send a password reset email. Returns success regardless of whether the email exists (prevents enumeration).

Request Body

NameTypeRequiredDescription
email string Required

Code Examples

curl -X POST "https://crm.revorbit.com/api/auth/forgot-password" \
  -H "Content-Type: application/json" \
  -d '{"email":"..."}'
const response = await fetch(
  "https://crm.revorbit.com/api/auth/forgot-password",
  {
    method: "POST",
    headers: {
      "Content-Type": "application/json"
    },
    body: JSON.stringify(
      {
          "email": "..."
      }
    )
  }
);
const data = await response.json();
POST /auth/reset-password Reset password
Public

Reset password using a token received via email.

Request Body

NameTypeRequiredDescription
token string Required Password reset token from email
password string Required New password

Code Examples

curl -X POST "https://crm.revorbit.com/api/auth/reset-password" \
  -H "Content-Type: application/json" \
  -d '{"token":"...","password":"..."}'
const response = await fetch(
  "https://crm.revorbit.com/api/auth/reset-password",
  {
    method: "POST",
    headers: {
      "Content-Type": "application/json"
    },
    body: JSON.stringify(
      {
          "token": "...",
          "password": "..."
      }
    )
  }
);
const data = await response.json();
GET /auth/me Get current user
JWT Required

Retrieve the authenticated user's profile and organization list.

Response

User profile

{
    "success": true,
    "data": {
        "id": 1,
        "first_name": "...",
        "last_name": "...",
        "email": "...",
        "role": "...",
        "phone": "...",
        "timezone": "...",
        "title": "...",
        "organizations": [
            {}
        ]
    }
}

Code Examples

curl -X GET "https://crm.revorbit.com/api/auth/me" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"
const response = await fetch(
  "https://crm.revorbit.com/api/auth/me",
  {
    method: "GET",
    headers: {
      "Authorization": "Bearer YOUR_JWT_TOKEN",
    }
  }
);
const data = await response.json();
PUT /auth/password Change password
JWT Required

Change the authenticated user's password.

Request Body

NameTypeRequiredDescription
current_password string Required
new_password string Required

Code Examples

curl -X PUT "https://crm.revorbit.com/api/auth/password" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"current_password":"...","new_password":"..."}'
const response = await fetch(
  "https://crm.revorbit.com/api/auth/password",
  {
    method: "PUT",
    headers: {
      "Authorization": "Bearer YOUR_JWT_TOKEN",
      "Content-Type": "application/json"
    },
    body: JSON.stringify(
      {
          "current_password": "...",
          "new_password": "..."
      }
    )
  }
);
const data = await response.json();
PUT /auth/profile Update profile
JWT Required

Update the authenticated user's profile fields.

Request Body

NameTypeRequiredDescription
phone string Optional
timezone string Optional
title string Optional
avatar_type string Optional Values: initials, upload
avatar_value string Optional

Code Examples

curl -X PUT "https://crm.revorbit.com/api/auth/profile" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"phone":"...","timezone":"...","title":"...","avatar_type":"initials","avatar_value":"..."}'
const response = await fetch(
  "https://crm.revorbit.com/api/auth/profile",
  {
    method: "PUT",
    headers: {
      "Authorization": "Bearer YOUR_JWT_TOKEN",
      "Content-Type": "application/json"
    },
    body: JSON.stringify(
      {
          "phone": "...",
          "timezone": "...",
          "title": "...",
          "avatar_type": "initials",
          "avatar_value": "..."
      }
    )
  }
);
const data = await response.json();
POST /auth/avatar Upload avatar
JWT Required

Upload a custom avatar image (max 2MB).

Request Body

NameTypeRequiredDescription
avatar file Optional

Code Examples

curl -X POST "https://crm.revorbit.com/api/auth/avatar" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -F "file=@/path/to/file"
const response = await fetch(
  "https://crm.revorbit.com/api/auth/avatar",
  {
    method: "POST",
    headers: {
      "Authorization": "Bearer YOUR_JWT_TOKEN",
    }
  }
);
const data = await response.json();
POST /auth/logout Logout
JWT Required

Invalidate the current JWT token.

Code Examples

curl -X POST "https://crm.revorbit.com/api/auth/logout" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"
const response = await fetch(
  "https://crm.revorbit.com/api/auth/logout",
  {
    method: "POST",
    headers: {
      "Authorization": "Bearer YOUR_JWT_TOKEN",
    }
  }
);
const data = await response.json();
POST /auth/switch-org Switch organization
JWT Required

Switch to a different organization the user belongs to. Returns a new JWT scoped to the target org.

Request Body

NameTypeRequiredDescription
organization_id integer Required

Response

Switched to new org

{
    "success": true,
    "token": "...",
    "user": {}
}

Code Examples

curl -X POST "https://crm.revorbit.com/api/auth/switch-org" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"organization_id":1}'
const response = await fetch(
  "https://crm.revorbit.com/api/auth/switch-org",
  {
    method: "POST",
    headers: {
      "Authorization": "Bearer YOUR_JWT_TOKEN",
      "Content-Type": "application/json"
    },
    body: JSON.stringify(
      {
          "organization_id": 1
      }
    )
  }
);
const data = await response.json();