All settlement endpoints require authentication. Include the JWT token in the Authorization header.
Create Settlement
Create a new settlement for a group. This calculates the minimum number of transactions needed to settle all debts and marks the group as settled.Headers
Bearer token for authentication
Request Body
Group ID to create settlement for
Response
Confirmation message
Settlement object containing transaction details
Example Request
cURL
Example Response
200 OK
The settlement algorithm calculates the minimum number of transactions needed to settle all debts in the group. This may result in fewer transactions than the actual number of expenses.
Error Responses
404 Not Found
400 Bad Request
403 Forbidden
500 Internal Server Error
Get Group Settlements
Retrieve all settlements for a specific group.Headers
Bearer token for authentication
Path Parameters
Group ID
Response
Returns an array of settlement objects with populated user information.Example Request
cURL
Example Response
200 OK
Error Responses
404 Not Found
403 Forbidden
500 Internal Server Error
Update Settlement Status
Update the status of a settlement. Only the person who created the settlement can update its status.Headers
Bearer token for authentication
Path Parameters
Settlement ID
Request Body
New settlement status. Options:
pending, completed, cancelledResponse
Returns the updated settlement object.Example Request
cURL
Example Response
200 OK
Error Responses
404 Not Found
403 Forbidden
500 Internal Server Error
Understanding Settlement Calculations
How the settlement algorithm works:
- Calculate Balances: For each member, calculate total amount paid minus total amount owed
- Identify Creditors and Debtors: Positive balances are creditors (owed money), negative balances are debtors (owe money)
- Minimize Transactions: Use a greedy algorithm to match the largest debtor with the largest creditor
- Generate Summary: Create a list of transactions that settles all debts with minimum transfers
Example Scenario
Imagine a group of 3 people with these expenses:- John paid $150 for groceries (split 3 ways)
- Alice paid $90 for gas (split 3 ways)
- Bob paid $60 for supplies (split 3 ways)
- John: +100 = +50)
- Alice: +100 = -10)
- Bob: +100 = -40)
- Bob pays John $40
- Alice pays John $10