Download OpenAPI specification:
Swarm Vault API enables managers to execute transactions on behalf of multiple users on Base.
For JavaScript/TypeScript projects, use the official SDK:
npm install @swarmvault/sdk
import { SwarmVaultClient, BASE_MAINNET_TOKENS } from '@swarmvault/sdk';
const client = new SwarmVaultClient({
apiKey: 'svk_your_api_key_here',
});
const result = await client.executeSwap('swarm-id', {
sellToken: BASE_MAINNET_TOKENS.USDC,
buyToken: BASE_MAINNET_TOKENS.WETH,
sellPercentage: 50,
});
const tx = await client.waitForTransaction(result.transactionId);
See the SDK README for full documentation.
Use the REST API directly by following this documentation.
All authenticated endpoints require an API key in the Authorization header:
Authorization: Bearer svk_xxxxx...
Important: Store your API key securely. If you lose it, you'll need to generate a new one (which revokes the old key).
Include the API key in the Authorization header for all requests:
const API_KEY = 'svk_your_api_key_here';
const response = await fetch('https://api.swarmvault.xyz/api/swarms', {
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
}
});
Managers can execute swaps across all swarm member wallets:
When creating custom transactions, use these placeholders:
| Placeholder | Description |
|---|---|
{{walletAddress}} |
Agent wallet address |
{{ethBalance}} |
Current ETH balance (wei) |
{{tokenBalance:0xAddr}} |
ERC20 token balance |
{{percentage:ethBalance:50}} |
50% of ETH balance |
{{percentage:tokenBalance:0xAddr:100}} |
100% of token balance |
{{blockTimestamp}} |
Current block timestamp |
{{deadline:300}} |
Timestamp + N seconds |
{{slippage:amount:5}} |
Amount minus 5% |
Verify your API key is valid and retrieve your user profile. Use this endpoint to test your API key is working correctly.
{- "success": true,
- "data": {
- "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
- "walletAddress": "string",
- "twitterId": "string",
- "twitterUsername": "string",
- "createdAt": "2019-08-24T14:15:22Z",
- "updatedAt": "2019-08-24T14:15:22Z"
}
}Get information about the user's current API key. Returns the key prefix (for identification) and creation date. The full API key is never returned.
{- "success": true,
- "data": {
- "hasApiKey": true,
- "prefix": "svk_a1b2c3d4",
- "createdAt": "2019-08-24T14:15:22Z"
}
}Generate a new API key for programmatic access to the Swarm Vault API.
IMPORTANT: The full API key is only returned ONCE in this response. Store it securely - you will not be able to retrieve it again.
If you already have an API key, generating a new one will automatically revoke the old key.
Use the API key by including it in the Authorization header:
Authorization: Bearer svk_xxxxx...
{- "success": true,
- "data": {
- "apiKey": "svk_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0",
- "prefix": "svk_a1b2c3d4",
- "createdAt": "2019-08-24T14:15:22Z"
}
}Get a list of all public swarms. If authenticated, the response includes whether the current user is a manager of each swarm.
{- "success": true,
- "data": [
- {
- "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
- "name": "string",
- "description": "string",
- "createdAt": "2019-08-24T14:15:22Z",
- "updatedAt": "2019-08-24T14:15:22Z",
- "managers": [
- {
- "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
- "walletAddress": "string",
- "twitterUsername": "string"
}
], - "memberCount": 0,
- "isManager": true
}
]
}Create a new swarm with the authenticated user as manager. Requires a linked Twitter account for manager verification. A new Lit Protocol PKP is minted for the swarm.
| name required | string [ 1 .. 100 ] characters Name of the swarm |
| description | string <= 500 characters Description of the swarm |
{- "name": "Alpha Traders",
- "description": "A swarm for professional traders"
}{- "success": true,
- "data": {
- "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
- "name": "string",
- "description": "string",
- "litPkpPublicKey": "string",
- "createdAt": "2019-08-24T14:15:22Z",
- "managers": [
- {
- "id": "string",
- "walletAddress": "string"
}
]
}
}Get detailed information about a specific swarm. Managers see additional details like PKP public key.
| id required | string <uuid> Swarm ID |
{- "success": true,
- "data": {
- "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
- "name": "string",
- "description": "string",
- "createdAt": "2019-08-24T14:15:22Z",
- "updatedAt": "2019-08-24T14:15:22Z",
- "managers": [
- {
- "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
- "walletAddress": "string",
- "twitterUsername": "string"
}
], - "memberCount": 0,
- "isManager": true
}
}Get a list of all active members in the swarm. Manager only - only swarm managers can view members.
| id required | string <uuid> Swarm ID |
{- "success": true,
- "data": [
- {
- "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
- "userId": "2c4a230c-5085-4924-a3e1-25fb4fc5965b",
- "walletAddress": "string",
- "agentWalletAddress": "string",
- "status": "ACTIVE",
- "joinedAt": "2019-08-24T14:15:22Z"
}
]
}Join a swarm as a member. The client must create the smart wallet and serialize the permission account before calling this endpoint.
| swarmId required | string <uuid> Swarm ID to join |
| agentWalletAddress required | string^0x[a-fA-F0-9]{40}$ The smart wallet address created by the client |
| sessionKeyApproval required | string Serialized permission account for PKP signing |
{- "agentWalletAddress": "string",
- "sessionKeyApproval": "string"
}{- "success": true,
- "data": {
- "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
- "swarmId": "cc85d9d1-37cf-435f-b6c2-cbe8983c7bdf",
- "swarmName": "string",
- "agentWalletAddress": "string",
- "status": "ACTIVE",
- "joinedAt": "2019-08-24T14:15:22Z"
}
}Get all active swarm memberships for the authenticated user
{- "success": true,
- "data": [
- {
- "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
- "swarmId": "cc85d9d1-37cf-435f-b6c2-cbe8983c7bdf",
- "swarmName": "string",
- "agentWalletAddress": "string",
- "status": "ACTIVE",
- "joinedAt": "2019-08-24T14:15:22Z"
}
]
}Get detailed information about a specific membership
| id required | string <uuid> Membership ID |
{- "success": true,
- "data": {
- "id": "string",
- "swarmId": "string",
- "agentWalletAddress": "string",
- "status": "string",
- "joinedAt": "2019-08-24T14:15:22Z",
- "swarm": {
- "id": "string",
- "name": "string",
- "description": "string",
- "memberCount": 0,
- "managers": [
- { }
]
}
}
}Leave a swarm membership. The agent wallet remains but swarm managers can no longer execute transactions.
| id required | string <uuid> Membership ID |
{- "success": true,
- "data": {
- "id": "string",
- "status": "LEFT"
}
}Get ETH and token balances for the membership's agent wallet
| id required | string <uuid> Membership ID |
| refresh | string Enum: "true" "false" Force refresh from blockchain (bypasses cache) |
{- "success": true,
- "data": {
- "walletAddress": "string",
- "chainId": 0,
- "ethBalance": "string",
- "tokens": [
- {
- "address": "string",
- "symbol": "string",
- "name": "string",
- "decimals": 0,
- "balance": "string",
- "logoUrl": "string"
}
], - "fetchedAt": 0,
- "cached": true
}
}Get a preview of what a swap would look like for all swarm members. Returns expected amounts for each member without executing the swap. Manager only - only swarm managers can preview swaps.
| id required | string <uuid> Swarm ID |
| sellToken required | string^0x[a-fA-F0-9]{40}$ Token address to sell (use 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE for ETH) |
| buyToken required | string^0x[a-fA-F0-9]{40}$ Token address to buy |
| sellPercentage | number [ 1 .. 100 ] Default: 100 Percentage of token balance to sell |
| slippagePercentage | number [ 0.01 .. 50 ] Default: 1 Slippage tolerance percentage |
{- "sellToken": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
- "buyToken": "0x4200000000000000000000000000000000000006",
- "sellPercentage": 100,
- "slippagePercentage": 1
}{- "success": true,
- "data": {
- "sellToken": "string",
- "buyToken": "string",
- "sellPercentage": 0,
- "slippagePercentage": 0,
- "members": [
- {
- "membershipId": "string",
- "userId": "string",
- "userWalletAddress": "string",
- "agentWalletAddress": "string",
- "sellAmount": "string",
- "buyAmount": "string",
- "feeAmount": "string",
- "estimatedPriceImpact": "string",
- "error": "string"
}
], - "totalSellAmount": "string",
- "totalBuyAmount": "string",
- "totalFeeAmount": "string",
- "successCount": 0,
- "errorCount": 0,
- "fee": {
- "bps": 0,
- "percentage": "string",
- "recipientAddress": "string"
}
}
}Execute a token swap for all active swarm members. The swap is executed asynchronously - poll the returned transaction ID for status updates. Manager only - only swarm managers can execute swaps.
A platform fee (default 0.5%) is deducted from the buy token amount.
| id required | string <uuid> Swarm ID |
| sellToken required | string^0x[a-fA-F0-9]{40}$ Token address to sell |
| buyToken required | string^0x[a-fA-F0-9]{40}$ Token address to buy |
| sellPercentage | number [ 1 .. 100 ] Default: 100 |
| slippagePercentage | number [ 0.01 .. 50 ] Default: 1 |
{- "sellToken": "string",
- "buyToken": "string",
- "sellPercentage": 100,
- "slippagePercentage": 1
}{- "success": true,
- "data": {
- "transactionId": "75906707-8c31-479c-b354-aa805c4cefbc",
- "status": "PENDING",
- "memberCount": 0,
- "message": "string",
- "fee": {
- "bps": 0,
- "percentage": "string",
- "recipientAddress": "string"
}
}
}Get aggregate token holdings across all swarm members. Returns total ETH and token balances with holder counts. Manager only - only swarm managers can view holdings.
| id required | string <uuid> Swarm ID |
{- "success": true,
- "data": {
- "ethBalance": "string",
- "tokens": [
- {
- "address": "string",
- "symbol": "string",
- "name": "string",
- "decimals": 0,
- "totalBalance": "string",
- "holderCount": 0,
- "logoUrl": "string"
}
], - "memberCount": 0,
- "commonTokens": [
- {
- "address": "string",
- "symbol": "string",
- "name": "string",
- "decimals": 0
}
]
}
}Execute a custom transaction across all swarm member wallets using a template. Templates support placeholders for wallet addresses, balances, and computed values. Manager only - only swarm managers can execute transactions.
The transaction is executed asynchronously - poll the returned transaction ID for status updates.
| id required | string <uuid> Swarm ID |
required | object |
{- "template": {
- "contractAddress": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
- "abi": [
- {
- "name": "transfer",
- "type": "function",
- "inputs": [
- {
- "name": "to",
- "type": "address"
}, - {
- "name": "amount",
- "type": "uint256"
}
]
}
], - "functionName": "transfer",
- "args": [
- "0x1234567890abcdef1234567890abcdef12345678",
- "{{percentage:tokenBalance:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913:50}}"
], - "value": "0"
}
}{- "success": true,
- "data": {
- "transactionId": "75906707-8c31-479c-b354-aa805c4cefbc",
- "status": "PENDING",
- "memberCount": 0
}
}Get a list of all transactions executed for this swarm. Manager only - only swarm managers can view transactions.
| id required | string <uuid> Swarm ID |
{- "success": true,
- "data": [
- {
- "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
- "swarmId": "cc85d9d1-37cf-435f-b6c2-cbe8983c7bdf",
- "status": "PENDING",
- "template": { },
- "createdAt": "2019-08-24T14:15:22Z",
- "updatedAt": "2019-08-24T14:15:22Z",
- "targetCount": 0,
- "statusCounts": {
- "pending": 0,
- "submitted": 0,
- "confirmed": 0,
- "failed": 0
}
}
]
}Get detailed status and results for a specific transaction. Includes per-member status for tracking progress. Manager only - only swarm managers can view transaction details.
| id required | string <uuid> Transaction ID |
{- "success": true,
- "data": {
- "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
- "swarmId": "cc85d9d1-37cf-435f-b6c2-cbe8983c7bdf",
- "status": "PENDING",
- "template": { },
- "createdAt": "2019-08-24T14:15:22Z",
- "updatedAt": "2019-08-24T14:15:22Z",
- "targets": [
- {
- "id": "string",
- "membershipId": "string",
- "userWallet": "string",
- "agentWallet": "string",
- "resolvedTxData": { },
- "userOpHash": "string",
- "txHash": "string",
- "status": "PENDING",
- "error": "string"
}
]
}
}