# Quickstart

The API is `https://api.ordan.io`, which every client uses by default. Set
`ORDAN_API_URL` only for another API. The clients are `ordan-sdk`,
`ordan-cli` and `ordan-mcp` on npm, and `ordan` on PyPI; see
[SDK, CLI and MCP](clients.md). To use ORDan from Claude, Codex, VS Code or
another MCP client, see [Connect your AI client](integrations.md).

**Connecting by URL?**
Use the [hosted connector](mcp-hosted.md) to sign in from your assistant
without installing a local server.

## Agent runtime: human pairing

Pairing gives an agent runtime its own credential under a human-approved
policy and budget. The CLI opens the device flow and prints a pairing
URL/code; the human signs in, reviews the requested capabilities and
budget, chooses the organization, and approves:

```bash
npx -y ordan-cli agents connect --name "Executive Assistant"
```

For direct integration, `POST /v1/oauth/device/authorize`:

```json
{
  "agent_name": "Executive Assistant",
  "requested_capabilities": ["numbers.provision", "voice.outbound", "sms.send", "sms.receive", "policy.check", "usage.read", "events.read"],
  "spend_limit_cents": 2500
}
```

Send the human `verification_uri` and `user_code`. Poll
`POST /v1/oauth/token` with
`grant_type: urn:ietf:params:oauth:grant-type:device_code` and the secret
`device_code`, respecting the returned interval. Handle
`authorization_pending`, `slow_down`, `access_denied`, and `expired_token`.
Keep the credential in the runtime's secret store — never in a prompt or
conversation.

## Owner-authorized server integration

An owner creates a project key in the console. `agents:write` creates
agents; **`grants:write` additionally delegates authority under the owner's
policy** — without it, agent creation does not mint a grant.

```ts
import { Ordan } from "ordan-sdk";
const client = new Ordan({ apiKey: process.env.ORDAN_API_KEY,
  baseUrl: process.env.ORDAN_API_URL });
const agent = await client.agents.create({ name: "Executive Assistant" });
const line = await client.lines.create({ agent: agent.id, country: "US" });
// Real carrier orders may return provisioning. Poll lines.retrieve(line.id)
// until active before using it; do not purchase another number to retry.
```

With an agent credential, omit `agent` — the agent acts as itself. A
project key names the agent when placing calls/texts. Every action needs a
live grant, pinned policy, Line binding, and sufficient budgets.

## Check, act, observe

An agent with `policy.check` can POST `/v1/policies/check` with its own
credential (a project key or a session is refused):

```json
{"action":"sms.send","to":"+12125550101","body":"Appointment confirmed."}
```

This reports policy, segment and cost estimates; it does not authorize or
reserve anything. Execute with `POST /v1/calls` or `/v1/messages`, one
stable `Idempotency-Key` per logical operation. On `approval_required`,
the org's owners and admins are emailed a link to the returned `apr_…`;
once one approves, retry with that `approval` in the body and a **new**
key (the body changed).

Poll calls/messages or subscribe to signed events. See
[errors](errors.md) for blocked/pending recovery and
[webhooks](webhooks.md) for delivery.

A call's `objective` is context and audit data: ORDan never speaks it or
supplies intelligence. On a Line with [ORDan voice](voice.md#ordan-voice),
the agent speaks with `/speak` and listens with `/transcript`.
