> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ionicfi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How agents work

> Agents, handles, agent keys, access, and permissions: the objects behind every agent call.

An agent on Ionic is a named identity that holds its own keys and acts only
where a business has given it access. Five objects work together on every
agent call.

| Object | What it is |
| - | - |
| Agent | The identity (`agt_…`) with a name and a permanent `@handle`. |
| Agent key | A secret key (`ak_v1_…`) bound to one agent, used by the code where the agent runs. |
| Access | A business's approval for the agent in one mode, with a set of permissions. |
| Permission | One kind of operation, such as `sessions:write` to create checkout sessions. |
| Activity | The record of each call the agent made, each call Ionic refused, and each change to the agent. |

## The agent

Each agent has an ID that starts with `agt_` and a handle that starts with its
account's handle prefix, such as `@juniper-checkout`. An owner or admin claims
the prefix once, and it never changes. Handles are permanent and unique, so
businesses and activity records always show which agent acted.

An agent is `active`, `suspended`, or `deactivated`. Suspending an agent stops
every key for it on its next request, and resuming restores them.
Deactivation is permanent, and the handle stays reserved.

## Agent keys

An agent key is how code acts as an agent. Your agent's runtime sends it as a
Bearer token, like any other secret key.

| Key | Prefix | Acts as | Permissions |
| - | - | - | - |
| Secret key | `sk_v1_test_`, `sk_v1_live_` | Your account | Ionic's standard policy |
| Restricted secret key | `rk_v1_test_`, `rk_v1_live_` | Your account | The permissions you select |
| Agent key | `ak_v1_test_`, `ak_v1_live_` | One agent | The agent permissions you select |

* **Issued by an owner.** Owners issue agent keys from the agent's **Keys**
  tab, choose when each one expires, and copy it once. Admins can create
  agents but cannot issue their keys.
* **One mode per key.** The prefix sets the mode. A test key makes test calls
  only.
* **Its own account, or connected businesses.** A key for your own account acts
  there without extra headers. A platform agent's key for connected businesses
  sends `Ionic-Account` with the business's ID on every call.
* **Rotate and revoke.** Rotating a key replaces its secret. Revoking a key
  stops only that key; the agent and its other keys keep working.
* **Agent work only.** An agent key calls the operations listed in
  [agent permissions](https://docs.ionicfi.com/api-reference/agent-permissions.md). Other endpoints
  return `403 AGENT_OPERATION_UNAVAILABLE`, including creating and changing
  agents.

Keep agent keys on the server or in the secure runtime where the agent runs,
never in a browser or a model prompt.

## Access and permissions

Access is a business's approval for an agent, in one mode, with a set of
permissions. Your own agents get access in your account when you create them.
A platform's agent gets access to a business when an owner of that business
approves its agent grant request.

A call goes through only when every check passes:

```mermaid theme={null}
flowchart TD
    A["Agent key"] --> B{"Agent active?"}
    B -->|yes| C{"Access in the key's mode?"}
    C -->|yes| D{"Permission on the key<br/>and in the access?"}
    D -->|yes| E["Request runs"]
    B -->|no| F["Refused, recorded in Activity"]
    C -->|no| F
    D -->|no| F
```

The key and the access each hold permissions, and a call needs both. Removing
a permission from the access blocks it on the agent's next request. Adding a
permission to the access does not change an existing key: issue a new key that
includes it.

For a platform's agent, Ionic also checks your connection with the business
and your Platform Program on every call.

## Agents over MCP

An AI assistant connected through an MCP client, such as Claude or ChatGPT,
uses no agent key. The person connecting signs in to Ionic and approves the
connection, and the connection becomes an agent with its own handle and
access. Disconnecting removes its access and keeps the agent and its activity.
See [Connect an AI agent over MCP](https://docs.ionicfi.com/guides/connect-ai-assistants.md).

## Activity

**Agent activity** on the **Agents** page shows each call an agent made, each
call Ionic refused with the reason, and each change to the agent or its
access. A business also sees the platform agents acting in its account there.

## Writes and retries

Every write an agent makes needs an `Idempotency-Key`. Use a unique key for
each change and reuse it when you retry, so a retry returns the original
result instead of repeating the change. See
[Idempotency](https://docs.ionicfi.com/api-reference/idempotency.md).

## What's next

> [card] [Agent quickstart](https://docs.ionicfi.com/agents/quickstart.md)
>
> Issue an agent key and take a test payment through it.

> [card] [Agent permissions](https://docs.ionicfi.com/api-reference/agent-permissions.md)
>
> Each permission and the operations it allows.

> [card] [Connect your AI agent](https://docs.ionicfi.com/guides/agents.md)
>
> Create, manage, and review your own agents in the dashboard.

> [card] [Platform agents](https://docs.ionicfi.com/guides/connect-agents.md)
>
> Act for the businesses you serve with your agent's key.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.