> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rebelfi.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Accounts

> AccountsAPI — Open client accounts and read their figures

## AccountsAPI

Access via `client.accounts`. For organizations that open [client accounts](https://docs.rebelfi.io/docs/guides/client-accounts.md); for any other
organization `create` returns `CLIENT_ACCOUNTS_NOT_ENABLED` and the other calls return `ACCOUNT_NOT_FOUND`. Available from SDK 1.4.5.

### create

Open a client account. RebelFi emails the contact an activation link; the response never carries it. Idempotent on
`reference` with the same contact email. Needs a profile-scoped key.

```typescript theme={null}
async create(request: CreateAccountRequest): Promise<AccountResponse>
```

```typescript theme={null}
interface CreateAccountRequest {
  /** Your own reference for this client, unique within your organization. Becomes the userId of its wallets */
  reference: string;
  /** The client organization's name */
  organizationName: string;
  contact: AccountContact;
}

interface AccountContact {
  firstName: string;
  lastName: string;
  /** Where the activation email goes. Must not already belong to a RebelFi user or another client account */
  email: string;
}
```

### get

Get a client account: its status and linked wallets.

```typescript theme={null}
async get(accountId: number): Promise<AccountResponse>
```

### resendActivation

Email the contact a new activation link; the previous one stops working. Only while the account is pending
activation and the contact hasn't used the link (`ACCOUNT_ALREADY_ACTIVE`, `ACTIVATION_LINK_USED`). Needs a
profile-scoped key.

```typescript theme={null}
async resendActivation(accountId: number): Promise<AccountResponse>
```

### summary

The account's figures as its RebelFi Earn portal shows them.

```typescript theme={null}
async summary(accountId: number): Promise<AccountSummaryResponse>
```

### AccountResponse Type

```typescript theme={null}
enum ClientAccountStatus {
  /** The contact hasn't accepted the terms yet. Supply is refused */
  PENDING_ACTIVATION = 'PENDING_ACTIVATION',
  /** Supply is allowed */
  ACTIVE = 'ACTIVE',
  /** Suspended by RebelFi. Supply is refused; unwind is allowed */
  SUSPENDED = 'SUSPENDED',
}

interface AccountResponse {
  accountId: number;
  reference: string;
  organizationName: string;
  status: ClientAccountStatus | 'PENDING_ACTIVATION' | 'ACTIVE' | 'SUSPENDED';
  /** ISO 8601 */
  createdAt: string;
  /** When the client accepted the terms (ISO 8601); absent while pending */
  activatedAt?: string;
  /** Linked wallets. A profile-scoped key sees its own profile's wallets; an admin key sees all */
  wallets: WalletResponse[];
}
```

### AccountSummaryResponse Type

Amounts are strings in base units (show them with `tokenDecimals`), APYs are decimals, and times are ISO 8601 UTC.

```typescript theme={null}
interface AccountSummaryResponse {
  /** The oldest lastUpdated among the positions; null when there are none */
  asOf: string | null;
  /** The positions' 30-day APY weighted by current value; null when no position has both */
  apy30d: number | null;
  /** One entry per token symbol, each the sum of that token's positions */
  totals: AccountTokenTotals[];
  wallets: AccountEarnWallet[];
  positions: AccountPosition[];
}

type AccountChain = 'SOLANA' | 'ETHEREUM' | 'BASE' | 'ARC' | 'POLYGON';

interface AccountTokenTotals {
  token: string;
  tokenDecimals: number;
  principal: string;
  currentValue: string;
  yieldEarned: string;
}

interface AccountEarnWallet {
  walletId: number;
  address: string;
  chain: AccountChain;
  /** null when the chain has no explorer */
  explorerUrl: string | null;
  balances: AccountWalletBalance[];
}

interface AccountWalletBalance {
  token: string;
  tokenAddress: string;
  tokenDecimals: number;
  /** In the wallet and not supplied */
  available: string;
  /** Current value of what is supplied from this wallet, after the yield share */
  supplied: string;
}

/** The allocation row allocations.list() returns, plus IDs, decimals and the 30-day APY */
interface AccountPosition {
  allocationId: number;
  walletId: number;
  strategyId: number;
  strategyName: string;
  venueId: number;
  venueName: string;
  walletAddress: string;
  /** 'solana' | 'ethereum' | 'polygon' | 'base' */
  blockchain: string;
  chain: AccountChain;
  token: string;
  tokenAddress: string;
  tokenDecimals: number;
  principal: string;
  /** After the yield share */
  currentValue: string;
  /** Never negative */
  yieldEarned: string;
  /** Before the yield share */
  apy: number;
  /** After this wallet's yield share */
  apyNet: number;
  /** Mean daily net APY over the last 30 UTC days with data; null when none */
  apy30d: number | null;
  lastUpdated: string;
}
```

### Example

```typescript theme={null}
import { RebelfiError, ErrorCode, ClientAccountStatus } from '@rebelfi/sdk';

const account = await client.accounts.create({
  reference: 'CLIENT-0042',
  organizationName: 'Example Capital LP',
  contact: { firstName: 'Jane', lastName: 'Doe', email: 'jane@example.com' }
});

await client.wallets.register({
  walletAddress,
  blockchain: 'solana',
  accountId: account.accountId,
  proof: { challengeId, signature }
});

try {
  await client.operations.supply({ walletAddress, strategyId, amount: '1000000', tokenAddress });
} catch (error) {
  if (error instanceof RebelfiError && error.is(ErrorCode.CLIENT_ACCOUNT_NOT_ACTIVE)) {
    // error.details.status is PENDING_ACTIVATION until the contact accepts the terms
  }
}

const { status } = await client.accounts.get(account.accountId);
if (status === ClientAccountStatus.ACTIVE) {
  const summary = await client.accounts.summary(account.accountId);
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.