Skip to main content

Register User

Create a new user account.

Request Body

name
string
required
User’s full name (max 50 characters)
email
string
required
User’s email address (must be valid email format)
password
string
required
User’s password (minimum 6 characters)

Response

success
boolean
Indicates if the registration was successful
token
string
JWT authentication token (valid for 30 days)

Example Request

cURL
curl -X POST https://api.billbuddy.com/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "name": "John Doe",
    "email": "[email protected]",
    "password": "securepass123"
  }'

Example Response

201 Created
{
  "success": true,
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}

Error Responses

400 Bad Request
{
  "message": "User already exists"
}
500 Internal Server Error
{
  "message": "Server error"
}

Login User

Authenticate a user and receive a JWT token.

Request Body

email
string
required
User’s email address
password
string
required
User’s password

Response

success
boolean
Indicates if the login was successful
token
string
JWT authentication token (valid for 30 days)

Example Request

cURL
curl -X POST https://api.billbuddy.com/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "securepass123"
  }'

Example Response

200 OK
{
  "success": true,
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}

Error Responses

400 Bad Request
{
  "message": "Invalid credentials"
}
500 Internal Server Error
{
  "message": "Server error"
}

Get Current User

Retrieve the currently authenticated user’s information.

Headers

Authorization
string
required
Bearer token for authenticationExample: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...

Response

_id
string
User’s unique identifier
name
string
User’s full name
email
string
User’s email address
groups
array
Array of group IDs the user belongs to
createdAt
string
ISO 8601 timestamp of account creation

Example Request

cURL
curl -X GET https://api.billbuddy.com/api/auth/me \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

Example Response

200 OK
{
  "_id": "507f1f77bcf86cd799439011",
  "name": "John Doe",
  "email": "[email protected]",
  "groups": [
    "507f191e810c19729de860ea",
    "507f191e810c19729de860eb"
  ],
  "createdAt": "2024-01-15T10:30:00.000Z"
}

Error Responses

401 Unauthorized
{
  "message": "Not authorized to access this route"
}
500 Internal Server Error
{
  "message": "Server error"
}

Build docs developers (and LLMs) love