Extensions
Messages
The postMessage protocol between an extension's screen and the Console.
PreviewFor developers
This is a published preview. Names and fields may still change before general availability; changes will be listed in the changelog.
Your screen and the Console talk through window.postMessage. Your screen is sandboxed, so its origin is opaque ("null"): the Console trusts a message only because it comes from your frame's own window, and you trust a message only because it comes from window.parent.
Your screen to the Console
Send each to window.parent with the target origin "*" (an opaque origin can't name its parent's).
| Message | What happens |
|---|---|
{ "type": "agoo:ready" } | The Console sends your context. Send it once your listener is in place. |
{ "type": "agoo:resize", "height": 480 } | The frame becomes that tall: 120 to 1,200 pixels for a panel, up to 4,000 for a page. |
{ "type": "agoo:open", "kind": "task", "id": "task_…" } | The Console opens that record. kind is task, project, invoice or contact. |
{ "type": "agoo:renew" } | The Console draws your frame again with a new context token. |
Anything else is ignored.
The Console to your screen
| Message | Fields |
|---|---|
agoo:context | version (1), token (the context token), point, record (an ID, or null on a page), theme (light or dark), expiresIn (seconds) |
agoo:expired | The context token is about to run out. Send agoo:renew when your screen next needs one. |
Example
window.addEventListener("message", async (event) => {
if (event.source !== window.parent) return
const m = event.data
if (m?.type === "agoo:context") {
// Send the token to your own server, which checks it with your install secret.
const res = await fetch("/agoo/session", { method: "POST", body: JSON.stringify({ token: m.token }) })
render(await res.json(), m.theme)
window.parent.postMessage({ type: "agoo:resize", height: document.body.scrollHeight }, "*")
}
if (m?.type === "agoo:expired") window.parent.postMessage({ type: "agoo:renew" }, "*")
})
window.parent.postMessage({ type: "agoo:ready" }, "*")Never trust what a message says about who is looking: check the context token on your server.