Skip to main content
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>"
}
'
{
  "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
Creates a new user account with the provided information. Automatically creates an associated customer profile and sends a welcome email.

Request Body

email
string
required
User’s email address. Must be a valid email format and unique in the system.
nombre
string
required
User’s first name. Must be at least 2 characters long.
apellido
string
required
User’s last name. Must be at least 2 characters long.
password
string
required
User’s password. Must be at least 6 characters long.
telefono
string
User’s phone number (optional).

Response

success
boolean
Indicates whether the request was successful.
data
object
Contains the newly created user data and JWT token.

Status Codes

201
Created
Registration successful. Returns user data and JWT token.
400
Bad Request
Invalid request body or validation error.
409
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": "[email protected]",
    "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: '[email protected]',
    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': '[email protected]',
    'nombre': 'María',
    'apellido': 'García',
    'telefono': '+1234567890',
    'password': 'miPassword123'
  }
)

data = response.json()
print(data)

Example Response

{
  "success": true,
  "data": {
    "user": {
      "id": 456,
      "email": "[email protected]",
      "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 telefono field is optional and can be omitted from the request

Build docs developers (and LLMs) love