Authentication

Cleos API routes expect an authenticated staff user tied to an organization and branch. There is no POST /api/auth/login REST endpoint; the web app login flow issues the JWT.

Bearer token

Pass the JWT in the Authorization header:

Authorization: Bearer YOUR_JWT

The token is validated on each route via getAuthContextForRequest in the Cleos app. Missing or invalid tokens return:

{
  "error": "Unauthorized"
}

with HTTP status 401.

Browser / same-origin requests

When calling /api from the Cleos SPA on the same origin, the auth-token HTTP-only cookie is sent automatically with credentials: "include". Integrations running outside the browser should use the bearer header.

Session contents

A successful auth context includes:

  • Name
    organizationId
    Type
    string
    Description

    Active organization for the session.

  • Name
    currentBranchId
    Type
    string
    Description

    Branch scope for list and create operations.

  • Name
    roles
    Type
    array
    Description

    Effective roles used for legacy permission checks.

  • Name
    deniedKeys
    Type
    array
    Description

    Permission keys denied by the user's custom role (allow-by-default model).

  • Name
    isCentralized
    Type
    boolean
    Description

    Whether org centralization features apply.

Use GET /api/auth/me to inspect the resolved user and scope.

OAuth account linking

Google and Microsoft OAuth are available under /api/auth/oauth/* for linking accounts to an existing Cleos user, not for standalone API access without a Cleos JWT.

Was this page helpful?