# ZenHero — Agent Authentication Guide

Agents can use ZenHero in two modes. Both are self-serve — no human approval step.

## 1. Session mode (user-scoped)

Act as the signed-in user; every tool call is scoped server-side to the session's active
organization. The org cannot be overridden from the client.

- Sign in at https://app.zenhero.io
- MCP endpoint: `POST https://api.zenhero.io/api/mcp`
- Send the session cookie, or `Authorization: Bearer <token>` (JWT/bearer from the auth plugins)

## 2. Machine mode (workspace keys)

For autonomous agents and internal automation:

- Create a key in the ZenHero app under **Settings → API keys** (free, self-serve, org-scoped)
- Header: `x-api-key: sk_ssuite_...`
- Tools accept an explicit `orgId` argument; mismatched scopes are rejected server-side
- Rate limit: 120 requests/minute per identity (429 responses include `Retry-After`)

## 3. OAuth 2.0 / OIDC (RFC 9728)

OAuth is live: **GetAuth is an OAuth 2.0 / OIDC authorization server** with self-serve
(dynamic) client registration, so MCP clients can onboard without a human in the loop.

- **Authorization server discovery:** `GET https://api.getauth.app/.well-known/openid-configuration`
  (issuer metadata, authorization/token endpoints, dynamic registration endpoint)
- **Protected-resource metadata (RFC 9728):** `GET https://api.zenhero.io/.well-known/oauth-protected-resource`
- **Scopes:** `mcp:read`, `mcp:write`
- **401 hint:** unauthenticated MCP calls return `WWW-Authenticate: Bearer resource_metadata=...`

Agent flow: ① read the RFC 9728 document → ② resolve the authorization server → ③ register a
client dynamically (or use a pre-registered client) → ④ complete the OAuth flow → ⑤ call
`POST /api/mcp` with the bearer token.



- MCP pointer document: `GET https://api.zenhero.io/.well-known/mcp`
- Server card with tool schemas: `GET https://api.zenhero.io/.well-known/mcp/server-card.json`
- API catalog (RFC 9727): `GET https://api.zenhero.io/.well-known/api-catalog`
- Agent guidance: [llms.txt](https://zenhero.io/llms.txt)

## Errors and retries

All endpoints return JSON errors (`{ "error": { "code", "message" } }`). Retry on 429 using
`Retry-After`; 5xx are transient — back off exponentially.
