# Cases

> The review queue for anything that needs a human decision, and how your app follows it.

## Introduction

A case is a task for your team when something needs a human decision. It records who looked, what they saw and what they decided. A case never decides by itself. Aqoonsi takes no action on its outcome, with one exception: when a verification waits for a person (a photo too poor to compare with, or an age that needs a second look), clearing its case verifies it and declining fails it. For everything else, you read the decision and act on it in your own systems.

## What opens a case

| Kind           | Opened when                                    | Priority                                    |
| -------------- | ---------------------------------------------- | ------------------------------------------- |
| `match`        | A screening or monitor finds potential matches | `high`                                      |
| `verification` | A verification fails                           | `medium`                                    |
| `document`     | A business document contradicts the registry   | `medium`                                    |
| `risk`         | A risk assessment asks for review              | `high` for a high level, otherwise `medium` |
| `manual`       | A member or your app opens one                 | As given, default `medium`                  |

A subject has at most one unresolved case of each kind. A new trigger is added to the open case's timeline, and raises its priority if it is more urgent, instead of opening another.

## Statuses

| Status      | Meaning                                                 |
| ----------- | ------------------------------------------------------- |
| `open`      | Waiting for someone to pick it up                       |
| `inReview`  | Assigned to a member                                    |
| `escalated` | Handed to compliance                                    |
| `resolved`  | Decided, with a `resolution` of `cleared` or `declined` |

Cases move between statuses only through recorded decisions, so every change appears in the timeline. Compliance can reopen a resolved case.

## Working cases from the API

Your app can read cases and add to them, with `cases:read` and `cases:write`:

- `GET /v1/cases` with `filter[status]`, `filter[kind]`, `filter[priority]` or `filter[subject]`;
- `POST /v1/cases` with a `subject` and an `Idempotency-Key` to open a manual case;
- `POST /v1/cases/{id}/notes` to add a note, and `POST /v1/cases/{id}/attachments` to link existing evidence;
- `GET /v1/cases/{id}/timeline` for every change, oldest first.

Deciding a case is a decision for people: members decide in the dashboard, and API keys cannot.

## Reacting to decisions

Subscribe to `case.opened` and `case.resolved`. When a case resolves, read it and act on `resolution`:

```bash
curl https://api.aqoon.si/v1/cases/$CASE_ID \
  -H "Authorization: Bearer $AQOONSI_KEY" \
  -H "Accept: application/vnd.api+json" | jq '.data.attributes | {status, resolution}'
```

Events carry identifiers only, never the text of notes or decisions.
