Report model and API reference
Section titled “Report model and API reference”This page is for integrators and developers who create, run or export reports through the API, or need to know exactly how a rendition is produced. It documents the report model, the validation rules and error codes, the endpoints, the export pipeline and scheduled delivery.
A report is a saved, tabular projection over a data entity. It binds a data query (the row source) to an ordered list of fields (the columns), plus presentation, scheduling, notification, and access options. Once defined, a report can be executed to return live rows, counted, and exported to PDF or XLSX renditions.
- Web-only. Reports are available in the web application only. A report link opens only on the web; on mobile it resolves to a
NotSupportedLinkand cannot be navigated to.
Concepts and data model
Section titled “Concepts and data model”A report is stored as a DataEntry of the core Report entity. The concrete model is ReportEntry, whose value holds a ReportEntryValue:
ReportEntry (extends DataEntry) value: ReportEntryValueReportEntry’s constructor force-assigns dataEntity = REPORT_ENTITY_ID, so every report row is tagged to the Report core entity regardless of the payload.
ReportEntryValue fields
Section titled “ReportEntryValue fields”From report-entry-value.model.ts:
| Field | Type | Required | Notes |
|---|---|---|---|
name | LocalizedValue | yes | Report display name (per-language). Must be unique per related data entity — see validation. |
normalizedName | string | no | Auto-generated programmatic identifier derived from name; unique per related DataEntity. |
description | NullableLocalizedValue | no | Localized description; used in the PDF header text. |
icon | Icon | (require: true) | Report icon. |
dataSource | DataEntrySource | (require: true) | The row source. Only the Query type is supported (see below). |
fields | string[] | (require: true, minItems: 1) | Ordered list of entity field paths to project as columns. Order is preserved. |
allowChangeFields | boolean | no | If true, export callers may narrow the exported columns via selectedColumns. |
relatedTo | DataEntityReferenceProperty | (require: true) | The entity the report runs against ({dataEntity, dataEntry}). |
authenticated | AuthenticatedViewOption | no | Access/authentication config. Defaults to {isRestricted: false, enabled: true}. |
isPublished | boolean | no | Default false. Publishing gates the permission requirement and schedule validation. |
schedule | ReportScheduleModel | no | Optional scheduled delivery timer. |
inAppNotification | SendReportNotificationActionOptions | no | In-app notification delivery config. |
emailNotification | SendReportEmailActionOptions | no | Email delivery config. |
displayOrder | number | no | Default 0. Ordering hint. |
design | ReportDesignOptions | no | PDF layout / header / footer options. |
domain | ReferenceProperty | no | Optional domain reference. |
sharing | ApplicationSharing | yes | Application-sharing metadata. |
help | ReportHelp | no | Contextual help text. Since 1.2 |
Note on
requirevsrequired. Several properties in the model use the misspelled decorator keyrequire: true(e.g.icon,dataSource,fields,relatedTo). LoopBack’s property validation readsrequired(notrequire), so these are not enforced as required by the framework schema — the business rules inReportService(below) are what actually enforcedataSourcetype,fieldscontent, andrelatedTo.
Data source (the row source)
Section titled “Data source (the row source)”dataSource is a DataEntrySource:
| Field | Type | Notes |
|---|---|---|
type | DataCollectionTypeEnum | Must be Query (enum value 2). Store and Collection are rejected. |
store | string | Store name (pattern-constrained). |
collection | UUID | Collection id. |
query | UUID | The data query id that produces the rows. |
DataCollectionTypeEnum = { Store = 0, Collection = 1, Query = 2 }. Report validation requires type === Query, so every report resolves its rows through a data query.
The report-reference-property.model.ts constrains a report reference to always point at the DataEntity core entity (dataEntity is a JSON-schema const of CoreEntities.DataEntity) with a dataEntry UUID. ReportEntryValue.relatedTo is typed as the more general DataEntityReferenceProperty, but the same {dataEntity, dataEntry} shape applies.
Access and authentication
Section titled “Access and authentication”authenticated is an AuthenticatedViewOption:
| Field | Type | Notes |
|---|---|---|
enabled | boolean | Whether authenticated access is enabled (schema default false). |
defaultView | boolean | Whether this is the default view (schema default false). |
isRestricted | boolean | Whether the report has explicit permissions attached. Calculated only — it is not accepted from create/update payloads directly for this purpose; it drives the publish permission check. |
Design options
Section titled “Design options”The designer’s Report Design choices map to ReportDesignOptions, whose defaults are pageHeader = true, organizationHeader = true, pageFooter = true, organizationFooter = false.
Permissions
Section titled “Permissions”Permissions are not stored on the report document; they live in access-rights (see Internals and invariants). Publishing a restricted report with no permissions selected is rejected.
Validation rules
Section titled “Validation rules”All create/update paths run through ReportService.validateReportValue and validateNameUniqueness.
validateReportValue(value)
value.dataSource.typemust beDataCollectionTypeEnum.Query, elseReportDataSourceSupportedException(errorREPORT_DATA_SOURCE_NOT_SUPPORTED).- When
relatedTo.dataEntity === CoreEntities.DataEntity:- The query (
dataSource.query) must exist, elseDataQueryNotFound. - The related entity (
relatedTo.dataEntry) must exist, elseEntryNotExistException. - The entity must not be archived, else
EntityArchivedException. - The query’s
dataEntitymust equalrelatedTo.dataEntry, elseDataQueryNotBelongToEntity. - Field validation (
validateReportFields):fieldsmust be non-empty (ReportFieldsLengthException,REPORT_FIELDS_LENGTH) and every entry must exist in the entity’sgetAllFieldsPaths()— unknown fields raiseReportFieldsNotExistException(REPORT_FIELDS_NOT_EXIST), listing the offending paths.
- The query (
- If the report
isPublishedand has aschedule.enabledone-time send whoseoneTimetimestamp is in the past,ReportSendingTimeCanNotBeInThePastException(REPORT_SENDING_TIME).
validateNameUniqueness(report, selfId?) — for each configured language, if name[lang] is set, the service looks for an existing report with the same value.relatedTo.dataEntry and the same value.name.<lang>. On PATCH, selfId excludes the current report (id neq selfId). A collision raises ReportExistException (REPORT_EXISTS). Uniqueness is therefore scoped per related data entity, per language.
Endpoints
Section titled “Endpoints”All routes are on ReportEntryController, authenticated with the OSOS OAuth2 strategy and authorized per-route. id is the report entry id.
| Method | Path | Purpose |
|---|---|---|
POST | /v1/reports | Create a report. |
GET | /v1/reports | List reports (LoopBack filter). |
GET | /v1/reports/count | Count reports (LoopBack where). |
GET | /v1/reports/{id} | Get one report (joins permissions). |
PATCH | /v1/reports/{id} | Update a report. |
PATCH | /v1/reports/{id}/permissions | Update only the report’s access/permissions. |
DELETE | /v1/reports/{id} | Delete a report. |
GET | /v1/reports/{id}/entries | Execute the report to rows (v1 filter). |
GET | /v2/reports/{id}/entries | Execute the report to rows (criteria + search). |
GET | /v1/reports/{id}/entries/count | Row count (v1 where). |
GET | /v2/reports/{id}/entries/count | Row count (criteria + search). |
GET | /v2/reports/{id}/export/{format} | Export rows to a file (pdf or xlsx). |
Create (POST /v1/reports) — body is a ReportEntryDto without id (a NewReportEntry): the ReportEntryValue plus optional permissions: Permission[]. The flow runs validateNameUniqueness then validateReportValue, strips permissions, sends a CreateDataEntryCommand on the service bus (async, CQRS-style) for the Report entity, awaits invokerService.registerToken(messageId) to get the created result, then stores permissions separately in access-rights. The row is created by the command handler, not inline.
Read (GET /v1/reports/{id}) — returns the stored report plus a permissions array joined at read time from access-rights (convertAccessRightToPermissions(Report, id)); permissions are not stored on the report document.
Update (PATCH /v1/reports/{id}) — body is a partial ReportEntryDto. After validation, a publish permission guard applies: if value.isPublished and authenticated.enabled and authenticated.isRestricted and the supplied permissions are empty and no permissions already exist, it throws ReportPermissionsNotSelectedException (HTTP 422, REPORT_PERMISSION_NOT_SELECTED). The report is then persisted via updateById; access-rights are reconciled before publishing (order matters — dependency-sync re-fetches via GET /v1/reports/{id}): if isRestricted === false, stored permissions are cleared; otherwise a non-empty supplied set is stored. Finally a DataEntryUpdatedEvent is published, carrying a changed-field marker for isPublished when it changed.
Update permissions (PATCH /v1/reports/{id}/permissions) — authorized by systemAdminVoterFactory() (system-admin only). Body is an UpdateResourcePermissionsDto (permissions + authenticated). It applies the same publish guard, writes the new authenticated block, publishes a DataEntryUpdatedEvent, then reconciles access-rights.
Delete (DELETE /v1/reports/{id}) — sends a DeleteDataEntryCommand on the bus, awaits its token, then publishes a ReportDeletedEvent. Deletion is command-driven like creation.
Executing a report
Section titled “Executing a report”v1 (/v1/reports/{id}/entries, /v1/reports/{id}/entries/count) accept a LoopBack filter/where. The controller resolves the related entity from report.value.relatedTo.dataEntry, then forces state = Active, virtual != true (unless include_virtual=true), and dataEntity = <entity id>, and calls dataSourceService.find(entity, report.value.fields, filter, count?, report.value.dataSource).
v2 (/v2/reports/{id}/entries, /v2/reports/{id}/entries/count) accept a structured filterCriteria/whereCriteria (a FilterExpression tree) plus a free-text search param. The controller builds an AND expression that always pins state = Active (and virtual != true unless include_virtual), optionally AND-ed with the caller’s criteria, and delegates to dataSourceService.findV2 / countV2. The entries endpoint passes revealSensitiveFields = true.
Common query params:
| Param | Type | Meaning |
|---|---|---|
include_virtual | boolean | Include rows flagged virtual (default excludes them). |
search | string (v2) | Free-text search across the projected fields. |
filterCriteria / whereCriteria | object (v2) | Structured filter expression. |
Export renditions
Section titled “Export renditions”Triggering an export from the UI
Section titled “Triggering an export from the UI”End users start an export from the report’s actions menu in the web application — Export to Excel or Export to PDF. Both options call the export endpoint below.
Export endpoint
Section titled “Export endpoint”GET /v2/reports/{id}/export/{format} — format is an ExportFormatEnum: pdf or xlsx (there is no CSV export). Query params: filterCriteria, search, include_virtual, and selectedColumns (a string array). The response is a file download — content type and Content-Disposition: attachment; filename=... come from the exporter result. The declared content types are application/vnd.openxmlformats-officedocument.spreadsheetml.sheet (XLSX) and application/pdf. Since 1.2 the export URL carries {format} as a path segment.
Format scope: reports never export CSV
Section titled “Format scope: reports never export CSV”The report route’s format is typed ExportFormatEnum (pdf | xlsx), the declared content types are XLSX and PDF only, and the XLSX and PDF exporters are the only two registered. The CSV that 1.10 introduced belongs to the quick export of a gallery and its admin twin on the entity page — GET /v3/entities/{entity}/views/{id}/entries/export and GET /v3/entities/{entity}/entries/export, both format=xlsx|csv — documented in Data Views & Faces. Nothing in that change reaches reports, which remain XLSX / PDF and web-only (the mobile app has no reports).
ReportService.exportReportV2 loads the report, derives the file name from the localized report name in the caller’s language, builds the same state = Active (+ optional virtual != true) AND filter as v2 execute (AND-ed with any filterCriteria), selects columns, fetches rows via dataSourceService.findV2(..., revealSensitiveFields = true), and calls ExportService.export.
Column selection and value formatting
Section titled “Column selection and value formatting”By default the exported columns are report.value.fields. If selectedColumns is provided and non-empty and report.value.allowChangeFields is true, the exported columns become selectedColumns intersected with the report’s own fields (a report can never export a column it does not define). If allowChangeFields is false, selectedColumns is ignored. Since 1.2 (selectedColumns + allowChangeFields).
ExportService.export resolves the concrete exporter through ExporterFactoryService (an unknown format yields InvalidExportFormatException). Before handing rows over, convertDataEntryToExportableData flattens each DataEntry.value into display-ready strings per field type:
| Field kind | Export rendering |
|---|---|
| ADT string / date / datetime / time | Resolved collection value; dates dd/MM/yyyy, datetime dd/MM/yyyy hh:mm, time hh:mm (user timezone or UTC). |
| Reference / User | _resolved.mainTitle (localized). |
| Localized text | Localized value for the user’s language. |
| DateTime | dd/MM/yyyy hh:mm. |
| Date | dd/MM/yyyy. |
| Date / DateTime range | Two endpoints joined by -. |
| Time | hh:mm. |
| Month-Year | MM/yyyy. |
| Category | _resolved.label (localized). |
| Blob / file | File name. |
| Map | JSON.stringify(geometry.coordinates). |
| Switch | _resolved.mainTitle (localized). |
| Password | Masked as ****. |
| Other (icon, phone, …) | Raw value. |
Repeatable / multi-value fields render each element with the same rule and join with , (ranges join their two dates with -). Report execution and export share this converter, so exported values match what the entries endpoint returns.
Sensitive fields. Execution and export request sensitive-field values (revealSensitiveFields = true), but each sensitive field is still masked (****) for anyone without sensitive-field access to it, and password-typed fields are always masked. Masking applies identically to the exported file, the on-screen report, and the emailed attachment.
XLSX export
Section titled “XLSX export”ExportExcel (format xlsx, ExcelJS) builds one worksheet named after the report/entity:
- Columns come from the entity’s fields filtered to the report’s field set (
getAllFields(true)), each 20 units wide, header = localized field name. - Block fields produce a merged sub-header row spanning their child columns. Repeatable blocks expand horizontally — each block instance repeats the child columns (
<field>.<index>), sized to the maximum instance count across the exported rows. - If a default organization header image exists, it is placed in a merged
A1:D1banner and the data starts on row 2. - Header cells are bold, centered, thin-bordered; sub-header cells bold with a bottom border.
- Returns
{ fileName: "<name>.xlsx", file: <ArrayBuffer>, mimeType: spreadsheetml.sheet }.
XLSX has no column cap.
PDF export
Section titled “PDF export”ExportPdf (format pdf) uses the @osos/fluentreports engine:
- Column cap. At most
MAX_COLUMNS_COUNT(default 7) columns are rendered;fieldsbeyond the 7th are dropped (rptFields.slice(0, 7)). This is a hard PDF-only limit. - Column header labels use the localized field name (columns are internally keyed
<normalizedName>#<localizedName>; block fields renderblock.field). - Layout follows
design.layout(ReportLayoutEnum:Portrait = 0,Landscape = 1) — landscape whenlayout === Landscape. - Header/footer sections are driven by
ReportDesignOptions:organizationHeader/organizationFooterpull the default organization’sorganization_header/organization_footerimages;pageHeaderprints the report name/description text (defaulttrue);pageFooterprintsPage {0} of {1}/صفحة {0} من {1}page numbers (defaulttrue, and printed even when there is nodesign);reportHeader/reportFootercarry aReportHeaderFooterValuewhosetypeisText(0) orImage(1). - RTL/Arabic support uses right-aligned images and the Tajawal font (registered from
FONTS_PUBLIC_DIR, defaultpublic/fonts). - Section text is truncated to
SECTION_MAX_CHAR_COUNT(default 171) acrossSECTION_MAX_LINE_COUNT(default 3) lines. - On any render error, the exporter logs and throws
DataExportException. - Returns
{ file: <Buffer>, fileName: "<name>.pdf", mimeType: "application/pdf" }.
The PDFExporterOptions handed to the exporter set pdfDesign = report.design and pdfHeaderText = "<report name> \n <description>", plus an empty pdfDesignConfigs — so the exporter falls back to its built-in defaults.
Scheduling and notifications
Section titled “Scheduling and notifications”A report may carry delivery configuration; these are stored on the report but executed by other subsystems (timer/notification services), not by the endpoints above.
schedule(ReportScheduleModelextendsTimerOptionsEventConfig):enabled: boolean, plusoneTime?: stringandrepeat?(aDataEntityTriggerRepeatwith a cron/human-readableexpressionand optionaltimezone/startDate/endDate). A published report with anenabledone-time schedule in the past is rejected at save time (see validation).emailNotification(SendReportEmailActionOptions):to/cc/bccrecipient lists, atemplate(UUID or inlineEmailTemplateValue), atokensMap, optionallink,attachment/attachments, and an optionalfromconfig.inAppNotification(SendReportNotificationActionOptions):channels,recipients, optionalmodule/notificationType, atemplate(UUID or inlineNotificationTemplateValue), and atokensMap.
Scheduled delivery and the attachment — correction Since 1.8
Section titled “Scheduled delivery and the attachment — correction Since 1.8”When a scheduled report’s timer job fires, data-service’s ScheduledReportJobTriggeredHandler loads the report and sends the configured email only when it is both isPublished and schedule.enabled. emailNotification.attachment.enabled and emailNotification.link.enabled are independent toggles — a common configuration is link-only, with the attachment turned off.
Before this fix, the handler unconditionally read the attachment upload’s result even when attachment.enabled was false, so the read threw and the email was silently skipped — the surrounding try/catch rethrew into the message-bus consumer with no user-facing surface, and the bus retried and then gave up. Exporting/uploading the attachment is now best-effort: it runs inside its own try/catch, and a storage outage, a render failure, or a disabled attachment all degrade to sending the email without an attachment instead of dropping the notification. The failure is still logged as a structured warning ({reportId, err}) so an attachment failure stays diagnosable per report.
Error reference
Section titled “Error reference”| Exception | Code | HTTP | Cause |
|---|---|---|---|
ReportDataSourceSupportedException | REPORT_DATA_SOURCE_NOT_SUPPORTED | 4xx (validation) | dataSource.type is not Query. |
ReportFieldsLengthException | REPORT_FIELDS_LENGTH | 4xx (validation) | Empty fields. |
ReportFieldsNotExistException | REPORT_FIELDS_NOT_EXIST | 4xx (validation) | One or more fields are not on the entity. |
ReportSendingTimeCanNotBeInThePastException | REPORT_SENDING_TIME | 4xx (validation) | Published report scheduled for a past one-time send. |
ReportExistException | REPORT_EXISTS | 4xx (validation) | Name collides with another report on the same entity/language. |
ReportPermissionsNotSelectedException | REPORT_PERMISSION_NOT_SELECTED | 422 | Publishing a restricted report with no permissions selected. |
DataQueryNotFound | — | 4xx | dataSource.query does not exist. |
DataQueryNotBelongToEntity | — | 4xx | Query’s entity ≠ relatedTo.dataEntry. |
EntryNotExistException | — | 4xx | relatedTo.dataEntry entity missing. |
EntityArchivedException | — | 4xx | Related entity is archived. |
InvalidExportFormatException | — | 4xx | Export format has no bound exporter. |
DataExportException | — | 5xx | XLSX/PDF render failure. |
Internals and invariants
Section titled “Internals and invariants”- Only Query sources. Report execution always resolves rows through a data query; store/collection sources are rejected.
ReportDataSourceSupportedExceptionis the single guard. - Fields are the column contract.
fields(order-significant) drive both execution projection and export columns. PDF silently truncates to 7 columns; XLSX has no such cap. - Permissions live in access-rights, not on the doc. Read joins them in; write reconciles them separately and deliberately before publishing so the dependency-sync re-fetch sees the new set.
- CQRS for create/delete. Create and delete go through service-bus commands (
CreateDataEntryCommand/DeleteDataEntryCommand) and await an invoker token; update writes the repository directly and emits aDataEntryUpdatedEvent. - Sensitive fields revealed on execute/export, then masked per access. v2 execute and export pass
revealSensitiveFields = true; each sensitive field is still masked (****) for anyone lacking access to it, and password-typed fields are always masked. - Legacy
virtualhandling. Filters usevirtual != true(notvirtual == false) so pre-existing rows without the field are still returned.
Platform 1.10.0 · Backend 1.11.0-alpha.11 · Frontend 1.11.0-alpha.6 · Mobile 1.10.2 · Chart 1.11.8 · Gateway 2.6.11 · MCP 0.2.0 · Grafana DS 1.2.0Docs build 2026-11-27