# Writing

The write endpoints change things in your team, as the person who made the token. They follow the same rules as the web app:
plan limits (sources, monitors, alerts, regions, check intervals), who may do what (deleting a source is for owners and admins), and
client-group restrictions. A write that the web app would refuse is refused here, with `403` (a limit or a role) or
`422` (`error.details` names the fields).

## Bodies and updates

Send JSON (`Content-Type: application/json`). A `POST` creates and answers `201` with the new resource. A `PUT` **replaces** the resource's
settings: send the whole thing, as you would submit the whole form. A `DELETE` answers `204`. Answers are `{ "data": ... }`.

Secrets never come back: a monitor's request header **values** and the secrets of notification channels are not in any answer. To keep a
saved header value when you replace a monitor, send the header with an empty value. A new source's ingest token is in the answer to the
`POST` that creates it, and in the answer to `rotate-token`, and nowhere else.

## Idempotency

Add an `Idempotency-Key` header (1 to 128 letters, digits and `_ . : -`) to a `POST` to make it safe to retry:

```bash
curl https://tailcove.dev/api/v1/monitors \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Idempotency-Key: create-checkout-monitor-2026-10-27" \
  -H "Content-Type: application/json" \
  -d '{"name":"Checkout","type":"http","url":"https://shop.example.com/health","method":"get","expected_status":200,"interval_seconds":300,"timeout_ms":10000,"channels":{"mail":{"members":true}}}'
```

- The same key with the **same request** within 24 hours returns the first answer (marked `Idempotent-Replayed: true`) and does nothing again.
- The same key with a **different** request is refused: `422`, `idempotency_key_reused`.
- The same key while the first request is still running: `409`, `request_in_progress`; retry in a second.
- Only a successful answer is remembered. If the first attempt failed (a validation error, a limit, a server error), fix it and retry with the same key.
- Keys belong to the token that used them. The remembered answer is stored encrypted, because it can hold a secret.

## Audit

Every successful write is recorded in an append-only audit trail (a page to browse it comes with the audit log): who (the token's owner and the token), what, which thing, from which address, when. Request bodies
and headers are not recorded.

## Limits

Writes are limited to 30 a minute per token. See [Errors & Rate Limits](https://tailcove.dev/docs/api/errors-and-rate-limits).
