What this describes
Every screen in the application is a client of this API. There is no separate integration surface: the work orders you see in the product are the rows/open_work_orders returns, and creating one from the
API runs the same function, under the same permissions, with the same audit trail as pressing the
button.
That has two consequences worth understanding before you read further.
Your permissions apply. A token carries the roles and site scope of the person it was issued to.
An endpoint you can reach still refuses the rows that person cannot see, and refuses the writes their
permissions do not allow. Nothing here is a way around the product’s own rules.
Reads and writes are shaped differently. Reads are views — filter, order and paginate them with
PostgREST’s query syntax. Writes
are functions under /rpc/, each doing one thing completely, because the transactional logic lives in
the database rather than in a client.
Getting a token
Every endpoint except sign-in needs one. Exchange an email and password for a session:token. Send it on every subsequent request:
Tokens are short-lived and idle out.
/rpc/refresh_session renews one that is still within its
session ceiling; past that, sign in again. A tenant on its own hostname uses that hostname here
instead of app.assetinfinity.ai.
