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 '
{
  "email": "<string>",
  "password": "<string>",
  "nombre": "<string>",
  "apellido": "<string>",
  "telefono": "<string>"
}
'
{
  "message": "<string>",
  "user": {
    "id": 123,
    "email": "<string>",
    "nombre": {},
    "apellido": {},
    "telefono": {},
    "email_verified": true
  }
}
Creates a new user account with email and password. Upon successful registration, a verification email is sent to the provided email address. A FREE subscription plan is automatically created for new users.

Request Body

email
string
required
User’s email address. Must be a valid email format and unique in the system.
password
string
required
User’s password. Must be at least 8 characters long and cannot be empty or contain only whitespace.
nombre
string
User’s first name (optional). Trimmed of leading/trailing whitespace.
apellido
string
User’s last name (optional). Trimmed of leading/trailing whitespace.
telefono
string
User’s phone number (optional). Trimmed of leading/trailing whitespace.

Response

message
string
Success message indicating the user was registered and should verify their email.
user
object
The created user object.
id
number
User’s unique identifier.
email
string
User’s email address (lowercase and trimmed).
nombre
string | null
User’s first name.
apellido
string | null
User’s last name.
telefono
string | null
User’s phone number.
email_verified
boolean
Email verification status (always false for new registrations).

Error Responses

400 Bad Request

Returned when validation fails:
  • Email is invalid or missing
  • Password is missing, less than 8 characters, or empty/whitespace only
  • Invalid field types

409 Conflict

Returned when the email is already registered in the system.

500 Internal Server Error

Returned when:
  • Database connection fails
  • Password hashing fails
  • User creation fails
  • Subscription creation fails
If the subscription creation fails, the user account is automatically deleted to maintain data consistency.

Example Request

curl -X POST https://api.tresacontafy.com/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "securePassword123",
    "nombre": "Juan",
    "apellido": "Pérez",
    "telefono": "+52 55 1234 5678"
  }'

Example Response

{
  "message": "Usuario registrado correctamente. Por favor verifica tu email.",
  "user": {
    "id": 123,
    "email": "[email protected]",
    "nombre": "Juan",
    "apellido": "Pérez",
    "telefono": "+52 55 1234 5678",
    "email_verified": false
  }
}

Implementation Details

  • Emails are automatically converted to lowercase and trimmed
  • Passwords are hashed using bcrypt with a salt rounds of 10
  • A verification token is generated and expires in 24 hours
  • A FREE subscription with status ACTIVE is automatically created
  • Verification emails may fail silently - users can request a new verification email later

Build docs developers (and LLMs) love