# Sessions

> POST /session tells the creek what an agent session is doing. Every field, and the errors.

## The request

`POST localhost:4404/session`, with `content-type: application/json`.

| Field | Type | What it is |
|---|---|---|
| `session` | string | The session's id: 8 to 64 letters, digits and dashes. Required. |
| `event` | string | `start`, `prompt`, `tool`, `turn` or `end`. Required. |
| `cwd` | string | The session's folder, from `/`. Its last part names the duckling. Required. |
| `pid` | number | The agent's process id. Send it if you can: Waddle drops the duckling when that process exits (without it and without `end`, a duckling stays up to 12 hours). |
| `agent` | string | Which agent: `claude`, `codex`, `opencode` or `pi`. Leave it out for your own agent: Waddle then counts it as Claude Code (it predates the field), so Claude Code shows as heard in Preferences. |
| `term` | object | Where it runs, so a click can jump there: `app` (the terminal's bundle id), `program` (`$TERM_PROGRAM`), `iterm` (`$ITERM_SESSION_ID`), `tty` (like `ttys004`). Each is optional and checked. |
| `web` | boolean | On a `tool` event: the step read the web. Only that it did, never what. |

## The events

| Event | When | The duckling |
|---|---|---|
| `start` | A session begins | Swims in |
| `prompt` | Someone asks it something | Works |
| `tool` | It takes a step | Works |
| `turn` | It's done, or waiting on you | Up on the bank |
| `end` | The session is over | Leaves |

## Replies

```sh
curl localhost:4404/session -H 'content-type: application/json' -d '{"event":"start","cwd":"/tmp"}'
```

```json
{ "ok": false, "error": "Send \"session\": the session id" }
```

A good request answers `{ "ok": true }`. A bad one answers 400 with what to send instead: a missing `event` lists the five, a missing or relative `cwd` asks for the session's folder.

A session event only moves the duckling. For Waddle to walk over, send news to [/quack](https://docs.waddle.sh/quack.md) with a phrase.
