Skip to main content
All expense endpoints require authentication. Include the JWT token in the Authorization header.

Create Expense

Create a new expense and add it to a group.

Headers

Authorization
string
required
Bearer token for authentication

Request Body

description
string
required
Expense description (max 100 characters)
amount
number
required
Expense amount (must be non-negative)
group
string
required
Group ID where this expense belongs
splitAmong
array
required
Array of user IDs to split the expense among
category
string
Expense category. Options: Food, Travel, Shopping, Entertainment, Utilities, OtherDefault: Other

Response

_id
string
Expense’s unique identifier
description
string
Expense description
amount
number
Expense amount
paidBy
string
User ID of the person who paid
splitAmong
array
Array of user IDs
group
string
Group ID
category
string
Expense category
date
string
ISO 8601 timestamp

Example Request

cURL
curl -X POST https://api.billbuddy.com/api/expenses \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -H "Content-Type: application/json" \
  -d '{
    "description": "Groceries for camping",
    "amount": 150.50,
    "group": "507f191e810c19729de860ea",
    "splitAmong": [
      "507f1f77bcf86cd799439011",
      "507f1f77bcf86cd799439012"
    ],
    "category": "Food"
  }'

Example Response

201 Created
{
  "_id": "507f191e810c19729de860eb",
  "description": "Groceries for camping",
  "amount": 150.50,
  "paidBy": "507f1f77bcf86cd799439011",
  "splitAmong": [
    "507f1f77bcf86cd799439011",
    "507f1f77bcf86cd799439012"
  ],
  "group": "507f191e810c19729de860ea",
  "category": "Food",
  "date": "2024-01-15T14:30:00.000Z"
}

Error Responses

500 Internal Server Error
{
  "message": "Server error"
}

Get Recent Expenses

Retrieve the 10 most recent expenses for the current user (either paid by them or split with them).

Headers

Authorization
string
required
Bearer token for authentication

Response

Returns an array of expense objects sorted by date (newest first), limited to 10 items.

Example Request

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

Example Response

200 OK
[
  {
    "_id": "507f191e810c19729de860eb",
    "description": "Groceries for camping",
    "amount": 150.50,
    "paidBy": {
      "_id": "507f1f77bcf86cd799439011",
      "name": "John Doe",
      "email": "[email protected]"
    },
    "splitAmong": [
      {
        "_id": "507f1f77bcf86cd799439011",
        "name": "John Doe",
        "email": "[email protected]"
      },
      {
        "_id": "507f1f77bcf86cd799439012",
        "name": "Alice Smith",
        "email": "[email protected]"
      }
    ],
    "group": {
      "_id": "507f191e810c19729de860ea",
      "name": "Weekend Trip"
    },
    "category": "Food",
    "date": "2024-01-15T14:30:00.000Z"
  }
]

Get Group Expenses

Retrieve all expenses for a specific group.

Headers

Authorization
string
required
Bearer token for authentication

Path Parameters

groupId
string
required
Group ID

Response

Returns an array of expense objects for the specified group, sorted by date (newest first).

Example Request

cURL
curl -X GET https://api.billbuddy.com/api/expenses/group/507f191e810c19729de860ea \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

Example Response

200 OK
[
  {
    "_id": "507f191e810c19729de860eb",
    "description": "Groceries for camping",
    "amount": 150.50,
    "paidBy": {
      "_id": "507f1f77bcf86cd799439011",
      "name": "John Doe",
      "email": "[email protected]"
    },
    "splitAmong": [
      {
        "_id": "507f1f77bcf86cd799439011",
        "name": "John Doe",
        "email": "[email protected]"
      },
      {
        "_id": "507f1f77bcf86cd799439012",
        "name": "Alice Smith",
        "email": "[email protected]"
      }
    ],
    "category": "Food",
    "date": "2024-01-15T14:30:00.000Z"
  },
  {
    "_id": "507f191e810c19729de860ec",
    "description": "Gas for the trip",
    "amount": 75.00,
    "paidBy": {
      "_id": "507f1f77bcf86cd799439012",
      "name": "Alice Smith",
      "email": "[email protected]"
    },
    "splitAmong": [
      {
        "_id": "507f1f77bcf86cd799439011",
        "name": "John Doe",
        "email": "[email protected]"
      },
      {
        "_id": "507f1f77bcf86cd799439012",
        "name": "Alice Smith",
        "email": "[email protected]"
      }
    ],
    "category": "Travel",
    "date": "2024-01-15T12:00:00.000Z"
  }
]

Error Responses

404 Not Found
{
  "message": "Group not found"
}
403 Forbidden
{
  "message": "Not authorized to access this group"
}

Get Single Expense

Retrieve details of a specific expense.

Headers

Authorization
string
required
Bearer token for authentication

Path Parameters

id
string
required
Expense ID

Response

Returns an expense object with populated user information.

Example Request

cURL
curl -X GET https://api.billbuddy.com/api/expenses/507f191e810c19729de860eb \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

Example Response

200 OK
{
  "_id": "507f191e810c19729de860eb",
  "description": "Groceries for camping",
  "amount": 150.50,
  "paidBy": {
    "_id": "507f1f77bcf86cd799439011",
    "name": "John Doe",
    "email": "[email protected]"
  },
  "splitAmong": [
    {
      "_id": "507f1f77bcf86cd799439011",
      "name": "John Doe",
      "email": "[email protected]"
    },
    {
      "_id": "507f1f77bcf86cd799439012",
      "name": "Alice Smith",
      "email": "[email protected]"
    }
  ],
  "group": "507f191e810c19729de860ea",
  "category": "Food",
  "date": "2024-01-15T14:30:00.000Z"
}

Error Responses

404 Not Found
{
  "message": "Expense not found"
}
403 Forbidden
{
  "message": "Not authorized to access this expense"
}

Update Expense

Update an existing expense. Only the person who paid can update the expense.

Headers

Authorization
string
required
Bearer token for authentication

Path Parameters

id
string
required
Expense ID

Request Body

description
string
Updated expense description (max 100 characters)
amount
number
Updated expense amount (must be non-negative)
splitAmong
array
Updated array of user IDs to split the expense among
category
string
Updated expense category

Example Request

cURL
curl -X PUT https://api.billbuddy.com/api/expenses/507f191e810c19729de860eb \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -H "Content-Type: application/json" \
  -d '{
    "description": "Updated groceries description",
    "amount": 165.75,
    "category": "Food"
  }'

Example Response

200 OK
{
  "_id": "507f191e810c19729de860eb",
  "description": "Updated groceries description",
  "amount": 165.75,
  "paidBy": "507f1f77bcf86cd799439011",
  "splitAmong": [
    "507f1f77bcf86cd799439011",
    "507f1f77bcf86cd799439012"
  ],
  "group": "507f191e810c19729de860ea",
  "category": "Food",
  "date": "2024-01-15T14:30:00.000Z"
}

Error Responses

404 Not Found
{
  "message": "Expense not found"
}
403 Forbidden
{
  "message": "Not authorized to update this expense"
}

Delete Expense

Delete an expense. Only the person who paid can delete the expense.

Headers

Authorization
string
required
Bearer token for authentication

Path Parameters

id
string
required
Expense ID

Example Request

cURL
curl -X DELETE https://api.billbuddy.com/api/expenses/507f191e810c19729de860eb \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

Example Response

200 OK
{
  "message": "Expense removed"
}

Error Responses

404 Not Found
{
  "message": "Expense not found"
}
403 Forbidden
{
  "message": "Not authorized to delete this expense"
}

Settle Group Expenses

Calculate balances and settle all expenses in a group.

Headers

Authorization
string
required
Bearer token for authentication

Path Parameters

groupId
string
required
Group ID to settle

Response

message
string
Confirmation message
balances
object
Object mapping user IDs to their final balance in the group

Example Request

cURL
curl -X POST https://api.billbuddy.com/api/expenses/settle/507f191e810c19729de860ea \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

Example Response

200 OK
{
  "message": "Group settled successfully",
  "balances": {
    "507f1f77bcf86cd799439011": 75.25,
    "507f1f77bcf86cd799439012": -75.25
  }
}
Positive balance means the user is owed money. Negative balance means the user owes money.

Error Responses

404 Not Found
{
  "message": "Group not found"
}
403 Forbidden
{
  "message": "Not authorized to settle this group"
}

Build docs developers (and LLMs) love