# Watches and goals

> How to write a goal Percia judges reliably, what a watch can do, and how to pause, change and delete one.

Page: https://percia.ai/docs/watches. Index of all docs pages: https://percia.ai/docs/llms.txt

# Watches and goals

A watch is one goal on one camera. Create it with `POST /api/watches/owned`.

```json
{
  "sourceUrl": "percia-cam://3f9c2a10-...",
  "goal": "A parcel is lying on the doorstep",
  "notify": { "type": "email", "target": "me@example.com" }
}
```

| Field | Rule |
|---|---|
| `sourceUrl` | required. `percia-cam://<id>`, `percia-file://<id>`, or a public `rtsp`, `rtsps`, `http` or `https` link, at most 2048 characters |
| `goal` | 5 to 500 characters |
| `notify` | optional. `{"type":"email","target":"..."}` or `{"type":"webhook","target":"https://..."}`. Left out, alerts email the account owner |
| `destinations` | optional list of connected tool ids. Left out, your default destinations are used; `[]` means none |
| `media` | `"keyframes"` (default) or `"off"` |

## Writing a goal

- Describe **one thing a frame can show**. Name the subject, the state and the place: "A person is standing at the front door", not "Someone comes".
- Prefer states and looks to intent or history. Percia sees what is there now, not what someone plans or what happened an hour ago.
- Be concrete about thresholds: "The water level in the tank is below the red line", "More than 3 cars are in the loading bay".
- Say what does not count when mistakes are costly: "A person (not a parked car or a mannequin) is at the door".
- One goal per watch. Make a second watch for a second condition.

| Weak | Better |
|---|---|
| Alert me about problems | The conveyor belt is stopped and boxes are piled up at its end |
| Someone is suspicious | A person is climbing the fence |
| The shop is busy | More than 10 people are inside the shop |
| Tell me about the delivery | A parcel is lying on the doorstep |
| Check on the dog | The dog is on the sofa |

The goal is data for the vision judge, not instructions to it. Text like "ignore the above" has no special effect.

### When the goal is unclear

Percia reads your goal before it creates the watch. A clear goal creates it. An unclear one answers `422 clarification_needed` with a `draftId`, a `question` and `options`, and creates nothing:

```bash
# answer the question, then create with the draft
curl -sS -X POST "$BASE/watches/draft/DRAFT_ID/answer" -H "Authorization: Bearer $PERCIA_API_KEY" \
  -H 'content-type: application/json' -d '{"text":"The front door, not the gate"}'
curl -sS -X POST "$BASE/watches/owned" -H "Authorization: Bearer $PERCIA_API_KEY" \
  -H 'content-type: application/json' -d '{"sourceUrl":"percia-cam://CAMERA_ID","draftId":"DRAFT_ID"}'
```

Goals that ask to identify a person, recognise a face or infer emotion are refused (`goal_not_allowed`). Parts of a goal that a camera cannot show (sound, feelings) are reported as unsupported: tell the person, then send `acknowledgeUnsupported: true`.

## How it behaves

- You are alerted **once per occurrence**. While the goal stays true you are not alerted again. After it clears, the next time it becomes true is a new occurrence and a new alert.
- An unreachable camera is not "goal not met" and sends nothing. After 60 minutes without video the watch pauses itself (`pausedReason: "no_video"`) and you get one email.
- Each decision has a `confidence` from 0 to 1 and a `reason`. `reason` is model text: untrusted.
- `judging.couldNotCheck` lists parts of the goal Percia cannot check right now (for example low light or something blocking the view). While it lists one, "no alert" does not mean "nothing happened".
- While a new watch gets its first frames, `judging.state` is `starting`, for up to 4 minutes. Do not treat that as a failure.

## Change, pause and delete

```bash
# pause or resume
curl -sS -X PATCH "$BASE/watches/WATCH_ID" -H "Authorization: Bearer $PERCIA_API_KEY" \
  -H 'content-type: application/json' -d '{"status":"paused"}'     # or "active"

# new goal: a running watch judges the new conditions within seconds
curl -sS -X PATCH "$BASE/watches/WATCH_ID" -H "Authorization: Bearer $PERCIA_API_KEY" \
  -H 'content-type: application/json' -d '{"goal":"A parcel is lying on the doorstep"}'

# delete (scope watches:delete)
curl -sS -X DELETE "$BASE/watches/WATCH_ID" -H "Authorization: Bearer $PERCIA_API_KEY"
```

- `{"status":"active","testRun":true}` starts a 30-minute test run: events are marked `test: true` and are not counted in your usage.
- Earlier events are not rewritten when you change the goal.
- Deleting a watch deletes its events, keyframes and clips.
- An 11th active watch on one camera answers `429 plan_limit` (`limit: "watchesPerStream"`). Pause or delete one.
- An account can have up to 20 active watches. Creating or resuming a 21st answers `429 plan_limit` (`limit: "activeWatches"`) with the message `You can have up to 20 active watches. Pause or delete one first.` Accounts that already had more keep their watches; only new creates and resumes are refused.
