# Booking for agents: the agent guide

Calendly for AI agents, at <https://ai.picktimeapp.com>. You set up booking pages for the person you work for, the
**owner**, through an API. Their clients book on a public page, in their own time zone. You hear about every booking.

**This service sends no email, SMS or chat message, ever.** You send the confirmation, the reminders and the
follow-ups yourself, from the owner's own mailbox or messenger. **It never reads a calendar either:** you send the
owner's busy times in, and you put each booking into the owner's calendar.

- API: `https://ai.picktimeapp.com/v1`, JSON. Header: `Authorization: Bearer <key>`.
- OpenAPI 3.1: <https://ai.picktimeapp.com/openapi.json>
- MCP server (streamable HTTP, the same calls as tools): <https://ai.picktimeapp.com/mcp>
- Times are ISO 8601. A time with no offset is read in the owner's time zone.
- Send an `Idempotency-Key` header with every create call. A retry with the same key returns the first answer and
  makes nothing twice.
- Errors look like `{"error": {"code": "slot_taken", "message": "that time is not free", "hint": "…"}}`.
- Free.

## 1. Get a key (once)

`POST /v1/keys` with `{"name": "my-agent"}` answers `{"id": "key_…", "key": "ptk_…", "limits": {…}}`. No email, no
human. Keep the key secret: only its hash is stored, so a lost key can't be shown again. `GET /v1/me` shows the key's
limits and owners.

## 2. Set up the owner

`POST /v1/owners`:

```json
{"handle": "bree", "name": "Bree's Suits", "time_zone": "America/Phoenix",
 "intro": "Competition suits to rent and to order.",
 "hours": {"weekly": {"tue": [["10:00", "18:00"]], "wed": [["10:00", "18:00"]],
                      "thu": [["10:00", "13:00"], ["14:00", "18:00"]]},
           "exceptions": {"2026-12-24": []}}}
```

The owner's page is `https://ai.picktimeapp.com/bree`. Hours are wall-clock ranges in the owner's zone. An exception
replaces that date's hours, and an empty list closes the day. Change them with `PUT /v1/owners/bree/hours` (same
shape), and the rest with `PATCH /v1/owners/bree`.

## 3. Make a booking page

`POST /v1/owners/bree/pages`:

```json
{"slug": "fitting", "title": "Suit fitting", "minutes": 45,
 "description": "Try on suits for your show.", "location": "Studio, 123 Main St, Phoenix",
 "min_notice_minutes": 240, "days_ahead": 60, "buffer_after": 15,
 "contact": {"email": "required", "phone": "optional"},
 "fields": [
   {"id": "show_date", "label": "Show date", "type": "date", "required": true},
   {"id": "division", "label": "Division", "type": "choice", "required": true,
    "options": ["Bikini", "Figure", "Wellness"]}
 ]}
```

The answer carries `url`: `https://ai.picktimeapp.com/bree/fitting`.

- **Field types:** `text`, `long_text`, `number`, `date`, `choice`, `choices`, `yes_no`. Name is always asked.
  `contact` makes email and phone `required`, `optional` or `off`.
- **Group sessions:** `"seats": 12` gives 12 places per time. Clients book one or more places until the time is
  full. The page and the free times show the places left.
- **Bookings that wait for you:** `"confirm": "agent"` makes a new booking `requested`. It holds its time for
  `hold_minutes` (default 60) until you confirm or decline it. If you do neither, it expires and the time is free
  again.
- Also: `step_minutes` (gap between start times), `buffer_before`, `cancel_cutoff_minutes` (clients can't cancel or
  move later than this before the start, default 60), `listed` (false = by link only), `active` (false = switched
  off), and `hours` (the page's own hours instead of the owner's).

`PATCH /v1/owners/bree/pages/fitting` changes any of these except the slug. `GET /v1/owners/bree/pages` lists them.

## 4. Keep the owner's calendar counted

The service can't see the owner's calendar, so send it her busy times. You read them from her Google or Microsoft
calendar.

`PUT /v1/owners/bree/busy/google` replaces everything this source said for the range:

```json
{"from": "2026-12-01T00:00", "to": "2027-01-30T00:00",
 "busy": [["2026-12-03T09:00", "2026-12-03T11:00"]]}
```

Send it when her calendar changes, and every 15 minutes as a safety net. The source name is yours (`google`,
`outlook`, …), and each source is replaced on its own.

For a one-off block ("away Friday afternoon"), `POST /v1/owners/bree/blocks` with
`{"start": "2026-11-28T13:00", "end": "2026-11-28T19:00", "note": "away"}`. `DELETE /v1/owners/bree/blocks/<id>`
removes it.

## 5. Give clients a link

- The page link: `https://ai.picktimeapp.com/bree/fitting`.
- A link for one client: `POST /v1/links` with
  `{"owner": "bree", "page": "fitting", "name": "Irakli M.", "email": "irakli@example.com", "expires": "2026-12-15"}`.
  It answers `{"url": "https://ai.picktimeapp.com/l/…"}`. The link opens with the client's name and email filled in,
  and works once (`"single_use": false` for more). The booking it makes carries `"via": "link lk_…"`.
  `DELETE /v1/links/<id>` stops it.
- Free times to offer in a chat:
  `GET /v1/owners/bree/pages/fitting/slots?from=2026-12-01&to=2026-12-07&tz=America/Denver` answers days with times,
  in the zone you ask for.

You send every link yourself.

## 6. Hear about bookings

Two ways:

- **Poll:** `GET /v1/events?after=<last id>&wait=30` returns the new events, or waits up to 30 seconds for one. It
  works with no public address. Keep `next_after` for the next call.
- **Webhook:** `PUT /v1/webhook` with `{"url": "https://…"}`. It answers with a `secret`. Each delivery is a POST
  of the event. It is signed in `X-Booking-Signature: t=<unix time>,v1=<hex>`, where the hex is
  HMAC-SHA256 of `<t>.<raw body>` with the secret. A delivery is retried for about a day until it gets a 2xx.

The events are `booking.created`, `booking.confirmed`, `booking.declined`, `booking.expired`, `booking.cancelled`
and `booking.moved`. Each carries the whole booking:

```json
{"id": 42, "type": "booking.created", "created_at": "2026-11-24T18:02:11Z",
 "booking": {"id": "bk_7q2…", "status": "confirmed", "owner": "bree", "page": "fitting", "title": "Suit fitting",
   "start": "2026-12-03T15:00:00-07:00", "end": "2026-12-03T15:45:00-07:00",
   "start_utc": "2026-12-03T22:00:00Z", "end_utc": "2026-12-03T22:45:00Z", "time_zone": "America/Phoenix",
   "location": "Studio, 123 Main St, Phoenix", "seats": 1,
   "client": {"name": "Jenna K.", "email": "jenna@example.com", "phone": "", "time_zone": "America/Denver"},
   "client_start": "2026-12-03T15:00:00-07:00",
   "answers": {"show_date": "2027-02-14", "division": "Bikini"}, "via": "page",
   "manage_url": "https://ai.picktimeapp.com/m/…", "ics_url": "https://ai.picktimeapp.com/m/….ics"}}
```

A `requested` booking also has `hold_expires_at`. A moved one has `previous_start`. A cancelled, declined or
expired one has `changed_by` (`client`, `agent` or `system`) and `reason`.

Then do the owner's side yourself:
- put the booking in her calendar;
- send the client the confirmation, with the `ics_url` and the `manage_url` (the client's own cancel/change page);
- schedule the reminders;
- tell the owner.

## 7. Change bookings

- `GET /v1/bookings?owner=bree&from=2026-12-01&to=2026-12-31&status=confirmed,requested`. Other filters: `page`,
  `changed_since`, `limit`.
- `GET /v1/bookings/<id>` and `GET /v1/bookings/<id>/ics` (`?audience=owner` titles it with the client's name).
- `POST /v1/bookings` with `{"owner": "bree", "page": "fitting", "start": "2026-12-03T15:00", "client": {"name":
  "Nino"}}`: a booking for a client who phoned. Required answers are not enforced here.
- `POST /v1/bookings/<id>/cancel` with `{"reason": "…"}`.
- `POST /v1/bookings/<id>/move` with `{"start": "…"}`.
- `POST /v1/bookings/<id>/confirm` and `POST /v1/bookings/<id>/decline` with `{"reason": "…"}`, for requested
  bookings.

Add `"force": true` to book or move outside the hours, or over another booking, when the owner says so. The service
tells the client nothing: that is yours to do. `POST /v1/erase` with `{"email": "…"}` removes a client's details from
every booking of your key. Bookings are erased 12 months after they end.

## 8. Booking for a person, with no key

A client's own agent can book on the public page, without a key:

- `GET https://ai.picktimeapp.com/bree/fitting.md` (or the page itself with `Accept: text/markdown`) describes the
  page: the next free times with their `start_utc`, the fields, and the call.
- `GET /bree/fitting/slots.json?from=YYYY-MM-DD&to=YYYY-MM-DD&tz=<zone>` gives more free times.
- `POST /bree/fitting/book` with
  `{"start": "<start_utc>", "client": {"name": "…", "email": "…", "time_zone": "…"}, "answers": {…}, "seats": 1}`.
  The answer has the `status`, a `message`, the `manage_url` and the `ics_url`.
- On a personal link, use `/l/<token>.md`, `/l/<token>/slots.json` and `POST /l/<token>/book`.
- The client's own page: `/m/<token>.json` (or `.md`), `POST /m/<token>/cancel` with `{"reason": "…"}`, and
  `POST /m/<token>/move` with `{"start": "<start_utc>"}`. Free times for a move are at `/m/<token>/slots.json`.

These calls are limited per address.

## 9. MCP

Connect to `https://ai.picktimeapp.com/mcp` with the header `Authorization: Bearer <key>`. The `create_key` tool works
without a key. The tools:

- `create_key`, `list_owners`, `create_owner`, `update_owner`, `set_hours`;
- `create_page`, `update_page`, `list_pages`, `get_free_times`;
- `add_block`, `delete_block`, `set_busy`, `create_link`;
- `list_bookings`, `get_booking`, `book`, `cancel_booking`, `move_booking`, `confirm_booking`, `decline_booking`;
- `get_events`, `erase_client`.

## Rules

- The service sends nothing to anyone. Every message is yours to send.
- Send a personal link only to the client it was made for.
- Collecting bookings under false pretenses closes the key.
- Every request is logged for 90 days: the address, the user agent, the path, the status, and the id of the key
  used (never the key). Request bodies are not logged.
- Limits per key: 50 owners, 20 pages per owner, 1,000 bookings a day, 300 calls a minute.
