Skip to main content
POST
/
api
/
v1
/
auth
/
register
Register
curl --request POST \
  --url https://api.example.com/api/v1/auth/register \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "<string>",
  "email": "<string>",
  "phone": "<string>",
  "password": "<string>",
  "password_confirmation": "<string>"
}
'
{
  "status": "<string>",
  "data": {
    "access_token": "<string>",
    "token_type": "<string>",
    "expires_at": "<string>",
    "user": {
      "id": 123,
      "name": "<string>",
      "email": "<string>",
      "phone": "<string>",
      "roles": [
        {}
      ],
      "permissions": [
        {}
      ],
      "created_at": "<string>"
    }
  }
}
Create a new user account. Either email or phone is required, but not both. Returns an access token upon successful registration.

Authentication

This endpoint does not require authentication.

Request Body

name
string
required
Full name of the userValidation: Required, maximum 255 charactersExample: "Juan Pérez"
email
string
User’s email address. Required if phone is not provided.Validation: Must be a valid email format, unique in the systemExample: "[email protected]"
phone
string
User’s phone number without country code. Required if email is not provided.Validation: Must be exactly 10 digits, unique in the systemExample: "5512345678"
The phone number is automatically sanitized - non-numeric characters are stripped.
password
string
required
User’s passwordValidation: Minimum 8 characters, must be confirmedExample: "securePassword123"
password_confirmation
string
required
Password confirmation - must match passwordExample: "securePassword123"
You must provide either email or phone, but not both. The system will create a unique identifier based on the provided contact method.

Response

status
string
Response status, always “success”
data
object
Registration response data

Success Response Example

{
  "status": "success",
  "data": {
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9...",
    "token_type": "Bearer",
    "expires_at": "2026-04-06T15:30:00+00:00",
    "user": {
      "id": 42,
      "name": "Juan Pérez",
      "email": "[email protected]",
      "phone": null,
      "roles": [],
      "permissions": [],
      "created_at": "2026-03-06T15:30:00+00:00"
    }
  }
}

Error Responses

422 Validation Error

Returned when validation fails (missing required fields, duplicate email/phone, password mismatch, etc.).
{
  "message": "The given data was invalid.",
  "errors": {
    "email": [
      "The email has already been taken."
    ],
    "password": [
      "The password confirmation does not match."
    ]
  }
}

Common Validation Errors

Error: "Email is required when phone is not provided."Cause: Neither email nor phone was providedSolution: Provide either email or phone
Error: "The email has already been taken."Cause: Email address already exists in the systemSolution: Use a different email or prompt user to log in
Error: "The phone has already been taken."Cause: Phone number already exists in the systemSolution: Use a different phone number or prompt user to log in
Error: "The phone format is invalid."Cause: Phone number is not exactly 10 digitsSolution: Provide a 10-digit national phone number (e.g., 5512345678)
Error: "The password must be at least 8 characters."Cause: Password is less than 8 charactersSolution: Use a password with at least 8 characters
Error: "The password confirmation does not match."Cause: password and password_confirmation don’t matchSolution: Ensure both fields contain the exact same password

Code Examples

curl -X POST http://localhost:8080/api/v1/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Juan Pérez",
    "email": "[email protected]",
    "password": "securePassword123",
    "password_confirmation": "securePassword123"
  }'

Usage Notes

Auto-Login

Upon successful registration, the user receives an access token and is automatically logged in

Phone Sanitization

Phone numbers are automatically cleaned - spaces, dashes, and parentheses are removed

Default Role

New users start with no roles - roles must be assigned by an administrator

Password Security

Passwords are hashed using Laravel’s bcrypt algorithm with a cost factor of 10

Login

Authenticate existing user credentials

Build docs developers (and LLMs) love