PlanewardPlaneward Docs
PlanewardPlaneward Docs
Welcome

Developers

REST APIAuthenticationWebhooksMCPMCP journeyEmbedded projectsTask description contentDeveloper hub
Planeward appsQuickstartIdentity tokenApp permissionsThemeAPI accessApp webhooksTesting your appList your app in the directorypostMessage protocol

API

Planeward apps

App permissions

Declare your app's own permissions, let workspaces grant them, and check them from the viewer token.

Scopes decide what your backend can do in Planeward. App permissions decide what each viewer can do in your app, such as Create posts or Delete any post. You declare them; the workspace decides who has them; Planeward tells you, in the identity token, which ones the current viewer holds.

There are two separate lists:

ListGranted toWhere the workspace sets themIn the token for
DashboardWorkspace roles, on or offSettings › Roles › a role › Permissions › Appsdashboard view
CommunityMembers (@everyone), membership plans and staff roles, On or OffThe app channel's Permissions dialog, or its category'sexperience view

Declare them

Serve the declaration at GET {experience origin}/.well-known/planeward-permissions, on the origin of your app's Experience URL. A 404 means your app declares none.

{
  "dashboard": [
    { "key": "reports.export", "name": "Export reports", "default": "off" }
  ],
  "community": [
    { "key": "posts.create", "name": "Create posts", "default": "on" },
    {
      "key": "posts.delete_any",
      "name": "Delete any post",
      "description": "Delete posts other members wrote.",
      "default": "off"
    }
  ]
}
FieldRule
keyLowercase and dotted, at least two parts (posts.create), up to 64 characters, unique in its list
name1 to 60 characters, shown to the workspace
descriptionOptional, up to 200 characters
default"on" or "off": the value when nobody has set one

Each list holds at most 25 entries; a missing list means none. Answer with Content-Type: application/json, under 64 KB.

With the SDK (0.2.4 or later), definePermissions keeps the keys typed and validatePermissionsResponse checks the same rules Planeward does:

app/.well-known/planeward-permissions/route.ts
import { definePermissions } from "@planeward/sdk/server";

const permissions = definePermissions({
  dashboard: [
    { key: "reports.export", name: "Export reports", default: "off" },
  ],
  community: [
    { key: "posts.create", name: "Create posts", default: "on" },
    { key: "posts.delete_any", name: "Delete any post", default: "off" },
  ],
});

export function GET() {
  return Response.json(permissions);
}

planeward init writes a starter route like this one.

When Planeward reads them

Planeward fetches the declaration when a workspace installs your app, and again when someone with Manage apps selects Refresh permissions in the app's ⋯ menu on the workspace Apps page. It keeps the result and never asks your app while someone views it. After you change the list, ask each workspace to refresh.

  • A failed install-time fetch doesn't stop the install. Refresh permissions shows what went wrong: a status other than 200 or 404, a body that isn't JSON, a rule above, or a timeout.
  • A key you drop disappears from the dialogs and tokens. What the workspace set for it is kept, and comes back if you declare the key again.
  • Planeward can't reach a localhost app, so it isn't read there. Check it with planeward permissions instead.

Dashboard permissions

Each workspace role has an on/off switch per dashboard permission, at the bottom of the role's Permissions tab under Apps. Editing it needs Manage roles.

  • A switch nobody has set uses your declared default.
  • The workspace owner has every dashboard permission.
  • A viewer with several roles has a permission when any of their roles has it on.

Only people with Manage apps open dashboards, so these narrow what they can do inside yours.

Community permissions

Community permissions are set per channel, in the same Permissions dialog as View channel and the others. An app channel's dialog has a group named after your app with its community permissions. A category's dialog shows the group for every app that has a channel in that category, and channels synced to the category follow it. See Channel permissions.

Each row is On, Unset or Off, for:

  • Members (@everyone): everyone in the community;
  • a membership plan: members on a plan of a product that gives community access;
  • a staff role: a workspace role.

For each key, Planeward starts at your declared default and applies, in order:

  1. @everyone;
  2. the member's membership plans, combined: if any plan has it On, it is on;
  3. the viewer's staff roles, the higher-ranked role winning.

The category's settings apply first, then the channel's, unless the channel is synced to its category.

Managing or moderating the community does not include app permissions. An admin holds a key only when it is granted to them, through @everyone, a plan or a role.

Check them

The token's permissions claim lists the keys the viewer holds: community keys for that channel in an experience token, dashboard keys in a dashboard token. Check it on your backend for every action:

import { can, verifyPlanewardToken } from "@planeward/sdk/server";

const viewer = await verifyPlanewardToken(token, { appId: "your-app-id" });
if (!can(viewer, "posts.create")) {
  return new Response("Forbidden", { status: 403 });
}

In the browser, app.can("posts.create") reads the current token without verifying it. Use it to hide buttons, and keep the check on your backend. A token without the claim grants nothing.

Tokens last 5 minutes, so a change the workspace makes reaches your app with the next token.

Test your permissions

The planeward CLI (0.1.7 or later) helps without a workspace:

  • planeward permissions fetches your declaration from dev.url (or --url), validates it and prints both lists. It exits non-zero on any problem.
  • The emulator's Permissions tab sets community keys On, Unset or Off for @everyone or a plan, and dashboard keys on or off, then re-mints the token and reloads your app. It saves them to dev.grants in planeward.json.
  • dev.plans in planeward.json lists fake membership plans, so you can view as a member on a plan.

See the CLI README for the dev.grants format.

Identity token

The signed JWT that tells your app who is viewing.

Theme

Match the look of the community or dashboard your app runs in.

On this page

Declare themWhen Planeward reads themDashboard permissionsCommunity permissionsCheck themTest your permissions