Skip to main content

FlagCalculator

APIs for calculating and managing flags for monitoring workflows

📄️Run synchronous flag calculation for a monitoring workflow

Evaluates practitioner data against a monitoring workflow and creates, updates, or deactivates flags based on the difference from the current flag state, returning counts of flags created, updated, deactivated, and a total. Call this endpoint to trigger on-demand, synchronous flag calculation for a single monitoring workflow — do not use it for bulk or event-driven recalculation, which separate Kafka-driven consumers handle instead. If the workflow's status is REVIEWED_BY_CERTIFYOS, the endpoint accepts the request but performs no flag evaluation, does not update lastFlagCalculationTimestamp, and returns all-zero counts (verified: calculateFlagsWithTenantId returns early for workflows whose status is in MonitoringWorkflowConstants.COMPLETED_WORKFLOW_STATUSES). The monitoring workflow identified by monitoringWorkflowId must already exist and belong to the tenant identified by the required tenant-id header, or the call returns 404. Pass sections in the request body to limit calculation to a subset of the accepted section names; omitting it or passing an empty array calculates flags across all sections, and any unrecognized section name is silently ignored rather than rejected. The X-Monitoring-Api-Key header is only enforced while the monitoring.api-key-enabled kill-switch is turned on (off by default) — when enforced, a missing or mismatched key returns 401. On a real (non-no-op) evaluation, lastFlagCalculationTimestamp is written back to the monitoring workflow record. Repeated calls re-evaluate flags from current practitioner data each time — the call is safe to retry after a transient error, but successive successful calls may produce different flag counts if the underlying practitioner data changed between calls.