8  Anomalies

2 operations.

8.0.1 getAnomalyDatasetDistribution

GET /api/anomalies/dataset-distribution

Charts anomaly counts per dataset.

Why it exists. ‡ Break the same defect labels down by dataset, so the dashboard can show which campaigns carry which kinds of defect rather than only the totals.

Called by — lib/workspaces/queries/anomaly-distribution.ts

Reached from — /w/data-explorer/anomalies · /w/integrity/insights

Aggregates per-dataset anomaly-tag counts across an organization’s images, optionally filtered to specific dataset slugs. The caller must be a member of the supplied organizationId (403 otherwise, checked via a membership probe under the caller’s own RLS); the aggregation itself runs under the caller’s own client too (CONTRACT-API-001) — a member’s private, non-organization-visibility dataset does not contribute to an org-mate’s view of this distribution.

Authentication: CookieAuth, SupabaseAuth

Returns — distribution · totalImages · totalDatasets

Field names as the handler returns them; the source states no types for them.

Effect — reads images · organizations

Parameters

Name In Required Type Notes
organizationId query no string (uuid)
datasetSlug query no array of string

Responses

Status Meaning Body
200 Distribution sorted by tagged-image count.
400 Organization ID is required. Error
401 Unauthorized. Error
403 Forbidden — not a member of the target organization. Error
500 Failed to fetch tag distribution. Error

8.0.2 getAnomalyLabelDistribution

GET /api/anomalies/label-distribution

Charts how finding labels are distributed across an organization’s datasets.

Why it exists. † Count how often each defect label occurs across an organisation’s imagery, so the dashboard can show what kinds of defect the campaigns are finding.

Counts how often each tag occurs across an organization’s imagery — the datasets each tag appears on and a per-tag, per-dataset image count — sorted by count descending. Runs under the caller’s own RLS scope (CONTRACT-API-001): organizationId narrows, it does not authorize, so naming an organization the caller does not belong to yields an empty distribution rather than another tenant’s data.

Authentication: CookieAuth, SupabaseAuth

Returns — distribution · totalAnnotations

Field names as the handler returns them; the source states no types for them.

Effect — reads images

Parameters

Name In Required Type Notes
organizationId query no string (uuid)

Responses

Status Meaning Body
200 Tag distribution, sorted by count descending.
400 Organization ID is required. Error
401 Not authenticated. Error
500 Failed to fetch tag distribution, or an internal error. Error