Skip to main content
Get started with RebelFi’s API in 10 minutes. This guide shows you how to integrate programmatically without using the dashboard.
Dashboard Alternative: Prefer a visual interface? See the Dashboard Quick Start for a no-code approach.

Prerequisites

Before starting, ensure you have:
  1. Sign up at midas.rebelfi.io
  2. Verify your email
  3. Complete organization setup
Generate an API key from the dashboard:
  1. Navigate to Settings → API Keys
  2. Click Generate New API Key
  3. Copy and store securely (shown only once)
Your API key will look like: rfk_live_xxxxxxxxxxxxx
Store your API key securely. Never commit it to version control.
You’ll need a Solana wallet address that you control. RebelFi will monitor this wallet for yield optimization, but you maintain full custody.Example: 9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin
This guide uses TypeScript/JavaScript, but RebelFi’s REST API works with any language.For TypeScript:
npm install axios
# or
yarn add axios

Step 1: Import Your Wallet

Import your wallet address into RebelFi for monitoring.
import axios from 'axios';

const REBELFI_API_KEY = process.env.REBELFI_API_KEY;
const baseURL = 'https://api.rebelfi.io';

const client = axios.create({
  baseURL,
  headers: {
    'X-API-Key': REBELFI_API_KEY,
    'Content-Type': 'application/json'
  }
});

// Step 1: Import wallet
async function importWallet() {
  const response = await client.post('/api/v1/wallets/import', {
    address: '9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin',
    blockchain: 'SOLANA',
    label: 'Treasury Wallet'
  });

  const { orgWalletId } = response.data.data;
  console.log('Wallet imported! ID:', orgWalletId);

  return orgWalletId;
}

const orgWalletId = await importWallet();
Importing a wallet does NOT transfer custody. RebelFi only monitors the address — you maintain complete control of private keys.

Step 2: Enable Yield Monitoring

Configure the wallet for automatic yield optimization.
// Step 2: Enable yield monitoring
async function enableYield(orgWalletId: number) {
  const response = await client.post('/api/core/wallets/add-and-monitor', {
    orgWalletId,
    enableYield: true,
    bufferAmount: '100.00'  // Keep 100 USDC liquid
  });

  const { opWalletId } = response.data.data;
  console.log('Yield monitoring enabled! OpWallet ID:', opWalletId);

  return opWalletId;
}

const opWalletId = await enableYield(orgWalletId);
What is bufferAmount? The buffer is the minimum liquidity kept available (not deployed to yield). In this example:
  • Buffer: 100 USDC (always available)
  • Funds above 100 USDC → automatically deployed to yield
Set your buffer to cover typical daily withdrawal needs. You can adjust it anytime via PUT /api/core/wallets/monitored/:id/buffer-settings.

Step 3: Deploy Funds to Yield

Once your wallet has funds, deploy them to yield protocols.
// Step 3: Create supply operation
async function deployToYield(opWalletId: number) {
  const response = await client.post('/api/v1/allocations', {
    opWalletId,
    amount: '1000.00',
    asset: 'USDC'
  });

  const { reservationId, bundleId } = response.data;

  console.log('Supply operation created!');
  console.log('Reservation ID:', reservationId);
  console.log('Operation ID (bundleId):', bundleId);

  return bundleId;
}

const operationId = await deployToYield(opWalletId);
What happens next?
  1. RebelFi creates a reservation (locks 1000 USDC from available balance)
  2. Operation enters PLANNED status
  3. Your custody agent polls and executes the transaction
  4. Funds are deployed to yield protocols
  5. Allocation becomes ACTIVE and starts earning yield

Step 4: Set Up Custody Agent

For operations to execute, you need an agent that polls for pending transactions and signs them via your custody solution. Easiest: RebelFi runs the agent infrastructure for you.
  1. Navigate to Settings → Custody in the dashboard
  2. Select RebelFi Managed Agent
  3. Provide custody credentials (e.g., Tatum API key, Privy credentials)
  4. RebelFi handles polling, signing, and reporting
No code required — operations execute automatically.

Option B: Your Own Agent

Maximum control: Run your own polling service.
// Agent polling loop
import { Connection, Transaction } from '@solana/web3.js';

const solanaConnection = new Connection('https://api.mainnet-beta.solana.com');

async function agentPollLoop() {
  console.log('Agent started. Polling for work...');

  while (true) {
    try {
      // Poll for pending transactions
      const { data } = await client.post('/api/agent/transactions/poll', {
        leaseDurationMs: 30000
      });

      if (data.data.transaction) {
        const tx = data.data.transaction;
        console.log('Claimed transaction:', tx.id);

        // Deserialize unsigned transaction
        const transaction = Transaction.from(
          Buffer.from(tx.unsignedTx, 'base64')
        );

        // Sign with your custody solution
        const signedTx = await yourCustodySolution.sign(transaction);

        // Submit to Solana
        const txHash = await solanaConnection.sendRawTransaction(
          signedTx.serialize()
        );

        console.log('Submitted! TxHash:', txHash);

        // Report success
        await client.post(`/api/agent/transactions/${tx.id}/report`, {
          attemptId: tx.attemptId,
          status: 'SUCCESS',
          result: {
            txHash,
            submissionMode: 'AGENT'
          }
        });

        console.log('Reported success for tx:', tx.id);
      } else {
        // No work available
        await new Promise(resolve => setTimeout(resolve, 10000)); // Wait 10s
      }
    } catch (error) {
      console.error('Agent error:', error);
      await new Promise(resolve => setTimeout(resolve, 10000)); // Wait before retry
    }
  }
}

// Start agent
agentPollLoop();
For complete agent integration details, see the Custom Custody Integration Guide.

Step 5: Track Allocations

Monitor your deployed funds and yield performance.
// Get all allocations
async function getAllocations() {
  const response = await client.get('/api/v1/allocations');

  const { allocations, portfolioSummary } = response.data;

  console.log('Portfolio Summary:');
  console.log('  Total Deployed:', portfolioSummary.totalDeployed);
  console.log('  Total Yield:', portfolioSummary.totalYieldEarned);
  console.log('  Average APY:', portfolioSummary.averageAPY);

  allocations.forEach(allocation => {
    console.log(`\nAllocation ${allocation.id}:`);
    console.log('  Protocol:', allocation.protocol);
    console.log('  Deployed:', allocation.allocatedBase);
    console.log('  Current Value:', allocation.currentValue);
    console.log('  Yield Earned:', allocation.yieldEarned);
    console.log('  APY:', allocation.apy);
  });
}

await getAllocations();

Step 6: Withdraw Funds (Disburse)

When you need liquidity, unwind allocations and transfer funds.
// Create disburse operation
async function withdrawFunds(opWalletId: number) {
  const response = await client.post('/api/v1/operations/disburse', {
    opWalletId,
    amount: '500.00',
    asset: 'USDC',
    destination: 'YourExternalWalletAddress...'
  });

  const { operationId } = response.data.data;
  console.log('Disburse operation created:', operationId);

  // Wait for completion
  await waitForCompletion(operationId);
}

async function waitForCompletion(operationId: number) {
  while (true) {
    const { data } = await client.get(`/api/core/operations/${operationId}`);

    if (data.data.status === 'COMPLETED') {
      console.log('Operation completed!');
      console.log('TxHash:', data.data.blockchainTransactions[0].txHash);
      break;
    } else if (data.data.status === 'FAILED') {
      console.error('Operation failed');
      break;
    }

    await new Promise(resolve => setTimeout(resolve, 5000)); // Poll every 5s
  }
}

await withdrawFunds(opWalletId);
Disburse Flow:
  1. RebelFi unwinds allocations (if needed)
  2. Transfers funds to destination address
  3. Updates wallet balances
Instant Liquidity: If funds are already available (not deployed), the transfer happens immediately without unwinding.

Complete Example

Here’s a complete end-to-end example combining all steps:
import axios from 'axios';

const REBELFI_API_KEY = process.env.REBELFI_API_KEY;
const WALLET_ADDRESS = '9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin';

const client = axios.create({
  baseURL: 'https://api.rebelfi.io',
  headers: {
    'X-API-Key': REBELFI_API_KEY,
    'Content-Type': 'application/json'
  }
});

async function quickStart() {
  try {
    // 1. Import wallet
    console.log('Step 1: Importing wallet...');
    const importResponse = await client.post('/api/v1/wallets/import', {
      address: WALLET_ADDRESS,
      blockchain: 'SOLANA',
      label: 'API Quick Start Wallet'
    });
    const orgWalletId = importResponse.data.data.orgWalletId;
    console.log('✓ Wallet imported! ID:', orgWalletId);

    // 2. Enable yield monitoring
    console.log('\nStep 2: Enabling yield monitoring...');
    const monitorResponse = await client.post('/api/core/wallets/add-and-monitor', {
      orgWalletId,
      enableYield: true,
      bufferAmount: '100.00'
    });
    const opWalletId = monitorResponse.data.data.opWalletId;
    console.log('✓ Yield monitoring enabled! OpWallet ID:', opWalletId);

    // 3. Deploy to yield
    console.log('\nStep 3: Deploying funds to yield...');
    const supplyResponse = await client.post('/api/v1/allocations', {
      opWalletId,
      amount: '1000.00',
      asset: 'USDC'
    });
    console.log('✓ Supply operation created!');
    console.log('  Reservation ID:', supplyResponse.data.reservationId);
    console.log('  Operation ID:', supplyResponse.data.bundleId);

    // 4. Wait a bit, then check allocations
    console.log('\nStep 4: Waiting for execution...');
    await new Promise(resolve => setTimeout(resolve, 30000)); // Wait 30s

    const allocationsResponse = await client.get('/api/v1/allocations');
    const { allocations, portfolioSummary } = allocationsResponse.data;

    console.log('\n✓ Allocations:');
    console.log('  Total Deployed:', portfolioSummary.totalDeployed);
    console.log('  Total Yield:', portfolioSummary.totalYieldEarned);
    console.log('  Average APY:', portfolioSummary.averageAPY);

    console.log('\n🎉 Quick start complete!');
    console.log('Your funds are now earning yield automatically.');

  } catch (error) {
    console.error('Error:', error.response?.data || error.message);
  }
}

quickStart();

Next Steps


Common Patterns

Automatically deploy funds when they arrive in your wallet:
// Monitor wallet balance
async function monitorAndDeploy(opWalletId: number) {
  setInterval(async () => {
    const { data } = await client.get('/api/core/wallets/monitored');
    const wallet = data.data.find(w => w.id === opWalletId);

    const availableAmount = parseFloat(wallet.availableBalance);
    const bufferAmount = parseFloat(wallet.bufferAmount);

    // If we have excess funds above buffer
    if (availableAmount > bufferAmount + 100) {
      const deployAmount = (availableAmount - bufferAmount).toFixed(2);

      await client.post('/api/v1/allocations', {
        opWalletId,
        amount: deployAmount,
        asset: 'USDC'
      });

      console.log(`Auto-deployed ${deployAmount} USDC to yield`);
    }
  }, 60000); // Check every minute
}
Schedule regular withdrawals (e.g., monthly payouts):
import cron from 'node-cron';

// Run on the 1st of every month at 9 AM
cron.schedule('0 9 1 * *', async () => {
  console.log('Running monthly withdrawal...');

  await client.post('/api/v1/operations/disburse', {
    opWalletId: 456,
    amount: '5000.00',
    asset: 'USDC',
    destination: 'MonthlyPayoutAddress...'
  });

  console.log('Monthly withdrawal initiated');
});
Get notified when yield drops below threshold:
async function checkPerformance() {
  const { data } = await client.get('/api/v1/allocations');
  const { portfolioSummary } = data;

  const currentAPY = parseFloat(portfolioSummary.averageAPY);

  if (currentAPY < 4.0) {
    // Send alert (email, Slack, etc.)
    console.warn(`⚠️ APY dropped to ${currentAPY}%`);
    await sendAlert(`APY alert: ${currentAPY}%`);
  }
}

// Check every 6 hours
setInterval(checkPerformance, 6 * 60 * 60 * 1000);

Troubleshooting

Cause: Invalid or missing API keySolution:
  • Verify API key is correct
  • Check it’s included in X-API-Key header (not Authorization)
  • Regenerate API key from dashboard if needed
Cause: No custody agent runningSolution:
  • Set up RebelFi Managed Agent in dashboard, OR
  • Run your own agent polling loop (see Step 4)
  • Check agent logs for errors
Cause: Available balance is less than requested amountSolution:
  • Check available balance: GET /api/core/wallets/monitored
  • Remember: Total = Available + Reserved + Allocated
  • Wait for pending operations to complete, or
  • Reduce requested amount
Cause: Waiting for approval or agent executionSolution:
  • Check if approval required: GET /api/core/operations/queue
  • Approve manually: POST /api/core/operations/:id/approve
  • Ensure agent is running and polling

Support

Need help?