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
- The portal gets a Google ID token from Google Sign-In (company accounts only).
createAdminSession—POST /v1/admin/sessionwith{"googleIdToken": "..."}. In dev only,{"testEmail": "test.admin@moxiepestcontrol.com"}works without Google.- 201: keep
token;mehas the user’s permissions and offices. SendAuthorization: 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
- Read it (for example
getSubscriptionType), keep itsversion. - Save the whole record with that
version(for exampleupdateSubscriptionType). - 409
version_conflict: reload and redo. 422validation_failed: show eachfieldErrors[].fieldnext 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.