> For the complete documentation index, see [llms.txt](https://sonic-ai-works.gitbook.io/sonic-networks-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sonic-ai-works.gitbook.io/sonic-networks-docs/api-reference/auth-and-access-context-api.md).

# Auth & Access Context API

Canonical SONIC v1.0.0 Auth Context, SaaS Context and route-aware Access Context contracts with Developer role, entitlements and AAL-aware policy projections.

**Status:** `Preview / Development` unless an endpoint is promoted to `Live` or `Verified`.

```
/api/v1/auth/context
  who is authenticated?

/api/v1/saas/me
  what workspace/subscription/entitlements are available?

/api/v1/access/context?path=<internal-path>
  may this principal access this route/resource now?
```

## Auth Context

```ts
type WorkspaceRole =
  | "OWNER"
  | "ADMIN"
  | "CREATOR"
  | "DEVELOPER"
  | "FINANCE"
  | "MODERATOR"
  | "MEMBER"
  | "VIEWER";

type AuthContext = {
  authenticated: boolean;
  user: { id: string; displayName?: string; email?: string } | null;
  workspace: { id: string; slug?: string } | null;
  role: WorkspaceRole | null;
  permissions: string[];
  aal: 0 | 1 | 2 | 3;
  verifiedWalletCount: number;
  authorityRevision: string;
};
```

Provider claims, raw session tokens, wallet signatures, API-key secrets and internal security metadata are never returned.

## SaaS Context

Plan/subscription state projects product entitlements. It does not grant operational authority.

```
subscription → entitlements
workspace role → permissions
resource/policy/AAL → final decision
```

A Developer can therefore have `developer.portal.read` but still lack a paid entitlement for a premium provider feature; conversely Premium does not create Developer/Admin authority.

## Access Context

Representative fields:

```
path
allowed
role
permissions
entitlements
aal
requiredPermissions
requiredEntitlements
requirements
decision.reason
decision.redirectTo
policyVersion
authorityRevision
```

Recommended reasons include `UNAUTHENTICATED`, `WORKSPACE_REQUIRED`, `ROLE_REQUIRED`, `PERMISSION_REQUIRED`, `ENTITLEMENT_REQUIRED`, `AAL_REQUIRED`, `FEATURE_DISABLED`, `PATH_NOT_ALLOWED` and `ALLOWED`.

## Developer examples

```
/app/developers
  DEVELOPER + developer.portal.read

/app/developers/api-keys
  developer.api_key.read

create/rotate/revoke key
  developer.api_key.manage + fresh auth when policy requires

/app/developers/webhooks
  developer.webhook.read/manage
```

`allowed: true` is a UI projection, not a reusable capability token. Destination mutations re-authorize.

## Caching

```http
Cache-Control: private, no-store, max-age=0
Vary: Cookie, Authorization
```

Refresh after session, workspace, membership, role, permission, entitlement, verified-wallet or policy-revision changes.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://sonic-ai-works.gitbook.io/sonic-networks-docs/api-reference/auth-and-access-context-api.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
