Agent Gateway Docs

Overview

Agent Gateway lets AI agents request TON blockchain transactions that are approved by a human wallet owner. The agent never holds private keys — it only submits transfer requests that you review and sign via TON Connect.

How it works

  1. You connect your wallet and receive an Agent Token
  2. Give this token to your AI agent (Claude, GPT, custom bot, etc.)
  3. The agent calls the API to request transfers
  4. You see pending requests in the dashboard and approve or reject them
  5. Approved transactions are signed by your wallet via TON Connect
The token is scoped to a unique session. Even if someone knows your wallet address, they cannot create requests in your session without your exact token.

Quick Start

1. Get your token

Connect your wallet on the main page and copy the token.

2. Make a transfer request

curl -X POST https://api.tongateway.ai/v1/safe/tx/transfer \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{
    "to": "EQD...destination-address",
    "amountNano": "1000000000"
  }'

3. Approve in dashboard

The request appears in your dashboard within seconds. Click Approve to sign with your wallet.

REST API

Base URL: https://api.tongateway.aiSwagger UI

All /v1/safe/* endpoints require Authorization: Bearer TOKEN header.


POST /v1/auth/token

Exchange wallet address for a JWT token.

// Request
{ "address": "0:2dfd5e74cd9cd05b..." }

// Response
{ "token": "eyJhbG...", "address": "0:2dfd5e74cd9cd05b..." }

GET /v1/auth/me

Verify token and get wallet address.

// Response
{ "address": "0:2dfd5e74cd9cd05b..." }

POST /v1/safe/tx/transfer

Request a TON transfer. The request is queued for wallet owner approval.

FieldTypeRequiredDescription
tostringYesDestination TON address
amountNanostringYesAmount in nanoTON (1 TON = 1000000000)
payloadBocstringNoBOC-encoded payload
// Response
{
  "id": "0ad28efd-d44a-4ac8-9104-1c3f0b7bfc7a",
  "status": "pending",
  "to": "0:2dfd5e...",
  "amountNano": "1000000000",
  "expiresAt": 1773329201052
}

GET /v1/safe/tx/pending

List all pending transfer requests for your session.

// Response
{ "requests": [ { "id": "...", "to": "...", "amountNano": "...", "status": "pending", ... } ] }

GET /v1/safe/tx/:id

Get a specific request by ID.


POST /v1/safe/tx/:id/confirm

Confirm a pending request after wallet signs. Body: { "txHash": "..." } (optional).


POST /v1/safe/tx/:id/reject

Reject a pending request.

MCP Server (Claude Code / AI Agents)

The easiest way to connect an AI agent is via the MCP server. It exposes Agent Gateway tools directly — no HTTP knowledge needed.

Install

git clone https://github.com/niccolocase/agent-api.git
cd agent-api/mcp
npm install

Configure in Claude Code

Add to your .claude/settings.json or project settings:

{
  "mcpServers": {
    "agent-gateway": {
      "command": "npx",
      "args": ["tsx", "/path/to/agent-api/mcp/src/index.ts"],
      "env": {
        "AGENT_GATEWAY_TOKEN": "YOUR_TOKEN_HERE",
        "AGENT_GATEWAY_API_URL": "https://api.tongateway.ai"
      }
    }
  }
}

Available Tools

ToolDescription
request_transferRequest a TON transfer (to, amountNano, payloadBoc?)
get_request_statusCheck status of a transfer request by ID
list_pending_requestsList all pending requests

Example conversation

You: Send 0.5 TON to EQD...abc

Claude: I'll request that transfer for you.
        [calls request_transfer with to="EQD...abc", amountNano="500000000"]

        Transfer request created (ID: abc-123).
        Please approve it in your Agent Gateway dashboard.

Direct HTTP (Python / JS / Any language)

Python

import requests

API = "https://api.tongateway.ai"
TOKEN = "your-token-here"
headers = {"Authorization": f"Bearer {TOKEN}", "Content-Type": "application/json"}

# Request a transfer
resp = requests.post(f"{API}/v1/safe/tx/transfer", headers=headers, json={
    "to": "0:destination-address",
    "amountNano": "1000000000"  # 1 TON
})
print(resp.json())  # {"id": "...", "status": "pending", ...}

# Check status
req_id = resp.json()["id"]
status = requests.get(f"{API}/v1/safe/tx/{req_id}", headers=headers)
print(status.json()["status"])  # "pending" | "confirmed" | "rejected"

JavaScript / Node.js

const API = "https://api.tongateway.ai";
const TOKEN = "your-token-here";

const res = await fetch(`${API}/v1/safe/tx/transfer`, {
  method: "POST",
  headers: { "Authorization": `Bearer ${TOKEN}`, "Content-Type": "application/json" },
  body: JSON.stringify({ to: "0:destination", amountNano: "1000000000" }),
});

const { id, status } = await res.json();
console.log(id, status); // "abc-123" "pending"

Security Model