Register
curl --request POST \
--url https://api.example.com/api/auth/register \
--header 'Content-Type: application/json' \
--data '
{
"email": "<string>",
"nombre": "<string>",
"apellido": "<string>",
"password": "<string>",
"telefono": "<string>"
}
'import requests
url = "https://api.example.com/api/auth/register"
payload = {
"email": "<string>",
"nombre": "<string>",
"apellido": "<string>",
"password": "<string>",
"telefono": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
email: '<string>',
nombre: '<string>',
apellido: '<string>',
password: '<string>',
telefono: '<string>'
})
};
fetch('https://api.example.com/api/auth/register', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/auth/register",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'email' => '<string>',
'nombre' => '<string>',
'apellido' => '<string>',
'password' => '<string>',
'telefono' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/auth/register"
payload := strings.NewReader("{\n \"email\": \"<string>\",\n \"nombre\": \"<string>\",\n \"apellido\": \"<string>\",\n \"password\": \"<string>\",\n \"telefono\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/api/auth/register")
.header("Content-Type", "application/json")
.body("{\n \"email\": \"<string>\",\n \"nombre\": \"<string>\",\n \"apellido\": \"<string>\",\n \"password\": \"<string>\",\n \"telefono\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/auth/register")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"email\": \"<string>\",\n \"nombre\": \"<string>\",\n \"apellido\": \"<string>\",\n \"password\": \"<string>\",\n \"telefono\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"201": {},
"400": {},
"409": {},
"success": true,
"data": {
"user": {
"id": 123,
"email": "<string>",
"nombre": "<string>",
"apellido": "<string>",
"telefono": "<string>",
"role": "<string>"
},
"token": "<string>"
}
}Authentication
Register
Create a new user account
POST
/
api
/
auth
/
register
Register
curl --request POST \
--url https://api.example.com/api/auth/register \
--header 'Content-Type: application/json' \
--data '
{
"email": "<string>",
"nombre": "<string>",
"apellido": "<string>",
"password": "<string>",
"telefono": "<string>"
}
'import requests
url = "https://api.example.com/api/auth/register"
payload = {
"email": "<string>",
"nombre": "<string>",
"apellido": "<string>",
"password": "<string>",
"telefono": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
email: '<string>',
nombre: '<string>',
apellido: '<string>',
password: '<string>',
telefono: '<string>'
})
};
fetch('https://api.example.com/api/auth/register', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/auth/register",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'email' => '<string>',
'nombre' => '<string>',
'apellido' => '<string>',
'password' => '<string>',
'telefono' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/auth/register"
payload := strings.NewReader("{\n \"email\": \"<string>\",\n \"nombre\": \"<string>\",\n \"apellido\": \"<string>\",\n \"password\": \"<string>\",\n \"telefono\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/api/auth/register")
.header("Content-Type", "application/json")
.body("{\n \"email\": \"<string>\",\n \"nombre\": \"<string>\",\n \"apellido\": \"<string>\",\n \"password\": \"<string>\",\n \"telefono\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/auth/register")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"email\": \"<string>\",\n \"nombre\": \"<string>\",\n \"apellido\": \"<string>\",\n \"password\": \"<string>\",\n \"telefono\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"201": {},
"400": {},
"409": {},
"success": true,
"data": {
"user": {
"id": 123,
"email": "<string>",
"nombre": "<string>",
"apellido": "<string>",
"telefono": "<string>",
"role": "<string>"
},
"token": "<string>"
}
}Endpoint
POST /api/auth/register
Request Body
string
required
User’s email address. Must be a valid email format and unique in the system.
string
required
User’s first name. Must be at least 2 characters long.
string
required
User’s last name. Must be at least 2 characters long.
string
required
User’s password. Must be at least 6 characters long.
string
User’s phone number (optional).
Response
boolean
Indicates whether the request was successful.
object
Contains the newly created user data and JWT token.
Show data properties
Show data properties
object
string
JWT authentication token valid for 7 days.
Status Codes
Created
Registration successful. Returns user data and JWT token.
Bad Request
Invalid request body or validation error.
Conflict
Email already registered in the system.
Error Response
{
"success": false,
"error": "El email ya está registrado"
}
Example Request
cURL
curl -X POST https://api.pcfix.com/api/auth/register \
-H "Content-Type: application/json" \
-d '{
"email": "nuevo@ejemplo.com",
"nombre": "María",
"apellido": "García",
"telefono": "+1234567890",
"password": "miPassword123"
}'
JavaScript
const response = await fetch('https://api.pcfix.com/api/auth/register', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: 'nuevo@ejemplo.com',
nombre: 'María',
apellido: 'García',
telefono: '+1234567890',
password: 'miPassword123'
})
});
const data = await response.json();
console.log(data);
Python
import requests
response = requests.post(
'https://api.pcfix.com/api/auth/register',
json={
'email': 'nuevo@ejemplo.com',
'nombre': 'María',
'apellido': 'García',
'telefono': '+1234567890',
'password': 'miPassword123'
}
)
data = response.json()
print(data)
Example Response
{
"success": true,
"data": {
"user": {
"id": 456,
"email": "nuevo@ejemplo.com",
"nombre": "María",
"apellido": "García",
"telefono": "+1234567890",
"role": "USER"
},
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
}
Notes
- Upon successful registration, a customer profile is automatically created and linked to the user
- A welcome email is sent asynchronously to the provided email address
- The JWT token is valid for 7 days from the time of issuance
- Password is securely hashed using bcrypt before storage
- The
telefonofield is optional and can be omitted from the request
⌘I