Tokens
The install token for the API, the install secret for webhooks and screens, and the context token a screen receives.
This is a published preview. Names and fields may still change before general availability; changes will be listed in the changelog.
The install token
Your server gets an access token for one install with its client credentials. It lasts an hour; ask again when it runs out. There is no refresh token.
curl https://api.agoohq.com/extension/token \
-u "$AGOO_CLIENT_ID:$AGOO_CLIENT_SECRET" \
-d grant_type=client_credentials \
-d install_id=extinst_01m6k4d6f8h0k2m4p6r8t0v2xz{
"access_token": "…",
"token_type": "Bearer",
"expires_in": 3600,
"scope": "finance:read tasks:read extension:read",
"organisation_id": "org_01kjpsrza0etzb0a4vf72x8ang",
"install_id": "extinst_01m6k4d6f8h0k2m4p6r8t0v2xz"
}- The token carries exactly the scopes the organisation agreed to. Each request is narrowed further by what the person who installed it holds at that moment.
- If the organisation limited the install to some sites or legal entities, the API answers only for those.
- While the install is paused, suspended or removed, the answer is
invalid_grant, and every token already issued stops at once. - Send the parameters in the body, never the address. The endpoint has no CORS: call it from your server.
Learn your install with GET /v1/extension/install: its organisation, version, scopes, hosts, places and limits.
The install secret
Each install has one secret (whsec_…). Collect it once with POST /v1/extension/install/secret and keep it in your secret store. It verifies:
- every webhook Agoo sends to your
webhook.url(Standard Webhooks signatures, as for any webhook); - every context token your screens receive.
Lost it, or think someone else has it? POST /v1/extension/install/rotate-secret gives you a new one. Context tokens use the new one at once; webhooks are signed with both for a day, so deliveries in flight still verify.
The context token
Your screen receives a context token in agoo:context. It says who is looking, where, and at what. It lasts five minutes and is not a key to the API: your server uses its own install token for that.
agx1.<claims, base64url>.<signature, base64url>The signature is HMAC-SHA256 over agx1. followed by the claims part, with the key in your install secret (the bytes after whsec_, base64-decoded).
| Claim | Meaning |
|---|---|
iss | Always agoo |
aud | Your install's ID. Refuse a token for any other. |
ext | Your extension's ID |
org | The organisation's ID |
sub | The person looking (person_…) |
pt | The extension point |
rec | The record's ID on a panel |
scp | The scopes the install holds |
theme | light or dark |
iat, exp | Issued and expires, in seconds. exp is five minutes after iat. |
jti | A unique ID, so you can refuse one used twice |
import crypto from "node:crypto"
export function verifyContext(token, secret, installId) {
const i = token.lastIndexOf(".")
const signed = token.slice(0, i)
const key = Buffer.from(secret.replace(/^whsec_/, ""), "base64")
const want = crypto.createHmac("sha256", key).update(signed).digest()
const got = Buffer.from(token.slice(i + 1), "base64url")
if (got.length !== want.length || !crypto.timingSafeEqual(got, want)) throw new Error("bad signature")
const claims = JSON.parse(Buffer.from(signed.slice("agx1.".length), "base64url").toString())
if (claims.iss !== "agoo" || claims.aud !== installId) throw new Error("not for this install")
if (Date.now() / 1000 > claims.exp + 5) throw new Error("expired")
return claims
}