Skip to navigation

Admin portal flow

How the admin portal signs staff in and works with the API. All admin routes are under /v1/admin.

1. Sign in

  1. The portal gets a Google ID token from Google Sign-In (company accounts only).
  2. createAdminSession — POST /v1/admin/session with {"googleIdToken": "..."}. In dev only, {"testEmail": "test.admin@moxiepestcontrol.com"} works without Google.
  3. 201: keep token; me has the user’s permissions and offices. Send Authorization: Bearer <token> on every admin call.

getMe (GET /v1/admin/me) reloads the user, permissions and offices.

2. Show only what the user may use

Permissions are IDs with a level, for example sub_manage: edit, disc_create: yes. Edit includes view. Offices limit what a user sees and changes: records in other offices are not found (404) and saves to them are refused (403). Office pickers use listOffices and listOfficeGroups.

3. Edit a record

  1. Read it (for example getSubscriptionType), keep its version.
  2. Save the whole record with that version (for example updateSubscriptionType).
  3. 409 version_conflict: reload and redo. 422 validation_failed: show each fieldErrors[].field next to its input.

4. Settings with office overrides

GET a section with officeId to see the office’s effective value. Save the global value with PUT (needs every office), override one office with PUT .../offices/{officeId}, and return it to the global value with DELETE .../offices/{officeId}.

5. Background jobs

FieldRoutes list refreshes (syncFieldRoutes) and ZIP pulls (pullServiceArea) return 202 with a Job. Poll getJob (GET /v1/admin/jobs/{jobId}) until succeeded (counts in result) or failed (error). Asking again while one runs returns the same job.

6. Dashboard

getDashboardSummary, listAbandonedCarts and listSetupAlerts power the home page. Visits stay 0 until GA4 is connected.