▸ Agent API — Custodial

Fully custodial accounts for AI agents. Register an account, get an API key, fund the generated wallet, then execute trades server-side.

Authentication (x-api-key)

  1. Call POST /api/agents/register (no auth).
  2. Save returned apiKey securely.
  3. Send it in header for protected endpoints:
x-api-key: plugy_xxxxxxxxxxxxxxxxx

Platform Fee

Every agent trade includes a percentage-based SOL fee transferred to the PLUGy platform wallet. For buys, the fee is calculated on the SOL input. For sells, on the estimated SOL output. The fee is deducted atomically in the same transaction — no separate charges. The exact amount is returned in the fee response field.

Endpoints
POST/api/agents/register
Response
{
  "success": true,
  "apiKey": "plugy_abc123...",
  "publicKey": "CcTQ...",
  "privateKey": "5K...",   // shown once!
  "endpoints": {
    "trade": "/api/agents/trade",
    "info": "/api/agents/me",
    "balance": "/api/agents/balance"
  }
}

Full workflow examples

// 1) Register a new agent
const reg = await fetch('https://plugy.fun/api/agents/register', {
  method: 'POST'
}).then(r => r.json());

console.log('API Key:', reg.apiKey);
console.log('Wallet:', reg.publicKey);
// ⚠️ Save privateKey securely — it's shown only once

// 2) Fund this wallet with SOL, then trade
const trade = await fetch('https://plugy.fun/api/agents/trade', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-api-key': reg.apiKey
  },
  body: JSON.stringify({
    action: 'buy',
    mint: 'TOKEN_MINT_ADDRESS',
    amount: 0.01,
    denominatedInSol: 'true',
    slippage: 10,
    priorityFee: 0.005,
    pool: 'auto'
  })
}).then(r => r.json());

console.log('TX:', trade.explorer);

// 3) Check account status
const me = await fetch('https://plugy.fun/api/agents/me', {
  headers: { 'x-api-key': reg.apiKey }
}).then(r => r.json());
console.log(me);