Authentication

User registration, login, email verification, and password reset endpoints

Register UserPOST
/api/auth/register

Create a new user account. Email verification will be sent automatically.

Request Body

JSON
{
  "email": "user@example.com",
  "password": "securepassword123",
  "confirmPassword": "securepassword123",
  "firstName": "John",
  "lastName": "Doe",
  "appId": "your-app-id"
}

Response

JSON
{
  "message": "User registered successfully. Please check your email to verify your account.",
  "userId": "user_123456"
}

Example Request

Bash
curl -X POST "https://your-auth-server.com/api/auth/register" \
  -H "x-api-key: your-app-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "user@example.com",
    "password": "securepassword123",
    "confirmPassword": "securepassword123",
    "firstName": "John",
    "lastName": "Doe",
    "appId": "your-app-id"
  }'
Login UserPOST
/api/auth/login

Authenticate a user and receive access tokens.

Request Body

JSON
{
  "email": "user@example.com",
  "password": "securepassword123",
  "appId": "your-app-id"
}

Response

JSON
{
  "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "user": {
    "id": "user_123456",
    "email": "user@example.com",
    "firstName": "John",
    "lastName": "Doe",
    "role": "user"
  }
}

Example Request

Bash
curl -X POST "https://your-auth-server.com/api/auth/login" \
  -H "x-api-key: your-app-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "user@example.com",
    "password": "securepassword123",
    "appId": "your-app-id"
  }'
Verify EmailPOST
/api/auth/verify

Verify a user's email address using the token sent via email.

Request Body

JSON
{
  "token": "verification_token_from_email"
}

Example Request

Bash
curl -X POST "https://your-auth-server.com/api/auth/verify" \
  -H "x-api-key: your-app-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "token": "verification_token_from_email"
  }'
Forgot PasswordPOST
/api/auth/forgot-password

Send a password reset email to the user.

Request Body

JSON
{
  "email": "user@example.com",
  "appId": "your-app-id"
}

Example Request

Bash
curl -X POST "https://your-auth-server.com/api/auth/forgot-password" \
  -H "x-api-key: your-app-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "user@example.com",
    "appId": "your-app-id"
  }'
Reset PasswordPOST
/api/auth/reset-password

Reset a user's password using the token from the reset email.

Request Body

JSON
{
  "token": "reset_token_from_email",
  "password": "newsecurepassword123",
  "confirmPassword": "newsecurepassword123"
}

Example Request

Bash
curl -X POST "https://your-auth-server.com/api/auth/reset-password" \
  -H "x-api-key: your-app-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "token": "reset_token_from_email",
    "password": "newsecurepassword123",
    "confirmPassword": "newsecurepassword123"
  }'