Generate and download a department spending report as an Excel file for a specified date range.
Get Department Spending Report as Excel File
This endpoint generates a spending report for a specific department and returns it as an Excel file. The report covers all card and account spending activity within the department for the requested time period. It is intended for finance teams and department managers who need structured, exportable spending data.
Endpoint
POST /api/teams/departments/{departmentId}/spend-report-xl
Authentication
Bearer token required. Obtain via:
POST https://api.banking.netevia.dev/api/auth/v2
Include in header: Authorization: Bearer {token}
Token lifetime: 10 minutes. Refresh via POST /api/auth/refresh.
When to use
Use this endpoint when a business customer needs to export department-level spending data into a spreadsheet for accounting, auditing, or budgeting purposes. It is useful for generating period-end reports or reconciling team expenditures against budget allocations. The returned file content can be decoded and saved as an .xlsx file.
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| departmentId | integer (int32) | Yes | The unique identifier of the department for which the spending report is generated. |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| dateFrom | string (date-time) | No | Start of the reporting period in ISO 8601 date-time format. |
| dateTo | string (date-time) | No | End of the reporting period in ISO 8601 date-time format. |
{
"dateFrom": "2024-01-01T00:00:00Z",
"dateTo": "2024-01-31T23:59:59Z"
}Response
200 OK
| Field | Type | Description |
|---|---|---|
| name | string | The filename of the generated Excel report (e.g., spend-report-dept-42.xlsx). |
| content | string | Base64-encoded content of the Excel file. Decode and save with an .xlsx extension. |
| contentType | string | MIME type of the file, typically application/vnd.openxmlformats-officedocument.spreadsheetml.sheet. |
{
"name": "spend-report-dept-42-2024-01.xlsx",
"content": "UEsDBBQABgAIAAAAIQD...",
"contentType": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
}Error Codes
| Code | When it happens |
|---|---|
| 400 | Missing required fields or validation error (e.g., dateTo is before dateFrom) |
| 401 | Token missing, expired, or invalid |
| 403 | Insufficient permissions to access the specified department |
| 404 | Department with the given departmentId not found |
| 500 | Internal server error |
Common Mistakes
- Providing a
dateTovalue that is earlier thandateFrom, resulting in an empty or invalid report. - Forgetting to Base64-decode the
contentfield before saving the file — the raw string is not a valid.xlsxfile until decoded. - Using a
departmentIdthat belongs to a different partner or business customer, which returns 403 or 404. - Omitting both
dateFromanddateTowhen a bounded report is needed — the API may return all available data or an empty report depending on server defaults.
Related Endpoints
POST /api/teams/departments/{departmentId}/spend-report— Get the department spending report as JSON data instead of an Excel file.GET /api/teams/departments— List all departments available for the authenticated business customer.GET /api/teams/departments/{departmentId}— Retrieve details for a specific department.
Example
curl -X POST https://api.banking.netevia.dev/api/teams/departments/42/spend-report-xl \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"dateFrom": "2024-01-01T00:00:00Z",
"dateTo": "2024-01-31T23:59:59Z"
}'