Runtime SDK
The sdk prop App Engine passes to every app. Session, input, context and identity; data, files, people and notifications; navigation; and the calls that end a session with or without output.
Your app never imports the runtime. App Engine builds an sdk object for each session and passes it as a prop to the
entry component. Pass it down through props; do not keep it in a React context or a global.
// src/main.jsx
export default function AppEntry({ sdk }) {
return <App sdk={sdk} />;
}What the app receives
sdk.session
| Property | What it is |
|---|---|
id | The session id. |
appId, appSlug | The app definition id and slug. |
launchMode | How the app was opened. See launch modes. |
routePath | The current route inside the app (/ by default). |
sdk.input
The payload the app was opened with, shaped by contracts/input.schema.json. It is {} when there is no input.
const input = sdk.input || {};
const hasInput = Object.keys(input).length > 0;sdk.context
| Property | What it is |
|---|---|
appDefinition | The app definition: name, slug, manifest, routes, contracts. |
appVersion | The active version. |
user | The signed-in identity (the same object as sdk.identity). |
task | The task metadata (priority, assignee, due date) when the app was opened from a task. |
data | Extra context from whoever opened the app. |
sdk.identity
The signed-in Veripass identity, or null while it loads: veripassIdentity, userId, organizationId,
displayName, username, avatarUrl, email and memberships.
Read and write
sdk.api
get(url, params?, options?), post(url, body?, options?), patch(url, body?, options?) and
delete(url, params?, options?). Requests are scoped to the endpoints the app is allowed to call. With
options.withIdentity: true, the request carries the identity headers (Authorization: Bearer <token>, the
organization and the app session).
const items = await sdk.api.get('/items', { status: 'active' });
await sdk.api.patch('/items/123', { status: 'active' });sdk.data
The app’s own record store. Records are always scoped to the app, so an app never reads another app’s records. Writes are optimistic and survive going offline: they are cached and replayed when the connection returns.
| Scope | Shared with |
|---|---|
app | Everyone in the organization who uses the app. |
user-appdata | One person, in one app and one organization. |
user | One person, across organizations. |
const note = await sdk.data.create('notes', {
scope: 'user-appdata',
title: 'Weekly sync',
data: { html: '' },
});
await sdk.data.update(note.id, { data: { html: '<p>Agenda</p>' } }, { expectedRevision: note.revision });
const { items } = await sdk.data.list('notes', { scope: 'user-appdata' });It also offers get, search, remove, restore, getKey and setKey, patch for atomic field operations,
batch for all-or-nothing writes, subscribe for changes and status for the sync state.
sdk.files
Binary content. upload(file, { space }) returns the file id; store the id, not the URL. getUrl(id) returns a
short-lived URL to display or download it.
sdk.directory
People of the active organization: searchPeople(text), listMembers(), listTeams(), listTeamMembers(teamId) and
getUser(identityOrEmail).
sdk.notify(notification)
Shows a host notification (title, body, severity, optional actions, deepLink, tag, duration), filtered by
the person’s notification preferences.
Move around
sdk.navigate(path)switches to another route of the app (/,/list,/settings).sdk.apps.open({ slug, route, input, mode })opens another app of the organization. The app must list the slug inmanifest.opens_apps. It resolves to{ opened: true }or{ opened: false, reason }withreasonnot_allowed,not_found,not_entitledorinvalid_route.sdk.apps.canOpen(slug)andsdk.apps.list()tell you beforehand.
End the session
| Call | What it does |
|---|---|
sdk.submitOutput(payload) | Stores the final output on the session, marks it completed and closes the app. |
sdk.saveDraft(payload) | Saves work in progress; the session stays open. Can be called many times. |
sdk.close() | Closes the app without output. |
sdk.cancel(reason) | Cancels the session without output. |
sdk.submitOutput({
decision: 'approved',
notes: 'All requirements met.',
reviewed_at: new Date().toISOString(),
});Good practice
- Use optional chaining (
sdk?.session?.launchMode): properties may be undefined while the app initializes. - Check the input before you render a view that depends on it.
- Call
saveDraftduring long reviews so people can leave and come back. - Keep the payload of
submitOutputto what consumers need.