Skip to main content
POST
/
api
/
register
Register User
curl --request POST \
  --url https://api.example.com/api/register \
  --header 'Content-Type: application/json' \
  --data '
{
  "username": "<string>",
  "email": "<string>",
  "password": "<string>",
  "avatar_url": "<string>",
  "description": "<string>"
}
'
{
  "message": "<string>",
  "error": "<string>"
}
Creates a new user account in the Mirage system. This endpoint validates the provided credentials, checks for existing users, hashes the password, and initializes the user profile with default statistics.

Request Body

username
string
required
The desired username for the account. Must be unique and non-empty.
email
string
required
The user’s email address. Must be unique and non-empty.
password
string
required
The user’s password. Will be hashed before storage.
avatar_url
string
Optional URL for the user’s avatar image.
description
string
Optional user bio or description. Maximum 500 words.

Response

message
string
Success message confirming user registration.
error
string
Error message if registration fails.

Status Codes

  • 201: User successfully created
  • 400: Invalid request (missing required fields, user already exists, or description exceeds 500 words)

Error Messages

  • "I can't see a single field you filled" - Missing required fields (username, email, or password)
  • "You are talking too much in the description" - Description exceeds 500 words
  • " the user already exists" - Username or email already registered

Example Request

curl -X POST https://api.mirage.com/api/register \
  -H "Content-Type: application/json" \
  -d '{
    "username": "johndoe",
    "email": "[email protected]",
    "password": "securepassword123",
    "avatar_url": "https://example.com/avatar.jpg",
    "description": "Software developer and tech enthusiast"
  }'

Example Response

{
  "message": "Welcome to MIRAGE"
}

Notes

  • Passwords are securely hashed using Werkzeug’s generate_password_hash before storage
  • A user profile is automatically created with initial stats (followers: 0, following: 0, posts: 0, upvotes: 0, downvotes: 0)
  • Username and email must be unique across the system
  • Description word count is validated (maximum 500 words)

Build docs developers (and LLMs) love