plugins
npx skills add https://github.com/crystallizeapi/ai --skill pluginsCrystallize Plugins
A Crystallize Plugin is a vendor-hosted application that extends the Crystallize App UI inside iframes at predefined placement points. Plugins do not run code in the App UI itself — they receive a scoped Backend Token to act on behalf of the signed-in user via Crystallize APIs, and any secrets they need are encrypted client-side with the vendor’s own public key.
The full normative contract — entities, fields, JWE/JWT specs, request shapes, sequence diagrams — lives in references/plugin-contract.md. This SKILL.md is the builder’s guide: how to ship a plugin end-to-end. Read the contract when a field, security guarantee, or wire format is in question.
Legacy Apps are not plugins. A tenant can also frame a page as an App, registered with PIM app.create. An App gets only ?crystallizeSignature=<JWT> (tenant and user, no item id or language), so use a plugin when the view needs the item. Apps, their signature, frame-ancestors and custom views (tenant.setPreferences(frontends)) are in references/legacy-apps.md.
Consultation Approach
Before writing code, get the lay of the land:
- What does the plugin do? Pure UI widget, server-side action on a Crystallize entity (order, catalogue item…), or tenant-wide dashboard? This drives the entrypoint placements.
- Does it need to call Crystallize APIs? If yes, you’ll use the
backendTokenfrom the decrypted payload as aBearercredential on the Core and PIM APIs. Other APIs need other credentials: see Backend Token rules. - Does it need secrets? API keys, webhook URLs, third-party credentials — these go in
secrets[]and are encrypted in the installer’s browser. Crystallize never sees plaintext. - Where does it run? Plugins are server-hosted (Cloudflare Worker, Vercel/Netlify edge, Lambda, plain Node/Bun server). Pure static hosting is not sufficient — the upstream must accept POST requests and decrypt JWE payloads.
- Which tenant(s)? Plugins are installed per-tenant. One plugin can be installed on many tenants, each with its own configuration.
Architecture in 30 Seconds
Three entities (full detail in the contract):
| Entity | Where it lives | Purpose |
|---|---|---|
| Plugin | /@me |
The plugin definition (name, identifier, logo). Has a state: pending → active. |
| Plugin Revision | /@me |
The locked contract surface: upstream, entrypoints, scopes, schema, secrets, key. |
| Plugin Installation | /@:tenant |
A (tenant, plugin, revision) triple with the tenant-specific config + ciphertexts. |
Key invariants:
- A revision is immutable once submitted. Code at
upstreamcan change anytime; only contract changes require a new revision. - Installations pin a
revisionIdand never auto-migrate. Re-install to upgrade. - Crystallize never holds plaintext secrets. The installer’s browser encrypts them with the revision’s
publicKey; only the vendor can decrypt.
End-to-End Workflow
1. Scaffold the upstream and generate the keypair
crystallize plugin create downloads a skeleton, generates the keypair, and fills in the plugin name, identifier and keys:
crystallize plugin create ./my-plugin hono-plugin-skeleton# headless: add --no-interactive --name "My Plugin" --author "Acme" [--identifier com.acme.my-plugin] [--plugin-url https://plugin.acme.com]Skeletons: hono-plugin-skeleton, cloudflare-hono-plugin-buddy, hello-world-plugin.
To add a keypair to an existing server: the vendor needs an RSA key (RSA-OAEP-256 / A256GCM, JWE compact). Use the Crystallize CLI:
crystallize plugin keygenThis emits a private.jwk.json and a public.jwk.json. Keep private.jwk.json on the server only; the public key goes into the revision.
2. Register the plugin
Run on the Me API (https://api.crystallize.com/@me), or create the plugin in the App under Settings → Apps. /@me answers 403 to tenant-bound credentials, including access tokens scoped to a tenant.
mutation { createPlugin( input: { author: "Acme" description: "Order preview plugin" icon: "https://acme.com/icon.png" identifier: "com.acme.order-preview" # reverse-DNS, immutable logo: "https://acme.com/logo.png" name: "Acme Order Preview" } ) { ... on BasicError { message } ... on Plugin { identifier } }}identifier is lowercase reverse-DNS with at least three dot-separated segments, each starting with a letter. The CLI is laxer: com.acme passes --identifier but createPlugin rejects it. logo and icon must be absolute URLs. No mutation updates these fields afterwards.
The plugin starts in pending state — until Crystallize approves a revision, only its owner can install it, as a private install (step 5).
3. Create the first revision
The revision is the contract the installer will see and consent to. Locked once submitted.
mutation CREATE_PLUGIN_REVISION($input: CreatePluginRevisionInput!) { createPluginRevision(identifier: "com.acme.order-preview", input: $input) { ... on BasicError { message } ... on PluginRevision { id version } }}Variables (the $input):
{ "input": { "version": "1.0.0", "upstream": "https://plugin.acme.com", "postInstallationUri": "/post-install", "scopes": [], "entryPoints": [ { "placement": "orders/order/top/inline", "target": "/order/preview", "label": "Preview Order", "icon": "https://acme.com/btn.png" } ], "configurationSchema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "additionalProperties": false, "required": ["apiKey"], "properties": { "apiKey": { "type": "string", "title": "Stripe API Key" }, "theme": { "type": "string", "enum": ["light", "dark"] } } }, "secrets": ["apiKey"], "publicKey": { "kty": "RSA", "kid": "public", "use": "enc", "alg": "RSA-OAEP-256", "enc": "A256GCM", "n": "<modulus from public.jwk.json>", "e": "AQAB" } }}Field cheat sheet
| Field | Notes |
|---|---|
upstream |
Base HTTPS URL of your origin. http://, localhost, private IPs and IPv6 literals are rejected. Crystallize POSTs to $upstream/$tenantIdentifier/$path. |
entryPoints[] |
Each: placement (from the table below), target (path under upstream, starting with /), optional label + icon (absolute URL). |
scopes |
Permissions the plugin needs, as <resource>:<action> (orders:read, never order:read): anything else is rejected. See Scopes for the values. Recorded on the installation but not enforced on the token yet — declare honestly anyway. |
configurationSchema |
JSON Schema draft 2020-12. Crystallize renders this as the install form. Validates submissions (with secret fields excluded). Without a schema, configuration must be empty. A top-level x-entryPoints key sets each entry point’s initial size and spinner: see below. |
secrets |
Names of top-level properties from the schema to treat as secrets. Each becomes <input type="password"> and is JWE-encrypted in the browser. |
publicKey |
JWK from crystallize plugin keygen. Must be kty=RSA with n and e. Keep the alg and enc the CLI sets: the API treats them as optional, but the App needs both to encrypt secrets. |
postInstallationUri |
Path Crystallize POSTs to on install / reinstall / uninstall events. Fire-and-forget, no retries — make your handler idempotent. |
version |
Vendor-declared semver. Cosmetic — does not drive any Crystallize behavior. |
Placements
The API accepts any placement string, but the App only renders these. Anything else, such as order/view/toolbar-button, is stored without error and never appears.
| Placement | Where the App renders it |
|---|---|
dashboard/home/top-card |
Home dashboard, replacing the default top card |
layout/sidebar-right |
Right sidebar, on every page |
layout/bottom-right/inline |
Fixed bottom-right bar, on every page |
orders/order/top/inline, orders/order/bottom/inline |
Order detail page |
catalogue/item/above-components/inline, catalogue/item/below-components/inline |
Item editor, around the components. Not on archived versions |
catalogue/variant/above-components/inline, catalogue/variant/below-components/inline |
Variant editor, around the components. Not on archived versions |
catalogue/item/split-view/inline |
An extra view in the item’s view switcher, using the entry point’s label and icon |
catalogue/folder-nerdy/nerdy-action/all, catalogue/folder-nerdy/nerdy-action/products, catalogue/folder-nerdy/nerdy-action/variants |
Bulk action in the catalogue data grid and Lightbox, opening a dialog. The suffix is the grid’s items type |
plugins/page/full |
Full page at /plugins/<identifier> |
apps/plugin/content |
The plugin’s page under Apps, replacing its config page |
The App renders only the first entry point of a revision for a given placement, so declare each placement once. Users whose role lacks read access to pluginInstallations see no plugin UI.
To set where an entry point’s iframe starts, add x-entryPoints to the configurationSchema, keyed by placement: { "layout/bottom-right/inline": { "initialWidth": 0, "initialHeight": 0, "showLoader": false } }. The initial size stays within the placement’s range, the plugin can still resize it, and a size it reported earlier wins. showLoader: false hides the App’s spinner. Details in Entrypoint Settings.
Sizes, entity context and signals per placement are in the contract’s Entrypoints section.
4. Get approval
Approval is what lets other tenants install the plugin. To try the plugin on your own tenant first, use a private install (step 5). Query state:
query { plugin(identifier: "com.acme.order-preview") { ... on Plugin { state approvedRevision { id } name } }}Contact Crystallize on Slack to move it from pending → active: only Crystallize staff can approve a revision. Once approved, approvedRevision.id is populated and the plugin can be installed from any tenant. Each later revision needs its own approval. The marketplace page in the App is a separate listing, so ask for it when you request approval: without a listing, an approved plugin can only be installed through the API.
5. Install on a tenant
An installation resolves to one of two modes, and the mutation fails unless the matching terms flag is true:
| Mode | Who | Revision | Required flag |
|---|---|---|---|
marketplace |
A user with create access to pluginInstallations |
The approved revision of an active plugin |
acceptMarketplaceTerms |
private |
The plugin’s owner, holding the tenantAdmin role on the target tenant | The latest revision, when it is not the approved one. Works on pending |
acceptPrivateInstallTerms |
Any other combination is refused, and an inactive plugin can’t be installed at all. To check first, query pluginInstallability(identifier: "com.acme.order-preview") { ... on PluginInstallability { mode } } on the Core API: it returns marketplace, private or notInstallable.
In the App, a marketplace install happens under Apps (renders the schema, encrypts secrets in the browser). A private install happens on the plugin’s page under Settings → Apps, and there you paste the configuration as JSON and the secrets already encrypted. For private installs and API installs, you must encrypt secrets yourself:
crystallize plugin encrypt-secret --public-key /path/to/public.jwk.json# paste the plaintext secret, or pass --value / pipe it; outputs a JWE compact stringThen call (on https://api.crystallize.com/@<tenant>):
mutation { createPluginInstallation( input: { pluginIdentifier: "com.acme.order-preview" revisionId: "<revisionId>" grantedScopes: [] configuration: { theme: "dark" } # non-secret fields encryptedSecrets: { apiKey: "<JWE compact string>" } # one entry per secret acceptMarketplaceTerms: true # or acceptPrivateInstallTerms: true } ) { ... on BasicError { message } ... on PluginInstallation { id } }}grantedScopes, configuration and encryptedSecrets are all required: pass [] or {} when empty. Every name in the revision’s secrets needs an entry, even when the schema does not mark it required. A missing one fails with Encrypted secret for "<name>" is not tagged with the target revisionId. A tenant holds one installation per plugin, so a second createPluginInstallation fails: use reinstallPluginInstallation.
On install, Crystallize POSTs the post-install body to $upstream/$tenantIdentifier/$postInstallationUri. See Develop the upstream below.
Reinstall, upgrade, uninstall
reinstallPluginInstallation takes the same input with installationId in place of pluginIdentifier. It replaces the revision, scopes, configuration and secrets, and keeps the same installationId. The modes and terms flags above apply again, so a private install pinned to a superseded revision can only move to the latest one. deletePluginInstallation(id:) uninstalls. See Re-install and Uninstall for both mutations.
Send every secret again, because a blank one is rejected rather than kept. To keep a value, resend its stored ciphertext. That only works while the key is unchanged: Crystallize can’t tell which key encrypted a ciphertext, so a stale one is accepted, and then decrypter throws on every payload of that installation.
Develop the Upstream
The upstream is your server. Two endpoint shapes to handle — both POST with the same wire format:
- Post-install webhook (
$postInstallationUri) — POST with form-encoded bodypayload=<JWE>. - Entrypoints (
$target) — POST with form-encoded bodypayload=<JWE>.
Both decrypt to the same plaintext shape (with different fields populated). Use createPluginPayloadDecrypter from @crystallize/js-api-client.
Decrypter setup
import { createPluginPayloadDecrypter } from "@crystallize/js-api-client";
const decrypter = createPluginPayloadDecrypter({ privateJwk: JSON.parse(process.env.PLUGIN_PRIVATE_JWK!), verify: { audience: process.env.PLUGIN_IDENTIFIER!, // matches `aud` in the Backend Token verifyBackendToken: true, // verifies RS256 via Crystallize JWKS },});Always read the private JWK from a secret env var — never commit it.
The decrypter does not reject a forged payload. It only throws when a payload can’t be decrypted. A bad or expired signature still returns the envelope, with signatureStatus.verified: false. Your public key is not secret, so anyone can build a payload that your private key decrypts: refuse the request unless signatureStatus.verified is true, as both handlers below do.
Post-install handler
app.post("/:tenantIdentifier/post-install", async (c) => { const tenantIdentifier = c.req.param("tenantIdentifier"); try { const body = await c.req.parseBody(); // form-encoded if (typeof body?.payload !== "string") return c.text("invalid body", 400);
const decoded = await decrypter(body.payload); if (!decoded.signatureStatus.verified) return c.text("invalid signature", 403); if (decoded.envelope?.tenantIdentifier !== tenantIdentifier) { return c.text("tenant mismatch", 403); // path tenant must match payload tenant } // decoded.envelope.event is "install" | "reinstall" | "uninstall" // decoded.envelope.configuration carries non-secret config; decoded.secrets // carries plaintext secrets (already decrypted by the decrypter). Neither is // delivered on "uninstall", and its backendToken no longer works. // Persist tenant-scoped state. Handler MUST be idempotent — no retries. return c.text("ok"); } catch { return c.text("bad payload", 400); }});Entrypoint handler
import { createClient } from "@crystallize/js-api-client";
app.post("/:tenantIdentifier/order/preview", async (c) => { const tenantIdentifier = c.req.param("tenantIdentifier"); try { const body = await c.req.parseBody(); // form-encoded if (typeof body?.payload !== "string") return c.text("invalid body", 400);
const decoded = await decrypter(body.payload); if (!decoded.signatureStatus.verified) return c.text("invalid signature", 403); if (decoded.envelope?.tenantIdentifier !== tenantIdentifier) { return c.text("tenant mismatch", 403); }
// Plaintext secrets are at decoded.secrets[name] — no manual decrypt step. // Call Crystallize APIs on behalf of the viewer using the Backend Token. const api = createClient({ tenantIdentifier, bearerToken: decoded.envelope.backendToken, }); const data = await api.nextPimApi<{ tenant: { id: string; name: string }; }>("{ tenant { ... on Tenant { id name } } }");
return c.html(renderPage(decoded, data)); } catch (err) { console.error(err); return c.text("bad payload", 400); }});Decoded payload shape
The decrypter returns a structured DecryptedPluginPayload (see @crystallize/js-api-client):
| Field | Description |
|---|---|
envelope.tenantIdentifier |
Always check against the path param. |
envelope.tenantId |
Tenant ID (string). |
envelope.installationId |
Stable across reinstalls of the same (tenant, plugin). An uninstall followed by an install creates a new one. |
envelope.pluginIdentifier |
Sanity-check it’s yours. |
envelope.revisionId |
Which revision this installation is pinned to. |
envelope.sub |
The viewing user’s ID. On webhooks, the user who first installed the plugin, whoever triggered the event. |
envelope.configuration |
Non-secret configuration values (plaintext). Absent on uninstall. |
envelope.encryptedSecrets |
Per-field JWE ciphertext (raw). The decrypter already plaintexts these into secrets — only touch this for re-encryption. Absent on uninstall. |
envelope.entityContext |
The page behind the iframe at load time, e.g. { entity: "orders", orderId: "...", mode: "view", placement, ... }. The App always sends it, even on the dashboard. |
envelope.event |
Webhook variant only: "install" | "reinstall" | "uninstall". Absent on iframe payloads. |
envelope.installMode |
Webhook variant only: "marketplace" | "private". Absent on uninstall. |
envelope.acceptedTermsAt |
Webhook variant only: ISO 8601 timestamp of the terms acceptance. Absent on uninstall. |
envelope.backendToken |
RS256 JWT (string) — pass as Authorization: Bearer … to the Core and PIM APIs. |
envelope.signatureSecret |
(optional) The tenant’s secret for verifying inbound Crystallize webhooks via createSignatureVerifier. Present when the tenant has one. |
envelope.staticAuthToken |
(optional) The tenant’s static auth token for protected Catalogue / Discovery APIs. Pass it as staticAuthToken, not as a bearer. Present when the tenant has one. |
secrets |
Plaintext map of secret values, already decrypted by the decrypter. Use this — don’t re-decrypt encryptedSecrets. |
signatureStatus.verified |
true if the signature of the JWT inside the JWE checks out. false when it fails, has expired, or verify was omitted; see signatureStatus.reason. |
backendTokenStatus.verified |
true if the JWKS verification of the Backend Token passed (when verifyBackendToken: true). |
backendTokenStatus.claims |
Decoded claims (sub = userId, aud = your plugin identifier, act = { pluginIdentifier, tenantId, installationId, revisionId }). |
Backend Token rules
- TTL: 1 hour. Never cache it across requests — every iframe load mints a fresh one. A mounted iframe is not re-POSTed, so there is no refresh until the user reloads the page.
- Send as
Authorization: Bearer <jwt>to the Core API (nextPimApi) and the PIM API (pimApi). No other API takes it:/@meanswers 403, Discovery and Catalogue ignore it, and the Shop API token fetch does not read it. - For a protected Catalogue or Discovery API, build a separate
createClient({ tenantIdentifier, staticAuthToken: decoded.envelope.staticAuthToken }). A client holding both credentials sends only the Bearer, so those calls fail. - The server verifies signature, installation and plugin state on every call. Uninstalling, or reinstalling onto another revision, revokes outstanding tokens at once, and the
inactivekill-switch is live, not TTL-bounded. A revoked or expired token gets a 400No authentication data provided.; a plugin in a refused state gets a 403. - The uninstall webhook carries a
backendToken, but the installation is already gone, so that token never works. Clean up without calling Crystallize. - The token impersonates the viewing user, bounded by their permissions. A plugin cannot escalate privileges. On webhooks it impersonates the user who first installed the plugin.
Talk to the App from the iframe
Use @crystallize/plugin-signal in the browser code your upstream serves. It is a typed JSON-RPC channel over postMessage:
import { createChannel, createWindowTransport } from "@crystallize/plugin-signal";
const channel = createChannel({ transport: createWindowTransport(), handlers: { setEntityContext: (_channel, context) => render(context), },});
channel.notify("ready", undefined); // the App answers with setEntityContextchannel.notify("notifyHeight", { height: document.body.scrollHeight });channel.notify("navigateTo", { entity: "order", id: "<orderId>" });envelope.entityContext goes stale. The App POSTs the payload once, when the iframe mounts. As the user navigates, a mounted iframe (the sidebar, for one) is not re-POSTed: the App sends each change through setEntityContext instead. Treat the payload’s value as the initial one.
Every method, and which placements honour it, is in the contract’s App Channel section.
Local Testing Without the App UI
You don’t need to click through the App UI to exercise an endpoint locally. Crystallize exposes the same payload-issuing mutation directly on the Core API (https://api.crystallize.com/@<tenant>). The entryPointId comes from pluginInstallation(id:) { ... on PluginInstallation { revision { entryPoints { id placement } } } }:
mutation { issuePluginPayload( installationId: "<installationId>" entryPointId: "<entryPointId>" entityContext: { entity: "orders", orderId: "<orderId>", mode: "view" } # optional ) { ... on BasicError { message } ... on PluginPayload { encryptedPayload url } }}Then POST it yourself:
curl -X POST "$URL" \ --data-urlencode "payload=$ENCRYPTED_PAYLOAD"To inspect a payload, run crystallize plugin decrypt-payload --private-key ./private.jwk.json --payload "$ENCRYPTED_PAYLOAD" --audience com.acme.order-preview.
For the post-install webhook, the wire format is identical — curl --data-urlencode "payload=$ENCRYPTED_PAYLOAD" "$URL" — but issuePluginPayload sets no event. To trigger a real lifecycle event for testing, re-install the plugin (it’s atomic, keeps the same installationId, and fires reinstall).
For local development of the upstream, expose your dev server with a tunnel (e.g. ngrok) and set that URL as the revision’s upstream. upstream is locked in the revision, so use a stable hostname: a new URL means a new revision and a reinstall. Code under upstream can change without a new revision.
Dev-payload Vite plugin (no Crystallize round-trip)
If you’re on Vite, the crystallize-plugin-skeleton and crystallize-buddy examples ship a vite/dev-payload.ts plugin that intercepts GETs in dev and mints a fake JWE envelope (encrypted with your local public.jwk.json, then re-POSTs it to your handler). You declare the routes you want to mock in dev-payload.config.jsonc (entrypoints, post-install events, entity context, plaintext secrets that get JWE-wrapped). This decouples local development from the App UI entirely — open the route in a browser, your handler sees a payload identical to production.
The plugin uses a dev-payload:// prefix on the locally-minted backendToken as a sentinel, and its payloads are unsigned. Do not copy the examples’ bypass as it stands: their middleware skips the signature check on that prefix alone, and anyone holding your public key can mint such a payload against production. Gate the bypass on something only your dev build sets, such as import.meta.env.DEV, so production always requires a verified signature.
Common Mistakes
| Mistake | What to do |
|---|---|
Storing PLUGIN_PRIVATE_JWK in source control |
Treat it like any other private key. Env var only, secret manager in production. |
| Acting on a payload without checking its signature | The decrypter returns the envelope even when the signature fails. Refuse it unless decoded.signatureStatus.verified is true. |
Forgetting to validate tenantIdentifier from the path vs payload |
Always compare both. The contract requires the path to match the payload’s tenantIdentifier. |
Trusting pluginIdentifier from payload without checking |
Compare it to your own PLUGIN_IDENTIFIER. The decrypter’s audience check covers the token; do this too. |
| Inventing a placement | The API accepts any string and the App renders nothing. Use a placement from the table. |
| Caching the Backend Token | Never. It’s per-load, 1h TTL, and live-revoked on uninstall, on a reinstall onto another revision, or when the plugin goes inactive. |
| Designing the post-install handler with side effects that aren’t idempotent | Webhook is fire-and-forget, no retries. Make it idempotent or rely on the next iframe load’s payload. |
| Trying to mutate revision fields after creation | A revision is immutable. Create a new revision and re-install to migrate. |
Putting secrets in plaintext configurationSchema properties |
List the property name in the top-level secrets[] array. The App UI then encrypts it client-side. |
| Auto-migrating users to a new revision | Installations pin a revisionId. Users must re-install to consent to the new contract. |
| Dropping the old private key after rotating keys | Installations on the old revision keep getting payloads encrypted with its key. Keep the old key until they have all moved. |
Working Examples
The Crystallize plugins monorepo ships three reference plugins. Check their payload handling against this skill before copying it: hello-world omits the signature check, and the other two have the dev-payload bypass described above.
plugins/crystallize-plugin-skeleton— the empty starting point behindcrystallize plugin create … hono-plugin-skeleton: a Node.js server with Vite and Hono.plugins/hello-world— minimal Bun + Hono server. Two routes (post-install+ entrypoint) showing payload decryption, envelope/tenant validation, and a Backend-Token-authenticated Crystallize API call. Mirror this layout (src/index.tsfor routes,.envforPLUGIN_PRIVATE_JWK+PLUGIN_IDENTIFIER) for any new plugin.plugins/crystallize-buddy— full-featured Cloudflare Workers plugin (Hono + Vite + JSX SSR with React islands, Awilix DI, webhook receiver, SSE channel). Useful when you outgrow a single-file server: shows a reusablepayloadDecryptermiddleware, a per-tenant routing pattern (/:tenantIdentifier/...), and a local dev-payload Vite plugin that mints fake JWE payloads on GET so you can develop without round-tripping through Crystallize.
References
- Plugin Contract — normative spec: entities, fields, JWE/JWT formats, sequence diagrams, entity context, App channel, security model, V1 vs V2 behavior.
- Legacy Apps — PIM API iframe views:
app.create, httpsbaseUrl,crystallizeSignatureandsignatureSecret,frame-ancestors, custom views, and when to pick a plugin instead. - Official documentation
- Companion skill: js-api-client —
createClient,createPluginPayloadDecrypter, all API callers. - CLI helpers:
crystallize plugin create,crystallize plugin keygen,crystallize plugin encrypt-secret --public-key <path>,crystallize plugin decrypt-payload --private-key <path>.
Reference Details
Legacy Apps (PIM API iframe views)
Before plugins, a tenant could frame any web page in the Crystallize App as an App. Apps still work and some tenants use them, so you will meet them. They are a much smaller contract than plugins: no manifest, no placements, no scopes, no Backend Token, and no item context.
Pick a plugin when the view needs the item, order or language the editor is on. An App only learns the tenant and the user. Pick an App for a tenant-wide view (a dashboard, a report, an import screen) on a tenant that already has one, or when a plugin is more than the task needs.
Register an App
Apps live on the legacy PIM API (https://pim.crystallize.com/graphql), with an access token pair. The Core API has
plugin installations but no apps.
mutation CreateApp($tenantId: ID!) { app { create( input: { tenantId: $tenantId identifier: "stock-dashboard" name: "Stock dashboard" baseUrl: "https://admin.example.com/apps/stock" } ) { identifier name baseUrl } }}baseUrlmust be https.http://localhost:3000is refused with “Invalid URL format, make sure URL contains https protocol”. Deploy the page, or put a tunnel in front of the dev server, before you register it.tenantIdis the tenant’s id, not its identifier.- Update and delete by identifier:
app { update(tenantId, identifier, input: { name, baseUrl }) }(the input takes onlynameandbaseUrl) andapp { delete(tenantId, identifier) }. Read them withapp { get }andapp { getMany }.
What the framed page receives
The App loads baseUrl with one query parameter:
https://admin.example.com/apps/stock?crystallizeSignature=<JWT>-
The JWT carries the tenant and the signed-in user. It carries no item id and no language. A per-item view needs its own deep-link parameters and a lookup from the item id to the item (Discovery, or Core from the server).
-
Verify the signature on the server with the tenant’s
signatureSecret, read from the PIM API:query Secret($id: ID!) {tenant {get(id: $id) {signatureSecret}}}Treat it like any secret: server-side only.
regenerateSecretson the tenant rotates it.
Allow the App to frame the page
The page must allow https://app.crystallize.com as a frame ancestor. A page component can’t set response headers,
so in Next.js put it in next.config headers() (or the proxy), scoped to the App’s routes:
export default { async headers() { return [ { source: "/apps/:path*", headers: [{ key: "Content-Security-Policy", value: "frame-ancestors https://app.crystallize.com" }], }, ]; },};Keep the rest of the site at frame-ancestors 'self' (or none).
Custom views (tenant frontends)
Custom views, the tenant’s list of frontends as { name, url }, are tenant preferences and are registered only on
the PIM API: tenant { setPreferences(tenantId, input: { frontends: [{ name, url }] }) }. The argument is
tenantId. Read them back with tenant { get(id) { preferences { frontends { name url } } } }.
Apps versus plugins
| Need | App | Plugin |
|---|---|---|
| Know the item, order or language being edited | No | Yes, in the decrypted payload |
| Call Crystallize APIs as the user | No: bring your own credentials | Yes, with the per-load Backend Token |
| Placement in the App | One App entry | Declared placements |
| Registration | PIM app.create, per tenant |
/@me plugin, revision, approval, install |
| Signature | JWT signed with the tenant’s signatureSecret |
JWE payload encrypted to your key |
Crystallize Plugin Contract
This document defines the technical and security conventions every Plugin (vendor-hosted application) must respect to integrate with Crystallize.
A Crystallize Plugin is a vendor-hosted application that extends the Crystallize App UI with custom functionality — rendered inside iframes at predefined placement points. Plugins don’t run code in the App UI itself; they receive a scoped Backend Token to act on behalf of the signed-in user via Crystallize APIs, and any secrets they need are encrypted client-side with the vendor’s own public key.
Plugins are server-hosted. The iframe is loaded via a form POST carrying an encrypted payload that contains the Backend Token, configuration, and secrets. Plugin vendors must operate a backend that can handle POST requests and decrypt the payload — a Cloudflare Worker, Vercel/Netlify edge function, Lambda, or any server-side runtime. Pure static file hosting is not sufficient.
The contract establishes the interface between three parties:
- Crystallize Core — manages identity, tenancy, the plugin collection, and the plugin registry
- Crystallize App UI — renders buttons, views, configuration forms, and plugin iframes
- Vendor Upstream — provides the actual business logic and secure endpoints
Core Concepts
Three entities manage the lifecycle of a plugin from creation to installation.
Plugin Collection
Where plugins are defined. A developer creates a plugin with createPlugin on /@me, providing the plugin metadata (name, description, logo, etc.), then adds its first revision with createPluginRevision. Both can also be done in the App under Settings → Apps.
Every plugin has a state:
pending— submitted, awaiting validation by Crystallize. Only its owner can install it, as a private install.active— validated and installableinactive— disabled. The plugin is no longer installable and stops working immediately across all tenants (live auth rejects any request made with a token whoseact.pluginIdentifiermatches an inactive plugin — the kill is not bounded by token TTL).
Apart from the owner’s private install (see Installation Modes), a plugin can’t be installed until it reaches active state.
Revisions
A plugin evolves through revisions. A revision locks the contract surface — the fields that define what the plugin is allowed to do and where it shows up:
upstream— the base URL of the plugin originentryPoints— where the plugin appears in the UIscopes— the permissions the plugin requiresconfigurationSchema— the JSON Schema defining the install-time configuration formsecrets— which configuration fields are secretspublicKey— the JWK public key for payload encryptionpostInstallationUri— path where Crystallize POSTs installation dataversion— vendor-declared semver for this revision
A revision is immutable once submitted. The code running at upstream is entirely under the vendor’s control — bug fixes, UI changes, and performance improvements can be deployed anytime without a new revision. A new revision is only needed when the contract itself changes.
Plugin-level fields (name, description, logo, etc.) live on the plugin, not on a revision. They’re cosmetic — they don’t affect what the plugin is allowed to do. createPlugin sets them, and no mutation updates them afterwards.
Revision fields are locked per revision because they directly affect the Backend Token: when a user installs a plugin, they consent to a specific upstream, a specific set of entrypoints, and a specific set of scopes. The token issued at runtime is bounded by that consent. Locking the contract per revision ensures the token always reflects what was approved at installation.
Each plugin carries an approvedRevisionId pointer. This is the revision that the Plugin Store surfaces and that new installations default to. Only Crystallize staff can set it. Installations pin a specific revisionId and never auto-migrate — upgrading an installation to a newer revision requires the user to re-install.
The full mutation input is detailed in the Revision Fields section.
Plugin Registry
Where installations live. When a user installs a plugin on their tenant, the Plugin Registry stores the result: which tenant, which plugin, which revision, the non-secret configuration, the granted scopes, and the encrypted secrets.
One plugin can be installed on many tenants, each with its own configuration and scopes. Each (tenant, plugin) pair maps to exactly one installation.
To change configuration, scopes, or revision, the plugin must be re-installed with reinstallPluginInstallation. Re-install is atomic and keeps the same installationId.
Plugin Store
The public-facing catalog of available plugins, shown as the marketplace under Apps in the App. Only plugins in active state can be installed from it. Its entries carry marketing content (descriptions, screenshots, vendor info, etc.) and are a separate listing: approving a revision does not create one.
Users browse the Plugin Store in the App UI to discover and install plugins.
Base Requirements
A valid Plugin must satisfy:
- Hosting: a publicly accessible HTTPS domain, operated by the vendor. The origin must accept POST requests and decrypt payloads with the vendor’s private key. Pure static hosting is not sufficient.
upstreammust behttps:and cannot belocalhost, a private or link-local IPv4 address, or an IPv6 literal. - Plugin registration: the developer creates the plugin and its first revision via mutations on
/@mein Crystallize Core. - Post-installation endpoint: a path declared in the revision (
postInstallationUri) where Crystallize POSTs configuration and encrypted secrets at install / reinstall time, and a final notice at uninstall time.
Vendor Endpoints
All URLs follow the same pattern:
$upstream/$tenantIdentifier/$path$upstreamis the plugin’s declaredupstreamURL (from the revision).$tenantIdentifieris the Crystallize tenant the request is scoped to.$pathis eitherpostInstallationUri(for install events) or an entrypoint’starget(for iframe loads).
Post-Installation Endpoint
When a user installs, re-installs, or uninstalls a plugin on their tenant, Crystallize POSTs a form-encoded body to:
$upstream/$tenantIdentifier/$postInstallationUriThe body is application/x-www-form-urlencoded with a single field payload=<JWE> — the same wire format used for entrypoints. The JWE wraps a JWT signed by Crystallize, whose claims are:
type PostInstallClaims = { event: "install" | "reinstall" | "uninstall"; tenantId: string; tenantIdentifier: string; installationId: string; pluginIdentifier: string; revisionId: string; backendToken: string; // never usable on uninstall: the installation is already gone configuration?: Record<string, JsonValue>; // omitted for uninstall encryptedSecrets?: Record<string, string>; // JWE-per-field, omitted for uninstall installMode?: "marketplace" | "private"; // omitted for uninstall acceptedTermsAt?: string; // ISO 8601, omitted for uninstall signatureSecret?: string; // the tenant's, when it has one staticAuthToken?: string; // the tenant's, when it has one // Standard JWT claims: iss, aud (your plugin identifier), iat, nbf, exp, jti, // and sub (the user who first installed the plugin, whoever triggered the event)};Delivery semantics: fire-and-forget, best-effort, no retries. The request times out after 5 seconds. A 2xx response counts as success; anything else is logged and ignored. The install/reinstall/uninstall mutation does not block on the vendor’s response — the user-visible operation completes regardless. Vendors should therefore design their post-install handler to be idempotent and to tolerate losing an occasional event.
Plugin UI Endpoints
All other endpoints (the ones loaded inside iframes) are addressed by an entrypoint’s target:
$upstream/$tenantIdentifier/$targetThese endpoints are called via POST. The body contains a single encrypted payload (see Plugin Loading Protocol).
The vendor chooses the target paths — the entrypoints registered in the revision are the source of truth.
Plugin Definition
The plugin definition is submitted via a mutation on /@me. It lives in the Plugin Collection.
The definition has two layers: plugin-level fields describing the plugin (set at creation) and revision-level fields defining the contract (locked per revision).
Plugin Fields
| Field | Type | Description |
|---|---|---|
name |
string |
Display name of the plugin |
identifier |
string |
Reverse-DNS identifier, globally unique, immutable (e.g. com.acme.invoice). Lowercase, at least three dot-separated segments, each starting with a letter |
author |
string |
(optional) Author / vendor name |
description |
string |
(optional) Short description |
logo |
string |
(optional) Absolute URL to a logo image |
icon |
string |
(optional) Absolute URL to an icon image |
Revision Fields
These define the contract surface and are locked per revision. Changing any of them requires a new revision via createPluginRevision.
| Field | Type | Description |
|---|---|---|
upstream |
String! |
Base HTTPS URL of the plugin origin |
entryPoints |
[PluginEntryPointInput!]! |
Where the plugin appears in the UI (see Entrypoints) |
scopes |
[PluginScope!] |
Permissions the plugin requires (see Scopes) |
configurationSchema |
JSON |
JSON Schema (draft 2020-12) defining the install-time configuration form (see Configuration) |
secrets |
[String!] |
Configuration property names to treat as secrets (see Secrets) |
publicKey |
PluginPublicKeyRevisionInput! |
JWK public key used to encrypt secrets at install time and the iframe payload at runtime (see Cryptography) |
postInstallationUri |
String! |
Path where Crystallize POSTs installation data (see Post-Installation Endpoint) |
version |
String! |
Semver by convention, not validated. The plugin’s “current version” is the version of approvedRevisionId |
input CreatePluginRevisionInput { upstream: String! entryPoints: [PluginEntryPointInput!]! scopes: [PluginScope!] configurationSchema: JSON secrets: [String!] publicKey: PluginPublicKeyRevisionInput! postInstallationUri: String! version: String!}Scopes
The scopes field declares the permissions the plugin needs. This is what the installer reviews before granting access. Each scope is <resource>:<action>, and createPluginRevision rejects anything else.
{ "scopes": ["orders:read", "orders:update", "customers:read"]}- Actions:
create,read,update,delete,publish,unpublish,transition. - Resources:
apps,assets,bookingPolicies,catalogue,customers,flows,fulfillment,grids,inviteTokens,languages,markets,metaPresets,operationLog,orders,pieces,pluginInstallations,plugins,priceLists,priceVariants,productBookable,reports,roles,shapes,stockLocations,subscriptionContracts,subscriptionPlans,tenant,tenantSso,topics,user,users,vatGroups,vocabularies,webhooks.
At install time, grantedScopes is recorded on the installation as submitted. The App grants everything the revision declares. The API lets the caller pass a subset, and checks the value neither against the revision’s scopes nor against the installer’s own permissions.
V1 behavior: granted scopes are recorded on the installation but are not enforced when minting the Backend Token. In V1, the Backend Token carries the current user’s full permissions (bounded by the user’s own role, as always). Scope intersection enforcement — narrowing the token to
grantedScopes ∩ userPermissions— is planned for V2. Declare scopes honestly now so that the installer’s consent is meaningful and so that V2 will “just work” for your plugin.
Cryptography
The revision must include a publicKey object in JWK format (RFC 7517). This key serves two purposes:
- At install time: encrypt each secret configuration value individually (client-side, in the App UI) before submitting to Crystallize.
- At runtime: encrypt the entire iframe payload on every load (server-side, in Crystallize Core).
Only the vendor holds the matching private key. Crystallize never holds plaintext secrets.
The key must be an RSA key with:
| JWK field | Accepted value |
|---|---|
kty |
RSA, with non-empty n and e |
use |
enc, by convention (not validated) |
alg |
RSA-OAEP-256 (default) or RSA-OAEP |
enc |
A256GCM (default), A192GCM or A128GCM |
crystallize plugin keygen emits RSA-OAEP-256 and A256GCM. Keep alg and enc on the key: the API treats them as optional, but the App reads both to encrypt secrets. Reading a key back through GraphQL returns alg as an enum (RSA_OAEP_256), so convert it to the JWK form (RSA-OAEP-256) before using the key.
JWE compact serialization is used on the wire.
{ "publicKey": { "kty": "RSA", "kid": "public", "use": "enc", "alg": "RSA-OAEP-256", "enc": "A256GCM", "n": "<modulus>", "e": "AQAB" }}Configuration
A plugin is a single application deployed once by the vendor, but it can be installed on many tenants, each with its own context. The configuration is what makes each installation unique.
The revision declares the shape of the configuration as a JSON Schema. When a user installs the plugin, the App UI renders that schema as a form. The values the user fills in become that installation’s specific configuration.
The same Invoice App can be installed on Tenant A with a purple theme pointing to Stripe instance X, and on Tenant B with a blue theme pointing to Stripe instance Y. The plugin code is identical — the configuration is what differentiates each installation.
Configuration is set at installation time and stored in the Plugin Registry. Non-secret values are stored in plaintext; secrets are stored as ciphertext (see below). To change any of it, the plugin must be re-installed.
The configurationSchema field must be a valid JSON Schema, draft 2020-12.
{ "configurationSchema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "additionalProperties": false, "required": ["organizations"], "properties": { "StripeApiKey": { "type": "string", "title": "Stripe API Key", "description": "API Key of the Stripe instance" }, "organizations": { "type": "array", "minItems": 1, "items": { "type": "object", "additionalProperties": false, "required": ["label", "email"], "properties": { "label": { "type": "string", "title": "Organization Label" }, "email": { "type": "string", "title": "Organization Email" }, "address": { "type": "string", "title": "Organization Address" } } } } } }}At install and re-install, Crystallize validates the submitted configuration against this schema, after removing secret fields from its top-level properties and required. A revision with no configurationSchema only accepts an empty configuration.
The schema can also carry how the App renders each entrypoint, under x-entryPoints. See Entrypoint Settings.
Secrets
A top-level array of configuration property names to treat as secrets:
{ "secrets": ["StripeApiKey", "mySuperSecretPassword"]}Every name in secrets[] must be a top-level property of configurationSchema.properties, or createPluginRevision fails. Nested properties can’t be secrets, and a revision with secrets needs a schema.
When a property is listed in secrets, the App UI, on a marketplace install:
- Renders an
<input type="password">for that field. - Encrypts the value in the browser using the plugin’s
publicKey, producing a JWE compact string. - Submits
{ configuration, encryptedSecrets }to Crystallize. The plaintext secret value never leaves the user’s browser.
A private install in the App does not encrypt anything: the developer pastes values already encrypted with crystallize plugin encrypt-secret. API callers do the same.
Crystallize stores the ciphertext verbatim, tagged with the revisionId of the installation it was submitted for. That tag records where the value was submitted, not which key encrypted it: Crystallize can’t read the ciphertext, so it can’t detect the wrong key.
Re-install rules:
encryptedSecretsmust hold an entry for every name in the revision’ssecrets, on every re-install. A missing entry is rejected, and the App’s marketplace form never prefills secrets, so they must be re-entered there.- To keep a value through the API, read
encryptedSecretsfrompluginInstallation(stored as{ ciphertext, revisionId }) and resend eachciphertextas a bare string. - If the new revision uses a different
publicKey, every secret must be re-encrypted against it. A stale ciphertext is accepted, butcreatePluginPayloadDecrypterthen throws on every payload of that installation.
At runtime, Crystallize passes the stored ciphertexts through into the iframe payload as-is. The payload itself is signed as a JWT and then wrapped in an outer JWE using the same publicKey. The plugin’s backend:
- Decrypts the outer envelope to retrieve the signed JWT, and verifies its signature.
- Reads
encryptedSecrets[field]— a per-field JWE — and decrypts it a second time with the same private key.
createPluginPayloadDecrypter does both, and exposes the result as secrets. Only the vendor can decrypt secrets. Crystallize never holds plaintext.
Entrypoints
Entrypoints declare where the plugin appears in the Crystallize App UI. Each entrypoint defines a unique placement.
placement is a free string for the API, which stores any value without error. The App only renders the placements below, so anything else never appears. It renders only the first entrypoint of a revision for a given placement.
| Placement | Rendering | Height (px) | Width (px) |
|---|---|---|---|
dashboard/home/top-card |
Home dashboard. Replaces the default top card | 120–1200 | Fixed |
layout/sidebar-right |
Right sidebar, on every page | 80–viewport | 240–640 |
layout/bottom-right/inline |
Fixed bottom-right bar, on every page | 0–320 | 0–320 |
orders/order/top/inline |
Order detail page, top | 0–1200 | Fixed |
orders/order/bottom/inline |
Order detail page, bottom | 0–1200 | Fixed |
catalogue/item/above-components/inline |
Item editor, above the components. Not on archived versions | 0–1200 | Fixed |
catalogue/item/below-components/inline |
Item editor, below the components. Not on archived versions | 0–1200 | Fixed |
catalogue/variant/above-components/inline |
Variant editor, above the components. Not on archived versions | 0–1200 | Fixed |
catalogue/variant/below-components/inline |
Variant editor, below the components. Not on archived versions | 0–1200 | Fixed |
catalogue/item/split-view/inline |
An extra view in the item’s view switcher, labelled by the entrypoint | 80–2000 | Fixed |
catalogue/folder-nerdy/nerdy-action/all |
Bulk action in the catalogue data grid and Lightbox, for all items | Dialog | Dialog |
catalogue/folder-nerdy/nerdy-action/products |
Same, when the grid shows products | Dialog | Dialog |
catalogue/folder-nerdy/nerdy-action/variants |
Same, when the grid shows variants | Dialog | Dialog |
plugins/page/full |
Full page at /plugins/<identifier> |
Full page | Full page |
apps/plugin/content |
The plugin’s page under Apps, replacing its config page | Full page | Full page |
Heights and widths are the ranges the App clamps notifyHeight and notifyWidth to. A size the plugin reported is kept per installation and placement in the browser, and the frame starts at it on the next visit.
Each entrypoint has the following fields:
| Field | Type | Description |
|---|---|---|
id |
string |
Server-assigned at revision creation. Used by the App UI in issuePluginPayload(installationId, entryPointId). |
placement |
string |
One of the placements above |
target |
string |
URI path suffix appended to $upstream/$tenantIdentifier/. Must start with /, must not start with //, must not contain ://, must not contain .. segments. |
label |
string |
(optional) Display label |
icon |
string |
(optional) Absolute URL to an icon |
Entrypoint Settings
The entrypoint has no field for how the App renders it. Set that in the revision’s configurationSchema, under a top-level x-entryPoints key, keyed by placement. The install form and Crystallize’s schema validation ignore the key, so it never shows up as a field or affects configuration.
{ "configurationSchema": { "type": "object", "properties": {}, "x-entryPoints": { "layout/bottom-right/inline": { "initialWidth": 0, "initialHeight": 0, "showLoader": false } } }}| Setting | Type | Default | Effect |
|---|---|---|---|
initialWidth |
number |
— | The width the iframe starts at, instead of the placement’s default |
initialHeight |
number |
— | The height the iframe starts at, instead of the placement’s default |
showLoader |
boolean |
true |
false hides the App’s spinner while the iframe loads |
- The initial size is only the start. The plugin still resizes with
notifyWidth/notifyHeight, and a size it reported on an earlier visit wins over the initial one. - The App clamps the initial size to the placement’s range in the table above: the settings can’t go past its minimum or maximum.
- A size applies only where the placement’s range lets the plugin change it: width and height on
layout/bottom-right/inline, width onlayout/sidebar-right, height on the others with a range. Placements markedFixed,DialogorFull pageignore it, and onlyshowLoaderapplies there. - An invalid value, such as a negative or non-numeric size, is ignored on its own.
- A schema with only
x-entryPointsand nopropertiesinstalls without a configuration step, like a revision with no schema.
For a widget that should only show up sometimes, such as a button in layout/bottom-right/inline, start it at 0 × 0 with showLoader: false, then notifyWidth / notifyHeight when it has something to show and 0 to hide it again.
Entity Context
Every payload the App issues carries an entityContext describing the page behind the iframe, including on the dashboard. It follows the page, not the placement: a layout/sidebar-right iframe gets the context of whatever is open.
{ entity, pathname, searchParams, placement, tenantIdentifier, language, ...fields }entity |
Fields |
|---|---|
dashboard, unknown |
— |
catalogue |
itemType, itemId, variantSku, itemLanguage, view, itemsType, selectedRowIds |
orders |
orderId, subscriptionId, mode |
customers |
identifier, mode |
subscription-contracts |
contractId, mode |
fulfilment |
pipelineId, mode |
flows |
identifier, flowType, mode |
topics |
topicId, topicLanguage, mode |
grids |
gridId, gridLanguage, mode |
assets |
imageKey, assetLanguage |
lightbox |
area, lightboxLanguage, selectedRowIds |
insight, special-prices |
section |
changelog |
documentId |
marketplace |
path |
apps, plugins |
identifier |
settings |
section |
All entity fields are optional. The EntityContext type and zEntityContext schema are exported by @crystallize/plugin-signal.
The payload holds the context at load time. A mounted iframe is not re-POSTed as the user navigates: the App sends changes through setEntityContext (see App Channel). A direct issuePluginPayload call passes whatever entityContext the caller provides, and the claim is omitted when there is none.
Examples
A plugin adding a “Preview Order” panel to the order page, a variant panel, and a dashboard card:
{ "entryPoints": [ { "placement": "orders/order/top/inline", "target": "/order/preview", "label": "Preview Order", "icon": "https://example.com/icon.png" }, { "placement": "catalogue/variant/below-components/inline", "target": "/variant/widget", "label": "Variant Details" }, { "placement": "dashboard/home/top-card", "target": "/dashboard/main", "label": "Tenant Overview" } ]}Installation Flow
Installation Modes
Every install and re-install resolves to one mode, or is refused. The mutation fails unless the terms flag for that mode is true, and the flag is required again on every re-install.
| Mode | Who | Revision | Required flag |
|---|---|---|---|
marketplace |
A user with create access to pluginInstallations |
The approved revision of an active plugin |
acceptMarketplaceTerms |
private |
The plugin’s owner, holding the tenantAdmin role on the target tenant | The latest revision, when it is not the approved one. Works on pending |
acceptPrivateInstallTerms |
inactive plugins are refused in both modes. A marketplace installation requires the plugin to stay active to keep running; a private installation also runs while the plugin is pending.
pluginInstallability(identifier:) on the Core API returns the mode that applies to the current user on the current tenant: marketplace, private or notInstallable. availablePlugin(identifier:) returns an active plugin with its approved revision, and null otherwise.
Sequence
End-to-end sequence when a user installs a plugin on their tenant. The same shape applies to re-install (event: "reinstall") and uninstall (event: "uninstall", no configuration / encryptedSecrets in the webhook body).
sequenceDiagram autonumber actor Installer participant AppUI as Crystallize App UI participant Core as Crystallize Core participant Vendor as Vendor Backend
Installer->>AppUI: Open Plugin Store, pick plugin AppUI->>Core: Fetch plugin + approved revision Core-->>AppUI: upstream, configuration schema,<br/>secrets[], scopes[], publicKey,<br/>revisionId, postInstallationUri AppUI->>Installer: Render form from JSON Schema<br/>(password inputs for secret fields) Installer->>AppUI: Fill configuration, accept terms
Note over AppUI: For each field in secrets[]:<br/>encrypt its value with revision.publicKey<br/>(RSA-OAEP-256 + A256GCM, JWE compact).<br/>Plaintext secret never leaves the browser.
AppUI->>Core: createPluginInstallation(<br/>pluginIdentifier, revisionId, grantedScopes,<br/>configuration, encryptedSecrets,<br/>acceptMarketplaceTerms)
Note over Core: Validate:<br/>• install mode is marketplace or private<br/>• terms flag matches that mode<br/>• configuration vs schema (secret fields stripped)<br/>• encryptedSecrets well-formed JWE,<br/> one per name in secrets[]
Core->>Core: Persist installation<br/>(configuration plaintext, encryptedSecrets<br/>stored verbatim, tagged with revisionId)
Note over Core: Sign the post-install claims as a JWT, wrap it<br/>in an outer JWE using revision.publicKey.<br/>encryptedSecrets passed through<br/>(already per-field encrypted).
par Webhook (fire-and-forget) Core-)Vendor: POST $upstream/$tenantIdentifier/$postInstallationUri<br/>Content-Type: application/x-www-form-urlencoded<br/>body: payload=<outer JWE of signed JWT><br/>{ event:"install", tenantId, tenantIdentifier,<br/> installationId, pluginIdentifier, revisionId,<br/> backendToken, configuration, encryptedSecrets,<br/> installMode, acceptedTermsAt } and Mutation returns Core-->>AppUI: { id, ... } AppUI-->>Installer: Installation complete end
Note over Vendor: 1. Decrypt outer JWE, verify the JWT signature<br/>2. Decrypt each encryptedSecrets[field]<br/> a second time (same private key)<br/>3. Persist tenant-scoped state<br/>Handler MUST be idempotent — no retries. Vendor--)Core: 2xx (logged, not blocking)Notes on the flow
- Crystallize never sees plaintext secret values. The only party that can decrypt them is the vendor, who holds the private key matching
revision.publicKey. - The webhook is delivered once, best-effort. If the vendor is down, the install still completes — the authoritative state is always re-delivered on the next iframe load (see below).
- Re-install requires an entry for all secret fields, encrypted against the
publicKeyof the target revision. See the re-install rules. - The uninstall webhook fires after the installation is deleted, so its
backendTokencan’t call Crystallize APIs.
Re-install and Uninstall
On the Core API (https://api.crystallize.com/@<tenant>):
mutation { reinstallPluginInstallation( input: { installationId: "<installationId>" revisionId: "<revisionId>" grantedScopes: [] configuration: { theme: "dark" } encryptedSecrets: { apiKey: "<JWE compact string>" } acceptMarketplaceTerms: true # or acceptPrivateInstallTerms: true } ) { ... on BasicError { message } ... on PluginInstallation { id revisionId } }}mutation { deletePluginInstallation(id: "<installationId>") { ... on BasicError { message } ... on DeleteCount { removed } }}The target revision must qualify under Installation Modes, and a re-install onto another revision revokes every Backend Token minted for the previous one. An uninstall followed by a fresh install creates a new installationId. In the App, an installation whose revision differs from the approved one is offered as an update.
Plugin Loading Protocol
The App UI uses a form-submit-to-named-iframe pattern to load each entrypoint:
- The App UI calls
issuePluginPayload(installationId, entryPointId, entityContext?)on Crystallize Core. The server returns{ url, encryptedPayload }, whereurlis$upstream/$tenantIdentifier/$targetandencryptedPayloadis a JWE compact string. - An empty iframe is rendered with a
nameattribute. - A hidden
<form>targets that iframe by name and submits viaPOST.
<iframe name="plugin-frame-<entryPointId>"></iframe><form method="POST" action="<url>" target="plugin-frame-<entryPointId>"> <input type="hidden" name="payload" value="<encryptedPayload>" /></form>Encrypted Payload
The POST body contains a single encrypted payload, built by Crystallize Core and encrypted with the revision’s publicKey. The JWE wraps a JWT signed by Crystallize (cty: "JWT", RS256, 1 hour TTL), verifiable against the same JWKS as the Backend Token. Its claims are:
type PluginPayloadClaims = { backendToken: string; // RS256 JWT — see next section configuration: Record<string, JsonValue>; // plaintext non-secret settings encryptedSecrets: Record<string, string>; // per-field JWE compact strings entityContext?: Record<string, JsonValue>; // see Entity Context tenantId: string; tenantIdentifier: string; installationId: string; pluginIdentifier: string; // reverse-DNS; sanity-check that this matches you revisionId: string; signatureSecret?: string; // the tenant's, when it has one staticAuthToken?: string; // the tenant's, when it has one // Standard JWT claims: iss, aud (your plugin identifier), sub (the viewing user), iat, nbf, exp, jti};This pattern provides:
- No sensitive data in the URL or query string
- Nothing in server/CDN access logs
- No browser history pollution
- No URL length limits
- A single round-trip on load (POST, not GET)
- End-to-end encryption between Crystallize Core and the plugin’s backend
The plugin origin must accept the POST, decrypt the payload, and return HTML.
Loading Flow
End-to-end sequence for rendering one entrypoint in the App UI.
sequenceDiagram autonumber actor Viewer participant AppUI as Crystallize App UI participant Core as Crystallize Core participant Frame as Browser iframe participant Vendor as Vendor Backend participant API as Crystallize API
Viewer->>AppUI: Navigate to page<br/>(e.g. an order) AppUI->>Core: List installed entrypoints<br/>matching placement for this page Core-->>AppUI: [{ installationId, entryPointId,<br/> label, icon, ... }]
loop For each matching entrypoint AppUI->>Core: issuePluginPayload(<br/>installationId, entryPointId,<br/>entityContext?)
Note over Core: 1. Check the plugin state allows this installation<br/>2. Mint Backend Token (RS256 JWT):<br/> iss = Core base URL<br/> sub = viewing userId<br/> aud = pluginIdentifier<br/> exp = iat + 3600<br/> act = { pluginIdentifier, tenantId,<br/> installationId, revisionId }<br/>3. Sign the claims as a JWT:<br/> { backendToken, configuration,<br/> encryptedSecrets (passthrough),<br/> entityContext, tenantId, tenantIdentifier,<br/> installationId, pluginIdentifier, revisionId,<br/> signatureSecret, staticAuthToken }<br/>4. Wrap the JWT in an outer JWE<br/> using revision.publicKey
Core-->>AppUI: { url: $upstream/$tenantIdentifier/$target,<br/> encryptedPayload }
AppUI->>AppUI: Render empty <iframe name=...><br/>+ hidden <form method=POST action=url<br/> target=iframeName><br/> <input name="payload"<br/> value="<encryptedPayload>">
AppUI->>Frame: Auto-submit form Frame->>Vendor: POST $upstream/$tenantIdentifier/$target<br/>body: payload=<encryptedPayload>
Note over Vendor: 1. Decrypt outer JWE → signed JWT<br/>2. Verify the JWT and backendToken via JWKS<br/> ($CORE/.well-known/jwks.json):<br/> iss, aud, exp<br/>3. Decrypt encryptedSecrets[field]<br/> (same private key)
opt Vendor calls Crystallize APIs on behalf of the viewer Vendor->>API: Request<br/>Authorization: Bearer <backendToken>
Note over API: • Verify RS256 signature via JWKS<br/>• Load real user by sub = userId<br/>• Live checks, not bounded by token TTL:<br/> installation exists, still on this revision,<br/> plugin state allows it<br/>• Apply user's permissions
API-->>Vendor: Response end
Vendor-->>Frame: HTML Frame-->>Viewer: Rendered plugin UI endNotes on the flow
- The URL is assembled server-side — the App UI treats
urlas opaque and never composes it from parts. - Nothing sensitive appears in the iframe’s
srcor in any URL. The encrypted payload rides in the POST body. - The
inactivekill-switch is enforced at the API boundary on every call, not just at token issue time — a token minted just before a plugin is disabled stops working immediately. createPluginPayloadDecrypterreturns the claims even when the signature check fails, and thepublicKeyis not secret. Never act on a payload unlesssignatureStatus.verifiedistrue.- The App POSTs the payload once per mount. It does not re-issue it as the user navigates: see Entity Context.
App Channel
@crystallize/plugin-signal (public npm package) is a typed JSON-RPC 2.0 channel over postMessage between the iframe and the App. Both sides validate params, and invalid params fail with a -32602 error.
const channel = createChannel({ transport: createWindowTransport(), handlers: { setEntityContext: (_channel, context) => {} },});channel.notify("ready", undefined);const result = await channel.call("updateItemComponent", params); // rejects with an RpcError after 5 seconds by defaultcreateWindowTransport() targets the parent window and only accepts messages from https://app.crystallize.com and http://localhost. Pass allowedOrigin to change that. The upstream must allow being framed by the App, so it can’t send X-Frame-Options or a frame-ancestors policy that excludes that origin.
| Method | Direction | Params | Effect |
|---|---|---|---|
ready |
iframe → App | — | Send once mounted. The App answers with setEntityContext, and setDataGrid for a bulk action |
setEntityContext |
App → iframe | EntityContext |
Sent after ready, then on every change of context |
notifyHeight |
iframe → App | { height }, integer ≥ 0 |
Resizes the iframe within the placement’s range. No effect on full-page placements or bulk actions |
notifyWidth |
iframe → App | { width }, integer ≥ 0 |
Resizes the iframe on layout/sidebar-right and layout/bottom-right/inline |
promoteToDialog |
iframe → App | { width?, height? } |
Shows the iframe as a centered dialog, keeping its state. No effect on full-page placements or bulk actions |
demoteFromDialog |
iframe → App | — | Returns it to its slot |
navigateTo |
iframe → App | NavigateToParams |
Navigates the App. See below |
updateItemComponent |
iframe → App | { itemId, language, sku?, componentId, input } |
call, not notify. Sets a component value in the open editor. See below |
refetchItem |
iframe → App | { itemId, language } |
Reloads the base item in the open editor. Dropped without error unless that item and language are open |
refetchItemComponents |
iframe → App | { itemId, language } |
Reloads the item’s components, under the same condition |
refetchItemVariantComponents |
iframe → App | { itemId, language } |
Reloads the displayed variant’s components, under the same condition |
setDataGrid |
App → iframe | DataGridPayload |
Bulk actions: the selected rows, sent after ready |
updateDataGrid |
iframe → App | DataGridPayload |
Bulk actions: edited rows, applied to the grid as unsaved changes |
closePluginDialog |
iframe → App | — | Bulk actions: closes the dialog |
closeSplitView |
iframe → App | — | catalogue/item/split-view/inline: closes the split |
navigateTo targets, by entity: item (id or externalReference, optional language), productVariant (sku, optional language), image (key), order (id), fulfilmentPipeline (id), customer (identifier), grid (id), topic (id, optional language), priceList (identifier), plugin (identifier, for a plugins/page/full plugin), page (path, any App screen under the tenant and language, such as /settings/shapes, starting with a single /), and lightbox (area: "catalogue", groups). All except lightbox accept target: "_blank" and splits, a list of item or productVariant targets to open alongside.
updateItemComponent sets the value in the rendered editor field. It does not save: the user still saves the item, and the change only lands if that item, language and variant are open. It works on leaf components only, so targeting a chunk, choice or piece itself returns NOT_RENDERED: address the leaf inside it. componentId is the /-separated component path, e.g. summary-chunk/0/summary, and input is a component content input without its own componentId, e.g. { singleLine: { text: "New title" } }. The result is { applied: true } or { applied: false, reason: "NOT_RENDERED" | "TYPE_MISMATCH", message }.
To change data for good, call the API from your upstream with the Backend Token, then send a refetch* signal so the open editor catches up.
Backend Token
The Backend Token is generated by Crystallize Core on every plugin load and delivered inside the encrypted payload. No exchange step is required — the plugin uses it immediately to call Crystallize APIs server-side.
The token impersonates the visitor (the user currently viewing the page). On webhooks it impersonates the user who first installed the plugin.
Format
RS256 JWT, signed by Crystallize Core.
Claims
| Claim | Value |
|---|---|
iss |
Crystallize Core base URL |
sub |
The viewing user’s userId |
aud |
Your plugin’s identifier (reverse-DNS) |
exp |
iat + 3600 (1 hour TTL) |
iat |
Issue time (epoch seconds) |
nbf |
Same as iat |
jti |
Random UUID |
act |
{ pluginIdentifier, tenantId, installationId, revisionId } — RFC 8693 “actor” claim, identifies the plugin acting on behalf of the user |
Verification
Verify every token you receive:
- Fetch Crystallize’s public JWKS at
$CORE_BASE_URL/.well-known/jwks.json(https://api.crystallize.comin production). - Verify the RS256 signature.
- Check
issmatches the Crystallize Core base URL you expect. - Check
audmatches your plugin’sidentifier. - Check
expis in the future. - Check
act.pluginIdentifier/act.tenantId/act.installationId/act.revisionIdmatch the installation you’re handling.
createPluginPayloadDecrypter with verify: { audience, verifyBackendToken: true } covers steps 1 to 5, and reports the result in backendTokenStatus without throwing.
Send the token as a Bearer credential:
Authorization: Bearer <jwt>The Core API (/@tenant) and the PIM API accept it. No other API does:
/@meanswers 403Tenant bounded tokens cannot access the /@me endpoint.- Discovery and Catalogue ignore it. They read the static auth token, and Catalogue also an access token pair. Use
envelope.staticAuthTokenon a protected tenant. - The Shop API token fetch does not read it, so a Backend Token can’t obtain a Shop API token.
Crystallize verifies the token against the JWKS on every call, then runs live checks that are not bounded by the token’s TTL. The installation must still exist, so uninstalling revokes the token. It must still be pinned to the token’s revisionId, so reinstalling onto another revision revokes every token minted before. The plugin’s state must allow the installation: active, or pending for a private install.
A token that fails these checks or has expired gets a 400 No authentication data provided. A plugin in a refused state gets a 403.
Permissions Model
Plugin permissions follow least privilege:
- The plugin revision declares the permissions the plugin requires (
scopes). - At install time, the granted scopes are recorded on the installation. An API caller can pass a subset of the declared scopes.
- At runtime, the effective permissions are — conceptually — the intersection of:
- The scopes granted to the plugin at installation
- The current viewing user’s own permissions
This means a plugin can never escalate a user’s privileges. If a user has read-only access to orders, the plugin cannot write orders on their behalf — regardless of what the plugin requested.
V1 behavior: the Backend Token currently carries the viewing user’s full permissions.
grantedScopesis stored on the installation but not yet enforced when minting the token. The user’s own permissions still bound the token in the usual way. Scope-intersection enforcement is planned for V2; declaring accurate scopes now is still the right thing to do — the installer’s consent is recorded and becomes binding in V2 without any vendor change.
Security Considerations
- Plugin validation. Plugins must be approved by Crystallize before other tenants can install them. The state model (
pending→active) ensures nothing reaches them without review. The one exception is the private install: a plugin’s owner, as tenantAdmin, can run an unapproved revision.inactiveis a live kill-switch that invalidates every outstanding Backend Token for the plugin regardless of TTL. - Revision locking. Each revision locks the contract surface (upstream URL, entrypoints, scopes, configuration, secrets, public key, post-installation URI, version). The contract the user approved at install time is the one that runs. Code changes at
upstreamdon’t require a new revision; changes to the contract itself do. - Pinned installations. Installations pin a specific
revisionIdand never auto-migrate. The user has to re-install to move to a newer revision — at which point they re-consent to the new contract and re-encrypt all secrets if the public key changed. - Key rotation. A rotated key lives in a new revision, and installations on older revisions keep receiving payloads encrypted with the old key. Keep the old private key until every installation has moved.
- Payload authenticity. The JWE only proves that the payload was encrypted to your public key, which anyone may hold. The signature on the JWT inside proves it came from Crystallize, so verify it on every request and never bypass it in production.
- End-to-end payload encryption. Every iframe load delivers a JWE-encrypted payload that only the plugin’s backend can decrypt. The Backend Token, configuration, entity context, and secrets are never readable in the DOM or in any intermediate layer.
- Secrets isolation. Secret configuration values are encrypted in the installer’s browser using the revision’s
publicKeyand are stored as ciphertext only. The outer payload envelope is then encrypted again with the same public key. Crystallize never sees plaintext secrets — not during install, not during storage, not during runtime delivery, not during the post-install webhook. - No code execution in the UI. The App UI only renders iframes, links, and forms. No vendor code runs in the App UI’s JavaScript context.
- Plugin-to-App UI communication. A defined protocol (postMessage-based) governs iframe ↔ parent communication, through
@crystallize/plugin-signal. See App Channel. - Vendor trust. Installing a plugin means trusting the vendor with any secrets passed, and with the tenant’s
signatureSecretandstaticAuthToken, which every payload carries when the tenant has them. The Plugin Store surfaces vendor identity clearly. - Webhook idempotency. The post-install webhook is fire-and-forget with no retries. Design your handler to be idempotent and to tolerate occasional lost events — the authoritative state always lives on the next iframe load’s payload, which carries full
configurationandencryptedSecrets.
Crystallize AI