Skip to content

API endpoint to trigger reports as jobs#2298

Draft
Flix6x wants to merge 3 commits into
feat/2288-report-automationsfrom
feat/2288-report-trigger-api
Draft

API endpoint to trigger reports as jobs#2298
Flix6x wants to merge 3 commits into
feat/2288-report-automationsfrom
feat/2288-report-trigger-api

Conversation

@Flix6x

@Flix6x Flix6x commented Jul 11, 2026

Copy link
Copy Markdown
Member

Description

Closes #2288 (API part): adds POST /api/v3_0/assets/<id>/reports/trigger, which queues a one-off reporting job on the reporting queue, mirroring how forecasts and schedules are triggered via the API. Builds on the reports-as-jobs infrastructure from #2297.

Request body

{
    "reporter": "PandasReporter",
    "config": { ... reporter configuration (static, stored on the reporter's data source) ... },
    "parameters": { "input": [...], "output": [...], "start": "...", "end": "..." }
}
  • reporter (required): reporter class registered in FlexMeasures or a plugin (see flexmeasures show reporters).
  • config (optional): validated by the reporter's config schema.
  • parameters (required): validated against the base ReporterParametersSchema and then by the reporter's own parameters schema; must reference at least one output sensor.

Response

{"status": "PROCESSED", "report": "<job UUID>", "message": "Request has been processed."}

The job status can be polled via the existing generic GET /api/v3_0/jobs/<uuid> endpoint, and the queued job records its trigger as {"origin": "API"} in the job meta.

Permissions

The asset in the URL path scopes permissions: create-children access is required (any account member, or consultants), matching the schedule trigger endpoint. Output sensors are assumed to belong to the asset or its (grand)children (documented, not hard-enforced), and parameters without any output are rejected with a 422.

Look & Feel

New endpoint documented in the Swagger UI (with a PandasReporter example), in documentation/features/reporting.rst ("Automating reports") and in the API change log.

How to test

python -m pytest flexmeasures/api/v3_0/tests/test_report_trigger_api.py

Covers the permission matrix (anonymous 401 / other account 403 / account member 200), successful queueing (job on the reporting queue with meta["trigger"] == {"origin": "API"}), and a range of invalid messages (missing timing fields, missing output, unknown reporter, invalid config, missing required fields) each yielding a 422 without queueing a job.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX

Add POST /api/v3_0/assets/<id>/reports/trigger, which queues a one-off
reporting job on the reporting queue, mirroring how forecasts and
schedules are triggered via the API. The job status can be polled via
the generic GET /api/v3_0/jobs/<uuid> endpoint.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX
Flix6x and others added 2 commits July 11, 2026 22:25
The report trigger endpoint now applies the same sensor-access guard as
automation creation: the caller must be able to read every input sensor and
record data on every output sensor.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant