> ## 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.

# Connect your AI agent

> Connect your AI agent to Ionic, choose what it can do for your business, and review its activity.

Let your AI agent create invoices, prepare checkout sessions, and manage
customers in your Ionic account. Give it its own key, choose what it can do,
and review its activity in the dashboard.

> [card] [Connect over MCP](https://docs.ionicfi.com/guides/connect-ai-assistants.md)
>
> Use any compatible MCP client. Sign in and approve access without creating an API key.

> [card] [Build for connected businesses](https://docs.ionicfi.com/guides/connect-agents.md)
>
> Let your platform's AI agent work for businesses that approve it.

The steps below are for an AI agent you are building for your own business.
Start in **Sandbox** with an account owner who can issue its key. Admins can
create agents, but an owner must issue the key.

## 1. Create the agent

1. On the **Agents** page, select **Create agent**. The first time, Ionic asks
   you to claim your account's agent handle prefix, such as `juniper`. Every
   agent handle starts with it, for example `@juniper-billing`. The prefix is
   permanent.
2. Enter a name, a handle, and a description of what the agent does.
3. Choose **View customers** and **Manage customers** for the example below.
   The agent is allowed in the mode you are viewing as
   soon as it is created. To allow it in the other mode, switch modes and open
   its **Access** tab.
4. Choose when its key expires, then select **Create agent**. Issuing the key
   requires an owner.
5. Copy the key. It starts with `ak_v1_test_` or `ak_v1_live_` and is shown
   once. Store it where the agent runs.

## 2. Make your first call

Set `AGENT_KEY` in your runtime to the key you copied. The agent sends it as
a Bearer token. A test key makes test-mode calls.

```bash theme={null}
curl https://api.ionicfi.com/v1/customers \
  -H "Authorization: Bearer $AGENT_KEY" \
  -G -d limit=10
```

The key acts only in your account, so it needs no `Ionic-Account`. Writes need
an `Idempotency-Key`. Set `CUSTOMER_KEY` to a unique value for this customer
creation and reuse it if you retry. This example creates a test customer:

```bash theme={null}
curl https://api.ionicfi.com/v1/customers \
  -H "Authorization: Bearer $AGENT_KEY" \
  -H "Idempotency-Key: $CUSTOMER_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "jordan@example.com",
    "first_name": "Jordan",
    "last_name": "Lee"
  }'
```

A successful create returns `201` and a customer with an ID beginning `cus_`.
Open the agent's **Activity** to find the call.

Choose additional permissions for other tasks, such as `invoices:write` for
invoices or `sessions:write` for checkout. See the
[full permission reference](https://docs.ionicfi.com/api-reference/agent-permissions.md). Customers complete
their own payments; these permissions do not let the agent charge a card directly.

| Code | Meaning |
| - | - |
| `403` `AGENT_ACCESS_DENIED` | The agent has no current access for this call: it is not allowed in the key's mode, lacks the permission, or is suspended. |
| `403` `AGENT_OPERATION_UNAVAILABLE` | The endpoint is not one agents can call. |
| `400` `IDEMPOTENCY_KEY_REQUIRED` | A write was sent without an `Idempotency-Key`. |

## 3. Review its activity

The agent's page shows its latest Activity: each call it made, each change to
the agent or its access, and each call Ionic refused, with the reason. Filter
by **Actions**, **Milestones**, or **Refused**, and select **View all
activity** for the full timeline. **Agent activity**, on the **Agents** page,
shows every agent acting in your account, including agents from your
platforms.

## Manage access

* **Add or remove a permission.** On the **Access** tab, remove a permission,
  or add one with **Add permission**. Removing a permission blocks it on the
  agent's next request. Adding a permission also requires a key that includes
  it. If the current key lacks that permission, issue a new key on the
  **Keys** tab and update the agent to use it.
* **Revoke access in a mode.** On the **Access** tab, select **Revoke access**.
  Its keys stop working in that mode. To allow it again, select **Allow in**.
* **Suspend the agent.** **Suspend agent** stops every key for the agent on its
  next request, everywhere it is allowed. Its keys and access are kept, so
  **Resume agent** restores them.
* **Deactivate the agent.** **Deactivate agent** is permanent. Every key stops
  working, the agent cannot be resumed, and its handle stays reserved.
* **Rotate or revoke a key.** On the **Keys** tab, rotate a key to replace its
  secret, or revoke it. Revoking a key stops only that key.

## Agents from your platforms

A platform your business is connected to can ask you to allow its agent, so
the agent can work in your account for that platform. The platform sends you a
link, and the request also appears under **Requests** on the **Agents** page.

1. Open the request and sign in to your business's account if needed. Sign-in
   returns you to the request. Review the platform, the agent, what it will
   be able to do, the mode, and when the request expires.
2. Select **Allow** or **Decline**. Only an owner can decide. Admins can see
   the request.

An allowed agent appears under **Connected agents** on the **Agents** page,
named by its platform. Open it to see what it can do and when you approved it.
Select **Revoke access** to stop it; the platform has to ask again to get
access back. Its calls appear in **Agent activity**.

A platform agent can do only what you allowed, within the connection you
approved for that platform.

## Cards and purchase approvals

To let an agent buy with your business card, see
[Manage cards and agent purchases](https://docs.ionicfi.com/guides/spend-card-access.md). You manage card
access, purchase approvals, and limits there, separately from the agent's
permissions.


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