Skip to main content

Update Expense (v1)

Method & Path

PATCH /api/v1/admin/expenses/:expenseId

Description

Update an existing expense record. All fields are optional - only provided fields will be updated.

Authentication

Required: Admin authentication with dashboard.view permission.

Headers

Authorization: Bearer <admin_token>
Content-Type: application/json

Path Parameters

ParameterTypeRequiredDescription
expenseIdstringYesThe unique identifier of the expense to update

Request Body

{
"amount": 1600.00,
"description": "Monthly office rent (updated)",
"category": "rent",
"notes": "Updated notes"
}

Request Body Schema

All fields are optional. Only provided fields will be updated.

FieldTypeRequiredDescription
amountnumberNoExpense amount in USD (must be > 0 if provided)
datedateNoExpense date
descriptionstringNoExpense description (cannot be empty if provided)
categorystringNoExpense category: services, salaries, rent, utilities, marketing, or other
notesstringNoAdditional notes about the expense
receiptImageobject | nullNoReceipt image information (see Receipt Image Schema in List Expenses)

Response 200 OK

{
"id": "507f1f77bcf86cd799439011",
"amount": 1600.00,
"date": "2025-01-15T10:30:00.000Z",
"description": "Monthly office rent (updated)",
"category": "rent",
"receiptImage": {
"url": "https://storage.googleapis.com/bucket/admin-expenses/expense-id/receipt-1234567890-abc123.webp",
"path": "admin-expenses/expense-id/receipt-1234567890-abc123.webp",
"width": 1000,
"height": 1000,
"sizeBytes": 50000,
"contentType": "image/webp"
},
"notes": "Updated notes",
"createdBy": "507f1f77bcf86cd799439014",
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-15T11:45:00.000Z"
}

Common Errors

400 Bad Request:

  • Invalid expense ID format
  • Invalid category value
  • Amount must be greater than 0 (if provided)
  • Description cannot be empty (if provided)

401 Unauthorized: Missing or invalid authentication token

403 Forbidden: Admin does not have dashboard.view permission

404 Not Found: Expense not found

500 Internal Server Error: Server error occurred while updating the expense

Notes

  • The updatedAt timestamp is automatically updated when any field is modified
  • To remove notes, send notes: null or an empty string
  • To remove receipt image, send receiptImage: null