Skip to main content

Documentation 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.

The users endpoints let authenticated clients inspect their own account and discover other people on the platform. Both routes sit behind the authMiddleware, so every request must carry a valid Bearer token. The password field is never included in any user response — only _id, username, and email are returned. All endpoints below require the following header:
Authorization: Bearer <token>

GET /api/users/me

Returns the profile of the user identified by the JWT in the Authorization header. The server decodes the token, extracts userId, and performs a findById query that selects only the _id, username, and email fields.

Request body

None.

Success response — 200 OK

{
  "_id": "64f1a2b3c4d5e6f7a8b9c0d1",
  "username": "alice",
  "email": "alice@example.com"
}
_id
string
The user’s MongoDB ObjectId, serialised as a 24-character hex string.
username
string
The unique display name chosen at registration.
email
string
The email address associated with the account.

Error responses

StatusCondition
401 UnauthorizedThe Authorization header is absent, malformed, or the token is expired/invalid
404 Not FoundThe userId encoded in the token no longer matches any document in the database
500 Internal Server ErrorAn unexpected server error occurred

Example

curl -X GET http://localhost:3000/api/users/me \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
{
  "_id": "64f1a2b3c4d5e6f7a8b9c0d1",
  "username": "alice",
  "email": "alice@example.com"
}

GET /api/users

Returns an array of all registered users except the currently authenticated user. The server queries for every document whose _id is not equal to the caller’s userId, selecting only _id, username, and email.

Request body

None.

Success response — 200 OK

An array of user objects. Returns an empty array [] if no other users exist.
[
  {
    "_id": "64f1a2b3c4d5e6f7a8b9c0d2",
    "username": "bob",
    "email": "bob@example.com"
  },
  {
    "_id": "64f1a2b3c4d5e6f7a8b9c0d3",
    "username": "carol",
    "email": "carol@example.com"
  }
]
_id
string
The user’s MongoDB ObjectId, serialised as a 24-character hex string.
username
string
The unique display name of the other user.
email
string
The email address of the other user.

Error responses

StatusCondition
401 UnauthorizedThe Authorization header is absent, malformed, or the token is invalid
500 Internal Server ErrorAn unexpected database or server error occurred

Example

curl -X GET http://localhost:3000/api/users \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
[
  {
    "_id": "64f1a2b3c4d5e6f7a8b9c0d2",
    "username": "bob",
    "email": "bob@example.com"
  }
]
The React client uses this endpoint to populate the chat sidebar with the list of users you can open a conversation with. Because your own account is excluded from the results, every entry in the array is a valid conversation partner.

Build docs developers (and LLMs) love