Skip to main content
Documentation
Docs
Esc

    Loading the search index…

    Authentication

    The three credentials the Pagebread API accepts, for workspace members, applicants and portal members, and how each is obtained.

    The API has three kinds of caller, and each has its own credential. They are kept strictly apart: a member session never opens a console route, and a console token never opens the member portal.

    CallerCredentialRefused with
    A person in your workspaceAuthorization: Bearer <access token>401 UNAUTHORIZED
    An applicant filling in a formX-Applicant-Secret: <secret> on their own draft404 NOT_FOUND
    A member in the member portalThe pagebread_member_session cookie401 MEMBER_UNAUTHENTICATED

    Console routes: bearer access tokens

    Console routes take the access token of a signed-in Pagebread account in the Authorization header. This is the token Pagebread's sign-in (Supabase Auth) issues when someone signs in to the console. An API key is not accepted here: API keys are for the public API at /v1.

    bash
    curl "$PAGEBREAD_API/api/v2/policies?page=1&per_page=20" \
      -H "Authorization: Bearer $TOKEN"

    On every request the server:

    1. verifies the token with the identity provider (an expired, revoked or unverifiable token is 401 UNAUTHORIZED, with the same body whatever the cause; when the identity provider can't be reached, times out or is rate-limiting, the answer is 503 AUTH_UNAVAILABLE with Retry-After, and the token is not treated as invalid);
    2. finds the workspace this account is a member of, and its role there;
    3. checks the role has the permission the route needs.

    Nothing in the request can choose the workspace or the role. A record in another workspace, a record that doesn't exist and an action your role doesn't allow all answer 404 NOT_FOUND. See Security overview.

    Warning

    An access token acts as the person it belongs to, with their role. Treat it like a password, and expect it to expire: refresh it the way the sign-in library does rather than storing it.

    Other refusals you may meet on console routes:

    CodeStatusMeaning
    PROFILE_INCOMPLETE403The workspace profile must be completed first.
    CREATOR_ACCOUNT403The account is a marketplace creator account, which has no workspace.
    WORKSPACE_SUSPENDED403The workspace is read-only; reads still work.
    READ_ONLY_CONSOLE503Pagebread is in maintenance; reads still work.
    AUTH_UNAVAILABLE503The sign-in couldn't be checked right now. Retry after Retry-After.
    ORGANIZATION_UNAVAILABLE503Your workspace, or its profile, couldn't be loaded right now. This includes GET /api/v2/organizations/me, the onboarding routes and accepting an invitation. Retry after Retry-After.

    Deleting an account (DELETE /api/v2/account) also needs a token from a sign-in in the last 5 minutes, or it answers 403 REAUTHENTICATION_REQUIRED.

    Applicant routes: the draft secret

    Someone applying through a public link has no account. Instead, the draft they start is protected by a secret.

    Start a draft

    POST /api/v2/submissions with the flow's id. The response returns the secret once, in meta.applicant_secret. Only a hash of it is stored, so it can't be shown again.

    Present it on every change

    Send the secret in the X-Applicant-Secret header on PATCH /api/v2/submissions/:id, POST /api/v2/submissions/:id/answers and POST /api/v2/submissions/:id/documents.

    Submit

    PATCH the draft with "status": "submitted". After that the applicant can no longer change it, except to answer an open request for changes.

    bash
    # Start a draft
    curl -X POST "$PAGEBREAD_API/api/v2/submissions" \
      -H "Content-Type: application/json" \
      -d '{"flow_id": "<flow id>"}'
    # → { "data": { "id": "<submission id>", … }, "meta": { "applicant_secret": "<secret>" } }
    
    # Save answers with the secret
    curl -X POST "$PAGEBREAD_API/api/v2/submissions/<submission id>/answers" \
      -H "Content-Type: application/json" \
      -H "X-Applicant-Secret: <secret>" \
      -d '{"answers": [{"field_key": "full_name", "value": "Asha Rao"}]}'

    A missing or wrong secret answers exactly as if the submission didn't exist: 404 NOT_FOUND. A submission that has left the applicant's hands answers 409 SUBMISSION_LOCKED. When the organization can't take new applications, starting a draft answers 409 FORM_PAUSED.

    Members sign in to the portal with a one-time link sent by email.

    POST /api/v2/public/members/magic-links with {"email": "…"}. The answer is always 202, whether or not the address is on a roster, so it reveals nothing. If it is, each organization whose roster has the address sends its own link.

    Redeem it

    The link opens the member portal, which sends its token to POST /api/v2/public/members/sessions with {"token": "…"}. A valid link starts a session and sets the pagebread_member_session cookie: HTTP-only, SameSite=Lax, for 14 days. Links last 30 minutes and work once. An expired, used or unknown link always answers the same 400 INVALID_MAGIC_LINK.

    Use the session

    Routes under /api/v2/public/members/ read the member from the cookie, for example GET /api/v2/public/members/me. DELETE /api/v2/public/members/sessions signs out.

    bash
    curl -X POST "$PAGEBREAD_API/api/v2/public/members/sessions" \
      -H "Content-Type: application/json" \
      -c cookies.txt \
      -d '{"token": "<token from the link>"}'
    
    curl "$PAGEBREAD_API/api/v2/public/members/me" -b cookies.txt

    Important

    A change sent with the member cookie from a page whose origin Pagebread doesn't allow is refused with 403 ORIGIN_NOT_ALLOWED. Browsers can only use the member session from Pagebread's own pages.

    Sign-in requests are rate limited per address and per client; see Rate limits.