Side panel, home and settings pages
MarkdownBesides its actions, an application can serve screens of its own: a side panel inside a site’s page, a home page and a settings page.
A page’s server knows the person only by
x-apigami-user-ref, which Apigami’s session sets on every route of your app’s own address: a visitor and the side panel get none, and anyone can load a page, so it renders nothing personal without it. In the page, apigami.js calls an action for the person, andapigami.call()fetches their data through it. An action learns who it serves only from its run token:GET /v1/meanswersuser_ref, the person, the same in every browser of theirs. Key every per-person row onuser_ref. Never pick the person from the input, from the most recent row, frominstall_reforbrowser_pseudonym, which name a browser, or from a person a URL names. An OAuth callback reads the person inx-apigami-user-ref, and checks itsstateagainst a__Host-cookie its/oauth/startset.
Full page at your app’s own address, every request a person’s browser sends carries who they are, in
x-apigami-user-ref, once they have a session there:
a page, a route of your own API, a file. In the page,
apigami.js calls your actions under
that session, which no script reads, and in the side panel under a page token the panel sends it by message. A page opened by someone without a
session, from a bookmark or a shared address, is a visitor’s until apigami.connect() or
apigami.ready() gives them one. One more script after apigami.js adds
a support bubble, through which the person writes to your team.
A form a visitor submits without signing in can ask them to pass a bot challenge first:
Bot protection.
An application can show screens of its own: a side panel inside a site’s page, a settings screen, and a home.
Your code serves them like any other route, and x-apigami.pages declares them:
"domains": [{ "domain": "example.com", "via": "extension" }],"pages": [ { "kind": "side_panel", "id": "reply", "title": "Reply", "page_url": "/panel/reply", "show_only_on_domains": ["example.com"], "match": { "type": "regex", "value": "^https://www\\.example\\.com/messages/" } }, { "kind": "settings", "id": "accounts", "title": "Mailboxes", "page_url": "/settings/accounts" }, { "kind": "home", "id": "home", "title": "Inbox", "page_url": "/" }]kind |
Where it shows | When | Its own fields |
|---|---|---|---|
side_panel |
The side panel Apigami inserts into the site’s page, opened from the app bar at the site’s right edge (before Apigami 0.17.0, Chrome’s side panel) | When the tab’s URL matches | show_only_on_domains, required; match, optional |
home |
Full page, right after the user connects through your connect link, and each time they open it again. Never in the side panel | Once connected | alias, optional |
settings |
Full page from your connect link when you declare no home, else from the « Settings » button of your home; then a last tab of your side panel, on a site one of your panels matches |
Once connected; then when the user opens that tab | alias, optional |
page |
Full page, only where a link or a redirect leads: neither your connect link, nor « Settings », nor the side panel opens it | When the user follows that link | alias or redirect, optional (alias and redirect) |
An application has at most one settings page and one home page. A page’s id is unique across the application
and keeps the page’s identity from one version to the next.
page_url is a path of your application. Your application lives at the root of its own host. A
path such as /panel/reply resolves to https://{slug}.apigami.tech/panel/reply for the version
in production, and to https://{slug}--staging.apigami.tech/panel/reply for the version your latest
deployment put there; once that version is sent to review or refused, --staging goes back to the newest
version still deployed. Once a domain of yours is active, production’s pages open on it instead, as
https://app.example.com/panel/reply (Your own address), and --staging stays on
Apigami’s. It resolves to nothing until your first deploy
has reserved the slug, and a path may not leave your host. Apigami opens only the pages a version serves: an
absolute https:// URL is refused, page_url_on_app_address on an address of an application, yours naming the
path to write instead, and page_url_not_served anywhere else. Serve that page from your version’s code. app_deploy,
app_version and app_status give the URL of each page.
Both addresses are known before your first deploy: every version’s answer carries address,
{ production, staging }, built from the slug of its manifest, so you can register OAuth redirect URIs
and JavaScript origins ahead. A new slug moves both once published, and the old ones answer 404
(The slug).
Your application’s address serves your pages and your actions. A method and a path your manifest declares
is an action, served only to a credential Apigami checked, unless it is in open_actions; every other request
reaches your code as a page, from anyone (Calling an application at its address).
apigami.call() calls an action at the page’s own address, with the person’s session. Its pages are served there
whatever the application’s visibility, private included: without x-apigami-user-ref they must render nothing personal. The
--staging address is public but unlisted, like a preview link: anyone who has it reads the pages and the files of
public/ of your unpublished version, so they must reveal nothing either. Only a member of your group gets a session
there, its pages calling that version’s actions; a visitor’s call to an open action at that address runs that version
too, and app_run with version tries any action of it. A token is accepted only from its page’s origin.
In the side panel, a page id that production also declares shows production’s page. A page that only an
unpublished version declares shows in the side panel of your group’s browsers.
What your code receives, and what it answers, are its own. Your address is served by your code, with only Apigami’s session in front of it (Who is behind a request):
request.urlcarries your public address,https://acme-basket.apigami.tech/…or its--staginghost, for a request sent there, an action’s included: build your own URLs fromnew URL(request.url).originthere. A run Apigami starts itself, a cron, a task orapp_run, reaches your version on an internal address instead: never build a public URL, such as an OAuthredirect_uri, fromrequest.urlin one.- Apigami vouches for no header naming the client’s address,
X-Forwarded-For,ForwardedorX-Real-IP: never decide what a request may do from one. - Every cookie reaches your code, except Apigami’s own (
__Host-apigami_access,__Host-apigami_refresh, their__Host-apigami_framed_…twins in a frame on another site,__Host-apigami_start_…), which it takes out. Apigami removesDomainfrom everySet-Cookieyou send, so yours stay on your host, and drops any whose name starts with__Host-apigami_orapigami_. Do not trust a cookie you did not set: another application’s page can still set one for all ofapigami.techfrom its script. - Apigami adds to your answers only what its session needs: a
Set-Cookiewhen it renews or ends it, andCache-Control: privatewhen the session named someone and you set none (private, no-storewith thatSet-Cookie). Set these on your pages:X-Content-Type-Options: nosniff,Referrer-Policy: no-referrerandCross-Origin-Opener-Policy: same-origin-allow-popups(a popup you open can still answer you). - Every answer at your
--stagingaddress carriesX-Robots-Tag: noindex, Apigami’s own included, so search engines never index it. Production is indexable: sendX-Robots-Tag: noindexyourself on a page search engines should not index. - The side panel shows your page in a frame inside the site’s own page, so the site is one of its ancestors: The header a side panel page sends.
A side panel shows only on sites your application reaches through the browser. Every domain in
show_only_on_domains must be declared in x-apigami.domains with "via": "extension". match
narrows it further, to an exact URL ({ "type": "url" }) or a regular expression
({ "type": "regex" }) that stays on those domains. Without match, the panel shows on every page
of the domains. A settings or home page is about the whole application, so it takes neither field.
A side panel shows only once its domain is approved for your application by the user, with Chrome’s permission for it in that browser. Until then your application has no icon in the app bar, and Apigami opens the approval window for that domain on its own.
The app bar shows your logo. Each application whose side panel matches the tab has one icon there,
which opens its panel (The site the side panel is open on):
its logo, set with app_settings and logo, when it is a PNG, JPEG, WebP or GIF; an SVG logo shows its
initial there.
The screens where a person signs in and connects carry your logo and one colour. app_settings with
brand_color, a #rrggbb dark enough for white text (a contrast of 4.5:1 at least, a paler one is refused
with the ratio measured), colours their buttons and checkboxes, and the tile shown when you have no logo;
brand_color: null gives the neutral buttons back. Nothing else on those screens takes it.
Pages built by Vite: page_url and apigami.js
Section titled “Pages built by Vite: page_url and apigami.js”On a version built by Vite, each page_url of x-apigami.pages is a
route of your pages: /, /settings and /panel all answer dist/index.html, and your own router shows the screen.
Load apigami.js in the index.html at the root of the project, the one Vite turns into dist/index.html, as a
classic script at its absolute address, before your module:
<script src="https://api.eu.apigami.com/apigami.js"></script><script type="module" src="/src/main.tsx"></script>Vite leaves it as it is, and says it cannot bundle a script without type="module": that is expected. The
apigami.js warnings below read this file. Keep the path of every page out of every action’s path.
The header a side panel page sends
Section titled “The header a side panel page sends”Your page sits under the site, Apigami’s own frame (chrome-extension:) and https://app.apigami.com, and
the browser judges every one of them. At your app’s address Apigami sets the frame-ancestors itself, in place
of yours: https: chrome-extension: for a side_panel page, the origins of x-apigami.embeddable_on for any
other (Who may frame your pages).
What can still leave the panel blank is yours:
X-Frame-Options: SAMEORIGINorDENY, a default of some frameworks: the browser obeys it besideframe-ancestors. Do not send it from a page the side panel shows.
A deployment and a publication answer panel_framing_warning for a side_panel page, or the settings
page of an application that has one, whose header refuses one of those documents: it names the sources
refused and gives the header to send.
The home page
Section titled “The home page”The home page is your application itself, the page your connect link opens: a game’s podium, a
dashboard, an inbox. Right after a user connects through /connect?app_id=…, and each time they open
that link again, Apigami opens it full page in their tab, through /__apigami/start on your address, so it
loads with their session: apigami.js, apigami.ready() with page_kind: "home", apigami.call() and
the browser the user just connected all work. It never shows in the side panel.
The home is also where a person sets your application up: its own options, and the settings of the
applications it calls (Show the settings of the sub-apps you call),
and the button that accepts an optional one.
A settings page is optional. When the application the person connected to declares one, apigami.js adds a
« Settings » button at the bottom left of the home, with no code of yours, which opens that application’s
settings full page (/connect?app_id=…&view=settings): on the home of a sub-app reached from yours, it opens
yours. Keep what matters in your actions, not in
the page.
Make pages feel instant. Render the page at once with a loading state, then fill it from
apigami.call(). Cache what a page shows for about a minute, in your app’s database, keyed
by user_ref, so that coming back to it costs no new computation. Call slow third-party services after
the first paint, never before it.
A public page is cached an hour in production. On your production address, and on your own domain, a page
a visitor loads (GET, 200, text/html) that sets neither Cache-Control nor a cookie is kept an hour by
Apigami, which adds Cache-Control: public, max-age=3600 and Vary: Cookie. A person signed in
carries their session cookie, so is never served that copy, and the --staging address is never cached. The
copy belongs to one version: a publication or a rollback reaches a new visitor within about a minute, but a
visitor’s browser that already loaded the page may keep showing the previous version for up to that hour,
since the same header reaches it, until they reload. A page whose content
changes without a new version, a list of offers read from your database, or that carries a value per visitor,
such as a CSRF token, sets its own: Cache-Control: no-store, or max-age=60. app_deploy names the pages
production will keep.
The settings page
Section titled “The settings page”Your settings page opens full page from the « Settings » button of your home, and right after a user
connects through your connect link when you declare no home: it is then where the connection lands, and
nothing sends the user back. The same page is the last tab of your side panel.
Give people one link: your connect link. https://app.apigami.com/connect?app_id={your app_id}
connects them, then opens your home page, else your settings page, at once each time they open it again:
give them that link to bookmark. A bookmark of any page of yours works too: it opens for anyone, and goes
through Apigami’s connect page when the page asks for a person
(A visitor on your page). The link opens the
page only if a version serving that user declares one when they arrive: your latest deployed version is
enough for your group; published, for anyone else. Opened before, it ends on « Connected », and they see
the page only on their next visit to the link. An application that connects people of its own, through its
redirect_uri, gets its user back on its own site instead (Connect a user).
Opened full page, the settings page goes through apigami.js too, as every page does: never read a
token yourself. apigami.ready() gives the user’s user_ref and page_kind, apigami.call() calls your
actions, and the token stays fresh for as long as the person’s session
(A page token’s lifetime). Your actions drive the
browser the user just connected, as they do from the side panel: request.fetch and the browser
operations work there, on the sites the user allowed. apigami.state.url is null there: the page is on
no site. apigami.state.install_ref names that browser once apigami.ready() resolves, or is
null when the user connected without one.
<script src="https://api.eu.apigami.com/apigami.js"></script><script type="module"> const { user_ref } = await apigami.ready() const { state } = await apigami.call('settingsStatus', {}) render(state)</script>A sign-in to another service is an ordinary redirect. At your app’s own address, leaving the page for
the service and coming back loses nothing: the session comes back with the person, and your
/oauth/callback reads them in x-apigami-user-ref
(Sign in to a third-party service).
Keep what a page learns on your server, through an action, keyed on user_ref, not in a cookie
or in the storage of the page. Your host is its own origin, but storage stays in one browser, and
production and --staging are two hosts, which a new slug changes. If you do set a cookie, every other
Apigami application counts as the same site: never rely on SameSite, prefer the __Host- prefix, and
keep every GET free of side effects. In the side panel, framed under the site, your cookies are
third-party: they need SameSite=None; Secure, and a Partitioned one is kept per site. On a site that
isolates itself (Cross-Origin-Embedder-Policy), the panel has no cookie and no lasting storage at all.
A page opens at its bare address, with no Apigami parameter.
The home or settings page of a version not yet published opens full page at the --staging address
for a member of your group, when production declares no page of that kind. Try it by opening your
application’s connect link. Its files load, and a reload keeps the page, as in production.
What the validation refuses
| Code | What to fix |
|---|---|
duplicate_settings_page |
Keep one settings page. |
duplicate_home_page |
Keep one home page. |
duplicate_page_id |
Give each page its own id. |
page_url_on_app_address |
An absolute page_url on an application’s address: on yours, write the path the message names; on another’s, make the page an alias of that application, declared as a sub-app. |
page_url_not_served |
An absolute page_url on no address of an application: Apigami opens only the pages a version serves. Serve the page from your version’s code, and write its path. |
page_domain_not_declared |
Declare the domain of a side panel in x-apigami.domains. |
page_domain_not_extension |
Declare it with "via": "extension": a direct domain has no browser to show a panel in. |
page_match_outside_domains |
Keep match on the domains the panel names. |
page_script_on_app_host |
A page with a relative page_url loads /apigami.js or /__apigami/panel.js from your app’s own address, and no file loads it from the API: nothing serves either path there, so the page never gets window.apigami. Load https://api.eu.apigami.com/apigami.js. |
A show_only_on_domains missing on a side panel, or present on another kind, is refused by the
schema itself, and so is a connect page: declare a settings page, which the connection opens.
What the validation warns about
A warning comes with the validation, "level": "warning", and blocks neither deploying nor
publishing: the version stays valid. It is a guess made from your files, and it says why it
guessed.
| Code | What it saw |
|---|---|
page_without_panel_script |
A page with a relative page_url, and no file outside the manifest and the .md files that mentions /apigami.js. A side panel that writes APIGAMI_PANEL_READY by hand gets a gentler word; a settings page is reminded that it also opens full page. A home page of a public site is not checked: no settings page, and no file calling apigami.call, apigami.ready, apigami.session, apigami.connect or apigami.open. |
page_script_relative |
A page with a relative page_url, and every file that mentions apigami.js does it by a relative path other than the root one, /static/apigami.js or a path joined to a variable: that request never reaches Apigami’s script, so the page gets no token. Load https://api.eu.apigami.com/apigami.js. |
per_person_data_without_user_ref |
Pages, a database read through env.DB or DATABASE_URL, and no file that mentions user_ref: every person would read the same rows. |
database_not_declared |
A file reads env.DB, DATABASE_URL or DIRECT_URL, and the manifest declares no database: an application that never had a database gets none. |
files_not_declared |
A file reads env.FILES, and the manifest declares no "files": true: an application that never had file storage gets none. |
database_kind_mismatch |
The code reads only the other kind of database than the one the manifest declares. |
A deployment also reads the HTML each page answered and says, in its answer only, which page loads
no apigami.js, or loads it by a relative path: a page your code writes at run time is invisible to the
validation. A home page whose HTML runs no script, with no settings page, is not asked for it. The
deployment then asks, once each, up to 20 pages of your app’s own address that those pages link to, and
lists what they answered: a broken link is only reported, a page serving an Apigami key or token blocks
publication like a declared one. It also asks up to 40 of the stylesheets, scripts, images and media those
pages load from your address, and names the ones that fail: reported, never blocking. A page whose HTML loads it from /apigami.js on your app’s own address blocks publication
(page_failed).
A deployment and a publication also answer panel_framing_warning
(The header a side panel page sends).
Another application’s page at your address: alias and redirect
Section titled “Another application’s page at your address: alias and redirect”A page of yours can be the page of a sub-app you call, opened from your own address in the same tab, with no
click: an alias. It can also lead to another page of yours: a redirect. Apigami answers both itself at
their page_url, so your code never receives that path.
"subapps": [{ "app_id": "THE_ACCOUNT_APP_ID" }, { "app_id": "THE_CONNECTORS_APP_ID" }],"pages": [ { "kind": "home", "id": "home", "title": "Sync", "page_url": "/" }, { "kind": "settings", "id": "account", "title": "Account", "page_url": "/account", "alias": { "app_id": "THE_ACCOUNT_APP_ID", "page": "settings" } }, { "kind": "page", "id": "connectors", "title": "Connectors", "page_url": "/connectors", "alias": { "app_id": "THE_CONNECTORS_APP_ID", "page": "home" } }, { "kind": "page", "id": "services", "title": "Connectors", "page_url": "/services", "redirect": { "page": "connectors", "type": "permanent" } }]-
An alias keeps its
kind, its role in your application: asettingsalias is what « Settings » opens, ahomealias what your connect link opens, apageone is reached by your own links, such aslocation.replace('/connectors'). A side panel takes no alias. -
alias.app_idis a sub-app the version declares inx-apigami.subapps, mandatory: an optional one is refused for now, so open its page withapigami.open().alias.pageis theidof ahome,settingsorpagein that sub-app’s production, served at its own address. -
An alias of an alias is followed: when the sub-app’s page is itself an alias of a page of its own mandatory sub-app, the person lands straight on that last page, as if you aliased it, up to 8 aliases in a row. Each application on the way must be one your team may call, and each alias past yours must open a mandatory sub-app. Writing the version says where the chain ends, with the warning
alias_opens_chain. The chain is read again at each opening: when an application down the chain changes its alias, your page follows it. -
The person lands on the sub-app’s address, not yours: Apigami answers
303to the sub-app’s/__apigami/start, which gets them a session there under your application, then the sub-app’s page with the query they sent. Serving the sub-app’s page under your address would hand it your session. AHEAD, a prefetch or afetch()get404. Someone not connected to your application lands on Apigami’s screen asking them to open yours first. From your--stagingaddress, a member of your team gets the sub-app judged on your--stagingversion. -
An alias opens in a frame: put
<iframe src="/connectors">in a page of your own, or<iframe src="https://your-app.apigami.tech/connectors">on a site your version lists inx-apigami.embeddable_on, and the frame lands on the sub-app’s page, still under your application. Who may hold that frame depends on the sub-app:- the sub-app lists
"apigami"in its ownembeddable_on(Inside the applications that declare yours): a page at your own address, with nothing in your list, and any site your version lists. The sub-app must be mandatory in your version, neveris_optional; - it does not: only a site both your version and the sub-app list, so the same site goes in both.
The page holding the frame is told by its
Referer(the browser’s default policy sends it; a page withreferrerpolicy="no-referrer"gets404, as does a page anywhere else). The frame’s sign-in window then opens the person’s session under your application, and only when every site around the frame is allowed the same way. A frame that already held a session of the sub-app under another application loses it, and signs in again once. A redirect opens in a frame only when your version lists sites, on those sites. Alias a page that lives in the frame, such as a home: a step that ends withapigami.done()belongs in a tab or anapigami.open()window, asdone()rejects in a frame, whileapigami.open()from the frame opens its window under your application. Keep a plain link to the alias beside the frame, for the browsers where a frame has no session (Browsers). - the sub-app lists
-
A redirect is a
kind: "page"whoseredirect.pageis theidof another page of the same version, served at a path of your address, not a side panel, and not a redirect itself.redirect.typeistemporary, a307and the default, orpermanent, a308, for a page renamed for good: the browser keeps a308, so the old path never serves another page again, and no new alias may aim at apermanentredirect. The query received is passed on. -
The
page_urlof an alias or a redirect is a path of your application, with no query: Apigami finds the page by its path alone. A path an action, a file ofpublic/or another page already takes is refused. -
A sub-app’s page that goes away is said three ways. Its author, publishing, is warned
aliased_page_removed, and declaring aredirecton the oldidkeeps your alias working: Apigami follows atemporaryone, with the warningalias_target_is_redirect. Yourapp_statussaysalias_target_unknownuntil the page comes back or a publication removes the alias; when it is an alias further down the chain that breaks, it names the application whose team fixes it, and when. The person gets Apigami’s « no longer available » page, with a link to your home carrying?apigami_result=failed.
A sub-app’s page that ends a step calls apigami.done({ result }),
which leads back to your home with ?apigami_result=connected, cancelled or failed: read it there, and
read the state itself again from the sub-app’s settingsStatus. A home that leaves on its own for an alias
uses location.replace, and never leaves again with an apigami_result in its address, nor on a
back_forward navigation: an account already approved at the service would loop.
What the validation refuses for an alias or a redirect
| Code | What to fix |
|---|---|
page_source_ambiguous |
A page declares both alias and redirect: keep one. |
alias_not_a_subapp |
Declare the application in x-apigami.subapps, or alias a page of one it declares. |
alias_of_optional_subapp |
An alias cannot open an optional sub-app yet: declare it with "is_optional": false, or open it with apigami.open(). |
alias_target_unknown |
The sub-app’s production has no such page, or its chain of aliases breaks further down: a page gone, an optional sub-app or one your team may not call on the way, a loop, more than 8 aliases. The message lists the pages you can alias, and names the team that fixes a break down the chain. |
alias_target_not_hosted |
The sub-app’s page, or the last one of its chain of aliases, is a side panel, or its page_url is absolute: alias one the message lists. |
alias_target_is_redirect |
The sub-app’s page now redirects: alias the page it leads to. An error when that redirect is permanent. |
redirect_target_unknown |
redirect.page is not a page of this version. |
redirect_chain |
The target redirects too: point straight at the page it leads to. |
redirect_target_not_hosted |
The target is a side panel, or its page_url is absolute: redirect to a page served at a path of your address. |
page_path_taken |
An action, a file of public/ or another page already answers at that page_url: pick another path. |
alias_without_code |
A version with no code has no address to serve its aliases and redirects from: add an entrypoint. |
The same alias checks run again at deployment and at publication, against the sub-app’s production of then. An
alias whose chain opens gets alias_opens_chain, a warning that blocks nothing, naming each page on the way.
See your side panel
Section titled “See your side panel”An assistant calls app_page_preview, which opens the site in a 1280 × 800 window of its own in your
browser, never one of your tabs, with your panel open on the page asked
(The site the side panel is open on). It answers a
tab_id with what the panel saw of the page in its first seconds, and names a frame-ancestors that
refuses the site, with the header to send. On that tab_id, without a domain, the usual tools act on your
page alone, never the site: page_read, page_screenshot (the panel only), console_list, page_click,
page_type, tabs_navigate to reload, tabs_close. Storage, cookies and network stay out of reach, and
what the person’s panel remembers is neither read nor changed.
It shows the version the panel would serve you, production’s page or else the latest version’s, and needs
Apigami Dev Assistant 0.15.0 or later; before 0.17.0 it shows your page alone, without the site, so a
frame-ancestors that refuses the site goes unseen. On a site it needs your account connected and the
domain allowed; otherwise, and for a home page or a settings page with no side panel page, it opens the
page full page from Dev Assistant 0.15.2, connecting you as your connect link does.
With staging: true, it opens instead the page of the version at your --staging address, full page there,
whatever its kind: what app_publish would put in production, seen before it does. Only a member of your group
gets a session at that address, so only they see what it shows signed in. Deploy with app_deploy first, or it
refuses.
One preview per page: opening the same page again closes the previous tab, and its tab_id then
points to the new one. While a test waits on a tab, preview other pages only.