Skip to main content

Endpoint

POST /users/register
Register a new user account and receive a JWT token valid for 30 days.

Request body

username
string
required
Username for the new account. Must be between 2 and 8 characters.
password
string
required
Password for the new account. Must be at least 6 characters long.

Response

token
string
JWT token valid for 30 days. Use this token in the Authorization header for authenticated requests.

Response format

Returns a plain text JWT token string:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...

Error codes

409 Conflict
Username already exists. Thrown when attempting to register with a username that is already taken.Exception: UserAlreadyExistsException
400 Bad Request
Payload was malformed, or your username or password was invalid. This error can occur for several reasons:
  • Username is too short (less than 2 characters) - UsernameTooShortException
  • Username is too long (more than 8 characters) - UsernameTooLongException
  • Password is too short (less than 6 characters) - PasswordTooShortException
  • Request body is missing required fields

Example request

curl -X POST https://api.example.com/users/register \
  -H "Content-Type: application/json" \
  -d '{
    "username": "johndoe",
    "password": "mySecurePassword123"
  }'

Example response

Success (200)

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwidXNlcm5hbWUiOiJqb2huZG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c

Error (409 Conflict)

{
  "message": "User already exists"
}

Error (400 Bad Request)

{
  "message": "Password must be at least 7 characters long"
}

Build docs developers (and LLMs) love