Skip to content
LogoLogo

App protocol

The app protocol is the set of requests between Picked and the server of an app. It also includes the messages between the dashboard and a page of an app. @picked/app-kit implements it. This page is for a server that does not use @picked/app-kit, or for a reader who needs the exact rules.

About app authentication tells why the protocol has this design.

Requests from Picked

Picked sends lifecycle events, app events and workflow tool calls to a path below the endpoint of the manifest that the installation uses. Picked sends MCP requests to the mcp.url of the manifest. An app with no endpoint and no mcp gets no requests.

RequestMethod and URLWhen Picked sends it
Lifecycle eventPOST <endpoint>/lifecycleAfter a person installs or upgrades the app on a project, and before a person removes it.
App eventPOST <endpoint>/eventsAfter an event that the manifest lists in events.
Workflow tool callPOST <endpoint>/tools/<name>When a workflow node runs the tool <name> of the manifest.
MCP requestPOST, GET or DELETE <mcp.url>When the AI agent in the dashboard uses the MCP server of the app.

Headers

HeaderOnValue
picked-signatureAll requestst=<unix seconds>,kid=<key id>,v1=<signature>. See The picked-signature header.
picked-installation-idAll requestsThe ID of the installation, for example appi_….
picked-contextMCP requestsThe base64url of the JSON of an InstallationRef.
content-typeLifecycle events, app events, tool callsapplication/json.
acceptLifecycle events, app events, tool callsapplication/json.
idempotency-keyApp events, tool callsThe same value on each resend of one request.
user-agentLifecycle events, app events, tool callsPicked/1.0 (+https://picked.app).
user-agentMCP requestsPickedMcpProxy/1.0 (+https://picked.app).

An MCP request also carries the content-type, accept, mcp-protocol-version and mcp-session-id headers of the AI agent, when it sends them. Picked does not forward the Authorization, Cookie or Origin headers of the person.

The picked-signature header

Picked signs each request with its Ed25519 private key. The picked-signature header has three parts. A , separates each part from the next:

PartValue
tThe time at which Picked signed, in unix seconds.
kidThe ID of the Picked key that signed.
v1The base64url of the Ed25519 signed value of the signed text.

The signed text is <t>.<body>, with the body exactly as Picked sent it. For an MCP request, the body part is <picked-context>\n<body>: the value of the picked-context header, a line feed, and the body. A GET or DELETE MCP request has an empty body.

A request is from Picked when all of these are true:

  • A public key of Picked has the ID kid.
  • That key verifies v1 over the signed text.
  • t is not more than 300 seconds before or after the current time.

This Node.js example verifies a request without @picked/app-kit. For an MCP request, put `${pickedContext}\n${body}` in signedText.

import { createPublicKey, verify } from 'node:crypto'
 
const PICKED_API_URL = process.env.PICKED_API_URL ?? 'https://api.picked.app'
 
let keys = new Map()
 
async function loadKeys() {
  const response = await fetch(`${PICKED_API_URL}/.well-known/picked-app-keys.json`)
  const { keys: jwks } = await response.json()
  keys = new Map(jwks.map((jwk) => [jwk.kid, createPublicKey({ key: jwk, format: 'jwk' })]))
}
 
export async function verifyPickedSignature(header, signedText) {
  if (header === null) return false
  const parts = Object.fromEntries(header.split(',').map((part) => part.trim().split('=')))
  const timestamp = Number(parts.t)
  if (!Number.isFinite(timestamp) || Math.abs(Date.now() / 1000 - timestamp) > 300) return false
  if (!keys.has(parts.kid)) await loadKeys()
  const key = keys.get(parts.kid)
  if (key === undefined || parts.v1 === undefined) return false
  return verify(
    null,
    Buffer.from(`${parts.t}.${signedText}`),
    key,
    Buffer.from(parts.v1, 'base64url'),
  )
}

@picked/app-kit loads the keys again for an unknown kid at most one time each minute.

Public keys of Picked

Picked publishes its public keys as a JSON Web Key Set at <Picked API>/.well-known/picked-app-keys.json, for example https://api.picked.app/.well-known/picked-app-keys.json. The response has cache-control: public, max-age=300.

{
  "keys": [
    {
      "kty": "OKP",
      "crv": "Ed25519",
      "alg": "EdDSA",
      "use": "sig",
      "kid": "HQ5n5zqPQ-Dy39Ix",
      "x": "mjKkpr8T2m_9DePfc7SHBxKxSsNEe2JgHscMMxccNy0"
    }
  ]
}
FieldValue
kidThe key ID: the first 16 characters of the base64url of the SHA-256 of the 32 raw bytes of the public key.
xThe base64url of the 32 raw bytes of the public key.

The set holds the current key of Picked first. After Picked replaces its key, the set can also hold old keys.

App config of Picked

Picked publishes the dashboard origins of its environment at <Picked API>/.well-known/picked-app-config.json, for example https://api.picked.app/.well-known/picked-app-config.json. The response has cache-control: public, max-age=300.

{ "dashboardOrigins": ["https://dashboard.picked.app", "https://acme.picked.app"] }
FieldValue
dashboardOriginsThe origin of the dashboard, and the host of each client that shows the dashboard.

The origin of the dashboard is first. An app lets these origins show its pages in an iframe, and links to the first. See App config of Picked.

The InstallationRef fields

Each request body from Picked contains these fields. They identify the installation, and the Picked API that the app calls back.

FieldTypeDescription
installationIdstringThe ID of the installation, for example appi_….
organizationIdstringThe ID of the organization of the project.
projectIdstringThe ID of the project that the app is installed on.
apiUrlstringThe origin of the Picked API that sent the request, for example https://api.picked.app.
tokenstringA new installation token. See Installation tokens.
tokenExpiresAtstringThe time at which token expires, as ISO 8601. One hour after Picked made the token.

token and tokenExpiresAt are in each request body from Picked. A session token does not contain them. See Session tokens.

Lifecycle events

Picked sends lifecycle events to POST <endpoint>/lifecycle. The type field gives the event. Each body also contains the InstallationRef fields.

typeOther fieldsWhen
installation.createdscopes: the scopes of the installation, as string[].After Picked adds a new installation.
installation.upgradedversion: the new version number, as number. scopes: the new scopes, as string[].After Picked moves the installation to a new version.
installation.deletedNone.Before Picked removes the installation, its tokens and its labels.
{
  "type": "installation.created",
  "installationId": "appi_8gk2mz4q7xw1",
  "organizationId": "6f1c2b9e-4d3a-4e8b-9a7c-2d5e8f1a3b4c",
  "projectId": "proj_7d2h9k4m",
  "apiUrl": "https://api.picked.app",
  "scopes": ["organization_leads/read"],
  "token": "…",
  "tokenExpiresAt": "2026-10-30T11:00:00.000Z"
}

The answer of the app:

EventA 2xx answerOther answers, or no answer
installation.createdPicked keeps the installation.Picked removes the installation. The installation fails with <name> did not accept the installation (it answered <status>).
installation.upgradedPicked keeps the upgrade.Picked moves the installation back to its old version and its old scopes. The upgrade fails with <name> did not accept the upgrade (it answered <status>).
installation.deletedPicked removes the installation.Picked removes the installation.

When Picked gets no answer, the message does not have the (it answered <status>) part.

During installation.deleted, the labels of the installation still exist, and token can read them.

App events

Picked sends app events to POST <endpoint>/events. It sends an event only to an installation whose manifest lists it in events. The only event is workspace.published.

FieldTypeDescription
typestringworkspace.published.
eventIdstringThe ID of the event. It is the same on each resend.
workspaceIdstringThe workspace that was published.
workspaceVersionIdstringThe version that Picked wrote when it published the workspace.
occurredAtstringThe time at which the workspace was published, as ISO 8601.

The body also contains the InstallationRef fields. The idempotency-key header is <eventId>:<installationId>.

Picked does not show the answer of the app to a person. The workspace is published also when the delivery fails.

Workflow tool calls

Picked sends a tool call to POST <endpoint>/tools/<name>, where <name> is the name of the tool in the manifest.

FieldTypeDescription
typestringworkflow_tool.call.
toolstringThe name of the tool, as the manifest declares it.
argumentsobjectThe arguments of the node, after Picked resolves them.
idempotencyKeystring<runId>:<nodeId>. The same key is the same call. Picked also sends it as the idempotency-key header.
run.runIdstringThe ID of the workflow run.
run.nodeIdstringThe ID of the node that calls the tool.
run.testbooleantrue in a test run.

The body also contains the InstallationRef fields.

{
  "type": "workflow_tool.call",
  "tool": "score_lead",
  "arguments": { "email": "ada@example.com", "company": "Analytical Engines" },
  "idempotencyKey": "wkrun_5t8q2n:n3",
  "run": { "runId": "wkrun_5t8q2n", "nodeId": "n3", "test": false },
  "installationId": "appi_8gk2mz4q7xw1",
  "organizationId": "6f1c2b9e-4d3a-4e8b-9a7c-2d5e8f1a3b4c",
  "projectId": "proj_7d2h9k4m",
  "apiUrl": "https://api.picked.app",
  "token": "…",
  "tokenExpiresAt": "2026-10-30T11:00:00.000Z"
}

The app answers with a JSON ToolResult:

type ToolResult =
  { output: Record<string, unknown> } | { error: { message: string; retryable?: boolean } }
AnswerResult in the run
2xx with an output objectThe node records output.
5xxThe node fails with the app answered <status>. The failure has retryable: true.
Any other status, or a 2xx with no output objectThe node fails with the app answered <status>. The failure has retryable: false.
No answerThe node fails with the app could not be reached. The failure has retryable: true.

Picked uses the status to set retryable. When a tool throws an error, @picked/app-kit answers with status 422 and { "error": { "message": "…" } }. It answers an unknown tool with status 404.

MCP requests

The AI agent in the dashboard calls <Picked API>/mcp-proxy/app/<installation ID>. Picked then sends the request to mcp.url. Picked first checks that the person holds organization_apps/read on the project.

Picked adds three headers to each MCP request: picked-context, picked-installation-id and picked-signature. The body is the JSON-RPC body of the AI agent, without changes. That body does not identify the installation. picked-context identifies it. Picked signs picked-context together with the body.

LimitValue
Time to answer60 seconds
Request body1 MiB
Answer body4 MiB

Picked forwards the content-type, cache-control and mcp-session-id headers of the answer to the AI agent.

Delivery

These rules apply to lifecycle events, app events and tool calls.

RuleValue
Time to answer30 seconds for a tool call, installation.created and installation.upgraded. 15 seconds for an app event and installation.deleted. The time includes resends.
ResendsOnly for a request with an idempotency-key header: app events and tool calls. Picked sends such a request three times at most, after a 408, a 429, a 5xx or no answer.
RedirectsPicked does not go to a new address that a 3xx answer gives. A 3xx answer is not a 2xx answer.
Answer bodyPicked reads 1 MiB of the answer at most.

The endpoint must be a URL that the manifest permits. Before each request, Picked also checks the address:

Picked environmentAllowed addresses
ProductionA host that resolves to public IP addresses only, on port 443, port 80 or no port.
LocalThe same, and also a loopback host on any port.

So an app that you install from the production dashboard must have a public HTTPS endpoint. An http://localhost endpoint works only with a Picked API that runs on your computer.

Installation tokens

An installation token is a credential for the GraphQL API at <apiUrl>/api/graphql. Send it in the X-API-Key header:

POST /api/graphql HTTP/1.1
Host: api.picked.app
Content-Type: application/json
X-API-Key: <token>
PropertyValue
LifeOne hour after Picked makes it.
ScopesThe grantedScopes of the installation.
LabelsReads and writes the labels of the installation, with no scope. Reads secret values.
InstallationReads appInstallation for its own installation, with no scope.

The app gets a token in two ways:

The appInstallationTokenCreate mutation

mutation AppInstallationToken($input: AppInstallationTokenCreateInput!) {
  appInstallationTokenCreate(input: $input) {
    token
    expiresAt
  }
}

Send it to <apiUrl>/api/graphql with a picked-app-assertion token in the picked-app-assertion header. The operation accepts no other credential.

Input fieldTypeDescription
installationIdID!The installation. It must be the sub of the picked-app-assertion token.
sessionTokenStringThe session token of the person that the app answers. Required when the installation has no offlineAccess.
Result fieldTypeDescription
tokenString!The installation token.
expiresAtDateTime!One hour after Picked made the token.
Error messageCause
Authentication requiredThe request has no picked-app-assertion header. The error code is UNAUTHENTICATED.
Authentication failed: The app assertion does not verifyNo installation has the ID in sub. Or no key of the app of that installation signed the token. Or the token has incorrect fields, is expired, or Picked accepted it before. The error code is UNAUTHENTICATED.
The app assertion names another installationinstallationId is not the sub of the token.
The installation has no offline access; use the token Picked sends with each requestThe installation has no offlineAccess, and sessionToken is absent, not valid, or for another installation.

The picked-app-assertion token

The picked-app-assertion token is an EdDSA JWT. The app signs it with its own Ed25519 private key.

Header:

FieldValue
algEdDSA
typJWT
kidThe ID of the public key of the app.

Fields:

FieldTypeValue
substringThe ID of the installation that the app acts for.
audstringThe apiUrl of the Picked API that gets the token.
iatnumberThe time at which the app made the token, in unix seconds.
expnumberThe time of expiry, in unix seconds. @picked/app-kit sets iat plus 60.
jtistringA unique ID. Picked accepts each jti one time only.

Picked refuses the token when exp is more than 300 seconds after iat. It also refuses the token after exp.

This Node.js example makes a token without @picked/app-kit:

import { createHash, createPrivateKey, createPublicKey, randomUUID, sign } from 'node:crypto'
 
const privateKey = createPrivateKey(process.env.PICKED_APP_PRIVATE_KEY.replaceAll('\\n', '\n'))
const publicKey = createPublicKey(privateKey).export({ format: 'jwk' }).x
const kid = createHash('sha256')
  .update(Buffer.from(publicKey, 'base64url'))
  .digest('base64url')
  .slice(0, 16)
 
const encode = (value) => Buffer.from(JSON.stringify(value)).toString('base64url')
 
export function createAppAssertion(installationId, apiUrl) {
  const now = Math.floor(Date.now() / 1000)
  const header = encode({ alg: 'EdDSA', typ: 'JWT', kid })
  const claims = encode({
    sub: installationId,
    aud: apiUrl,
    iat: now,
    exp: now + 60,
    jti: randomUUID(),
  })
  const signature = sign(null, Buffer.from(`${header}.${claims}`), privateKey)
  return `${header}.${claims}.${signature.toString('base64url')}`
}

Public keys of an app

PropertyValue
Private key formatThe base64 of the PKCS#8 DER, on one line. A PKCS#8 PEM also works, and can have \n in place of line breaks.
Public key formatThe base64url of the 32 raw bytes of the Ed25519 public key.
Key IDThe first 16 characters of the base64url of the SHA-256 of the 32 raw bytes.
Keys for each appTwo at most. When an app holds two keys, the next key fails with An app holds at most 2 public keys; remove one before adding another.

picked app keys generate makes a private key and its public key. These register a public key: picked app deploy, picked app dev, appDeploy with publicKey, and appPublicKeyAdd. A key that the app holds already stays as it is. appPublicKeyRemove removes a key. After that, each picked-app-assertion token from that key fails.

Session tokens

A session token is an EdDSA JWT that Picked signs with the same key as its requests. The dashboard gets one with appSessionTokenCreate, and gives it to a page of the app in picked:context.

FieldTypeValue
installationIdstringThe installation.
organizationIdstringThe organization of the project.
projectIdstringThe project.
apiUrlstringThe origin of the Picked API.
userIdstringThe person in the dashboard.
expnumberThe time of expiry, in unix seconds. 600 seconds after Picked made the token.

The header of the token is { "alg": "EdDSA", "typ": "JWT", "kid": "<key id>" }. Verify the token with the public keys of Picked, and refuse it after exp.

appSessionTokenCreate needs a signed-in person who holds organization_apps/read on the project. An API key cannot get a session token.

The server functions of @picked/app-kit read the session token from an Authorization: Bearer <token> header on a request from the page. This is a convention of @picked/app-kit. Picked does not read that request.

Messages between the page and the dashboard

The dashboard shows each slot of the app in an iframe. The page and the dashboard send these messages with postMessage:

MessageFromData
picked:readyThe page{ "type": "picked:ready" }
picked:contextThe dashboard{ "type": "picked:context", "context": FrameContext }
picked:resizeThe page{ "type": "picked:resize", "height": number }
  • The dashboard answers each picked:ready with picked:context, and a new session token.
  • The dashboard sets the height of the iframe to height pixels, and 40 pixels at least. When the page of an app has one app-home slot, its iframe fills the page, and the dashboard ignores height.
  • The dashboard accepts a message only from the iframe of the slot, and only from the origin of the slot url. It sends picked:context only to that origin.

FrameContext:

FieldTypeDescription
installationIdstringThe installation.
organizationIdstringThe organization of the project.
organizationSlugstringThe slug of the organization, as in dashboard URLs.
projectIdstringThe project.
locationstringThe slot location: app-home, workspace-prepublish-actions or workspace-postpublish-actions.
appVersionnumberThe version that the installation uses.
sessionTokenstringA session token for the person and the installation.
themestringlight or dark.

The iframe has the sandbox value allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox. The dashboard does not show a slot whose URL has the same origin as the dashboard, or a URL that does not parse.

The server of the app controls which pages can show its pages in an iframe, with the frame-ancestors directive of its Content-Security-Policy. See frame-ancestors.