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.
| Request | Method and URL | When Picked sends it |
|---|---|---|
| Lifecycle event | POST <endpoint>/lifecycle | After a person installs or upgrades the app on a project, and before a person removes it. |
| App event | POST <endpoint>/events | After an event that the manifest lists in events. |
| Workflow tool call | POST <endpoint>/tools/<name> | When a workflow node runs the tool <name> of the manifest. |
| MCP request | POST, GET or DELETE <mcp.url> | When the AI agent in the dashboard uses the MCP server of the app. |
Headers
| Header | On | Value |
|---|---|---|
picked-signature | All requests | t=<unix seconds>,kid=<key id>,v1=<signature>. See The picked-signature header. |
picked-installation-id | All requests | The ID of the installation, for example appi_…. |
picked-context | MCP requests | The base64url of the JSON of an InstallationRef. |
content-type | Lifecycle events, app events, tool calls | application/json. |
accept | Lifecycle events, app events, tool calls | application/json. |
idempotency-key | App events, tool calls | The same value on each resend of one request. |
user-agent | Lifecycle events, app events, tool calls | Picked/1.0 (+https://picked.app). |
user-agent | MCP requests | PickedMcpProxy/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:
| Part | Value |
|---|---|
t | The time at which Picked signed, in unix seconds. |
kid | The ID of the Picked key that signed. |
v1 | The 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
v1over the signed text. tis 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"
}
]
}| Field | Value |
|---|---|
kid | The key ID: the first 16 characters of the base64url of the SHA-256 of the 32 raw bytes of the public key. |
x | The 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"] }| Field | Value |
|---|---|
dashboardOrigins | The 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.
| Field | Type | Description |
|---|---|---|
installationId | string | The ID of the installation, for example appi_…. |
organizationId | string | The ID of the organization of the project. |
projectId | string | The ID of the project that the app is installed on. |
apiUrl | string | The origin of the Picked API that sent the request, for example https://api.picked.app. |
token | string | A new installation token. See Installation tokens. |
tokenExpiresAt | string | The 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.
type | Other fields | When |
|---|---|---|
installation.created | scopes: the scopes of the installation, as string[]. | After Picked adds a new installation. |
installation.upgraded | version: the new version number, as number. scopes: the new scopes, as string[]. | After Picked moves the installation to a new version. |
installation.deleted | None. | 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:
| Event | A 2xx answer | Other answers, or no answer |
|---|---|---|
installation.created | Picked keeps the installation. | Picked removes the installation. The installation fails with <name> did not accept the installation (it answered <status>). |
installation.upgraded | Picked 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.deleted | Picked 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.
| Field | Type | Description |
|---|---|---|
type | string | workspace.published. |
eventId | string | The ID of the event. It is the same on each resend. |
workspaceId | string | The workspace that was published. |
workspaceVersionId | string | The version that Picked wrote when it published the workspace. |
occurredAt | string | The 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.
| Field | Type | Description |
|---|---|---|
type | string | workflow_tool.call. |
tool | string | The name of the tool, as the manifest declares it. |
arguments | object | The arguments of the node, after Picked resolves them. |
idempotencyKey | string | <runId>:<nodeId>. The same key is the same call. Picked also sends it as the idempotency-key header. |
run.runId | string | The ID of the workflow run. |
run.nodeId | string | The ID of the node that calls the tool. |
run.test | boolean | true 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 } }| Answer | Result in the run |
|---|---|
2xx with an output object | The node records output. |
5xx | The node fails with the app answered <status>. The failure has retryable: true. |
Any other status, or a 2xx with no output object | The node fails with the app answered <status>. The failure has retryable: false. |
| No answer | The 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.
| Limit | Value |
|---|---|
| Time to answer | 60 seconds |
| Request body | 1 MiB |
| Answer body | 4 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.
| Rule | Value |
|---|---|
| Time to answer | 30 seconds for a tool call, installation.created and installation.upgraded. 15 seconds for an app event and installation.deleted. The time includes resends. |
| Resends | Only 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. |
| Redirects | Picked does not go to a new address that a 3xx answer gives. A 3xx answer is not a 2xx answer. |
| Answer body | Picked 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 environment | Allowed addresses |
|---|---|
| Production | A host that resolves to public IP addresses only, on port 443, port 80 or no port. |
| Local | The 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>| Property | Value |
|---|---|
| Life | One hour after Picked makes it. |
| Scopes | The grantedScopes of the installation. |
| Labels | Reads and writes the labels of the installation, with no scope. Reads secret values. |
| Installation | Reads appInstallation for its own installation, with no scope. |
The app gets a token in two ways:
- In the
tokenfield of each request from Picked. - From
appInstallationTokenCreate, with apicked-app-assertiontoken.
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 field | Type | Description |
|---|---|---|
installationId | ID! | The installation. It must be the sub of the picked-app-assertion token. |
sessionToken | String | The session token of the person that the app answers. Required when the installation has no offlineAccess. |
| Result field | Type | Description |
|---|---|---|
token | String! | The installation token. |
expiresAt | DateTime! | One hour after Picked made the token. |
| Error message | Cause |
|---|---|
Authentication required | The request has no picked-app-assertion header. The error code is UNAUTHENTICATED. |
Authentication failed: The app assertion does not verify | No 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 installation | installationId is not the sub of the token. |
The installation has no offline access; use the token Picked sends with each request | The 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:
| Field | Value |
|---|---|
alg | EdDSA |
typ | JWT |
kid | The ID of the public key of the app. |
Fields:
| Field | Type | Value |
|---|---|---|
sub | string | The ID of the installation that the app acts for. |
aud | string | The apiUrl of the Picked API that gets the token. |
iat | number | The time at which the app made the token, in unix seconds. |
exp | number | The time of expiry, in unix seconds. @picked/app-kit sets iat plus 60. |
jti | string | A 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
| Property | Value |
|---|---|
| Private key format | The 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 format | The base64url of the 32 raw bytes of the Ed25519 public key. |
| Key ID | The first 16 characters of the base64url of the SHA-256 of the 32 raw bytes. |
| Keys for each app | Two 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.
| Field | Type | Value |
|---|---|---|
installationId | string | The installation. |
organizationId | string | The organization of the project. |
projectId | string | The project. |
apiUrl | string | The origin of the Picked API. |
userId | string | The person in the dashboard. |
exp | number | The 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:
| Message | From | Data |
|---|---|---|
picked:ready | The page | { "type": "picked:ready" } |
picked:context | The dashboard | { "type": "picked:context", "context": FrameContext } |
picked:resize | The page | { "type": "picked:resize", "height": number } |
- The dashboard answers each
picked:readywithpicked:context, and a new session token. - The dashboard sets the height of the
iframetoheightpixels, and 40 pixels at least. When the page of an app has oneapp-homeslot, itsiframefills the page, and the dashboard ignoresheight. - The dashboard accepts a message only from the
iframeof the slot, and only from the origin of the sloturl. It sendspicked:contextonly to that origin.
FrameContext:
| Field | Type | Description |
|---|---|---|
installationId | string | The installation. |
organizationId | string | The organization of the project. |
organizationSlug | string | The slug of the organization, as in dashboard URLs. |
projectId | string | The project. |
location | string | The slot location: app-home, workspace-prepublish-actions or workspace-postpublish-actions. |
appVersion | number | The version that the installation uses. |
sessionToken | string | A session token for the person and the installation. |
theme | string | light 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.
Related
- About app authentication — why the protocol has this design.
@picked/app-kit— the functions that implement it.- App manifest —
endpoint,workflowTools,mcp,eventsandslots. - Authentication — the other credentials of the API.
