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
| Parameter | Type | Required | Description |
|---|---|---|---|
expenseId | string | Yes | The 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.
| Field | Type | Required | Description |
|---|---|---|---|
amount | number | No | Expense amount in USD (must be > 0 if provided) |
date | date | No | Expense date |
description | string | No | Expense description (cannot be empty if provided) |
category | string | No | Expense category: services, salaries, rent, utilities, marketing, or other |
notes | string | No | Additional notes about the expense |
receiptImage | object | null | No | Receipt 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
updatedAttimestamp is automatically updated when any field is modified - To remove notes, send
notes: nullor an empty string - To remove receipt image, send
receiptImage: null