# Northlight Yoga — Poppy 1.0 Agent Guide

**Canonical origin:** `https://yoga.ferrite.run` (domain: `yoga.ferrite.run`, studio timezone: `Europe/London`).
Machine-readable JSON twin: `https://yoga.ferrite.run/poppy/guide.json`.

## 1. Discovery & Endpoints

- Discovery document: `GET https://yoga.ferrite.run/.well-known/poppy.json`
- OpenAPI 3.1 contract: `GET https://yoga.ferrite.run/poppy/openapi.json`
- Tasks & Agent Skills: `GET https://yoga.ferrite.run/poppy/tasks`
- Studio Concierge (§8): `https://yoga.ferrite.run/poppy/conversations`
- MCP endpoint: `POST https://yoga.ferrite.run/mcp`
- Orientation summary: `GET https://yoga.ferrite.run/llms.txt`

**Guest booking is the default.** No studio account or OAuth sign-in is required to inspect classes, check live availability, book a single class, or cancel using the signed `manage_url`. Booking a single class is free (`drop_in_price: null`; `booking is free; packs and memberships optional`).

## 2. Classes, Pricing & Optional Questions

| Slug (`event_type_id`) | Class | Duration | Room | Seats | Confirmation | Drop-in Price | Optional Questions (`responses`) |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `vinyasa-flow` (`evt_vinyasa`) | Vinyasa Flow | 60 min | Studio 1 | 12 | Instant | Free (`drop_in_price: null`) | Anything the teacher should know about, such as an injury? |
| `yin-and-restore` (`evt_yin`) | Yin and Restore | 75 min | Studio 2 | 10 | Instant | Free (`drop_in_price: null`) | Anything the teacher should know about? |
| `beginners-yoga` (`evt_beginners`) | Beginners' Yoga | 60 min | Studio 1 | 8 | Instant | Free (`drop_in_price: null`) | Have you practised before? |
| `private-session` (`evt_private`) | Private Session | 60 min | Studio 2 | 1 | Studio confirms by hand | Free (`drop_in_price: null`) | What would you like to work on? |

Optional class packs & memberships (never required for single-class guest bookings):

| Plan ID | Name | Price | Group Classes |
| --- | --- | --- | --- |
| `plan_5pack` | 5-Class Pack | $95 (one_time) | 5 credits |
| `plan_monthly` | Unlimited Monthly | $139 (monthly) | Unlimited |
| `plan_founding` | Northlight Founding Unlimited | $179 (monthly) | Unlimited |

## 3. Happy-Path Conversational Guest Booking (`operations` v3)

Include `Poppy-Version: 1.0`, `Poppy-Session: <jwt>`, and `Poppy-Extensions: "operations";v="3", "links";v="1", "disclosures";v="1"` on every conversation request.

1. **Open conversation & inspect availability** — `POST https://yoga.ferrite.run/poppy/conversations?wait=0`
```json
{"id":"req_1","message":{"author":{"type":"agent"},"text":"What classes do you have on Saturday, and which one do you recommend for a beginner?"}}
```
2. **Submit guest booking details** (natural language, structured `message.data`, API-shaped JSON, or fields-only follow-up) — `POST https://yoga.ferrite.run/poppy/conversations/{id}/messages?wait=0`
```json
{"id":"req_2","message":{"author":{"type":"agent"},"text":"Please book Beginners' Yoga on Saturday at 09:30 for Maya Lin (maya@example.org).","data":{"slug":"beginners-yoga","attendee_name":"Maya Lin","attendee_email":"maya@example.org","responses":{"Have you practised before?":"No, first time"}}}}
```
The concierge verifies live seat availability and replies with `message.extensions.operations.operation` (`operation_id`, `revision`, `summary`, `terms`, `expires_at`). **Nothing is booked yet.** Plain-text "yes" does not execute; replying "decline" clears the proposal.
3. **Approve via `operations` v3** — `POST https://yoga.ferrite.run/poppy/conversations/{id}/messages?wait=0`
```json
{"id":"req_3","message":{"author":{"type":"agent"},"text":"Approved","extensions":{"operations":{"approval":{"operation_id":"<op_id>","revision":"<rev>","approver":"user"}}}}}
```
The studio books the seat atomically and returns `booking.id`, `booking.status`, `seats_remaining_after`, and signed `manage_url` (`https://yoga.ferrite.run/book/manage#id=...&token=...`) in both prose and `message.data` (plus `extensions.links`).
4. **Cancel** — either ask the concierge (`"Cancel my booking"` or paste `manage_url`, then approve the `operations` v3 cancellation offer) or call `POST https://yoga.ferrite.run/api/bookings/manage` directly with `{"id":"<booking_id>","token":"<manage_token>","action":"cancel","scope":"occurrence","request_id":"<stable-key>"}`.

## 4. Conversation Lifetime & Lifecycle Recovery

- **Inactivity timeout:** 24 hours (`86400` seconds). Idle conversations auto-close cleanly while keeping events readable.
- **Event retention:** 7 days (`604800` seconds) after close.
- **List your active/recent conversations:** `GET https://yoga.ferrite.run/poppy/conversations` (optional `?status=open|closed|all`).
- **Close a conversation:** `POST https://yoga.ferrite.run/poppy/conversations/{id}/close` with `{"id":"<req_id>"}`.
- **Resume a closed/timed-out conversation:** `POST https://yoga.ferrite.run/poppy/conversations/{id}/resume` (optional `id` and `message`).
- **Clean open options on `POST https://yoga.ferrite.run/poppy/conversations`:** pass `"close_existing": true` to close prior open threads first, or `"resume_existing": true` to continue your active thread.

## 5. Idempotency & Hold-Expiry Semantics

- **`create_booking`:** Pass `idempotency_key` (24–120 chars from `[A-Za-z0-9_-]`, no `=`) plus `recovery_secret` from `POST /api/bookings/attempts` (`begin_booking`). Identical retries never double-book, and presenting the original `recovery_secret` recovers `manage_url` if a receipt was lost.
- **5-minute seat holds (`reserve_slot`):** Holds reserve 1 seat for 5 minutes. Release early via `release_hold` if the customer changes their mind. If a hold expires, `create_booking` returns `409`; re-read `list_slots` before retrying without the expired `hold_id`.
- **`operations` v3 at-most-once:** Replaying an approved `operation_id` returns the exact original receipt. If a revision expires before approval (15-minute TTL), submitting the expired approval automatically returns a refreshed offer with the **same `operation_id`** and a **new `revision`**.
- **Signed management links (`manage_booking`):** Always send a stable `request_id`. Rescheduling rotates the capability and returns a new `manage_token`; cancelling spends it permanently.

## 6. Error-Code Recovery Table

| Error / Status | Meaning | Recommended Recovery |
| --- | --- | --- |
| `invalid_session` (400) | Missing/expired `Poppy-Session`, wrong `aud`/`htu`/`htm`, replayed `jti`, or unknown key | Mint a fresh `Poppy-Session` targeting `https://yoga.ferrite.run` + exact path with a new `jti`. |
| `already_open` (409) | Active conversation limit reached | Continue using returned `conversation_id`, call `POST /{id}/close`, or retry with `close_existing: true` / `resume_existing: true`. |
| `conversation_closed` (409) | Closed or idle >24h | Call `POST /poppy/conversations/{id}/resume` or open a new thread at `POST /poppy/conversations`. |
| `direct_conversation_open` (409) | Direct Conversation locks parent | Message or close the returned child `conversation_id` first. |
| `request_id_conflict` (409) | Same request `id` reused with different body/path | Use a new `id` for new requests, or send the exact original body to replay. |
| `approval_required` (403) | `operations` v3 confirmation required or revision expired | Show exact terms to the user and resubmit with the returned `operation_id` and `revision`. |
| `approval_declined` (403) | Policy requires `approver="user"` | Ask the user directly and resubmit with `approver: "user"`. |
| `extension_required` (400) | Missing `Poppy-Extensions: "operations";v="3"` | Include `"operations";v="3"` in `Poppy-Extensions`. |
| `operation_in_progress` (503) | Concurrent execution of same `operation_id` | Wait `Retry-After` seconds and replay the same approval. |
| `409` slot/hold conflict | Session full, held, or hold expired | Re-read `list_slots`, offer open times, or call `join_waitlist`. |
| `403` on `/api/bookings/manage` | Invalid, expired, or spent `manage_token` | Use the latest `manage_url` / `manage_token` from the most recent receipt. |
| `401 auth_required` / `403 insufficient_scope` | Member-only endpoint called signed out or missing scope | Use signed-out guest booking (`create_booking` or `/poppy/conversations`) for single classes; use OAuth 2.1 only for member accounts/packs. |

## 7. Signed-Out vs Signed-In Capability Matrix

| Capability | Signed-Out Guest (Default) | Signed-In Member (OAuth 2.1) | Approval |
| --- | --- | --- | --- |
| Browse classes, teachers, live slots, pricing, questions | Yes | Yes | None |
| 5-minute hold (`reserve_slot` / `release_hold`) & `begin_booking` | Yes | Yes | None |
| Book single guest class (`create_booking` or Concierge) | **Yes (default)** | Yes | `operations` v3 (`agent` or `user`) |
| Book weekly series (`create_booking_series`) | Yes | Yes | `operations` v3 (`agent` or `user`) |
| View, reschedule, or cancel via signed `manage_url` (`manage_booking` or Concierge) | **Yes** | Yes | Signed token (`operations` v3 to cancel) |
| Join waitlist / send enquiry | Yes | Yes | None |
| View member profile & bookings (`get_my_account`, `list_my_bookings`) | No | Yes (`bookings:read`) | None |
| Redeem membership/pack credit (`book_with_membership`) | No | Yes (`bookings:write`) | `operations` v3 (`agent` or `user`) |
| Cancel member booking (`cancel_my_booking`) | No | Yes (`bookings:write`) | `operations` v3 (`approver="user"`) |
| Subscribe/pause/cancel membership (`subscribe_membership`, `manage_membership`) | No | Yes (`memberships:write`) | `operations` v3 (`approver="user"`) |
| 3-step Browser Join (`/poppy/browser-session`) | Signed-out join | Signed-in join (`poppy:browser-sign-in`) | OAuth consent |
| Studio staff calendar, payroll, schedules | Excluded (`internal_only`) | Excluded (`internal_only`) | Staff SSO only |
