Skip to Content
API ReferenceContact, Stats & ToursEndpoints

Contact, Stats & Tours

Three small routers: /contact (src/routes/contact.ts), /stats (src/routes/stats.ts) and /vtour (src/routes/vtour.ts). Terms are defined in the Glossary.

This page is the operation index. How a contact route reports to the CRM after it has answered is on Events & Messaging; the request sequence is workflow W7.

Operations

“Cached / header” names the server-side cache and the Cache-Control header the handler writes; “none” means neither. “passthrough” is middleware.jwt.passthrough: a guest with no token is allowed, a valid token makes the caller a user, an invalid token is a 401. “strict” is middleware.jwt.

Method & pathAuthCached / headerSide effectsErrorsDeep dive
POST /api/contact/contactuspassthroughnoneone Repliers Messages send, or one SMTP mail, awaited before the response; then a detached CRM event General Inquiry400 (validation); 401 (invalid token); relayed upstream status from the sendContact, Engagement reporting
POST /api/contact/requestinfopassthroughnoneas contactus, with the listing attached to the message; detached CRM event Inquiryas contactusas above
POST /api/contact/schedulepassthroughnoneas contactus; detached CRM event Property Inquiryas contactusas above
POST /api/contact/schedule/estimatepassthroughnoneRepliers Messages send (never SMTP), then a CRM note and a CRM event started from inside ContactService400 (validation); 401 (invalid token); 404 (estimate not found); relayed upstream statusContact, D06
POST /api/contact/subscribe/newsletterpassthroughnonedetached CRM event General Inquiry only; no message is sent400 (validation); 401 (invalid token)Contact
GET /api/stats/widgetspassthrough@cached("widgets") (CACHE_STATSWIDGET_TTL) → Cache-Control: private, max-agenone400 (validation); 401 (invalid token); relayed upstream statusStats
GET /api/stats/neighborhoodsranking (Not in OSS)passthrough@cached("nr") and @cached("stats") (CACHE_NEIGHBORHOODSRANKING_TTL) for a signed-in caller → Cache-Controlnone400 (validation); 401 (invalid token); relayed upstream statusStats
GET /api/stats/communitiesnone (no auth middleware)none server-side; the handler always sets Cache-Control: private, max-age = 86400none400 (validation); 204 (no community for districtId)Stats
POST /api/vtourstrict; Admin or Rootnoneinserts one vtour row400 (validation); 401; 403; 409 (slug exists)Virtual tours
GET /api/vtour/{slug}strict; any rolenonenone400 (slug format) and 404 (unknown slug), both before the JWT check; then 401Virtual tours
PUT /api/vtour/{slug}strict; Admin or Rootnoneupdates the row’s data400 (slug format, validation, or the row belongs to another user) and 404 (unknown slug), the slug ones before the JWT check; then 401; 403Virtual tours
DELETE /api/vtour/{slug}strict; Admin or Rootnonedeletes the row400 (slug format, or the row belongs to another user) and 404 (unknown slug), the slug ones before the JWT check; then 401; 403Virtual tours

Contact — /contact

src/routes/contact.ts: guest-allowed, every route answers the string "OK" and sets ctx.state['enable.xff']. contactus, requestinfo, schedule and subscribe/newsletter chain the primary handler to the events-collection handler, which reports to the CRM after the response is decided; the per-route event, tags and failure behaviour are in the engagement register. schedule/estimate has no second handler: ContactService.scheduleEstimate starts its CRM note and event itself (see D06).

EndpointWhat it does
POST /contact/contactusGeneral contact form; accepts optional tags (up to 5 labels of up to 50 characters) that land on the CRM person
POST /contact/requestinfoProperty inquiry; the message carries the listing (listings: [mlsNumber])
POST /contact/scheduleViewing request with method (InPerson or LiveVideo), date, time, mlsNumber; an optional message is appended to the email as note: and is the CRM event message
POST /contact/schedule/estimateEstimate-appointment request for an estimateId; the message carries the estimate URL and the client URL
POST /contact/subscribe/newsletterNewsletter signup (email, optional pageUrl); validates and answers OK, the CRM event is the only effect

Who the message is sent for. ContactService.defaultMessageFields uses the caller’s clientId (the JWT sub) and that client’s agent (RepliersClients.get); a guest uses REPLIERS_UNAUTHENTICATED_CLIENT_ID and REPLIERS_AGENT_ID. Delivery is RepliersMessages.send (POST /messages), or one SMTP mail to REPLIERS_AGENT_EMAIL when SMTP_ENABLED=true and that address is set (Email). schedule/estimate always uses the Messages API.

Per-instance validation. SETTINGS_VALIDATION_VERSION (preset: settings.validationVersion) selects an override module in src/validate/overrides/ that may replace the contactus and requestinfo schemas; anything it leaves out uses the shared schema. One override, for example, requires a name plus an email or a phone, treating a blank string as missing. An absent email or phone never reaches the CRM as an empty entry (contactEntries), and the notification email shows — in its place.

Gotchas

  • schedule/estimate skips the events middleware. Its CRM calls are made by ContactService.scheduleEstimate through EventsCollectionService, so they run for guests and signed-in callers alike and are not gated by the middleware’s boss.enabled check; with BOSS_ENABLED=false BossService.request returns an empty object instead (src/services/contact.ts, src/services/boss.ts).
  • subscribe/newsletter has no service call. The handler validates and sets ctx.body = "OK"; with BOSS_ENABLED=false the middleware is the empty one and nothing else happens (src/routes/contact.ts, src/providers/middleware/eventsCollection.ts).
  • phone is optional only on schedule/estimate. Every other contact schema requires it (src/validate/contact.ts, scheduleEstimateSchema).

Stats — /stats

src/routes/stats.ts. widgets and neighborhoodsranking are passthrough; communities has no auth middleware at all. Cached results go through sendCached, which sets Cache-Control: private, max-age=<seconds left> from the @cached wrapper.

EndpointWhat it does
GET /stats/widgetsMarket-stats widgets (average and median sold price, volume, count, days on market, new and active counts). Six parallel RepliersListings.search calls (listings=false plus statistics); community is expanded to its district ids
GET /stats/neighborhoodsrankingNot in OSS. Top-N neighborhood price movement over 30, 90 and 365 days, sorted by sorting (APP_STATSTOP_LIMIT is the default limit)
GET /stats/communitiesThe community → district-id table; with districtId, only the community that owns it, or 204

GET /api/stats/neighborhoodsranking, its service methods (fetchStats, neighborhoodsrankingAuthorised, neighborhoodsranking), its schema and the guest stub are in @oss-remove regions, and so is every entry of the communities table (src/services/stats/communities.ts): the export keeps the communities lookup with no entries, and the widgets route.

Status filters follow the instance’s vocabulary: standardStatus Closed / Active on a RESO instance (one with APP_ALLOWED_LISTINGS_STANDARD_STATUSES), status U / A otherwise; see Repliers API.

Virtual tours — /vtour

src/routes/vtour.ts: stored in the local database (persistence required), table vtour (VtourRepository). A tour is a slug plus a list of { type, title, url } links (url must be https).

  • router.param("slug") runs for GET, PUT and DELETE: it validates the slug against ^[a-z0-9-_]+$ (400), loads the row (404) and puts it in ctx.state.vtour, before the route’s own middleware.
  • POST takes owner_id from the JWT sub. PUT and DELETE validate that the row’s owner_id equals the caller’s sub, so an Admin or Root changes only their own tours.
  • DELETE is registered with router.del.

Verified against portal-backend 997ae3e, 2026-10-20.

Last updated on