> ## 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.

# Client Accounts

> Give each of your clients a RebelFi account, with its own consent and its own read-only portal

A **client account** is a RebelFi account you open for one of your clients. Use client accounts when your client, not
you, has to agree to RebelFi's terms before its funds are put to work: for example, when you hold your clients' assets
as a custodian and can't offer the yield product yourself.

With a client account:

* RebelFi emails a person at your client (the **contact**). They set a password, accept RebelFi's terms and risk
  disclosures, authorize you to act for them, and turn on two-factor login.
* Until the terms are accepted, RebelFi refuses to plan any supply to the client's wallets.
* Once active, the client signs in to the **RebelFi Earn portal** to see its positions, earnings and transactions. The
  portal is read-only: you keep the assets and the keys, and you still plan, sign and submit every operation.
* RebelFi holds the record of who agreed to what, and when.

> [!NOTE]
>
> Client accounts are enabled per organization by RebelFi. Contact us to turn them on. Until then,
> [Create Account](https://docs.rebelfi.io/docs/api-reference/accounts/create.md) and a register with `accountId` return `CLIENT_ACCOUNTS_NOT_ENABLED`,
> and the other account calls return `ACCOUNT_NOT_FOUND`.

## The flow

**1. Open the account**

Call [Create Account](https://docs.rebelfi.io/docs/api-reference/accounts/create.md) with your own `reference` for the client, its organization
name, and the contact's name and email. RebelFi emails the contact an activation link. The response never carries
the link.

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

**2. Link the client's wallets**

Register each wallet you hold for the client with the account's `accountId`, and a
[proof of control](https://docs.rebelfi.io/docs/api-reference/wallets/challenge.md). The wallet's `userId` becomes the account's `reference`.

```typescript theme={null}
const wallet = await client.wallets.register({
  walletAddress,
  blockchain: 'solana',
  accountId: account.accountId,
  proof: { challengeId, signature }
});
// wallet.accountId === account.accountId, wallet.userId === 'CLIENT-0042'
```

**3. The contact activates the account**

The contact opens the link in the RebelFi Earn portal, sets a password, and accepts the terms and the
authorization. The account becomes `ACTIVE`. Poll [Get Account](https://docs.rebelfi.io/docs/api-reference/accounts/get.md) to see it. If the
link expires (after 7 days) or the email is lost, call [Resend Activation](https://docs.rebelfi.io/docs/api-reference/accounts/resend-activation.md).

**4. Supply**

Plan supplies as usual with [Supply](https://docs.rebelfi.io/docs/api-reference/operations/supply.md). Before the account is active, supply is
refused with `CLIENT_ACCOUNT_NOT_ACTIVE`.

**5. Read the client's figures**

[Account Summary](https://docs.rebelfi.io/docs/api-reference/accounts/summary.md) returns the same totals, 30-day APY, wallets and positions the
client sees in the portal.

## Account states

| State | Supply | Unwind | Client portal |
| - | - | - | - |
| `PENDING_ACTIVATION` | Refused (`CLIENT_ACCOUNT_NOT_ACTIVE`) | Allowed | Activation only |
| `ACTIVE` | Allowed | Allowed | Signed in, read-only |
| `SUSPENDED` | Refused (`CLIENT_ACCOUNT_NOT_ACTIVE`) | Allowed | Signed in, read-only, with a notice |

Only RebelFi suspends and reinstates an account. When an account is suspended, supplies on its wallets that RebelFi has
not yet received a transaction or hash for are cancelled: do not broadcast their transactions.
[Submit Signed](https://docs.rebelfi.io/docs/api-reference/transactions/submit-signed.md) refuses a cancelled supply with `400` and broadcasts nothing.
Only a supply already submitted to RebelFi (by [Submit Hash](https://docs.rebelfi.io/docs/api-reference/transactions/submit-hash.md) or Submit Signed)
completes as planned. RebelFi can't know what you have already signed: if a cancelled supply's transaction is broadcast
anyway and lands, RebelFi records it (report its hash with Submit Hash), the supply becomes `CONFIRMED` and your
organization is alerted, so the funds are tracked, but the client's money has moved into a strategy on a suspended
account.

**Account status never blocks an unwind.** Suspending your whole organization is a different, broader switch: it
refuses your API key, unwinds included.

## Rules for organizations with client accounts

* **Every supply needs an active account.** A supply on a wallet linked to no account is refused with
  `CLIENT_ACCOUNT_REQUIRED`. Link the wallet with `accountId` first.
* **`userId` is set by RebelFi.** [Register Wallet](https://docs.rebelfi.io/docs/api-reference/wallets/register.md) and
  [Update Wallet](https://docs.rebelfi.io/docs/api-reference/wallets/update.md) refuse a `userId` with `USER_ID_NOT_ALLOWED`. A linked wallet's
  `userId` is its account's `reference`, so reads that select by `userId`, such as
  [List Allocations](https://docs.rebelfi.io/docs/api-reference/allocations/list.md), select the account's wallets.
* **A wallet belongs to one account.** Registering a linked wallet with another `accountId` is refused with
  `WALLET_LINKED_TO_ANOTHER_ACCOUNT`.
* **One email, one account.** A contact email that already belongs to a RebelFi user or another client account is
  refused with `CONTACT_EMAIL_UNAVAILABLE`.
* **Fresh unsigned transactions follow the same rule.** Once suspension has cancelled a supply,
  `GET /v1/operations/:id/unsigned-transactions` (`operations.getUnsignedTransactions()` in the SDK) answers `400`
  `VALIDATION_FAILED` ("No unsigned transactions found"). A supply still waiting for its first transaction answers
  `403` `CLIENT_ACCOUNT_REQUIRED` or `CLIENT_ACCOUNT_NOT_ACTIVE` only if its cancellation failed. A supply already
  under way is never refused.

## Words in the Earn portal

The portal shows your client the words agreed for both platforms: **Allocate** for a supply and **Withdraw** for an
unwind. The API keeps Supply and Unwind. See the [Glossary](https://docs.rebelfi.io/docs/guides/glossary.md#client-accounts-and-the-earn-portal) for
every portal word and its API equivalent.


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