ADR-0008: /api/v1/links is the short-link collection, and the correction is a defect fix
- Status: Accepted
- Date: 2026-08-13
- Deciders: Cardsite platform team (workstream
001-renaissance, phase 01 task 1)
Context
GET /api/v1/links selected with no type predicate
(apps/api/internal/repository/links.go, ListByWorkspaceID), so it returned
every row of the links router table: bio pages, vCards, events, files, static
pages, splash pages and payment links alongside short links. The /links page
rendered all of them in a table with no Type column and an edit action that sent
every row to the short-link detail page (audit 01-D1,
.archives/removal-safe/AUDITS-081226.md).
Two facts shape the decision:
- The published contract has always said short links. The OpenAPI summary
for the operation is "List short links"
(
shared/contracts/openapi.yaml), and every other registered type has its own endpoint. Six of them read the samelinkstable throughListByWorkspaceIDAndType—/api/v1/biolinks,/vcards,/events,/files,/static,/payment-links./api/v1/linkswas the only reader of that table that did not filter. The seventh,/api/v1/splash-pages, reads a different table entirely (splash_pages), which is the wrinkle noted under Consequences. - AGENTS.md §3 requires breaking API changes to ship under a new prefix
(
/api/v2/), never in place. Narrowing a response is, in the general case, exactly such a change.
So the question is not should the endpoint be filtered — the whole rest of the API says yes — but is filtering it in place permitted.
Decision
Filtering GET /api/v1/links to type='link' is a defect fix and ships in
place on /api/v1. It is not a breaking change requiring /api/v2, because
the behaviour being removed was never part of the contract: the operation's own
published summary describes the filtered behaviour, and the unfiltered result
was an omission in the implementation rather than an interface anyone was
offered. meta.total counts short links only, consistent with the rows
returned.
Three consequences of that framing are adopted with it:
- The registry is the write-path allowlist too.
POST /api/v1/linksrejects atypeoutside the registry with 400 (audit 01-D3). The registry —packages/link-model, mirrored toapps/api/internal/models/link.goand parity-gated in CI — was already the read-side authority; it now governs writes, so the list endpoint's predicate cannot be defeated by storing a type nothing recognises. - Plan-limit coverage is exhaustive by construction, not by inspection.
The type switch in
Createbecomes a table keyed by link type with an entry for every registered type, and a test fails when a registered type has no entry (audit 01-D4).payment_linkandsplash_page— the two types the audit named — carry explicit "no quota key registered" entries rather than falling through silently. Neither is given a check it cannot honour:splash_pages_limitexists but counts thesplash_pagestable, so applying it to alinksrow would reject on a quota that row can never move. The omission is now stated rather than implied, and a missing entry fails the suite where a nil one does not. - The narrowing is announced, not silent. The
/linkspage carries a one-time dismissible notice naming where the other types are listed, rendered from the registry. A user whose table shrinks is told why.
Consequences
The endpoint matches its published contract, and the "edit a vCard in the short-link editor" path is closed. The type-filtered predicate and the create-side allowlist are the same registry, so they cannot drift.
Costs, accepted:
- Any external integration that had come to rely on
/api/v1/linksas a whole-library feed loses it, with no deprecation window. The mitigation is the seven per-type endpoints, which are unchanged and already documented. - The dashboard's "Recents" tile reads this endpoint and therefore narrows to short links and bio pages. That surface has its own recorded defect (audit 01-D2, duplicate rows from disagreeing dedupe keys) and its own ROADMAP entry; it is deliberately not addressed here.
- There is still no
CHECKconstraint onlinks.type— the allowlist is enforced in the handler only. Direct SQL and any future writer can still store an unregistered type. A constraint is a migration and belongs with the schema work in a later phase. Any such row already in the table — an unregistered or empty type, which 01-D3 says was storable — drops out of every surface on deploy rather than appearing misfiled in the short-links table. That is the correct end state; it is not a migration of existing data, and none is attempted here. - A
linksrow of typesplash_pageis now listed nowhere. The filter excludes it, and/api/v1/splash-pagesreads thesplash_pagestable, so it never listed such a row either. The row is creatable because the registry markssplash_pageascreatableand the/linkscreate modal offers every creatable type through this endpoint — a mismatch that predates this change and that the audit already flagged ("its rows do not live inlinksat all"). The filter turns a misfiled row into an invisible one. Fixing the create path is a product decision about what a splash page is — decision 002's neighbour, and phase 01 task 2's territory — so it is recorded on the ROADMAP rather than resolved here.
Alternatives considered
- Ship the filter under
/api/v2/links, leaving/api/v1unfiltered — rejected. It would freeze the defect into a supported interface, require the frontend to move for a bug fix, and leave/api/v1/linkscontradicting its own OpenAPI summary indefinitely. - Add an optional
typequery parameter, defaulting to unfiltered — rejected. The default is the defect; making callers opt into correctness preserves the "Links" table that started the audit, and no sibling endpoint works that way. - Keep the endpoint unfiltered and add a Type column plus type-aware edit
routing to the page — rejected. It fixes the presentation of a collection
that should not exist at this route, leaves
meta.totalmeaning something different from every sibling, and still contradicts the OpenAPI summary. The collection view is a real product need; it is the catalogue surface in phase 01 task 4, not this endpoint. - Validate
typewith a databaseCHECKconstraint instead of in the handler — deferred, not rejected. It is a migration, it cannot produce the 400 with a useful message on its own, and this task was scoped to the handler.
Source: docs/decisions/0008-links-endpoint-is-short-links-only.md