---
agent_auth: bearer
auth_type: oauth2
token_format: vbm_
token_issuer: workspace (human-created MCP token) or OAuth authorization server
header: Authorization
mcp_endpoint: https://mcpbrain.valor.digital/mcp
oauth_discovery: https://valorbrain.valor.digital/.well-known/oauth-authorization-server
protected_resource: https://valorbrain.valor.digital/.well-known/oauth-protected-resource
---

> Note: this domain is ValorBrain's public website. The service described here runs on other hosts: MCP at https://mcpbrain.valor.digital/mcp, the engine REST API at https://valorbrain-api.valor.digital and the app (OAuth, ingest, dashboard) at https://valorbrain.valor.digital. The endpoints below point to them.


# auth.md — ValorBrain authentication for agents

New agent? The step-by-step onboarding (agent signup, per-client MCP setup,
verification with `memory_prepare`) is https://valorbrain.si/connect.md.

<!-- credential-matrix sha=1e1ecfce3a57 body=c7633b196f98: generated by valorbrain scripts/credential-docs.ts from src/credential-matrix.ts, do not edit -->
## Credentials and where each one works

Generated from the [credential matrix](https://valorbrain-api.valor.digital/.well-known/valorbrain-credentials.json) · version 1 · sha `1e1ecfce3a57`. Do not edit by hand: the source is `src/credential-matrix.ts` in the engine.

| Credential | Prefix and format | Who holds it | Accepted on | Refused on | Client env var |
|---|---|---|---|---|---|
| MCP token | `vbm_<65 base62 chars> (69 chars)` | Agent or person | MCP (Streamable HTTP), Engine REST, SaaS ingest, OAuth consent (pasted token), OAuth revocation (RFC 7009) | — | `VALORBRAIN_MCP_TOKEN` |
| Agent account key | `vb_agent_<random>` | Agent account (legacy) | Engine REST, OAuth consent (pasted token) | MCP (Streamable HTTP) (401 `wrong_credential_type`); SaaS ingest (401 `invalid_token`) | `VALORBRAIN_API_KEY` |
| Service key | `vb_<tenant-slug>_<random>` | Server-to-server service | Engine REST, OAuth consent (pasted token) | MCP (Streamable HTTP) (401 `wrong_credential_type`); SaaS ingest (401 `invalid_token`) | — |
| Workspace ingest key | `fk_<key-id>.sk_<secret>` | Server-to-server service | SaaS ingest | MCP (Streamable HTTP) (401 `wrong_credential_type`); Engine REST (401 `Unauthorized`) | — |
| Dashboard session | `cookie HttpOnly` | Person in a browser | SaaS dashboard | — | — |

Do not substitute one for another. `vbm_` is the client credential: MCP at https://mcpbrain.valor.digital/mcp, engine REST at https://valorbrain-api.valor.digital and the SaaS ingest. The tenant comes from the credential, never from a header.

| Variable | Holds |
|---|---|
| `VALORBRAIN_MCP_TOKEN` | `vbm_` token |
| `VALORBRAIN_API_KEY` | REST key (`vb_agent_`) |
| `VALORBRAIN_API_URL` | REST base (default https://valorbrain-api.valor.digital) |
| `VALORBRAIN_MCP_URL` | MCP URL (default https://mcpbrain.valor.digital/mcp) |

Older names still read, with a deprecation warning: `VALORBRAIN_TOKEN`, `VALORBRAIN_API_TOKEN`.

Validity, revocation and rotation: https://docs.valorbrain.com.br/en/docs/api/token-lifecycle. Rate limits: https://docs.valorbrain.com.br/en/docs/api/rate-limits. Error codes: https://docs.valorbrain.com.br/en/docs/api/errors. Machine-readable matrix: https://valorbrain-api.valor.digital/.well-known/valorbrain-credentials.json.
<!-- /credential-matrix -->

## MCP and memory tools

- MCP endpoint: https://mcpbrain.valor.digital/mcp
- Engine REST endpoint: https://valorbrain-api.valor.digital
- OAuth discovery: https://valorbrain.valor.digital/.well-known/oauth-authorization-server
- Protected resource metadata: https://valorbrain.valor.digital/.well-known/oauth-protected-resource
- Credential: a `vbm_…` MCP token (direct or issued by OAuth)
- Header: `Authorization: Bearer <token>`

Prefer OAuth when the client supports it. A human can create a dedicated MCP token
at https://valorbrain.valor.digital/settings/mcp-tokens. The same scoped `vbm_…` token works on
MCP, engine REST and SaaS ingest. It carries tenant, user and agent scope. A
`vb_agent_…`, `vb_…` or `fk_…` key on MCP gets 401 `wrong_credential_type`. Call `whoami` after
connecting and stop if the workspace or user is wrong.

## Public SaaS ingest

- Endpoint: `POST https://valorbrain.valor.digital/api/v1/ingest`
- Credential: a `vbm_…` MCP token (direct or issued by OAuth), or a workspace
  ingest key `fk_….sk_…`
- Header: `Authorization: Bearer <token>`
- Scope: a `vbm_…` token needs `write`. Without it the answer is 403 with
  `error="insufficient_scope"`.
- Contract: https://valorbrain.valor.digital/openapi.json

The workspace it writes to comes from the credential, never from a header. On 401
and 403 the response carries `WWW-Authenticate: Bearer …,
resource_metadata="https://valorbrain.valor.digital/.well-known/oauth-protected-resource"`, which
is where an unauthenticated client starts.

A workspace ingest key (`fk_…`) works only on the SaaS ingest endpoint. It is not
an MCP token and does not authenticate engine REST or dashboard routes.

## Device authorization for engine REST

A headless client can request a device code from
`POST https://valorbrain.valor.digital/api/v1/cli/device/code`. A human approves the displayed
code at the returned verification URL. The client polls
`POST https://valorbrain.valor.digital/api/v1/cli/device/token` and receives a `vb_…` engine
REST token once. It is a service key for engine REST, not an MCP credential: MCP
refuses it with 401 `wrong_credential_type`. For MCP, use a `vbm_…` token.

## Dashboard session

Dashboard APIs use the signed web session cookie. They are not a stable public
integration contract. Use MCP, engine REST or SaaS ingest for agents and external
systems.

Never put a token in prompts, source control, third-party logs or shared memory.
The one deliberate exception is delivery: `init --agent` prints the generated
key once, in full, so the agent can store it in its own local config (0600) —
that is the credential reaching its owner, not a leak. One token per person,
any harness and persona: agents identify themselves through the contract
headers (`X-Source-Agent`, `X-ValorBrain-Harness`, `X-Run-Kind`, `X-Requested-By`, `X-Agent-Team`),
never through a token per agent. Gateway and integration credentials exist for
systems without a person.
