# Onboarding for developers

> The platform pieces Onboarding added for any app: guest sessions, the identity verification connection and its result facts, DSL actions for retention and messages, and calling an app’s own pipelines.

Source: https://docs.ligament.ai/developers/onboarding/

Onboarding is a first-party app built as manifest data (`apps/onboarding`). Where the platform lacked something, the missing piece was added to the platform so other apps can use it. This page describes those pieces. How Onboarding looks to people is in the [Onboarding guide](https://docs.ligament.ai/guides/onboarding/index.md).

## Guest sessions

A [signed link](https://docs.ligament.ai/guides/compliance/evidence-methods/index.md) works once: right for “sign this”, wrong for a portal someone returns to over two weeks. A **guest session** is what a used signed link turns into: a cookie-bound session for one record (the link’s subject), for the email address the link was sent to, with an expiry and revocation.

-   It is created only by a server route that has just consumed a signed link (compare-and-set, so a link starts at most one session). The cookie is `HttpOnly`, `Secure`, `SameSite=Lax` and scoped to the portal’s paths; only the token’s SHA-256 is stored.
-   It expires after 30 days by default (at most 60), never later than the `notAfter` the caller gives (Onboarding: a week after the start date), and can be revoked for the whole subject.
-   It is **not** a member session: `requireAuth`, the records API, API keys, MCP and the CLI ignore it. Code that serves a guest reads and writes the subject record (and what hangs off it) as the system, after checking the session’s subject; record rules still run.

The functions are in `lib/guest-sessions.ts`: `startGuestSession`, `resolveGuestSession`, `endGuestSession`, `revokeGuestSessions` and `guestSessionsOf`.

## Identity verification connections

Identity checks run through the **Verify** app’s case (`verification`) and a provider chosen as a workspace connection of type `identity_verification` (**Settings › Connections**). The connection holds the provider’s API base URL, API key, optional webhook secret, and chip and device policy. Results come from the provider’s signed webhook (`/api/webhooks/attest`, `Attest-Signature` over `t.<body>`, five-minute window) or from a reconcile sweep that asks the provider for cases still open.

To get a check’s facts onto your own record, start the verification with `subjectEntity` and `subjectId`. When the decision arrives, the platform writes the facts, as the system, into the `idv_*` fields your entity declares and no others:

| Field | Fact |
| --- | --- |
| `idv_decision` | `approved`, `rejected`, `resubmission` or `pending` |
| `idv_verified_name`, `idv_birth_date`, `idv_nationality` | From the document (chip where read) |
| `idv_document_type`, `idv_document_country`, `idv_document_expiry` | The document |
| `idv_assurance`, `idv_method` | How strong the check was and how it was done |
| `idv_reference`, `idv_completed_at`, `idv_environment` | The provider’s session reference, when, `live` or `test` |
| `idv_reasons` | Why it was not approved |
| `idv_case` | The Verify case |

The case itself keeps only the decision. Pair the fields with a restriction (`hidden` unless a capability) and `auditReads: true` on the entity, as Onboarding’s `onb_rtw_check` does. E-signature’s identity check for signers uses the same connection.

## DSL additions

| Action or option | What it does |
| --- | --- |
| `attachment.delete` `{ entity, id, reason, nameContains? }` | Deletes a record’s attachments (all, or those whose file name contains `nameContains`) and writes an `attachment.delete` access-audit row with the reason. For retention rules: Onboarding deletes right-to-work copies N years after the leaving date |
| `notify` with `about: 'none'` | Sends the message about no record. By default a `notify` step is about the trigger record, and a recipient who can’t read that record (a plain email address) gets the generic “open it in the app”. Use `about: 'none'` when the text itself is the message and says nothing the recipient may not see |
| `workflow.call` from an app pipeline | Resolves the app’s own pipelines first (with the workspace’s overrides), then the workspace’s automations. An app can keep a “library” pipeline with a `manual` trigger and call it from its event pipelines |
| `onboarding.invite` `{ journeyId, revoke? }` | Onboarding’s own: emails the portal invite for a journey, or closes the portal |
| Date tokens `@start_of_month`, `@end_of_month` | In view and page filters, next to `@today` and `@today+30d` |

## Two things to know when writing an app like this

-   **Classified fields are masked unless a permission set lists them.** A field with `classification: 'sensitive'` (or `pii`) is `masked` for a set that grants the entity without naming the field. Give the people who need the value an explicit level (`read` or `write`) in their set’s `fields`; use a restriction for “everyone else, admins included”.
-   **Every event-triggered pipeline run counts**, even one whose `where` or `fields` filter then skips it: the filter runs inside the run, and runs count against the plan’s rate limit (the Free plan allows 10 a minute). Prefer one pipeline per entity event with `if` branches over several pipelines on the same event.
