Skip to main content
POST
/
api
/
auth
/
register
Register User
curl --request POST \
  --url https://api.example.com/api/auth/register \
  --header 'Content-Type: application/json' \
  --data '
{
  "email": "<string>",
  "password": "<string>",
  "full_name": "<string>",
  "phone": "<string>",
  "role": "<string>"
}
'
{
  "400": {},
  "403": {},
  "409": {},
  "500": {},
  "success": true,
  "message": "<string>",
  "token": "<string>",
  "user": {
    "id": "<string>",
    "email": "<string>",
    "full_name": "<string>",
    "role": "<string>"
  }
}

Endpoint

POST /api/auth/register

Authentication

No authentication required.

Request Body

email
string
required
User’s email address. Must be a valid email format. Will be normalized and converted to lowercase.
password
string
required
User’s password. Must be at least 8 characters long.
full_name
string
required
User’s full name. Cannot be empty.
phone
string
User’s phone number in international format (e.g., +5491112345678). Must match pattern: ^\+?[1-9][0-9]{7,14}$
role
string
User role. Only “seller” is allowed for public registration. Admin accounts cannot be created via this endpoint.

Response

success
boolean
Indicates whether the registration was successful.
message
string
Human-readable message describing the result.
token
string
JWT authentication token. Expires in 7 days by default.
user
object
Basic user information.
id
string
User’s unique identifier.
email
string
User’s email address.
full_name
string
User’s full name.
role
string
User’s role (always “seller” for public registration).

Example Request

curl -X POST https://api.horsetrust.com/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "securePassword123",
    "full_name": "John Smith",
    "phone": "+5491112345678"
  }'

Example Response

201 Success
{
  "success": true,
  "message": "User registered successfully",
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "user": {
    "id": "507f1f77bcf86cd799439011",
    "email": "[email protected]",
    "full_name": "John Smith",
    "role": "seller"
  }
}

Error Responses

400
error
Bad Request - Validation error.
{
  "success": false,
  "message": "Password must be at least 8 characters"
}
403
error
Forbidden - Attempted to register as admin.
{
  "success": false,
  "message": "Cannot register as admin"
}
409
error
Conflict - Email already registered.
{
  "success": false,
  "message": "Email already registered"
}
500
error
Server Error - Internal server error.
{
  "success": false,
  "message": "Server error"
}

Notes

  • Email addresses are automatically normalized and converted to lowercase
  • Passwords are securely hashed using bcrypt with 12 salt rounds
  • New users are created with is_email_verified: false and is_phone_verified: false
  • Seller profile is initialized with verification_status: "pending"
  • The JWT token should be stored securely and included in subsequent requests requiring authentication

Build docs developers (and LLMs) love