AgentPayAPI

Documentation

AgentPayAPI provides risk-first infrastructure for autonomous AI transactions. Give your AI agents the ability to transact on-chain with hard cryptographic limits, ensuring they can operate autonomously without risking your entire treasury.

Quickstart

Install the official Node.js SDK via npm, yarn, or pnpm:

npm install @agentpay/sdk

Initialize the client and execute your first transaction:

import { AgentPay } from '@agentpay/sdk';// Initialize with your API keyconst client = new AgentPay(process.env.AGENTPAY_API_KEY);// Execute a transactionconst receipt = await client.execute({  to: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e',  value: '0.05', // ETH  chain: 'base'});console.log(`Transaction successful: ${receipt.hash}`);

Authentication

Authenticate your API requests using your secret API key. You can generate and manage API keys in the Dashboard.

Pass the API key to the SDK constructor, or set it as an environment variable AGENTPAY_API_KEY. Never commit your API keys to version control.

Risk Controls

AgentPayAPI enforces risk limits cryptographically before any transaction is signed. If a transaction violates a limit, it is blocked at the API level and never broadcast to the network.

  • Global Limits: Maximum transaction value, daily volume limits, and allowed networks.
  • Per-Contract Limits: Restrict agents to interact only with specific smart contracts (e.g., only Uniswap V3 routers).
  • Velocity Limits: Maximum number of transactions per hour/day to prevent runaway loops.

Supported Networks

We currently support 7 networks (5 mainnets and 2 testnets). Use the exact string identifier in the chain parameter when executing transactions.

NetworkIdentifierType
EthereumethereumMainnet
BasebaseMainnet
PolygonpolygonMainnet
ArbitrumarbitrumMainnet
OptimismoptimismMainnet
SepoliasepoliaTestnet
Base Sepoliabase-sepoliaTestnet

Client Initialization

Initialize the AgentPay client with your API key. You can pass the key directly, or let the SDK automatically pick it up from the AGENTPAY_API_KEY environment variable.

import { AgentPay } from '@agentpay/sdk';// Option 1: Pass API key explicitlyconst client = new AgentPay('sk_live_...');// Option 2: Uses process.env.AGENTPAY_API_KEY automaticallyconst client = new AgentPay();

Execute Transaction

Execute a transaction on-chain. The API will automatically evaluate the transaction against your configured risk limits before signing and broadcasting.

const receipt = await client.execute({  to: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e',  value: '0.05',  chain: 'base',  data: '0x' // Optional contract calldata});

Parameters

ParameterTypeDescription
tostringThe destination address or contract. Required.
valuestringThe amount of native token to send (in ETH/MATIC/etc). Required.
chainstringThe network identifier (e.g., 'base'). Required.
datastringHex-encoded contract calldata. Optional, defaults to '0x'.