Skip to main content
Let your AI agent create invoices and checkout sessions for connected businesses. Each business approves what the agent can do and can revoke access at any time. This guide takes you from creating an agent to creating a checkout session for one business. Start in Sandbox.

Before you begin

  • An active Platform Program with delegated API access enabled in the mode you use. Ionic enables it for your platform.
  • A connected business, with a connection that includes the permissions your agent needs. See Connect an existing merchant.
  • A platform secret key with platform:act, from Connect → API keys. Your server uses it to ask businesses.

1. Create your AI agent

  1. On the Agents page, select Create agent. Owners and admins can create agents. The first agent asks you to claim your account’s agent handle prefix.
  2. Give the agent a name and a handle, then choose what it can do. Creating the agent allows it in your platform’s own account in the current mode, with those permissions, and an owner can issue a key for that account. That access and key cover only your own account.
  3. Open the agent and go to its Keys tab. Under Keys for connected businesses, create a key. Only owners can issue keys.
  4. Choose Create checkout sessions (sessions:write) for this example. Your Platform Program must allow this permission.
  5. Copy the key. It is shown once. Store it where the agent runs.
Use your platform secret key to request approval. Use the agent’s key after the business approves: Keep both in your server’s secret storage. The agent key needs Ionic-Account on every call. Platform keys default to 365 days in test and 180 days in live.

2. Ask a business

Call POST /v1/agent_grant_requests from your server with your platform secret key, without Ionic-Account. The request is in the key’s mode. Replace the example agent and business IDs with yours. Set REQUEST_KEY to a unique value for this request and reuse it if you retry.
Save the request id with the business. Send the url to an owner of the business, for example in your app or by email. The request expires after 7 days. Its initial status is pending and agent_grant is null. Request only permissions included in your connection and Platform Program. See AI agent permissions. To ask from the dashboard, open the agent’s Businesses tab, select Ask a business, and search by business name or merchant ID. Choose the business and permissions, then select Create request. Search covers your connected-business directory. Changing between Sandbox and Live clears the selection so you can prepare a request in the new mode.

3. Confirm approval

The owner opens the link and signs in to the business’s Ionic account if needed. Sign-in returns them to the request. They review your platform, the agent, its permissions, the mode, and the expiry, then select Allow or Decline. Admins can see requests but cannot decide them. Pending requests also appear under Requests on the business’s Agents page. If your connection, Platform Program, or agent changed after you asked, the approval is refused with AGENT_GRANT_REQUEST_STALE and nothing is granted. Send a new request. Retrieve the request with your platform secret key to check the answer. Replace the example request ID with the id you saved:
Continue when status is approved and agent_grant has status: active. For pending, declined, canceled, and expired requests, agent_grant is null. The response includes:
Your platform also receives agent_grant_request.updated when an owner approves or declines, and when you cancel. Its data.object is the same request. A request that expires sends no event; it reads as expired.

4. Create a checkout session

Send the agent’s platform key with Ionic-Account set to the business. This example creates a checkout session for the business. Set SESSION_KEY to a unique value and reuse it if you retry:
The mode comes from the key. Every request checks the key, the agent, the business’s approval, your connection with the business, and your Platform Program. Writes need an Idempotency-Key; reuse it when you retry. A successful call returns 201 and a checkout session with an ID beginning cs_. The session starts unpaid. Use the checkout guide to present checkout to the customer and confirm the payment result before fulfilling the order. See AI agent permissions for other tasks and the operations available to platform agents.

Return the owner to your app

Optionally include return_url when creating the request. First add its redirect domain under Connect → Domains. After the owner decides, Ionic returns their browser with agent_grant_request added to the URL, provided the origin is still approved. Retrieve the request to verify the decision; the redirect alone does not confirm approval.

Stop or restore access

  • The business revokes the agent. Its next request is refused with 403 AGENT_ACCESS_DENIED. The request reads agent_grant.status revoked, with revoked_at set. To act for the business again, send a new request.
  • You withdraw a pending request. Call POST /v1/agent_grant_requests/{id}/cancel with an Idempotency-Key. The link then shows the business that you withdrew it.
  • You stop the agent. On the agent’s page, Suspend refuses every call from its keys until you resume it. Deactivate stops it permanently. Revoking one key stops only that key.

See your agents across businesses

  • Agents, in your Connect workspace, lists each agent with the businesses that allow it, the ones waiting, and its actions over the last 30 days.
  • The agent’s Businesses tab shows each business’s latest answer, the agent’s actions there, and the business’s payment volume. Select a business to narrow the agent’s Activity to it. View all activity keeps that business selected; Clear shows all businesses again.
  • On Connected merchants, use Has agents or Agents waiting to filter the list. Open a business’s Agents tab to see your agents there and their activity.

Troubleshooting

  • The request is rejected: check that the agent is active, the business is connected in the same mode, and the requested permission is included in both the connection and your Platform Program.
  • The agent gets AGENT_ACCESS_DENIED: check its key permissions, the business’s current approval, and the Ionic-Account value. An approved request does not override a revoked grant or an inactive connection.
  • The agent gets AGENT_OPERATION_UNAVAILABLE: check the supported operations.
  • The dashboard cannot load businesses or requests: select Try again in the error message. A failed read does not mean there are no requests.
For individual error codes, see Errors.