The auth endpoints are the entry point to the TalkBox API. UseDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/abdelhafid37/talkbox/llms.txt
Use this file to discover all available pages before exploring further.
POST /api/auth/register to create a new account and POST /api/auth/login to authenticate and receive the JWT that every other endpoint requires. Neither endpoint needs an Authorization header.
POST /api/auth/register
Creates a new user account. The server validates the supplied fields, checks for duplicate usernames and emails, bcrypt-hashes the password with 10 salt rounds, and stores the user in MongoDB. Does not require authentication.Request body
A unique display name for the account. Must be between 3 and 30 characters after trimming leading and trailing whitespace.
The user’s email address. Must match the pattern
[a-zA-Z0-9.]{2,}@[a-zA-Z]{2,}.[a-zA-Z]{2,}. Whitespace is trimmed before validation.The account password. Must be at least 8 characters long. Stored as a bcrypt hash — never in plain text.
Success response — 201 Created
Error responses
| Status | Condition |
|---|---|
400 Bad Request | Any required field is missing, not a string, empty after trimming, or fails length/format validation |
409 Conflict | The username or email is already associated with an existing account |
500 Internal Server Error | An unexpected database or server error occurred |
Example
POST /api/auth/login
Authenticates an existing user by email and password. On success the server returns a signed JWT that encodes the user’s MongoDB_id as userId in the payload.
Does not require authentication.
Request body
The email address registered to the account. Whitespace is trimmed before the database lookup.
The plain-text password. Compared against the stored bcrypt hash using
bcrypt.compare.Success response — 200 OK
Error responses
| Status | Condition |
|---|---|
400 Bad Request | Either email or password is missing or not a string |
401 Unauthorized | No user found for the given email, or the password does not match |
500 Internal Server Error | An unexpected server error occurred |
Example
Store the returned
token securely (e.g. in localStorage or an in-memory variable) and include it as Authorization: Bearer <token> on every request to a protected endpoint. The token expires after 7 days, at which point you must log in again to obtain a new one.