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

# Create an agent

> Create your first agent, give it a test key, and read customers from your business.

An agent has three parts: an identity, access to a business, and a key. This
guide creates all three in Sandbox and makes a read-only request.

Keep the agent's key in the server or runtime that runs your agent. Don't put
it in model prompts or browser code.

## 1. Create the agent

Sign in to your business as an owner and select **Sandbox**. Open **Agents**
and select **Create agent**.

If this is your account's first agent, claim a handle prefix such as `juniper`.
You can't change the prefix later. Give the agent a name, a handle such as
`juniper-billing`, and a description of its task.

Choose **View customers** (`customers:read`) and a key expiry, then finish.
Copy the key now. It's shown only once. Test agent keys start
with `ak_v1_test_`.

Admins can create agents, but only an owner can issue the key, from the
agent's **Keys** tab.

## 2. Make a test request

Store the key in your runtime's secret storage as `AGENT_KEY`.

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

The response lists your test customers, or an empty list if you don't have
any yet. The request appears in the agent's **Activity** tab.

If the request is refused, check that:

* The agent is allowed in Sandbox.
* Its access and its key both include `customers:read`.
* The agent isn't suspended.

See [agent permissions](https://docs.ionicfi.com/api-reference/agent-permissions.md).

## 3. Give it a task

* **Invoices and checkout:** add the permissions and issue a key that includes
  them. See [Connect your AI agent](https://docs.ionicfi.com/guides/agents.md).
* **Other businesses:** use your platform's agent and ask each business to
  approve it. See [Connect your platform's AI agent](https://docs.ionicfi.com/guides/connect-agents.md).
* **Purchases:** give the agent access to a business card and have the owner
  approve each purchase. See [Agent purchases](https://docs.ionicfi.com/spend/overview.md).

> [!NOTE]
>
> A key keeps the permissions it was issued with. After you add a permission,
> issue a new key. Agent writes also need an `Idempotency-Key`; reuse it when you
> retry the same request.

## Create agents from your platform's server

Platforms can create agents with `POST /v1/agents`, using a platform secret key
with `agents:write`. Claim your handle prefix in the dashboard first. The API
creates the identity; an owner issues its key in the dashboard. See
[Manage your platform's agents](https://docs.ionicfi.com/connect/agents.md#create-an-agent) for the
request and response.

If you use an assistant that supports MCP, see
[Connect an AI agent over MCP](https://docs.ionicfi.com/guides/connect-ai-assistants.md). The connection
creates the agent for you.


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