# Keys and scopes

> Agent SDK keys, admin SDK keys, and organization API keys: which to use, what each scope allows, and how to create and revoke keys.

- Human URL: https://conto.finance/docs/sdk/authentication
- Raw Markdown: https://conto.finance/docs/sdk/authentication.md
- Terminal view: https://conto.finance/ai/docs/sdk/authentication

Documentation group: Integrate

Conto SDK requests authenticate with agent-specific SDK keys:

```text
conto_agent_[64-character-hex-string]
```

Every SDK key belongs to exactly one agent and always expires: the default lifetime is **365 days** and the maximum is **730 days**.

## Choose the right credential

| Credential               | Format            | Best for                                                                                 | Notes                                            |
| ------------------------ | ----------------- | ---------------------------------------------------------------------------------------- | ------------------------------------------------ |
| **Standard SDK key**     | `conto_agent_...` | The agent payment lifecycle (request, execute, approve, confirm) plus agent-scoped reads | Works with the `Conto` client                    |
| **Admin SDK key**        | `conto_agent_...` | Agents that also manage agents, wallets, or policies                                     | Still an agent key. Not accepted by `ContoAdmin` |
| **Organization API key** | `conto_...`       | Backend/admin automation across the whole organization                                   | Use with `ContoAdmin`                            |

Info:

  [`ContoAdmin`](https://conto.finance/docs/sdk/admin) requires an **organization API key** from **Developers > API keys**.
  Admin SDK keys can call elevated HTTP API endpoints, but `ContoAdmin` rejects them.

## Generate SDK keys

### Via dashboard

Go to **Agents** and select the agent that will use the key.

Open the **Connect** tab and click **Generate SDK key**.

    Select **Standard** for the payment lifecycle plus read access, or **Admin** if the agent also
    manages agents, wallets, or policies. Only organization owners and admins can create admin keys.

    Choose 30, 90, or 180 days, 1 year (the default), or 2 years (the maximum).

      The full key is shown only once. Store it in your secrets manager before closing the dialog.

### Via API

```bash
curl -X POST https://conto.finance/api/agents/{agentId}/sdk-keys \
  -H "Authorization: Bearer $CONTO_ORG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Production Key",
    "expiresInDays": 90,
    "keyType": "standard"
  }'
```

**Response**

```json
{
  "id": "cmm5d0key000l49h7entvd11p",
  "key": "conto_agent_abc123def456...",
  "name": "Production Key",
  "keyType": "standard",
  "scopes": [
    "payments:request",
    "payments:execute",
    "payments:approve",
    "payments:confirm",
    "wallets:read",
    "policies:read",
    "transactions:read",
    "counterparties:read",
    "alerts:read",
    "agents:read",
    "analytics:read",
    "network:read"
  ],
  "message": "Save this key now! It will not be shown again."
}
```

To create an admin key with `"keyType": "admin"`, the organization API key needs the `admin` or
`team:write` scope.

## Scopes

A scope authorizes an operation. Wallet links, policies, spend limits, approvals, and resource
ownership still decide what a key can pay.

### Agent key presets

Standard is the default. x402 and MPP recording require `payments:execute`, not
`transactions:write`, so they work with a standard key.

| Scope                  | Standard | Admin | Operation                                                                                          |
| ---------------------- | -------- | ----- | -------------------------------------------------------------------------------------------------- |
| `payments:request`     | Yes      | Yes   | Request authorization and protocol pre-authorization                                               |
| `payments:execute`     | Yes      | Yes   | Execute approved managed payments and record x402/MPP settlement                                   |
| `payments:approve`     | Yes      | Yes   | Authorize an external-wallet payment                                                               |
| `payments:confirm`     | Yes      | Yes   | Confirm an externally executed payment                                                             |
| `wallets:read`         | Yes      | Yes   | Read wallets, spending limits, and budget requests                                                 |
| `policies:read`        | Yes      | Yes   | Read assigned policies                                                                             |
| `transactions:read`    | Yes      | Yes   | Read transactions and payment status                                                               |
| `counterparties:read`  | Yes      | Yes   | Read counterparty relationships                                                                    |
| `alerts:read`          | Yes      | Yes   | Read alerts                                                                                        |
| `agents:read`          | Yes      | Yes   | Read the agent and setup summary                                                                   |
| `analytics:read`       | Yes      | Yes   | Read analytics and protocol budget/service summaries                                               |
| `network:read`         | Yes      | Yes   | Read network trust                                                                                 |
| `audit:read`           | No       | Yes   | Read audit logs                                                                                    |
| `alerts:write`         | No       | Yes   | Respond to alerts                                                                                  |
| `transactions:write`   | No       | Yes   | Retry a definitive failed transfer (also requires `payments:execute`)                              |
| `counterparties:write` | No       | Yes   | Create and update counterparties                                                                   |
| `merchant:purchase`    | No       | Yes   | Let Conto complete a card checkout for one approved cart (off unless enabled for the organization) |
| `policies:exceptions`  | No       | Yes   | Request policy changes for review                                                                  |
| `agents:write`         | No       | Yes   | Create and update agents in the organization                                                       |
| `wallets:write`        | No       | Yes   | Create and update wallets in the organization                                                      |
| `policies:write`       | No       | Yes   | Create and update policies in the organization                                                     |

### Admin SDK keys

Admin keys add the scopes that Standard lacks: audit reads, write access to agents, wallets,
policies, counterparties, and alerts, retries of failed transfers, policy change requests, and
`merchant:purchase` (off unless Conto enables it for your organization). On organization endpoints
an admin key acts with Manager permissions for the whole organization. Admin keys do not include
team management, organization settings, or the organization `admin` super-scope, and an admin key
cannot create another admin SDK key.

An admin key never loosens its own agent's controls. It cannot change its own profile, wallet links,
limits, freeze settings, or card access. On any agent, it cannot change the owner, assign or edit card
access, or resume paused card access. It can still pause, and revoke another agent's card access.
It cannot add, change, test, or delete notification channels.
Make those changes in the dashboard or with an organization API key.

An admin key can only tighten policies, including the ones that govern its own agent. It can create
a policy, add rules, lower an amount limit, rename a policy, and turn a policy on. It cannot turn a
policy off, change its priority or scope, delete it, raise a limit, delete or otherwise loosen its
rules, or roll it back. Conto refuses those with `403` and code `AGENT_KEY_TIGHTEN_ONLY`. The agent
proposes them with `POST /api/sdk/owner-actions`, and an owner confirms each one on a review page.

### Organization API key scopes

Only Owners create organization API keys, in **Developers > API keys** or with `POST /api/api-keys`.
Organization keys always expire: `expiresInDays` defaults to 365, which is also the maximum. The
dashboard offers three presets, and the API also accepts individual scopes.

| Preset        | Scopes included                                                                                                              |
| ------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| **Read Only** | `*:read` scopes only                                                                                                         |
| **Standard**  | Read and write for agents, wallets, policies, transactions, counterparties, and alerts, plus analytics, audit, and team read |
| **Admin**     | All scopes (Owner-only)                                                                                                      |

Available scopes: `agents`, `wallets`, `transactions`, `policies`, `counterparties`, and `alerts`
(each `:read` and `:write`), plus `analytics:read`, `audit:read`, `team:read`, `team:write`,
`org:read`, `org:write`, `spending:reconcile`, and `admin`. Of the presets, only **Admin** can reconcile a [shared budget](https://conto.finance/docs/sdk/shared-budgets) purchase.

## Revoke keys

### Via dashboard

1. Go to **Agents**
2. Open the agent
3. Open the **Connect** tab
4. Click **Revoke**

### Via API

```bash
curl -X DELETE "https://conto.finance/api/agents/{agentId}/sdk-keys?keyId={keyId}" \
  -H "Authorization: Bearer $CONTO_ORG_API_KEY"
```

Revocation is immediate.

Keys also end with the person they were issued to. Removing someone from your organization, or moving
them to a lower role, revokes the organization API keys, CLI logins, and agent SDK keys issued to
them there, and each revocation appears in your audit log. An agent running on such a key stops
until someone creates a new key for it.
Keys made before Conto recorded who created them are not linked to anyone, so review those by hand.

## Best practices

- Store SDK keys in a secrets manager, not in source control.
- Use separate keys for development, staging, and production.
- Prefer standard keys unless the agent needs elevated management access.
- Standard keys can move funds. Limit what they can spend with policies, spend limits, and approvals.
- Rotate keys on a schedule instead of waiting for emergency revocations.
- On other agents, an admin SDK key can only tighten controls, such as lowering a limit or pausing.
  Raising a limit, linking a wallet, or removing a policy happens in the dashboard or with an
  organization API key.
