Stable episode delivery and analytics on pod.place
resolver docs api.md
6.3 kB · 134 lines
Markdown
at main

Registry and resolver API #

Public reads expose registered podcast metadata, not listener events. All writes require Authorization: Bearer <platform-token> from a supported publishing platform. The operator configures platforms, not individual publishers or shows. One credential can register and manage episodes across publisher repositories.

Platforms are trusted to verify their users' publishing/migration permissions before calling this API. The resolver verifies canonical AT records, record identity, and requested CID visibility; it does not independently prove a platform's relationship to each publisher. Registry write access is broad, including withdrawal of existing entries. Keep platform tokens server-side and grant them only to trusted hosts. A replacement supported host can refresh the existing entry without publisher configuration changes on pod.place.

Record contract #

Canonical show and episode records remain in the publisher's PDS. The pilot requires both records in the same DID repository. showUri, episode guid, and AT record keys must remain unchanged during a hosting migration.

id = base64url(sha256(UTF8(JSON.stringify([showUri, guid])))), without padding. Use DID-based AT-URIs, not handles. Calculate the ID before writing the episode. Set audioUrl and media.url to ${PUBLIC_BASE_URL}/e/${id}. Keep media length and type consistent with audioSizeBytes, audioMimeType, and media.primary. The primary URL is a public HTTPS delivery URL, not a short-lived presigned URL. Hosts choose their storage/CDN URLs; there is no media-host allowlist or separate media-provider registration. URL/address/DNS safety checks reject malformed URLs, private-network destinations, and resolver loops, not particular hosting providers.

The vendored lexicons match the website's resolver schema update. Existing records without media remain protocol-valid but must be updated before resolver registration.

Register or update a show #

POST /v1/shows
Content-Type: application/json
Authorization: Bearer <token>

{"showUri":"at://did:plc:.../place.pod.show/...","expectedCid":"<PDS write CID>"}

Reads and validates the current AT record, then updates the indexed show entry. Show-level resolverAnalytics: true opts in. False/omitted disables collection for all registered episodes immediately after this operation succeeds.

Register an episode #

POST /v1/resolvers
Content-Type: application/json
Authorization: Bearer <token>

{"episodeUri":"at://did:plc:.../place.pod.episode/...","expectedCid":"<PDS write CID>"}

Reads the episode and parent show, validates media, and activates both registry entries in one transaction. Repeated registration is idempotent. The response contains the ID, resolverUrl, indexed record, status, mapping version, and verification time. Publish the RSS enclosure only after a successful response.

Refresh after changing hosts or replacing media #

POST /v1/resolvers/{id}/refresh
Content-Type: application/json
Authorization: Bearer <token>

{"expectedCid":"<new PDS write CID>"}

The trusted read must see the requested CID. Otherwise the response is 409 record_pending, and the previous verified mapping remains in place. Retry with backoff. HTTP 200 means the mapping transaction committed: subsequent local lookups use the new target. There is currently no distributed edge cache to propagate.

An observed invalid record/origin makes the existing mapping unavailable instead of continuing to serve a known-invalid update. A valid explicit refresh can restore it.

Use new object/CDN paths for replacement audio, verify delivery first, and retain the old audio during a grace period. Do not delete it before activation. This API never purges audio caches or accepts a caller-provided redirect destination.

Withdraw an episode #

DELETE /v1/resolvers/{id} requires a supported platform credential. The platform must authorize the publisher's withdrawal before calling it; there is no per-show scope or first-host ownership restriction. It creates a tombstone; /e/{id} then returns 410. Background reconciliation does not undo explicit withdrawal. A supported platform's explicit refresh can reactivate it.

Discover entries #

  • GET /v1/shows
  • GET /v1/shows/{showId}
  • GET /v1/shows/{showId}/episodes
  • GET /v1/resolvers/{id}

List endpoints accept limit (1–100, default 50) and after (the previous page's last ID). Responses have items and next. Show IDs are unpadded base64url SHA-256 of the show AT-URI. Discovery responses report stored status and verification time; only the resolver determines whether a mapping is currently usable.

Listener requests #

GET and HEAD /e/{id} return 302 with Cache-Control: no-store. Query parameters cannot override the registered destination. Unknown IDs return 404, withdrawn entries 410, and invalid/expired mappings 503. HEAD responses have no body. No PDS read, audio fetch, or synchronous analytics write occurs on this path.

Background reconciliation checks due entries in batches every 30 seconds, with a five-minute freshness target. Upstream outages do not extend verification time. Previously valid mappings can be used for at most six hours since verification, after which resolution fails closed. These settings are configurable.

Metrics #

Collection requires both a configured analytics secret and a show opt-in. Events contain minute-bucketed time, stable identity, mapping version, method, coarse user-agent class, range classification, and optional daily show-scoped IP pseudonym. Raw IP, user-agent, and referrer strings are not stored. The bounded in-memory queue flushes to SQLite out of band; crash/overflow can lose events. Default retention is seven days. Download estimation and reports are not implemented.

Errors #

  • 400: invalid input, identity, CID, or pagination.
  • 401: missing or invalid supported-platform credentials.
  • 409: requested record not yet visible, identity conflict, or concurrent update.
  • 413/415: oversized body or wrong content type.
  • 422: invalid AT record, inconsistent enclosure, or unsafe origin.
  • 429: write rate limit (60 writes/minute/platform, plus the app's basic per-source limit).
  • 502/503: invalid trusted response or upstream/operational unavailability.