Zügle Admin API
Admin-only ad management and event-log inspection. Requires role "admin".
Admin-only ad management and event-log inspection. Requires role "admin".
Every API here is available over the APIs.io API and to AI agents over MCP.
One button, every client — Claude, Cursor, VS Code and the rest.
https://apis.io/mcp
find_apisBrowse and filter every API in the catalog.get_api_artifactsOne API's artifacts, grouped by type.get_openapiThe primary OpenAPI for this API.find_similar_apisAPIs that look like this one.apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.resolveTurn a domain, URL or GitHub org into the provider it belongs to.find_cohortsEvery scored population of providers in the catalog.curl "https://apis.io/api/v1/apis/zuegle-com:zuegle-com-admin-api"
curl "https://apis.io/api/v1/apis?limit=25"
Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.
Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.
A second provider on the same verified email joins the account you already have.
openapi: 3.2.0
info:
title: Zügle Admin API
version: 1.0.0
description: 'Zügle is a Swiss "does it pay off to move?" app. Paste a Flatfox/Homegate listing
link (or enter costs manually) to compare a candidate apartment against a current
home: monthly living costs, the Swiss income-tax delta between municipalities
(federal/cantonal/Gemeinde), commute time and cost, and a quality-of-living score.
The app has **guest mode**: several routes are reachable with no session cookie at
all. A guest supplies their own income/relationship/confession/children/current-home
figures on the request itself (query params or, for ingest, a `profile` body object)
and gets a computed result back — nothing about a guest request is ever persisted
server-side. The same routes behave differently for an authenticated household
member: caller-supplied profile values are ignored and the stored profile
(`p1`/`p2`) is used instead. Guest traffic is additionally throttled by a set of
in-memory, per-IP rate-limit buckets described on each public operation; an
authenticated caller using their own app is never subject to those buckets.'
contact:
name: Zügle
servers:
- url: http://localhost:8090
description: Local dev (npm run dev) or local prod (npm run prod) — both serve on :8090
- url: https://zuegle.com
description: 'Public production deployment. The VPS holds no open ports: a Cloudflare Tunnel (cloudflared) fronts localhost:8090, so TLS terminates at Cloudflare and the app runs with TRUST_PROXY_HOPS=1 / FORCE_HTTPS=1. Auto-deployed from the main branch.'
- url: https://zugle-vps.barbel-char.ts.net
description: The same VPS over the Tailscale tailnet — admin/debug access that does not depend on Cloudflare. Tailscale Funnel is OFF here; a tailnet member reaches this, the public internet does not.
security:
- cookieAuth: []
tags:
- name: Admin
description: Admin-only ad management and event-log inspection. Requires role "admin".
paths:
/api/admin/ads:
get:
operationId: adminGetAds
summary: List every ad (admin) with impression/click stats
description: Admin only. Returns every ad regardless of active/enabled state, plus in-memory (since-restart) stats.
tags:
- Admin
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
required:
- ads
- stats
properties:
ads:
type: array
items:
$ref: '#/components/schemas/AdAdmin'
stats:
type: object
description: Map of adId → { impressions, clicks }, in-memory since the last process restart.
additionalProperties:
type: object
properties:
impressions:
type: integer
clicks:
type: integer
'401':
$ref: '#/components/responses/SessionExpired'
'403':
$ref: '#/components/responses/AdminOnly'
put:
operationId: adminPutAds
summary: Replace the whole ad list (admin)
description: 'Admin only. Body is either a bare array of ads or `{ "ads": [...] }`. Validated/normalized server-side (`normalizeAds`): unknown fields dropped, `href` must be http(s), `image` must be a base64 `data:image/...` URI capped at ~200 KB. Accepts up to a 2 MiB request body (data: URI creatives are bulky).'
tags:
- Admin
requestBody:
required: true
content:
application/json:
schema:
oneOf:
- type: array
items:
$ref: '#/components/schemas/AdAdminInput'
- type: object
properties:
ads:
type: array
items:
$ref: '#/components/schemas/AdAdminInput'
responses:
'200':
description: The normalized ad list that was saved.
content:
application/json:
schema:
type: object
required:
- ads
properties:
ads:
type: array
items:
$ref: '#/components/schemas/AdAdmin'
'400':
description: Validation error (bad href, oversized/invalid image, etc).
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
$ref: '#/components/responses/SessionExpired'
'403':
$ref: '#/components/responses/AdminOnly'
/api/admin/listing-sponsors:
get:
operationId: adminGetListingSponsors
summary: List every sponsored-placement record (admin)
description: 'Admin only. Returns every sponsor record regardless of enabled/schedule state (server/listingSponsors.js allSponsors). A listing whose `source` matches an active sponsor is reordered to the front of results and always disclosed with `sponsored: true` + `sponsorLabel` — see the Sponsor schema.'
tags:
- Admin
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
required:
- sponsors
properties:
sponsors:
type: array
items:
$ref: '#/components/schemas/Sponsor'
'401':
$ref: '#/components/responses/SessionExpired'
'403':
$ref: '#/components/responses/AdminOnly'
put:
operationId: adminPutListingSponsors
summary: Replace the whole listing-sponsors list (admin)
description: 'Admin only. Body is either a bare array of sponsors or `{ "sponsors": [...] }`. Validated/normalized server-side (`normalizeSponsors`): unknown fields dropped, `source` is required, `weight` coerced to a positive number (default 1), `label` capped at 24 chars (default "Sponsored"). Ranking is deterministic by weight, never an auction, and a promoted listing always carries a visible sponsor label.'
tags:
- Admin
requestBody:
required: true
content:
application/json:
schema:
oneOf:
- type: array
items:
$ref: '#/components/schemas/SponsorInput'
- type: object
properties:
sponsors:
type: array
items:
$ref: '#/components/schemas/SponsorInput'
responses:
'200':
description: The normalized sponsor list that was saved.
content:
application/json:
schema:
type: object
required:
- sponsors
properties:
sponsors:
type: array
items:
$ref: '#/components/schemas/Sponsor'
'400':
description: Validation error (missing source, etc).
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
$ref: '#/components/responses/SessionExpired'
'403':
$ref: '#/components/responses/AdminOnly'
/api/admin/journeys:
get:
operationId: adminGetJourneys
summary: Funnel, drop-off points and silent-error suspects (admin)
description: 'Admin only. Reconstructs visits from the event log by journey id and reports where people stop.
A journey opens at its first event and closes either at a terminal step (`result_view`/`result_adjust`/`saved` — the visitor got what they came for) or after 30 minutes of silence, which marks it abandoned. A journey still within that window is `active` and is counted as neither.
`suspects` is the point of the route: steps where journeys end in numbers AND where nothing was logged as an error. That combination is what a SILENT failure looks like from the outside. Journeys that ended after a logged 4xx/429 are excluded — they are explained, and mixing them in buries the unexplained ones. Shares `server/journey.js` with `npm run journeys`, so the CLI and this route cannot disagree.'
tags:
- Admin
parameters:
- name: hours
in: query
required: false
description: Window to analyse (default 24, max 720).
schema:
type: integer
default: 24
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
required:
- hours
- total
- concluded
- abandoned
- active
- conversionPct
- funnel
- dropOffs
- suspects
properties:
hours:
type: integer
total:
type: integer
concluded:
type: integer
abandoned:
type: integer
active:
type: integer
conversionPct:
type: integer
description: concluded / (concluded + abandoned). Active visits are excluded — counting a visit still in progress as a failure would make this meaningless.
funnel:
type: array
items:
type: object
properties:
step:
type: string
reached:
type: integer
pctOfAll:
type: integer
droppedFromPrevious:
type: integer
dropOffs:
type: array
items:
type: object
properties:
step:
type: string
journeys:
type: integer
withError:
type: integer
silent:
type: integer
suspects:
type: array
description: Drop-off steps where most journeys logged no error at all.
items:
type: object
properties:
step:
type: string
journeys:
type: integer
silent:
type: integer
silentShare:
type: number
recent:
type: array
items:
type: object
'401':
$ref: '#/components/responses/SessionExpired'
'403':
$ref: '#/components/responses/Forbidden'
/api/admin/logs:
get:
operationId: adminGetLogs
summary: Read the event log (admin)
description: Admin only. Events are newest-first, capped at 2000 total in memory (older events are dropped). Query strings are always redacted before being logged, so a guest's income never appears here even though it travels on favorable-municipalities/municipality-detail requests.
tags:
- Admin
parameters:
- name: kind
in: query
required: false
description: Filter to one event kind.
schema:
type: string
enum:
- request
- auth
- ratelimit
- error
- ad
- journey
- listing
- mail
- name: limit
in: query
required: false
description: Max events to return (most recent first).
schema:
type: integer
default: 200
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
required:
- events
- counts
properties:
events:
type: array
items:
$ref: '#/components/schemas/LogEvent'
counts:
type: object
description: Total event count per kind.
additionalProperties:
type: integer
'401':
$ref: '#/components/responses/SessionExpired'
'403':
$ref: '#/components/responses/AdminOnly'
delete:
operationId: adminClearLogs
summary: Clear the event log (admin)
tags:
- Admin
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
required:
- ok
properties:
ok:
type: boolean
example: true
'401':
$ref: '#/components/responses/SessionExpired'
'403':
$ref: '#/components/responses/AdminOnly'
/api/admin/experiences:
get:
operationId: adminListExperiences
summary: The moderation queue (admin)
tags:
- Admin
parameters:
- name: status
in: query
required: false
schema:
type: string
enum:
- pending
- approved
- rejected
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
items:
type: array
items:
$ref: '#/components/schemas/OwnerExperience'
'401':
$ref: '#/components/responses/SessionExpired'
'403':
$ref: '#/components/responses/AdminOnly'
put:
operationId: adminReviewExperience
summary: Approve or reject a post (admin)
description: No reviewer id is ever stored — the only admin is the installation owner, and recording who reviewed a row would add an account id beside otherwise-anonymous public content for no reader to use.
tags:
- Admin
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- id
- status
properties:
id:
type: integer
status:
type: string
enum:
- approved
- rejected
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
item:
$ref: '#/components/schemas/OwnerExperience'
'400':
description: status must be approved or rejected.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
$ref: '#/components/responses/SessionExpired'
'403':
$ref: '#/components/responses/AdminOnly'
'404':
description: No such post.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/api/admin/org/credits:
post:
operationId: adminGrantOrgCredits
summary: Grant or record purchased credits (admin)
description: Credit packs are sold by invoice in v1; an admin records the purchase here. Supply an idempotencyKey so a retry cannot double-credit.
tags:
- Admin
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- orgId
- delta
- reason
properties:
orgId:
type: string
delta:
type: integer
description: Non-zero.
reason:
type: string
enum:
- grant
- purchase
refId:
type: string
nullable: true
idempotencyKey:
type: string
nullable: true
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
created:
type: boolean
description: false when an idempotency key replayed.
delta:
type: integer
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/SessionExpired'
'403':
$ref: '#/components/responses/AdminOnly'
'404':
$ref: '#/components/responses/NotFound'
components:
responses:
NotFound:
description: The id does not exist, OR it belongs to an organisation the caller is not a member of. The two are deliberately indistinguishable, so the API never confirms another organisation's ids — the same rule repo.js applies to cross-tenant misses.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error: No organisation org_abc123
BadRequest:
description: The request was malformed or missing a required field.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error: orgId is required
SessionExpired:
description: No valid session cookie. This is the ONE error shape in the whole API that bypasses the standard ApiError → handleRouteError path (it's written directly by auth.js's authGate middleware before the route dispatcher runs), which is why it alone carries a `code` field.
content:
application/json:
schema:
$ref: '#/components/schemas/SessionExpiredError'
example:
error: Unauthorized — please log in
code: SESSION_EXPIRED
Forbidden:
description: Authenticated and a member, but the seat role is insufficient. Distinct from 404 on purpose — a member is allowed to learn that the organisation exists.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error: Organisation owner only
AdminOnly:
description: Valid session, but its role is not "admin".
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error: Admin only
schemas:
Sponsor:
type: object
description: 'A sponsored-placement record (server/listingSponsors.js). A listing whose `source` matches an active, enabled sponsor is reordered to the front of results (highest weight wins, deterministic — never an auction) and stamped with `sponsored: true` + `sponsorLabel` on the way out; see toPublicListing.'
required:
- id
- enabled
- source
- weight
- label
properties:
id:
type: string
enabled:
type: boolean
source:
type: string
description: Matches a listing's `source` field, e.g. flatfox, homegate.
weight:
type: number
default: 1
description: Higher wins when a source has more than one active sponsor.
label:
type: string
default: Sponsored
example: Sponsored
startsAt:
type:
- string
- 'null'
format: date
endsAt:
type:
- string
- 'null'
format: date
description: Inclusive of the whole day when given as a bare date.
AdAdmin:
type: object
description: Full ad record as stored/returned to an admin.
allOf:
- $ref: '#/components/schemas/Ad'
- type: object
properties:
enabled:
type: boolean
kind:
type: string
enum:
- house
- network
description: Only "house" (first-party) actually renders.
href:
type: string
format: uri
weight:
type: number
default: 1
startsAt:
type:
- string
- 'null'
format: date
endsAt:
type:
- string
- 'null'
format: date
SessionExpiredError:
allOf:
- $ref: '#/components/schemas/Error'
- type: object
required:
- code
properties:
code:
type: string
enum:
- SESSION_EXPIRED
AdAdminInput:
type: object
description: Input shape for PUT /api/admin/ads — same fields as AdAdmin, all optional (server fills in defaults/ids).
properties:
id:
type: string
enabled:
type: boolean
kind:
type: string
enum:
- house
- network
headline:
type: string
maxLength: 120
body:
type: string
maxLength: 300
label:
type: string
maxLength: 24
href:
type: string
description: Must start with http:// or https:// if present.
image:
type: string
description: A base64 data:image/(png|jpeg|gif|webp) URI
capped around 200 KB. SVG is rejected — it can carry a script payload.: null
weight:
type: number
startsAt:
type:
- string
- 'null'
format: date
endsAt:
type:
- string
- 'null'
format: date
PublicExperience:
type: object
description: What GET /api/experiences and the HTML page show — an approved post, with no userId, email or status. server/experienceRules.js's toPublic(). displayName is null when the author left it blank; the reader-facing "Anonymous" fallback is rendered client-side, localized to the reader's language, never baked into this field. approvedAt is set ONLY when the row is actually approved (never for a rejected post, which also carries a reviewed_at internally).
required:
- id
- lang
- kind
- displayName
- title
- body
- municipality
- approvedAt
properties:
id:
type: integer
lang:
type: string
enum:
- de
- fr
- it
- rm
- en
kind:
type: string
enum:
- experience
- need
displayName:
type:
- string
- 'null'
title:
type: string
body:
type: string
municipality:
type: object
nullable: true
properties:
bfsId:
type: integer
name:
type: string
canton:
type: string
approvedAt:
type: string
format: date-time
nullable: true
LogEvent:
type: object
description: One entry from the in-memory/logs/logbook.json event ring buffer (capped at 2000).
required:
- at
- kind
properties:
at:
type: integer
description: Epoch milliseconds.
kind:
type: string
enum:
- request
- auth
- ratelimit
- error
- ad
additionalProperties: true
example:
at: 1785660608000
kind: request
method: GET
path: /api/municipalities
status: 200
ms: 4
Error:
type: object
description: 'The base shape of every error response in this API: `{ error: <message>, ...extra }`, produced by throwing `ApiError(status, message, extra)` in server/app.js (caught centrally by handleRouteError) or, for unmatched routes, written directly by the dispatcher.'
required:
- error
properties:
error:
type: string
additionalProperties: true
Ad:
type: object
description: Public-facing ad shape — GET /api/ads strips everything operator-only.
required:
- id
- headline
- body
- image
- label
properties:
id:
type: string
headline:
type: string
body:
type: string
image:
type:
- string
- 'null'
description: A data:image/... URI
or null.: null
label:
type: string
example: Ad
OwnerExperience:
type: object
description: PublicExperience plus the author's own view of status, creation time and the raw moderation timestamp — used by GET /api/me/experiences, POST/DELETE's response, GET /api/me/export, and (as AdminExperience, same shape — no reviewer id exists to add) GET/PUT /api/admin/experiences. reviewedAt is set whenever the post WAS reviewed, approved or rejected — approvedAt alone cannot distinguish "rejected" from "still pending".
allOf:
- $ref: '#/components/schemas/PublicExperience'
- type: object
required:
- status
- createdAt
- reviewedAt
properties:
status:
type: string
enum:
- pending
- approved
- rejected
createdAt:
type: string
format: date-time
reviewedAt:
type: string
format: date-time
nullable: true
SponsorInput:
type: object
description: Input shape for PUT /api/admin/listing-sponsors — same fields as Sponsor, all optional except source (server fills in defaults/ids).
properties:
id:
type: string
enabled:
type: boolean
source:
type: string
weight:
type: number
label:
type: string
maxLength: 24
startsAt:
type:
- string
- 'null'
format: date
endsAt:
type:
- string
- 'null'
format: date
securitySchemes:
cookieAuth:
type: apiKey
in: cookie
name: zugle_session
description: 64-hex-character session token set as an HttpOnly, SameSite=Strict cookie by POST /api/auth/login. Routes NOT in the guest-mode public set return 401 with code SESSION_EXPIRED when it is missing or invalid.