A single server route with four actions — answer, record, auto, latest. Reference tables (jurisdictions / permit_rules / permit_sources) are global and readable by any approved user; lead_permit_lookups is tenant data, always filtered by the caller's org. Writes are restricted to admin, sales, project_manager and crew_lead.
Also called: permit api security · tenant isolation · who can write a permit lookup
- 1Clerk auth plus an approved account status is required for any action
- 2org_id and looked_up_by are stamped from the session — 'client values are ignored, so a tenant can't write into another org's namespace'
- 3The 'latest' read filters by org_id and the supplied opportunity ids (capped at 500)
- 4Citation URLs for all returned jurisdictions are fetched in one query, replacing an N+1 the old client implementation did
The route's own header: 'The permit reference tables… and the tenant table (lead_permit_lookups) are NOT exposed through /api/db, and the browser has no Supabase client (the secret key is server-only).' It mirrors the /api/db auth model rather than inventing a second one.
- A browser-side database client leaks the key and the tenancy boundary
- Per-jurisdiction citation queries hammer the database
See it on your own jobs
Twenty minutes, your numbers, no slide deck. We’ll build one of your real buildings in front of you and send you the estimate link at the end — yours to keep either way.
or keep browsing features →