POST /api/auth/register
Creates a new user account and automatically generates a TRON wallet for the user. Upon successful registration, the user is automatically logged in with access and refresh tokens set as HTTP-only cookies.Authentication
No authentication required.Request Body
User’s email address. Must be unique and follow valid email format.
Unique username for the account. Minimum 3 characters.
User’s password. Must be at least 8 characters long.
Password confirmation. Must match the password field.
Response
Success message confirming registration.
The newly created user object.
Unique user identifier.
User’s email address.
User’s username.
User’s role (default: “user”).
Cookies Set
accessToken- JWT access token (HTTP-only, 7 days expiry)refreshToken- JWT refresh token (HTTP-only, 7 days expiry)
Example Request
Example Response
Error Responses
Error message describing what went wrong.
400 Bad Request
- All fields are required - One or more required fields are missing
- Passwords do not match - Password and passwordConfirm don’t match
- Password must be at least 8 characters - Password is too short
- Email already registered - An account with this email already exists
500 Internal Server Error
- Server error with error message details
Notes
- Email addresses are automatically converted to lowercase
- Email must match the pattern:
/^\w+([-.]?\w+)*@\w+([-.]?\w+)*(\.\w{2,3})+$/ - Username must be at least 3 characters long
- Password is hashed using bcrypt before storage
- A TRON wallet is automatically created for each new user
- The private key is securely stored in the database (encrypted storage recommended for production)
- Users are set to “active” status by default (
isActive: true)