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

Create Group

Create a new expense-sharing group.

Headers

Authorization
string
required
Bearer token for authentication

Request Body

name
string
required
Group name (max 50 characters)
description
string
Group description (max 500 characters)
members
array
required
Array of member objects with email addresses

Response

_id
string
Group’s unique identifier
name
string
Group name
description
string
Group description
members
array
Array of member objects
createdBy
object
Creator’s user object with _id, name, and email
expenses
array
Array of expense IDs
isSettled
boolean
Whether the group has been settled
createdAt
string
ISO 8601 timestamp

Example Request

cURL
curl -X POST https://api.billbuddy.com/api/groups \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Weekend Trip",
    "description": "Expenses for our camping trip",
    "members": [
      { "email": "[email protected]" },
      { "email": "[email protected]" }
    ]
  }'

Example Response

201 Created
{
  "_id": "507f191e810c19729de860ea",
  "name": "Weekend Trip",
  "description": "Expenses for our camping trip",
  "members": [
    {
      "user": {
        "_id": "507f1f77bcf86cd799439011",
        "name": "John Doe",
        "email": "[email protected]"
      },
      "balance": 0
    },
    {
      "user": {
        "_id": "507f1f77bcf86cd799439012",
        "name": "Alice Smith",
        "email": "[email protected]"
      },
      "balance": 0
    }
  ],
  "createdBy": {
    "_id": "507f1f77bcf86cd799439011",
    "name": "John Doe",
    "email": "[email protected]"
  },
  "expenses": [],
  "isSettled": false,
  "createdAt": "2024-01-15T10:30:00.000Z"
}

Get All Groups

Retrieve all groups the current user is a member of.

Headers

Authorization
string
required
Bearer token for authentication

Response

Returns an array of group objects with populated member and creator information.

Example Request

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

Example Response

200 OK
[
  {
    "_id": "507f191e810c19729de860ea",
    "name": "Weekend Trip",
    "description": "Expenses for our camping trip",
    "members": [
      {
        "user": {
          "_id": "507f1f77bcf86cd799439011",
          "name": "John Doe",
          "email": "[email protected]"
        },
        "balance": 0
      }
    ],
    "createdBy": {
      "_id": "507f1f77bcf86cd799439011",
      "name": "John Doe",
      "email": "[email protected]"
    },
    "expenses": [],
    "isSettled": false,
    "createdAt": "2024-01-15T10:30:00.000Z"
  }
]

Get Single Group

Retrieve detailed information about a specific group.

Headers

Authorization
string
required
Bearer token for authentication

Path Parameters

id
string
required
Group ID

Response

Returns a group object with populated members, creator, and expenses.

Example Request

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

Example Response

200 OK
{
  "_id": "507f191e810c19729de860ea",
  "name": "Weekend Trip",
  "description": "Expenses for our camping trip",
  "members": [
    {
      "user": {
        "_id": "507f1f77bcf86cd799439011",
        "name": "John Doe",
        "email": "[email protected]"
      },
      "balance": 0
    }
  ],
  "createdBy": {
    "_id": "507f1f77bcf86cd799439011",
    "name": "John Doe",
    "email": "[email protected]"
  },
  "expenses": [
    {
      "_id": "507f191e810c19729de860eb",
      "description": "Groceries",
      "amount": 150.50
    }
  ],
  "isSettled": false,
  "createdAt": "2024-01-15T10:30:00.000Z"
}

Error Responses

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

Update Group

Update group information. Only the group creator can update the group.

Headers

Authorization
string
required
Bearer token for authentication

Path Parameters

id
string
required
Group ID

Request Body

name
string
Updated group name (max 50 characters)
description
string
Updated group description (max 500 characters)
members
array
Array of user IDs to set as group members. This will replace existing members (except the creator).

Example Request

cURL
curl -X PUT https://api.billbuddy.com/api/groups/507f191e810c19729de860ea \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Updated Weekend Trip",
    "description": "Updated description"
  }'

Example Response

200 OK
{
  "_id": "507f191e810c19729de860ea",
  "name": "Updated Weekend Trip",
  "description": "Updated description",
  "members": [...],
  "createdBy": "507f1f77bcf86cd799439011",
  "expenses": [],
  "isSettled": false,
  "createdAt": "2024-01-15T10:30:00.000Z"
}

Error Responses

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

Delete Group

Delete a group. Only the group creator can delete the group.

Headers

Authorization
string
required
Bearer token for authentication

Path Parameters

id
string
required
Group ID

Example Request

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

Example Response

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

Error Responses

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

Add Member to Group

Add a new member to an existing group. Only the group creator can add members.

Headers

Authorization
string
required
Bearer token for authentication

Path Parameters

id
string
required
Group ID

Request Body

email
string
required
Email address of the user to add

Response

Returns the updated group object with populated member and creator information.

Example Request

cURL
curl -X POST https://api.billbuddy.com/api/groups/507f191e810c19729de860ea/members \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]"
  }'

Example Response

200 OK
{
  "_id": "507f191e810c19729de860ea",
  "name": "Weekend Trip",
  "description": "Expenses for our camping trip",
  "members": [
    {
      "user": {
        "_id": "507f1f77bcf86cd799439011",
        "name": "John Doe",
        "email": "[email protected]"
      },
      "balance": 0
    },
    {
      "user": {
        "_id": "507f1f77bcf86cd799439013",
        "name": "New Member",
        "email": "[email protected]"
      },
      "balance": 0
    }
  ],
  "createdBy": {
    "_id": "507f1f77bcf86cd799439011",
    "name": "John Doe",
    "email": "[email protected]"
  },
  "expenses": [],
  "isSettled": false,
  "createdAt": "2024-01-15T10:30:00.000Z"
}

Error Responses

400 Bad Request
{
  "message": "User is already a member of this group"
}
404 Not Found
{
  "message": "Group not found"
}
404 Not Found
{
  "message": "User not found"
}
403 Forbidden
{
  "message": "Not authorized to add members to this group"
}

Build docs developers (and LLMs) love