Expenses

These endpoints are used to manage expense entries for your business.


List Expenses

GET /api/expenses

Description: Retrieves a paginated list of expenses with optional filtering and sorting.

Authorization: API Key (Bearer Token) required.

Query Parameters:

  • Name
    page
    Type
    integer
    Description

    Page number for pagination (default: 1).

  • Name
    limit
    Type
    integer
    Description

    Number of items per page (default: 10).

  • Name
    sortBy
    Type
    string
    Description

    Field to sort by (default: 'expenseDate').

  • Name
    sortOrder
    Type
    string
    Description

    Sort direction: 'asc' or 'desc' (default: 'desc').

  • Name
    status
    Type
    string
    Description

    Filter by status: 'pending', 'approved', 'rejected', or 'all'.

  • Name
    category
    Type
    string
    Description

    Filter by category ID.

  • Name
    startDate
    Type
    string
    Description

    Filter by expenses on or after this date (YYYY-MM-DD).

  • Name
    endDate
    Type
    string
    Description

    Filter by expenses on or before this date (YYYY-MM-DD).

  • Name
    search
    Type
    string
    Description

    Search query to filter expenses by vendor or description.

Request

curl -X GET "https://your-summit-instance.com/api/expenses?page=1&limit=10&sortBy=amount&sortOrder=desc&status=pending" \
     -H "Authorization: Bearer <YOUR_API_TOKEN>"

Response (Success: 200 OK)

{
  "data": [
    {
      "id": 1,
      "companyId": 1,
      "categoryId": 2,
      "vendorId": null,
      "vendor": "Office Depot",
      "description": "Office supplies",
      "amount": 149.99,
      "currency": "USD",
      "expenseDate": "2023-10-15",
      "receiptUrl": "https://storage.example.com/receipts/abc123.jpg",
      "status": "pending",
      "recurring": "none",
      "nextDueDate": null,
      "createdAt": "2023-10-15T10:30:00.000Z",
      "updatedAt": "2023-10-15T10:30:00.000Z",
      "softDelete": false,
      "category": {
        "id": 2,
        "name": "Office Supplies"
      }
    }
  ],
  "total": 1,
  "page": 1,
  "limit": 10,
  "totalPages": 1
}

Create Expense

POST /api/expenses

Description: Creates a new expense entry.

Authorization: API Key (Bearer Token) required.

Request Body: application/json

  • Name
    categoryId
    Type
    integer
    Description

    ID of the expense category.

  • Name
    vendorId
    Type
    integer
    Description

    ID of the vendor (optional).

  • Name
    vendor
    Type
    string
    Description

    Name of the vendor or merchant.

  • Name
    description
    Type
    string
    Description

    Description of the expense.

  • Name
    amount
    Type
    number
    Description

    Amount of the expense.

  • Name
    currency
    Type
    string
    Description

    Currency code (e.g., USD, EUR).

  • Name
    expenseDate
    Type
    string
    Description

    Date of the expense (YYYY-MM-DD).

  • Name
    receiptUrl
    Type
    string
    Description

    URL to the uploaded receipt image.

  • Name
    status
    Type
    string
    Description

    Status of the expense: 'pending', 'approved', or 'rejected' (default: 'pending').

  • Name
    recurring
    Type
    string
    Description

    Recurring frequency: 'none', 'daily', 'weekly', 'monthly', or 'yearly' (default: 'none').

  • Name
    nextDueDate
    Type
    string
    Description

    Next due date for recurring expenses (YYYY-MM-DD).

Request

curl -X POST "https://your-summit-instance.com/api/expenses" \
     -H "Authorization: Bearer <YOUR_API_TOKEN>" \
     -H "Content-Type: application/json" \
     -d '{
       "categoryId": 2,
       "vendor": "Delta Airlines",
       "description": "Flight to conference",
       "amount": 450.00,
       "currency": "USD",
       "expenseDate": "2023-10-20",
       "receiptUrl": "https://storage.example.com/receipts/flight123.jpg",
       "status": "pending",
       "recurring": "none"
     }'

Response (Success: 201 Created)

{
  "id": 2,
  "companyId": 1,
  "categoryId": 2,
  "vendorId": null,
  "vendor": "Delta Airlines",
  "description": "Flight to conference",
  "amount": 450.00,
  "currency": "USD",
  "expenseDate": "2023-10-20",
  "receiptUrl": "https://storage.example.com/receipts/flight123.jpg",
  "status": "pending",
  "recurring": "none",
  "nextDueDate": null,
  "createdAt": "2023-10-27T13:00:00.000Z",
  "updatedAt": "2023-10-27T13:00:00.000Z",
  "softDelete": false
}

Get Expense Details

GET /api/expenses/{expenseId}

Description: Retrieves details for a specific expense.

Authorization: API Key (Bearer Token) required.

Path Parameters:

  • Name
    expenseId
    Type
    integer
    Description

    ID of the expense to retrieve.

Request

curl -X GET "https://your-summit-instance.com/api/expenses/2" \
     -H "Authorization: Bearer <YOUR_API_TOKEN>"

Response (Success: 200 OK)

{
  "id": 2,
  "companyId": 1,
  "categoryId": 2,
  "vendorId": null,
  "vendor": "Delta Airlines",
  "description": "Flight to conference",
  "amount": 450.00,
  "currency": "USD",
  "expenseDate": "2023-10-20",
  "receiptUrl": "https://storage.example.com/receipts/flight123.jpg",
  "status": "pending",
  "recurring": "none",
  "nextDueDate": null,
  "createdAt": "2023-10-27T13:00:00.000Z",
  "updatedAt": "2023-10-27T13:00:00.000Z",
  "softDelete": false,
  "category": {
    "id": 2,
    "name": "Travel Expenses"
  }
}

Update Expense

PUT /api/expenses/{expenseId}

Description: Updates an existing expense.

Authorization: API Key (Bearer Token) required.

Path Parameters:

  • Name
    expenseId
    Type
    integer
    Description

    ID of the expense to update.

Request Body: application/json

  • Name
    categoryId
    Type
    integer
    Description

    ID of the expense category.

  • Name
    vendorId
    Type
    integer
    Description

    ID of the vendor (optional).

  • Name
    vendor
    Type
    string
    Description

    Name of the vendor or merchant.

  • Name
    description
    Type
    string
    Description

    Description of the expense.

  • Name
    amount
    Type
    number
    Description

    Amount of the expense.

  • Name
    currency
    Type
    string
    Description

    Currency code (e.g., USD, EUR).

  • Name
    expenseDate
    Type
    string
    Description

    Date of the expense (YYYY-MM-DD).

  • Name
    receiptUrl
    Type
    string
    Description

    URL to the uploaded receipt image.

  • Name
    status
    Type
    string
    Description

    Status of the expense: 'pending', 'approved', or 'rejected'.

  • Name
    recurring
    Type
    string
    Description

    Recurring frequency: 'none', 'daily', 'weekly', 'monthly', or 'yearly'.

  • Name
    nextDueDate
    Type
    string
    Description

    Next due date for recurring expenses (YYYY-MM-DD).

Request

curl -X PUT "https://your-summit-instance.com/api/expenses/2" \
     -H "Authorization: Bearer <YOUR_API_TOKEN>" \
     -H "Content-Type: application/json" \
     -d '{
       "status": "approved",
       "description": "Flight to annual sales conference"
     }'

Response (Success: 200 OK)

{
  "id": 2,
  "companyId": 1,
  "categoryId": 2,
  "vendorId": null,
  "vendor": "Delta Airlines",
  "description": "Flight to annual sales conference",
  "amount": 450.00,
  "currency": "USD",
  "expenseDate": "2023-10-20",
  "receiptUrl": "https://storage.example.com/receipts/flight123.jpg",
  "status": "approved",
  "recurring": "none",
  "nextDueDate": null,
  "createdAt": "2023-10-27T13:00:00.000Z",
  "updatedAt": "2023-10-27T14:30:00.000Z",
  "softDelete": false
}

Delete Expense

DELETE /api/expenses/{expenseId}

Description: Soft deletes an expense.

Authorization: API Key (Bearer Token) required.

Path Parameters:

  • Name
    expenseId
    Type
    integer
    Description

    ID of the expense to delete.

Request

curl -X DELETE "https://your-summit-instance.com/api/expenses/2" \
     -H "Authorization: Bearer <YOUR_API_TOKEN>"

Response (Success: 200 OK)

{
  "message": "Expense deleted successfully"
}

Was this page helpful?