POST /api/auth/register

Create a new user account using email and password.

This endpoint creates a new user account using an email and password.

It performs validation, hashes the password securely, and stores the user in the configured database.

When to use

  • When a new user signs up
  • When onboarding users with email and password

Request

HTTP
POST /api/auth/register
Content-Type: application/json
Request Body
{
  "email": "user@example.com",
  "password": "strong-password"
}

Request Fields

FieldTypeRequiredDescription
emailstringYesUser’s email address
passwordstringYesUser’s password (hashed server-side)

Response

Success (201 Created)

Response
{
  "success": true,
  "data": {
    "id": "user_id",
    "email": "user@example.com"
  }
}

The password is never returned in the response.

Errors

User already exists (409)

Error
{
  "success": false,
  "message": "User already exists"
}

Invalid request (400)

Error
{
  "success": false,
  "message": "Email and password are required"
}

Notes

  • Passwords are hashed using bcrypt before storage
  • Email uniqueness is enforced at the database level
  • This endpoint does not create a session

Related APIs

  • POST /api/auth/login – Authenticate the user
  • POST /api/auth/send-otp – Send email OTP