# Sempera auth.md

Machine-readable authentication and registration guide for AI agents that want
to use the [Sempera API](https://docs.sempera.org) to build, test and run AI
phone agents for businesses.

## Who this is for

AI agents (and the developers operating them) that want to create agents, read
calls and conversations, or connect an assistant to a Sempera workspace through
`https://api.sempera.org/v1` or the MCP server at `https://api.sempera.org/v1/mcp`.

## Registration

Sempera uses API keys for the REST API and OAuth for assistants that connect
over MCP. Register through either path below:

### Option A: API key (browser)

1. Create a free account: https://app.sempera.org/sign-up
2. As the workspace owner, open Settings > API keys and create a key. The
   secret is shown once; store it server-side.

### Option B: MCP with OAuth (assistants)

Add `https://api.sempera.org/v1/mcp` as a custom MCP server in Claude, ChatGPT,
Codex or another MCP client. The client discovers the authorization server from
`https://api.sempera.org/.well-known/oauth-protected-resource/v1/mcp`, registers
itself, and sends the workspace owner to sign in and approve access. The agent
never approves on the owner's behalf. OAuth grants cover phone tools
(`phone:read`, `phone:call`, `phone:text`) on MCP only and cannot grant
agent-authoring permissions.

To build and test agents over MCP, the owner instead creates a scoped
connection key in Settings > Connected clients and pastes it into the client.

Real-account Claude and ChatGPT connections are unverified in the setup guides.
An assistant must never approve consent on the owner's behalf. OAuth cannot
grant agent-authoring permissions: its tokens are MCP only. Access tokens last
one hour; refresh tokens last 30 days and rotate on use. OAuth uses PKCE S256.
Connecting a client does not activate phone service.

## Using credentials

Send your API key as a bearer token on every request:

```http
GET /v1/me HTTP/1.1
Host: api.sempera.org
Authorization: Bearer <api-key>
```

- Send keys only in the `Authorization: Bearer` header, never in a URL,
  client-side code, a chat, a prompt or a log.
- Keys belong to one workspace and carry explicit scopes (for example
  `agents:read`, `agents:write`, `calls:read`). Missing scope returns 403
  `insufficient_scope`.
- `GET /v1/me` shows what the calling key can do.
- Rotate or revoke keys any time in Settings > API keys.

Never put a workspace key in client-side JavaScript. Create a short-lived
browser conversation token on your server instead. Grant only the scopes the
workflow needs: for example `calls:write`, `phone_numbers:write` or
`webhooks:write`. A scope still requires the matching role and activation checks.
For retryable writes, follow the operation's idempotency rules. Never blindly retry a call with a new idempotency key: check its result first to avoid a duplicate action.

## Machine-readable resources

- API catalog: https://sempera.org/.well-known/api-catalog
- MCP server card: https://sempera.org/.well-known/mcp/server-card.json
- OpenAPI spec: https://api.sempera.org/openapi.json
- Docs for LLMs: https://sempera.org/llms.txt and https://sempera.org/llms-full.txt
- Authentication docs: https://api.sempera.org/docs/authentication.md
- MCP guide: https://api.sempera.org/docs/mcp.md
- OAuth metadata: https://api.sempera.org/.well-known/oauth-authorization-server
- Status: https://status.sempera.org/api/v1/summary

## Support

Humans and agents can reach us via https://sempera.org/demo/ or
hello@sempera.org.
