# API changelog

> Relevant changes to Agata's HTTP contract.

We treat the changelog as first-class documentation: visible, dated, and linked.

## URL history (browser vs HTTP)

| Era | Browser (team app) | HTTP |
| --- | --- | --- |
| Current | `/orgs/:orgHandle/:handle/...` | `/api/.../profiles/{studioId}/...` |
| 2026-09-10 | `/profiles/:handle/...` (UUID → handle redirect) | `/api/.../profiles/{studioId}/...` |
| Pre-rename | `/workspaces/:workspaceId/...` | `/api/.../workspaces/...` |

Older changelog bullets that say team-app `/profiles/:handle` or
`/workspaces/...` describe that day’s ship. Browser URLs later moved to
**`/orgs/`**. HTTP stayed on `profiles` after the workspace → profile rename.
Legacy browser `/studios` and `/workspaces` still 308 into the current org flow.

## 2026-09-19

### Integrated AI actions

- Added durable Studio-scoped operation claim, read, and finalize endpoints under `/ai-capabilities/profiles/{studioId}/operations`.
- Added direct-apply and conditional Undo endpoints for task tags, project, and priority; Finance transaction categorization; and Library item organization.
- Domain writes validate a short lease and source revision in the same transaction that records reversible effect receipts. Terminal operation receipts are retained for seven days; applied effects have a 24-hour Undo window.
- Provider input and output are not stored raw by the capability runtime. Operational telemetry uses hashed actor, Studio, and entity identifiers and content-free counts.

### Owner chat

- `POST /p/{handle}/messages/thread` opens the entitled owner-chat thread without sending a message. It replaces the mutating `GET /p/{handle}/messages` operation.

### Membership checkout

- Reservations revalidate selling eligibility transactionally and scope retry keys to buyer, Studio, and plan. Terminal reservations release their keys for later purchases.
- Membership checkout and cancellation updates bypass permanent HTTP response replay; their domain state handles retries and revalidation.
- Cancellation reads share the Stripe projection lock, preventing duplicate scheduled-cancellation notifications from concurrent updates.

### Removed geographic places

- Removed the Places HTTP domain, its OpenAPI schemas, and every place association from product and public-share contracts.
- Migrations `000091_drop_task_place` and `000092_drop_places` remove the obsolete foreign keys, route data, indexes, and `places` table.

## 2026-09-16

### Profiles and following

- `ProfilesProfile` responses include `handle`, `kind`, and optional `bio` (aligned with Go).
- `GET /users/me/following` lists entitled subscriptions as well as follows; each row includes `isSubscribed`.
- Share **write** schemas that were missing it now document `subscribers` in the visibility enum.
- JSON **responses** use `studioId`; legacy **inputs** may still send `profileId` on `POST /internal/membership/stripe/sync` (accepted when `studioId` is omitted).

### Organizations

- `PATCH /organizations/{organizationId}` accepts optional `name` and `handle` (slug, unique while not permanently deleted).
- Org invitations: list/send/cancel under the org; `POST /organizations/invitations/{invitationId}/accept` and `…/reject` for the invitee.
- `POST /organizations/{organizationId}/leave`, `…/transfer-ownership`, `…/soft-delete`, `…/restore`, and `DELETE …/permanent` complete lifecycle (delete requires zero studios and no pending invites).
- `GET /organizations/{organizationId}` returns org summary (`handle`, counts, `canManage`), members, org-owned studios, and teams with assignments (`studioId` on each assignment).

### Membership checkout

- `POST /profiles/{studioId}/membership/checkout` reserves a persisted intent (`idempotencyKey`, relative `returnPath` only) before Stripe Checkout; reuses an open session when one exists.
- `PATCH /profiles/{studioId}/membership/checkout/{intentId}` attaches the Stripe Checkout session id after Next creates the session.

### Schema (written, not applied locally)

- Migrations `000087`–`000090`: org handles/invitations/lifecycle, `profile_member_grants`, `membership_checkout_intents`, subscription monotonicity columns, and `profile_purge_jobs`. See [Schema changelog](/database/changelog).

## 2026-09-13

### Memberships and owner chat

- Public `GET /p/{handle}` adds `subscriberCount`, `isSubscribed`,
  `viewerCanMessage`, and active `membershipPlans`.
- `POST /p/{handle}/messages` — get-or-create subscriber thread (perk
  `owner_chat`).
- Owner: `/profiles/{studioId}/membership/plans` CRUD,
  `/subscribers`, `/connect`, `/connect/onboarding`.
- Fan: `GET /users/me/subscriptions`,
  `PATCH /users/me/subscriptions/{subscriptionId}` (`cancelAtPeriodEnd`).
- Messages: `/messages/threads`, send / read / block.
- Internal: `POST /internal/membership/stripe/sync` (`CRON_SECRET`).
  Does not write `profiles.profile_plan`.
- Share visibility gains `subscribers`. Miss stays 404.

### Public share rows (notes, routines, boards, habits)

- `GET /p/{handle}/notes` and `GET /p/{handle}/notes/{noteId}` — published `blog` / `research` / `report` notes the viewer may see.
- `GET /p/{handle}/routines` and `GET /p/{handle}/routines/{routineId}` — exercise templates (blocks, no sessions).
- `GET /p/{handle}/boards` and `GET /p/{handle}/boards/{boardId}` — vision boards; goal pins filtered to visible goals.
- `GET /p/{handle}/activities` and `GET /p/{handle}/activities/{activityId}` — habit templates only (no logs, streaks, or assignees).
- Member create/update accept `visibility` on notes, routines, vision boards, and activities (`members` \| `followers` \| `public`, default `members`).
- Nested public GETs honor row visibility even when the studio catalog is private.

## 2026-09-11

### Public share rows

- `GET /p/{handle}/plans` lists meal plans the viewer may see (same allowlist as recipes). Catalog on `/@handle` includes that list.
- Nested public GETs (`/recipes/{id}`, `/plans/{id}`, `/library/{id}`, `/collections/{id}`, `/goals/{id}`, `/meals/{dateKey}`) honor row visibility even when the profile catalog is private. `GET /p/{handle}` and list endpoints still 404 for a private profile unless the viewer is a member. Follow still requires a public profile.

## 2026-09-10

### Profiles — unique name

- Create and rename derive `handle` from `name` and reject a taken or reserved slug (`DUPLICATE_RESOURCE` / `VALIDATION_ERROR`). No `_2` suffix.
- Team app URLs use `/profiles/:handle` (superseded later by `/orgs/:orgHandle/:handle`; see URL history above). A UUID path redirects to the handle. HTTP stays `/api/profiles/:studioId`.

### Profiles — page visibility

- `ProfilesProfile.visibility`: `private` \| `public` (default `private` on create).
- `PATCH /profiles/{studioId}` accepts `visibility`.
- Public `GET /p/{handle}` and nested public reads return 404 when the profile is private and the viewer is not a member. Followers who are not members get 404. `POST /p/{handle}/follow` is the same miss.
- Migration `000080_profile_visibility`. Additive. Local migrate-up applied 2026-09-10 (79 → 80).

### Workspace → Profile rename

- Tenancy HTTP: `/api/workspaces` → `/api/profiles`. Domain routes: `/api/{domain}/workspaces/:workspaceId` → `/api/{domain}/profiles/:studioId`.
- JSON: `workspaceId` → `studioId`.
- Public HTTP: `/api/profiles/:handle` → `/api/p/:handle`. Browser `/@handle` unchanged; RSC `/p/[handle]`.
- Team app: `/workspaces/:workspaceId` → `/profiles/:handle` (UUID URLs redirect). Legacy 308: `/workspaces` → `/profiles`, `/workspaces/:id/*` → `/profiles/:id/*`. API stays `/api/profiles/:studioId`.
- Schema: migration `000079` (written, not applied). Tables `workspaces` → `profiles`, `workspace_members` → `profile_members`; column `workspace_id` → `profile_id`.
- Breaking for internal clients that still call `/workspaces` paths or send `workspaceId`.

### Profiles — share catalog

- Public reads: `GET /p/{handle}/library`, `GET .../library/{itemId}`, `GET .../collections`, `GET .../collections/{collectionId}`, `GET .../goals`, `GET .../goals/{goalId}`, `GET .../meals`, `GET .../meals/{dateKey}`.
- Schemas: `PublicLibraryItem`, `PublicLibraryCollection`, `PublicGoal`, `PublicMealDay`, `PublicMealLog`, `PublicPlace`.
- Member create/update accept `visibility` on library items/collections, goals, and meal logs (`members` \| `followers` \| `public`, default `members`).
- Migrations `000076`–`000078`. Additive. Local migrate-up applied 2026-09-10 (75 → 78). Public GETs are not membership-gated; miss is 404. Same-day rename moved these public prefixes from `/profiles/{handle}` to `/p/{handle}`.

## 2026-09-09

### Profiles

- Public reads: `GET /profiles/{handle}`, `GET .../recipes`, `GET .../recipes/{recipeId}`, `GET .../plans/{planId}`.
- Follow: `POST` / `DELETE /profiles/{handle}/follow` (signed-in; not membership).
- Schemas: `PublicProfile`, `PublicRecipe`, `PublicRecipeDetail`, `PublicMealPlan`.
- Migration `000073_profile_follows_nutrition_visibility`. Additive. Public GETs are not membership-gated; miss is 404.

### Places

- New domain: `GET/POST /places/workspaces/{workspaceId}/places`, `GET/PATCH/DELETE .../places/{placeId}`.
- Schemas: `GeoPlace`, `CreatePlaceInput`, `UpdatePlaceInput`. OpenAPI tag **Places**.
- Migration `000074_places` (table) and `000075_domain_places` (product `place_id`s). Additive. Membership-scoped; no app-section gate.
- Query `ids` lists specific places (skips cursor pagination).

## 2026-08-16

### Week plan — Later (`dateKey` optional)

- `WeekPlanItem.dateKey` and `WeekPlanCreateItemInput.dateKey` are nullable. `null` / omitted = a **Later** item (no day) for that week.
- `PATCH` / reorder: `dateKey: ""` moves the item to Later. A `YYYY-MM-DD` day places it.
- Later does not appear in Calendar, does not count toward progress, and cannot be marked done or added to the calendar until it has a day.
- Migration `000052_week_plan_later`. Additive (nullable).

## 2026-08-02

### Week plan (`week-plan`)

- New domain: `GET /week-plan/workspaces/{workspaceId}/by-week`, `POST .../items`, `PATCH`/`DELETE .../items/{itemId}`, `POST .../items/reorder`.
- Schemas: `WeekPlanByWeek`, `WeekPlanItem`, create/update/reorder inputs. OpenAPI tag **Week plan**.
- Migration `000044_week_plan` (`week_plans`, `week_plan_items`). Additive.
- Distinct from Nutrition's meal planner (`/nutrition/.../meal-plans`).

### Provenance of shopping items

- `NutritionShoppingItem` now exposes `unit`, `source`, `collectionId`, `recipeId`, `inventoryItemId`, and `checkedAt`. The columns already existed; the response omitted them.
- `NutritionCreateShoppingItemInput` accepts `source` (`manual` | `recipe` | `low_stock`), `recipeId`, and `inventoryItemId`, so the pantry can link what it sends to shopping.
- `PATCH .../shopping/items/{itemId}` stamps `checked_at` when moving to `done` and clears it when returning to `pending`.
- Additive; no existing field changes shape.

## 2026-08-01

### Removal of Eve proactivity / briefings

- Removed: `GET`/`PATCH /workspaces/{workspaceId}/agent/proactive-settings` and `POST .../agent/proactive-settings/mark-read`.
- Removed: schemas `EveFollowupRules`, `EveProactiveSettings`, `EveProactiveSettingsPatch`.
- In-app proactivity (briefings, weekly review, follow-ups) is no longer part of the product.

## 2026-07-30

### Platform contract (session and profiles)

- Non-breaking correction of response schemas for session, Connections, profiles, access, members, and invitations.
- The OpenAPI contract now describes the real envelopes of those responses; no HTTP handler changes.

## 2026-07-28

### Bulk create (partial success)

- New `POST .../bulk-create` for primary list entities (tasks, projects, tags, reminders, timers, notes, note groups, activities, goals, library items, transactions, meal logs/recipes/shopping/inventory/meal plans, health check-ins/sessions/metric entries).
- Contract: body `{ <plural>: CreateInput[] }`, response `201` `{ data: { ids, errors: [{ index, message }] } }`, cap **50**.
- Additive; no bulk delete.

## 2026-07-15

### Uncached rich-text documents

- Task **detail** no longer includes the document body as the editor source.
- Clients must use **`GET/PUT …/document`** (tasks and notes) always fresh.
- Monorepo helpers: `task-document.ts`, `note-document.ts`.

**Breaking for internal clients** that read `detail.document.content` from the detail cache.

### API docs (this tab)

- Quickstart, authentication, expanded errors, guides, and domain map.
- OpenAPI copied to `apps/docs/openapi/agata-v1.yaml` for the Docs7 playground.

## Format for future entries

```md
## YYYY-MM-DD

### Short title

- What changed
- Impact (breaking / additive)
- Affected endpoints
- Link to PR or migration
```

## Mental subscription

After every PR that touches `handler.go` or `openapi.yaml`, add a line here **in the same PR**.
