---
title: "Run Anomaly Detection"
method: POST
path: "/api/anomalies/detect/{user_id}"
tags: ["Anomalies"]
---

# Run Anomaly Detection

`POST /api/anomalies/detect/{user_id}`

## Request

- Base URL: `https://api.earmarkiq.app` (the document declares no server; this is the origin it was published from)
- URL: `https://api.earmarkiq.app/api/anomalies/detect/{user_id}`
- Auth: HTTP bearer

Run anomaly detection on the user's transactions.
Results are cached for 24 hours unless force=true.
Also persists detected anomalies to the anomalies table.

## Path parameters

- `user_id` string, uuid, required

## Query parameters

- `force` boolean: Force re-detection, skipping cache

## Response `200`

Successful Response

- DetectResponse
  - `anomalies` AnomalyResponse[], required
    - `id` string, nullable
    - `type` string, required
    - `severity` string, required
    - `title` string, required
    - `description` string, required
    - `ai_description` string, nullable
    - `data` object, required
    - `dismissed` boolean
    - `created_at` string, nullable
  - `total` integer, required
  - `cached` boolean, required

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/earmarkiq/apis/earmark-api.md) · [All operations](https://skmtc.dev/earmarkiq/apis/earmark-api/llms.txt) · [OpenAPI document](https://skmtc.dev/earmarkiq/apis/earmark-api/revisions/4a2c41907105?raw)
