Build with the API
Authentication
Sessions for people, API keys for programs, and how a token stays alive.
Every request to Gridline says who is asking, in one header: Authorization: Bearer <token>. There are two kinds of token, for two kinds of caller.
| A session | An API key | |
|---|---|---|
| For | A person using the dashboard, or your own app signing someone in | A script, a server or an AI agent |
| Looks like | A long token that expires in 15 minutes | gl_live_…, valid until revoked |
| Can reach | Everything the person's role allows | Only what its scopes allow, never more than its owner |
| Made by | Signing in | A person, in Developers → API keys |
Sign in
POST
/auth/loginPublic. 10 attempts a minute per address.curl https://gridline-data-analysis-app.duckdns.org/api/auth/login \
-H "Content-Type: application/json" \
-d '{ "email": "nino@acme.com", "password": "a long passphrase" }'{
"accessToken": "eyJhbGciOi…",
"refreshToken": "q3Zk…",
"tokenType": "Bearer",
"expiresIn": 900
}accessTokenis what you send in theAuthorizationheader. It lastsexpiresInseconds (15 minutes).refreshTokenis what you keep, to get a new access token without asking for the password again. It lasts 30 days.
When sign-in is refused
| Answer | Meaning |
|---|---|
401 | "Invalid email or password." It is the same answer for a wrong password and for an address that has no account, on purpose. |
403 | The password was right but the account cannot sign in: it is not activated yet, it was disabled, or its company is not active. |
429 | Too many attempts from this address. Wait a minute. |
Keep a session alive
POST
/auth/refreshPublic.When the access token expires, trade the refresh token for a new pair:
curl https://gridline-data-analysis-app.duckdns.org/api/auth/refresh \
-H "Content-Type: application/json" \
-d '{ "refreshToken": "q3Zk…" }'Sign out
POST
/auth/logoutSend the refreshToken.Ends that session immediately. The access token still expires on its own clock.
Other ways to sign in
- Google.
POST /auth/oauth/google/urlreturns the Google address to send the person to. When they return, you trade a one-time code atPOST /auth/oauth/exchange. See Your account. - An invitation.
POST /auth/accept-invitewith the emailedtokenand apasswordcreates the person's login and signs them in.
Your role is checked every time
A token says who you are, not what you may do. On every request Gridline reads your role, your status and your company's status from the database. If an admin demotes you, removes you, or the company is suspended, your very next request reflects it. There is no list of revoked tokens to wait on.
If something is wrong with the token
| Answer | Meaning |
|---|---|
401 | No token, a bad or expired token, a revoked API key, or the owner is gone. The message is deliberately the same for all of these. |
403 | The token is fine but not allowed here: the role is too low, the API key lacks a scope, or the company is suspended. |