TTRSY

API Documentation

Build agents that interact with the TRSY treasury network. All endpoints require authentication via API key passed in theAuthorization header.

Getting Started
Follow these steps to integrate your agents with TRSY:
  1. 1

    Get an API Key

    Sign up at treasury.codes to obtain your API key.

  2. 2

    Initialize a Treasury

    Use the /api/treasury/create endpoint to create your first treasury.

  3. 3

    Deploy Your Agents

    Create agent wallets and configure permissions. Your agents now have autonomous treasury access.

Base URL
API Base URL
https://api.treasury.codes

Endpoints

POST
/api/treasury/create
Create Treasury

Initialize a new agent treasury with a specified owner and initial configuration.

cURL
curl -X POST https://api.treasury.codes/api/treasury/create \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "owner": "8xBgK9LmN4QrS2TpV7WzY1Jc3Fh5Dg6Ak9MnBv",
    "name": "My Agent Treasury",
    "config": {
      "minSolBalance": 0.5,
      "autoRefill": true,
      "refillThreshold": 1.0,
      "refillTarget": 5.0
    }
  }'
Response
{
  "success": true,
  "treasury": {
    "id": "treasury_abc123",
    "address": "3xAbc...Wxyz",
    "owner": "8xBgK9LmN4QrS2TpV7WzY1Jc3Fh5Dg6Ak9MnBv",
    "createdAt": "2026-05-30T14:23:00Z"
  }
}
GET
/api/treasury/balance
Get Treasury Balance
POST
/api/treasury/transfer
Execute Transfer
POST
/api/agent/create-wallet
Create Agent Wallet
POST
/api/payments/create
Create Payment Stream
POST
/api/relay/send
Relay Transaction
Authentication

All API requests require an API key passed in the Authorization header:

Authorization: Bearer YOUR_API_KEY
  • API keys are scoped to specific treasuries and permissions.
  • Rate limit: 1,000 requests per minute per key.
  • All requests must be made over HTTPS.
Error Handling

Errors are returned with standard HTTP status codes and a JSON body:

Error Response
{
  "success": false,
  "error": {
    "code": "INSUFFICIENT_BALANCE",
    "message": "Treasury balance is insufficient for this transfer."
  }
}
400 Bad Request
401 Unauthorized
404 Not Found
429 Rate Limited
500 Internal Error