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>"
}
}
}Register a new user account with email or phone
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>"
}
}
}"Juan Pérez"phone is not provided.Validation: Must be a valid email format, unique in the systemExample: "[email protected]"email is not provided.Validation: Must be exactly 10 digits, unique in the systemExample: "5512345678""securePassword123"passwordExample: "securePassword123"email or phone, but not both. The system will create a unique identifier based on the provided contact method.Show data properties
Show user properties
{
"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"
}
}
}
{
"message": "The given data was invalid.",
"errors": {
"email": [
"The email has already been taken."
],
"password": [
"The password confirmation does not match."
]
}
}
Email/Phone Required
"Email is required when phone is not provided."Cause: Neither email nor phone was providedSolution: Provide either email or phoneDuplicate Email
"The email has already been taken."Cause: Email address already exists in the systemSolution: Use a different email or prompt user to log inDuplicate Phone
"The phone has already been taken."Cause: Phone number already exists in the systemSolution: Use a different phone number or prompt user to log inInvalid Phone Format
"The phone format is invalid."Cause: Phone number is not exactly 10 digitsSolution: Provide a 10-digit national phone number (e.g., 5512345678)Password Too Short
"The password must be at least 8 characters."Cause: Password is less than 8 charactersSolution: Use a password with at least 8 charactersPassword Mismatch
"The password confirmation does not match."Cause: password and password_confirmation don’t matchSolution: Ensure both fields contain the exact same passwordcurl -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"
}'
const response = await fetch('http://localhost:8080/api/v1/auth/register', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Juan Pérez',
email: '[email protected]',
password: 'securePassword123',
password_confirmation: 'securePassword123'
})
});
const data = await response.json();
if (response.ok) {
// Store the access token
localStorage.setItem('access_token', data.data.access_token);
console.log('Registered user:', data.data.user);
} else {
console.error('Registration failed:', data.errors);
}
use GuzzleHttp\Client;
$client = new Client();
try {
$response = $client->post('http://localhost:8080/api/v1/auth/register', [
'json' => [
'name' => 'Juan Pérez',
'email' => '[email protected]',
'password' => 'securePassword123',
'password_confirmation' => 'securePassword123'
]
]);
$data = json_decode($response->getBody(), true);
$token = $data['data']['access_token'];
$user = $data['data']['user'];
echo "Registered user ID: " . $user['id'];
} catch (\GuzzleHttp\Exception\ClientException $e) {
$error = json_decode($e->getResponse()->getBody(), true);
print_r($error['errors']);
}