Skip to content
Skip to content

API Endpoints

This page is a route-family map, not a full OpenAPI dump. It covers every major surface of the Balchemy REST API organized by domain. For detailed parameter schemas, see the linked domain pages.


Base URLs

EnvironmentBase URL
Productionhttps://api.balchemy.ai
Local developmenthttp://localhost:3000

Most routes live under /api/nest/. MCP routes are under /mcp/ — intentionally outside the /api namespace.


Authentication methods

Balchemy uses three authentication mechanisms depending on the caller type.

SIWE / SIWS session (Studio users)

Human operators authenticate with a wallet signature. Solana uses SIWS (Sign In With Solana), EVM uses SIWE (EIP-4361).

The session token is returned on login and sent as a Bearer token on all subsequent requests. Session tokens expire and can be refreshed.

CSRF flow

All mutating session-authenticated requests require a CSRF token. Fetch one before your first POST:

GET /api/nest/auth/csrf

Response:

{
  "csrfToken": "abc123..."
}

Include it on every POST, PATCH, PUT, DELETE:

X-CSRF-Token: abc123...

If the CSRF token is missing or invalid, the server returns 403 Forbidden.

API key (MCP and external integrations)

MCP API keys are created per-bot and sent as a Bearer token:

Authorization: Bearer <mcp-api-key>

Agent JWT (external agents)

External agents receive an ES256 identity access token during ERC-8004 onboarding. Use it as a Bearer token:

Authorization: Bearer <identity-access-token>

See ERC-8004 Agent Identity for token format and TTLs.


Auth routes

Session management endpoints for Studio operators.

MethodPathDescriptionAuth
GET/api/nest/auth/csrfGet CSRF tokenNone
POST/api/nest/auth/nonceGet Solana SIWS nonceNone
POST/api/nest/auth/loginSolana SIWS loginSIWS signature
POST/api/nest/auth/evm/nonceGet EVM SIWE nonceNone
POST/api/nest/auth/evm/loginEVM SIWE loginSIWE signature
POST/api/nest/auth/refreshRefresh session tokenBearer session
POST/api/nest/auth/logoutInvalidate sessionBearer session
POST/api/nest/auth/verifyVerify token validityBearer session

Login example (Solana SIWS)

POST /api/nest/auth/nonce
Content-Type: application/json
 
{
  "walletAddress": "8zFgn..."
}
POST /api/nest/auth/login
X-CSRF-Token: <csrf-token>
Content-Type: application/json
 
{
  "message": "<siws-message>",
  "signature": "<base58-signature>",
  "walletAddress": "8zFgn..."
}

Response:

{
  "accessToken": "<jwt>",
  "refreshToken": "<jwt>",
  "user": { "id": "...", "walletAddress": "8zFgn..." }
}

Bot routes (Studio)

CRUD and configuration for Studio bots.

Core bot management

MethodPathDescriptionAuth
GET/api/nest/botsList all bots for the authenticated userBearer session
GET/api/nest/bots/listSimplified bot list (name, id, status)Bearer session
POST/api/nest/botsCreate a new botBearer session + CSRF
GET/api/nest/bots/:idGet bot by IDBearer session
PATCH/api/nest/bots/:idUpdate bot (partial)Bearer session + CSRF
PUT/api/nest/bots/:idUpdate bot (full replace)Bearer session + CSRF
DELETE/api/nest/bots/:idDelete botBearer session + CSRF
POST/api/nest/bots/:botId/chatSend message to bot (web chat)Bearer session + CSRF

Bot MCP configuration

MethodPathDescriptionAuth
GET/api/nest/bots/:botId/mcpGet MCP config and key listBearer session
PUT/api/nest/bots/:botId/mcpUpdate MCP configBearer session + CSRF
GET/api/nest/bots/:botId/mcp/logsFetch MCP audit logsBearer session
POST/api/nest/bots/:botId/mcp/keysCreate new MCP API keyBearer session + CSRF
DELETE/api/nest/bots/:botId/mcp/keys/:keyIdRevoke MCP API keyBearer session + CSRF
POST/api/nest/bots/:botId/mcp/step-upIssue step-up token for manage scopeBearer session + CSRF
POST/api/nest/bots/:botId/mcp/tokenRotate MCP access tokenBearer session + CSRF

Bot platforms

MethodPathDescriptionAuth
POST/api/nest/bots/:botId/platforms/:platform/startStart a platform integrationBearer session + CSRF
POST/api/nest/bots/:botId/platforms/:platform/stopStop a platform integrationBearer session + CSRF
GET/api/nest/bots/:botId/telegram-configGet Telegram configBearer session
PUT/api/nest/bots/:botId/telegram-configUpdate Telegram configBearer session + CSRF
GET/api/nest/bots/:botId/discord-configGet Discord configBearer session
PUT/api/nest/bots/:botId/discord-configUpdate Discord configBearer session + CSRF

Bot agent card

MethodPathDescriptionAuth
GET/api/nest/bots/:botId/agent-cardGet agent card configurationBearer session
PUT/api/nest/bots/:botId/agent-cardUpdate agent cardBearer session + CSRF
POST/api/nest/bots/:botId/agent-card/publishPublish agent cardBearer session + CSRF
POST/api/nest/bots/:botId/agent-card/revokeRevoke agent cardBearer session + CSRF

Bot analytics

MethodPathDescriptionAuth
GET/api/nest/bots/:botId/trading/fees/channelsAggregate trading fees by channelBearer session

Trading routes

Trading operations proxied through the backend to the Rust trading engine over gRPC.

All trading routes are under /api/nest/trading/ and require Bearer session authentication unless noted.

Commands and approvals

MethodPathDescription
POST/api/nest/trading/commandExecute a natural-language trading command
GET/api/nest/trading/approvals/:userIdList pending approvals
POST/api/nest/trading/orders/:userId/:orderId/approveApprove a pending order

Positions and orders

MethodPathDescription
GET/api/nest/trading/positions/:userIdGet open positions
GET/api/nest/trading/positions/:userId/pnlGet positions with PnL data
GET/api/nest/trading/orders/:userIdList orders

EVM trading

MethodPathDescription
GET/api/nest/trading/evm/statusEVM trading engine status
GET/api/nest/trading/evm/wallets/:userIdList EVM wallets
POST/api/nest/trading/evm/wallets/:userIdAdd EVM wallet
POST/api/nest/trading/evm/wallets/:userId/custodialCreate EVM custodial wallet
POST/api/nest/trading/evm/wallets/:userId/delegateCreate EVM delegate wallet
POST/api/nest/trading/evm/wallets/:userId/defaultSet default EVM wallet
DELETE/api/nest/trading/evm/wallets/:userId/:walletIdRevoke EVM wallet
POST/api/nest/trading/evm/quote/:userIdGet EVM swap quote
POST/api/nest/trading/evm/swap/:userIdExecute EVM swap

Token approvals (EVM)

MethodPathDescription
POST/api/nest/trading/approvals/:userIdRecord token approval
POST/api/nest/trading/revoke/:userIdRecord approval revocation

Custodial wallets (Solana)

MethodPathDescription
GET/api/nest/trading/wallets/custodial/:userIdGet Solana custodial wallet
POST/api/nest/trading/wallets/custodial/:userIdCreate Solana custodial wallet

Trading config

MethodPathDescription
GET/api/nest/trading/config/:userIdGet trading config
GET/api/nest/trading/config/:userId/default-order-profileGet default order profile
PUT/api/nest/trading/config/:userId/default-order-profileUpdate default order profile
PUT/api/nest/trading/config/:userId/trade-defaultsUpdate trade defaults
PUT/api/nest/trading/config/:userId/risk-policyUpdate risk policy
PUT/api/nest/trading/config/:userId/notificationsUpdate notification config
PUT/api/nest/trading/config/:userId/wallet-modeUpdate wallet mode
GET/api/nest/trading/config/:userId/favoritesGet favorite tokens
POST/api/nest/trading/config/:userId/favoritesAdd favorite token
DELETE/api/nest/trading/config/:userId/favorites/:addressRemove favorite token
GET/api/nest/trading/config/:userId/blacklistGet blacklisted tokens
POST/api/nest/trading/config/:userId/blacklistAdd to blacklist
DELETE/api/nest/trading/config/:userId/blacklist/:addressRemove from blacklist
PUT/api/nest/trading/config/:userId/pool-preferencesUpdate DEX pool preferences
PUT/api/nest/trading/config/:userId/launchpads/:type/toggleToggle launchpad integration
PUT/api/nest/trading/config/:userId/launchpads/:type/priorityUpdate launchpad priority

DCA strategies

MethodPathDescription
GET/api/nest/trading/strategies/:userIdList DCA strategies
POST/api/nest/trading/strategies/:userIdCreate DCA strategy
DELETE/api/nest/trading/strategies/:userId/:strategyNameDelete DCA strategy
POST/api/nest/trading/dca/pause/:userIdPause DCA
POST/api/nest/trading/dca/resume/:userIdResume DCA
GET/api/nest/trading/dca/stats/:userIdGet DCA statistics

Research

MethodPathDescription
POST/api/nest/trading/research/tokenToken research and analysis

External agent routes (Hub)

Public onboarding (no auth required)

MethodPathDescription
POST/api/public/erc8004/onboarding/siweSIWE wallet onboarding
POST/api/public/erc8004/onboarding/identityWalletless identity onboarding
POST/api/public/erc8004/onboarding/tokens/revokeRevoke an identity access token
POST/api/public/erc8004/onboarding/tokens/revoke-statusCheck token revocation status

Public agent directory (no auth required)

MethodPathDescription
GET/api/public/erc8004/agents/pagePaged public agent directory
GET/api/public/erc8004/agents/:publicIdGet public agent card
GET/api/public/erc8004/agents/:publicId/snapshotGet live agent portfolio snapshot
GET/api/public/erc8004/discovery/feedVerified agent discovery feed

Authenticated agent wallet

Requires a valid trade-scoped identity token.

MethodPathDescription
GET/api/nest/agents/wallet/balanceGet agent wallet balance
POST/api/nest/agents/wallet/withdraw/evmWithdraw from EVM custodial wallet
POST/api/nest/agents/wallet/withdraw/solanaWithdraw from Solana custodial wallet

Control-plane (claim + manage scope + step-up required)

MethodPathDescription
POST/api/nest/agents/:agentId/control/claimClaim control plane for the agent
POST/api/nest/agents/:agentId/control/mcp/step-upIssue step-up token
PUT/api/nest/agents/:agentId/control/scopesUpdate agent scopes
POST/api/nest/agents/:agentId/control/mcp/keys/rotateRotate MCP API keys
PUT/api/nest/agents/:agentId/control/withdrawToggle withdraw ownership

MCP routes

The MCP surface is outside the /api prefix.

MethodPathDescriptionAuth
ALL/mcp/:publicIdJSON-RPC tool callBearer MCP key or identity token
GET/mcp/:publicId/events/sseSSE event streamBearer MCP key or identity token

The publicId is the public exposure identifier. See MCP Integration for the full request format.


Widget routes

The chat widget is served from the backend. Widget routes are public (no user session), but require a valid bot ID.

MethodPathDescription
GET/api/widget/:botId/script.jsServe the widget embed script
POST/api/widget/:botId/initInitialize a widget session
POST/api/widget/:botId/chatSend a chat message via widget
POST/api/widget/:botId/client-eventRecord a client-side widget event

Widget sessions are domain-validated against the bot's allowed origins. Sessions have a 1-hour TTL. Trading requires wallet authentication within the widget session.


Discovery routes (well-known, no auth)

These endpoints follow the /.well-known/ convention and are readable by any client — including AI agents performing cold-start discovery.

MethodPathDescription
GET/.well-known/erc8004-discovery.jsonERC-8004 discovery document
GET/.well-known/erc8004-onboarding.jsonOnboarding parameters (version erc8004-onboarding-v2)
GET/.well-known/erc8004-onboarding.mdHuman-readable onboarding guide
GET/.well-known/erc8004-skills-manifest.jsonSkills manifest (toolCount: 100)
GET/.well-known/jwks.jsonES256 public key set for token verification
GET/.well-known/mcp.jsonMCP endpoint template and capabilities

Error envelope

All API errors return a consistent JSON envelope:

{
  "statusCode": 401,
  "message": "Unauthorized",
  "error": "Unauthorized"
}

MCP errors follow JSON-RPC 2.0:

{
  "jsonrpc": "2.0",
  "id": "req-001",
  "error": {
    "code": -32603,
    "message": "Tool execution failed"
  }
}

Common HTTP status codes

CodeMeaning
200Success
201Created
400Bad request — invalid body or parameters
401Unauthorized — missing or invalid token
403Forbidden — valid token but insufficient scope or missing CSRF
404Not found
409Conflict — e.g., duplicate resource
422Unprocessable entity — validation error
429Too many requests
500Internal server error
503Service unavailable — trading engine down

Idempotency

Mutating trading routes that involve on-chain side effects require an idempotency key:

X-Idempotency-Key: <uuid-v4>

Generate a fresh UUID per unique operation. Replaying the same key within the TTL window returns the cached result without re-executing. Missing idempotency keys on guarded routes return 400 Bad Request.


Notes

  • publicId identifies an external agent or bot for MCP and public routes. It is different from the internal _id.
  • agentId is the canonical developer-assigned identity of an external agent.
  • Studio bots and external agents share the same execution core but have separate principal models.
  • Trading /:userId paths validate that the :userId matches the authenticated session — this is not an admin route.
  • The X-CSRF-Token header is required on all mutating session-authenticated requests.

Connection lost. Retrying...