Skip to main content
POST
/
api
/
auth
/
register
Register User
curl --request POST \
  --url https://api.example.com/api/auth/register \
  --header 'Content-Type: application/json' \
  --data '
{
  "firstName": "<string>",
  "lastName": "<string>",
  "email": "<string>",
  "password": "<string>",
  "phone": "<string>",
  "role": "<string>",
  "provider": "<string>"
}
'
{
  "success": true,
  "message": "<string>",
  "data": {
    "token": "<string>",
    "user": {
      "id": "<string>",
      "firstName": "<string>",
      "lastName": "<string>",
      "fullName": "<string>",
      "email": "<string>",
      "role": "<string>",
      "phone": "<string>",
      "isActive": true,
      "isEmailVerified": true,
      "fitnessProfile": {
        "questionnaireCompleted": true,
        "gender": "<string>",
        "age": 123,
        "height": 123,
        "weight": 123,
        "fitnessLevel": "<string>",
        "mainGoal": "<string>"
      },
      "customerLevel": "<string>",
      "loyaltyPoints": 123,
      "createdAt": "<string>"
    }
  },
  "error": "<string>"
}

Overview

This endpoint creates a new user account directly in the database. It is primarily used for Google OAuth registration, but can also be used for direct registration without email verification.
For registration with email verification code, use /api/auth/register-with-code instead.

Authentication

Authorization
string
Not required - public endpoint

Request Body

firstName
string
required
User’s first name
  • Minimum 2 characters, maximum 50 characters
  • Only letters and spaces allowed
  • Example: “John”
lastName
string
required
User’s last name
  • Minimum 2 characters, maximum 50 characters
  • Only letters and spaces allowed
  • Example: “Doe”
email
string
required
User’s email address
  • Must be a valid email format
  • Will be converted to lowercase
  • Maximum 100 characters
  • Must be unique (not already registered)
  • Example: “[email protected]
password
string
required
User’s password
  • Minimum 6 characters, maximum 100 characters
  • Must contain at least one uppercase letter, one lowercase letter, and one number
  • Cannot be common passwords like “12345678”, “password”, etc.
  • Example: “MySecure123”
phone
string
User’s phone number (optional)
  • Must be exactly 10 digits
  • Example: “5551234567”
role
string
default:"customer"
User role
  • Options: customer, admin, moderator
  • Default: customer
provider
string
default:"local"
Authentication provider
  • Options: local, google
  • Default: local
  • If set to google, user will be marked as email verified

Response

success
boolean
Indicates if the operation was successful
message
string
Success message: “Registro exitoso”
data
object
Response data object

Error Responses

success
boolean
Will be false for errors
error
string
Error type or message
message
string
Detailed error message

Common Errors

Status CodeError MessageDescription
400”firstName, lastName y email son obligatorios”Missing required fields
400”Ya existe una cuenta con este email”Email already registered
400”Debes proporcionar una contraseña o usar proveedor OAuth”Password required for local registration
400Validation errorsInvalid field formats (see validation rules above)
429Rate limit exceededToo many requests (rate limited)

Code Examples

curl -X POST https://api.fitaiid.com/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "firstName": "John",
    "lastName": "Doe",
    "email": "[email protected]",
    "password": "MySecure123",
    "phone": "5551234567"
  }'

Example Response

{
  "success": true,
  "message": "Registro exitoso",
  "data": {
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "user": {
      "id": "507f1f77bcf86cd799439011",
      "firstName": "John",
      "lastName": "Doe",
      "fullName": "John Doe",
      "email": "[email protected]",
      "role": "customer",
      "phone": "5551234567",
      "isActive": true,
      "isEmailVerified": false,
      "fitnessProfile": {
        "questionnaireCompleted": false
      },
      "customerLevel": "bronze",
      "totalOrders": 0,
      "totalSpent": 0,
      "loyaltyPoints": 0,
      "createdAt": "2024-03-06T10:30:00.000Z"
    }
  }
}

Validation Rules

First Name & Last Name

  • Length: 2-50 characters
  • Pattern: Letters and spaces only (including Spanish characters: áéíóúñ)
  • HTML characters are sanitized

Email

  • Must be valid email format
  • Converted to lowercase
  • Maximum 100 characters
  • Must be unique across all users

Password

  • Minimum 6 characters
  • Must contain at least:
    • One uppercase letter
    • One lowercase letter
    • One number
  • Cannot be common passwords

Phone

  • Exactly 10 digits
  • Optional field

Next Steps

Complete Profile

Update user profile with additional information

Login

Authenticate existing user

Build docs developers (and LLMs) love