Public subscription and feed endpoints

RouteMethodAccessPurpose
/api/subs/new?calendar_id=programsPOSTPublic; Turnstile when configuredCreate a 30-minute verification request and send a magic link
/api/subs/new?calendar_id=internalPOSTInternal boundaryForward the legacy Internal subscription request to n8n
/api/subs/verify?calendar_id=programs&v=...GETOne-time magic linkConsume the verification request and issue a private feed token
/api/turnstile-site-keyGETPublicReturn the configured public Turnstile site key
/cal/programs.ics?calendar_id=programs&token=...GET/HEADCalendar tokenValidate the token hash and serve programs.ics from R2
/cal/internal.icsGET/HEADInternal boundaryProxy the legacy Internal feed to n8n

Invalid, expired, disabled, or revoked feed tokens use non-revealing error behavior so calendar clients do not learn why a token failed.

Renewal

RouteMethodAccessPurpose
/renew?rt=...GETSigned renewal credentialRender a confirmation page without changing data
/extendGETExisting saved linksRedirect to the current renewal flow
/api/subs/extendPOSTSigned credential; legacy raw token accepted for old emailExtend the token row and reset warning state

The rt value is not a calendar token. It is an expiring HMAC-signed token-row id and cannot be used at /cal/programs.ics.

Webhook and scheduled endpoints

RouteMethodAccessPurpose
/api/webhooks/resendPOSTValid Svix signatureRecord delivered, bounced, or complained email outcomes
/api/cron/regenerate-programs-icsPOSTCRON_BEARER_TOKENQuery selected Notion events and rebuild R2 when bytes changed
/api/cron/renewal-warningsPOSTCRON_BEARER_TOKENSend the 14-day and 3-day renewal warnings

Admin authorization

All routes below pass through one directory-level middleware. It verifies the Cloudflare Access JWT, maps the request to an action, and asks RC Console whether the caller’s current Calendar role contains that action.

sequenceDiagram
  participant Browser
  participant Calendar
  participant Policy as RC Console policy service

  Browser->>Calendar: Admin request + Access session
  Calendar->>Calendar: Verify JWT and map route to action
  Calendar->>Policy: Check person + calendar + action
  Policy-->>Calendar: Explicit allow or deny
  Calendar-->>Browser: Continue or 403

Unmapped routes and policy-service errors fail closed.

Admin action map

RouteMethodAction
/api/admin/statsGETstats.read
/api/admin/eventsGETevents.read
/api/admin/activityGETactivity.read
/api/admin/funnelGETfunnel.read
/api/admin/cohortGETcohort.read
/api/admin/latencyGETlatency.read
/api/admin/healthGEThealth.read
/api/admin/replayGETreplay.read
/api/admin/subs/listGETsubscribers.list
/api/admin/subs/:idGETsubscriber.read
/api/admin/enablePOSTsubscriber.enable
/api/admin/revokePOSTsubscriber.revoke
/api/admin/token-extendPOSTtoken.extend
/api/admin/bulk-extendPOSTtoken.bulk_extend
/api/admin/token-resendPOSTtoken.resend
/api/admin/token-force-expirePOSTtoken.force_expire
/api/admin/test-emailPOSTemail.test
/api/admin/templates/:idGETtemplate.read
/api/admin/templates/:idPUTtemplate.edit
/api/admin/templates/:idDELETEtemplate.reset
/api/admin/templates/footerGETtemplate.read
/api/admin/templates/footerPUTtemplate.edit
/api/admin/templates/footerDELETEtemplate.reset
/api/admin/templates/previewPOSTtemplate.read

templates/preview accepts unsaved draft fields and renders them through the same generator used for delivered mail. It is a read action even though the request is POST. The shared footer endpoint manages reply text, support text, copyright, and the affiliation disclaimer.

Sources

  • ihnyc-rc-cal-landing/functions/_lib/route-actions.ts
  • ihnyc-rc-cal-landing/functions/api/admin/_middleware.ts
  • ihnyc-rc-cal-landing/functions/_lib/pdp-client.ts
  • ihnyc-rc-cal-landing/functions/_lib/renew-link.ts
  • route handlers under ihnyc-rc-cal-landing/functions/api/