Skip to main content

Endpoint

method
string
default:"POST"
HTTP Method
endpoint
string
default:"/register"
API Endpoint

Authentication

This endpoint does not require authentication (uses guest middleware).

Request Body

name
string
required
The user’s full name.
  • Maximum length: 255 characters
email
string
required
The user’s email address.
  • Must be a valid email format
  • Will be converted to lowercase
  • Maximum length: 255 characters
  • Must be unique (not already registered)
password
string
required
The user’s password.
  • Must meet Laravel’s default password requirements
  • Must be confirmed with password_confirmation
password_confirmation
string
required
Password confirmation. Must match the password field.

Response

status
number
default:"204"
No Content - Registration successful. User is automatically logged in and session is created.

Example Request

cURL
curl -X POST https://your-api.com/register \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "name": "John Doe",
    "email": "[email protected]",
    "password": "SecurePassword123!",
    "password_confirmation": "SecurePassword123!"
  }'
Next.js
const response = await fetch('http://localhost:8000/register', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/json',
  },
  credentials: 'include', // Important for session cookies
  body: JSON.stringify({
    name: 'John Doe',
    email: '[email protected]',
    password: 'SecurePassword123!',
    password_confirmation: 'SecurePassword123!',
  }),
});

if (response.status === 204) {
  // Registration successful, user is logged in
}

Success Response

HTTP/1.1 204 No Content
Set-Cookie: laravel_session=...; path=/; httponly

Error Responses

Validation Error (422)

{
  "message": "The email has already been taken. (and 1 more error)",
  "errors": {
    "email": [
      "The email has already been taken."
    ],
    "password": [
      "The password field confirmation does not match."
    ]
  }
}

Common Validation Errors

  • name field is required
  • name exceeds maximum length of 255 characters
  • email field is required or invalid format
  • email already exists in the database
  • password field is required
  • password does not meet minimum requirements
  • password_confirmation does not match password

Notes

  • Upon successful registration, a Registered event is dispatched which triggers email verification notification
  • The user is automatically authenticated after registration
  • A session cookie is set for maintaining authentication state
  • Password is hashed using Laravel’s Hash::make() before storage

Build docs developers (and LLMs) love