> ## Documentation Index
> Fetch the complete documentation index at: https://docs.deepest.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Authenticate Human and Agent requests

> Use the right Bearer credential on the Deepest control API and distinguish Agent-eligible operations from Human-only controls.

Deepest control API endpoints accept Bearer authentication from two distinct identities: an **Agent API Key** for automated operations, or an **authenticated Human session** from the Web Console. They are not interchangeable.

Passing authentication checks identity only—every operation still verifies resource ownership, active entitlement, and capacity.

## Choose the right credential

| Credential | Scope & Permissions | Cannot Do |
| - | - | - |
| **Agent API Key** | Account-wide automation across Machine lifecycle, Exec, Resources, SSH, Tools, Preview, Share, Desktop, and Vault operations | Manage Agent Keys, redeem invitations, submit human-assistance input signals, or manage billing/admin |
| **Current Human session** | All public Account operations for the signed-in Account, including Human-only controls | Access another Account or platform administration |
| **Preview / Share / Viewer URL** | Narrow runtime access to one Guest port or Desktop Viewer | Authenticate any control API endpoint |
| **SSH key** | Interactive shell, SFTP, and local TCP forwarding on one authorized Computer | Call control API endpoints |

### Human-only operations

Only a current Human session (used directly in the [Deepest Console](https://console.deepest.dev) or via an authorized Human-session client) can invoke these operations:

* `agentKeys.list`, `agentKeys.create`, `agentKeys.revoke`
* `invites.redeem`
* `computer(id).assistance.begin`, `computer(id).assistance.touch`, `computer(id).assistance.complete`

An Agent can call `assistance.request()` and `assistance.get()`, and must never obtain or replay a human session token to impersonate a user.

## Authenticate with an Agent API Key

> [tab] TypeScript SDK
>
> Run from a trusted server or local process with `@deepest/sdk` installed:
>
> ```js theme={null}
> import { Deepest } from "@deepest/sdk";
>
> const deepest = new Deepest({
>   baseUrl: process.env.DEEPEST_API_URL,
>   apiKey: process.env.DEEPEST_API_KEY,
> });
>
> const reply = await deepest.resources.get();
> if (!reply.ok) {
>   throw new Error(`${reply.error.code} (${reply.retry})`);
> }
> console.log("Account:", reply.result.account_id);
> ```

> [tab] Raw HTTP
>
> Send JSON requests to your control API origin (`https://console.deepest.dev` by default) with a Bearer token and redirect checks disabled:
>
> ```http theme={null}
> GET /v1/resources HTTP/1.1
> Host: console.deepest.dev
> Authorization: Bearer <AGENT_API_KEY>
> Accept: application/json
> ```
>
> From Node.js `fetch`, keep `redirect: "error"` and `credentials: "omit"`:
>
> ```js theme={null}
> const response = await fetch(new URL("/v1/resources", process.env.DEEPEST_API_URL), {
>   method: "GET",
>   redirect: "error",
>   credentials: "omit",
>   headers: {
>     Authorization: `Bearer ${process.env.DEEPEST_API_KEY}`,
>     Accept: "application/json",
>   },
> });
> const reply = await response.json();
> if (!response.ok || reply.ok !== true) {
>   throw new Error("Inspect error.code and retry; never log credentials.");
> }
> console.log("Account:", reply.result.account_id);
> ```

> [!NOTE]
>
> **Human-session SDK mode:** For interactive browser apps operating under a live Human sign-in session, the SDK constructor accepts `getSessionToken: async () => ...` instead of `apiKey`. The SDK calls `getSessionToken` per request without caching tokens. Supply **exactly one** of `apiKey` or `getSessionToken`—passing both or neither throws a client-side `TypeError`. Never ask users to copy session tokens into a terminal or Agent prompt.

## Keep control and runtime credentials separate

> [!WARNING]
>
> **Control vs. Runtime origins:** Control credentials (Agent API Keys and Human session tokens) belong strictly on the control origin (`https://console.deepest.dev` or your configured control host). Never attach `Authorization` headers or control cookies to Preview, Share, or Viewer runtime URLs, and never follow redirects on authenticated control requests—the SDK sets `redirect: "error"` and `credentials: "omit"` by default.

## Diagnose authentication failures

| Error / Symptom | Meaning & Next Step |
| - | - |
| `UNAUTHORIZED` (401) | Missing, invalid, or revoked credential, or calling a Human-only operation with an Agent API Key |
| `AUTH_UNAVAILABLE` (503, `retry: "safe"`) | Human session verification was temporarily unavailable; nothing was dispatched—retry safely after recovery |
| `NOT_FOUND` (404) | Asset does not exist in the authenticated Account; verify target ID without probing other tenants |
| `ENTITLEMENT_REQUIRED` (403) | Identity succeeded, but the Account lacks active compute entitlement; check `resources.get()` |
| Client `UNKNOWN` | Could be transport failure or invalid response rather than bad credentials; verify `baseUrl` and query the target resource |

Signing out of the Console does not revoke issued Agent Keys, and revoking an Agent Key does not delete or stop existing Computers. See [Agent Keys](https://docs.deepest.dev/account/agent-keys.md) and [Isolation and credentials](https://docs.deepest.dev/security/isolation-and-credentials.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.