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

# Sub-Accounts

> Run separate strategies from separate margin accounts.

export const LearnStyles = () => {
  useEffect(() => {
    const revealReference = () => {
      let id;
      try {
        id = decodeURIComponent(window.location.hash.slice(1));
      } catch {
        return;
      }
      if (!id) return;
      const target = document.getElementById(id);
      if (!target) return;
      let opened = false;
      for (let parent = target.parentElement; parent; parent = parent.parentElement) {
        if (parent.tagName === "DETAILS" && !parent.open) {
          parent.open = true;
          opened = true;
        }
      }
      if (opened) target.scrollIntoView({
        block: "start"
      });
    };
    const frame = requestAnimationFrame(revealReference);
    window.addEventListener("hashchange", revealReference);
    return () => {
      cancelAnimationFrame(frame);
      window.removeEventListener("hashchange", revealReference);
    };
  }, []);
  return <style>{`
.monaco-learn {
  --bg:#fff;
  --fg:#18261e;
  --body:#465149;
  --muted:#69756d;
  --line:#dce3dd;
  --accent:#233329;
  --callout:#f0f5ef;
  --amber:#9a6418;
}
.dark .monaco-learn {
  --bg:#0e1410;
  --fg:#edf3ed;
  --body:#c3cdc5;
  --muted:#9daa9f;
  --line:#344239;
  --accent:#c4dfc8;
  --callout:#1c2b20;
  --amber:#edc680;
}
.monaco-learn [data-as=p] {
  display: block;
  margin: 1.25em 0;
}
.monaco-learn .small-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.monaco-learn .example,
.monaco-learn .formula {
  margin: 24px 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--callout);
}
.monaco-learn .example strong {
  display: block;
  font-size: 19px;
  color: var(--fg);
}
.monaco-learn .example p {
  margin: 10px 0 0;
}
.monaco-learn .formula {
  font-family: monospace;
  overflow-x: auto;
}
.monaco-learn .callout {
  margin: 24px 0;
  padding: 18px 20px;
  border-left: 3px solid var(--accent);
  background: var(--callout);
  border-radius: 0 8px 8px 0;
}
.monaco-learn .callout.warning {
  border-color: var(--amber);
}
.monaco-learn .primary-link {
  display: inline-block;
  padding: 10px 18px;
  border-radius: 8px;
  background: #233329;
  color: white;
  text-decoration: none;
}
.monaco-learn .account-cards,
.monaco-learn .referral-levels {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 24px 0;
}
.monaco-learn .account-cards > div,
.monaco-learn .referral-levels > div {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.monaco-learn .account-cards h3 {
  margin: 0 0 8px;
  font-size: 16px;
}
.monaco-learn .account-cards p {
  margin: 0;
  font-size: 14px;
}
.monaco-learn .referral-levels {
  text-align: center;
}
.monaco-learn .referral-levels strong {
  display: block;
  font-size: 32px;
  color: var(--accent);
}
.monaco-learn .referral-levels span {
  display: block;
  font-size: 12px;
}
.monaco-learn .flow {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 24px 0;
}
.monaco-learn .flow > div {
  flex: 1;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.monaco-learn .flow b {
  display: block;
  color: var(--muted);
}
.monaco-learn .flow p {
  font-size: 13px;
  margin: 8px 0 0;
}
.monaco-learn .learn-reference {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
  margin-top: 36px;
}
.monaco-learn .learn-reference > summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
}
.monaco-learn .fee-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.monaco-learn .fee-tabs {
  display: flex;
  gap: 8px;
}
.monaco-learn .fee-controls button {
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--fg);
}
.monaco-learn .fee-tabs button[aria-selected=true] {
  background: var(--callout);
  font-weight: 600;
}
.monaco-learn .fee-panel {
  overflow-x: auto;
}
.monaco-learn .fees-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.monaco-learn .fees-table th,
.monaco-learn .fees-table td {
  padding: 12px;
  text-align: right;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.monaco-learn .fees-table th:first-child,
.monaco-learn .fees-table th:nth-child(2),
.monaco-learn .fees-table td:first-child,
.monaco-learn .fees-table td:nth-child(2) {
  text-align: left;
}
.monaco-learn .fees-table caption {
  text-align: left;
  font-weight: 600;
  margin-bottom: 10px;
}
.monaco-learn button:focus-visible,
.monaco-learn input:focus-visible,
.monaco-learn summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}
@media (max-width: 600px) {
  .monaco-learn .account-cards {
    grid-template-columns: 1fr;
  }
  .monaco-learn .flow {
    flex-direction: column;
    align-items: stretch;
  }
  .monaco-learn .flow > span {
    display: none;
  }
  .monaco-learn .referral-levels > div {
    padding: 14px 6px;
  }
  .monaco-learn .referral-levels span {
    font-size: 10px;
  }
}
@media print {
  .monaco-learn .fee-controls {
    display: none;
  }
  .monaco-learn .fee-panel[hidden] {
    display: block;
    margin-top: 20px;
  }
}
.monaco-learn .referral-calculator {
  margin: 30px 0;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 25px;
  background: var(--bg);
}
.monaco-learn .calculator-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.monaco-learn .calculator-heading h3 {
  font-size: 19px;
  margin: 0;
  letter-spacing: -.025em;
}
.monaco-learn .calculator-heading .small-label {
  margin-bottom: 5px;
}
.monaco-learn .unlimited-flag {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 30px;
  background: var(--callout);
  padding: 4px 9px;
  font-size: 10px;
  color: var(--accent);
  white-space: nowrap;
}
.monaco-learn .calculator-intro {
  font-size: 13px;
  line-height: 1.7;
  margin: 13px 0 25px;
}
.monaco-learn .calculator-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 26px;
  align-items: start;
}
.monaco-learn .referral-control {
  margin: 0 0 20px;
}
.monaco-learn .slider-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.monaco-learn .slider-label label {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--fg);
}
.monaco-learn .slider-label label span {
  display: block;
  font-weight: 400;
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
}
.monaco-learn .slider-label output {
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  flex: none;
}
.monaco-learn .referral-calculator input[type=range] {
  display: block;
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 24px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  --range-fill:0%;
}
.monaco-learn .referral-calculator input[type=range]::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 5px;
  background:
    linear-gradient(
      to right,
      var(--accent) var(--range-fill),
      var(--line) var(--range-fill));
}
.monaco-learn .referral-calculator input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 1px var(--accent);
  margin-top: -6px;
}
.monaco-learn .referral-calculator input[type=range]::-moz-range-track {
  height: 5px;
  border-radius: 5px;
  background: var(--line);
}
.monaco-learn .referral-calculator input[type=range]::-moz-range-progress {
  height: 5px;
  border-radius: 5px;
  background: var(--accent);
}
.monaco-learn .referral-calculator input[type=range]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 1px var(--accent);
}
.monaco-learn .slider-scale {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  line-height: 1.5;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.monaco-learn .referral-calculator .calculator-help {
  font-size: 10px;
  line-height: 1.7;
  color: var(--muted);
  margin: 6px 0 0;
}
.monaco-learn .calculator-inputs > .calculator-help {
  margin: -7px 0 20px;
}
.monaco-learn .volume-control {
  border-top: 1px solid var(--line);
  padding-top: 18px;
  margin-bottom: 0;
}
.monaco-learn .volume-control .slider-label {
  flex-wrap: wrap;
  gap: 4px;
}
.monaco-learn .volume-control label {
  font-size: 12px;
}
.monaco-learn .volume-control output {
  font-size: 17px;
}
.monaco-learn .earn-estimate {
  background: var(--callout);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 23px 20px;
  color: var(--accent);
  min-width: 0;
}
.monaco-learn .estimate-kicker {
  font-size: 10px;
  letter-spacing: .07em;
  text-transform: uppercase;
  font-weight: 600;
}
.monaco-learn .estimate-total,
.monaco-learn .estimate-annual {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  line-height: 1.25;
}
.monaco-learn .estimate-total {
  margin: 14px 0 15px;
}
.monaco-learn .estimate-total output {
  font-size: clamp(24px, 2.3vw, 34px);
  font-weight: 600;
  letter-spacing: -.045em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.monaco-learn .estimate-total span,
.monaco-learn .estimate-annual span {
  font-size: 11px;
  color: var(--muted);
}
.monaco-learn .estimate-annual output {
  font-size: 23px;
  font-weight: 500;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.monaco-learn .estimate-breakdown {
  border-top: 1px solid var(--line);
  padding-top: 17px;
  margin-top: 23px;
}
.monaco-learn .breakdown-title {
  display: block;
  font-size: 10px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--accent);
}
.monaco-learn .estimate-breakdown > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
  margin: 9px 0;
  line-height: 1.5;
}
.monaco-learn .estimate-breakdown > div > span {
  color: var(--body);
}
.monaco-learn .estimate-breakdown output {
  font-variant-numeric: tabular-nums;
  text-align: right;
  overflow-wrap: anywhere;
  min-width: 0;
}
.monaco-learn .earn-estimate p {
  font-size: 10px;
  line-height: 1.7;
  color: var(--muted);
  margin: 20px 0 0;
}
.monaco-learn .calculator-assumptions {
  border-top: 1px solid var(--line);
  margin-top: 24px;
  padding-top: 16px;
  font-size: 12px;
}
.monaco-learn .calculator-assumptions summary {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  list-style: none;
  cursor: pointer;
  color: var(--fg);
  font-weight: 500;
}
.monaco-learn .calculator-assumptions summary > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}
.monaco-learn .calculator-assumptions summary::-webkit-details-marker {
  display: none;
}
.monaco-learn .calculator-assumptions p {
  font-size: 11px;
  line-height: 1.8;
  margin: 12px 0 0;
}
.monaco-learn .referral-calculator .calculator-footnote {
  font-size: 10px;
  line-height: 1.8;
  color: var(--muted);
  margin: 13px 0 0;
}
@media (max-width: 600px) {
  .monaco-learn .referral-calculator {
    padding: 20px;
  }
  .monaco-learn .calculator-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  .monaco-learn .calculator-heading {
    gap: 10px;
  }
  .monaco-learn .calculator-heading h3 {
    font-size: 18px;
  }
  .monaco-learn .calculator-intro {
    font-size: 12px;
  }
  .monaco-learn .calculator-heading .small-label {
    font-size: 9px;
  }
  .monaco-learn .slider-label label {
    font-size: 13px;
  }
  .monaco-learn .slider-label output {
    font-size: 18px;
  }
  .monaco-learn .volume-control .slider-label {
    display: block;
  }
  .monaco-learn .volume-control output {
    display: block;
    font-size: 21px;
    margin: 6px 0;
  }
  .monaco-learn .earn-estimate {
    padding: 22px;
  }
  .monaco-learn .estimate-total output {
    font-size: 36px;
  }
  .monaco-learn .estimate-annual output {
    font-size: 27px;
  }
  .monaco-learn .estimate-breakdown > div {
    font-size: 12px;
  }
  .monaco-learn .calculator-assumptions summary {
    flex-wrap: wrap;
    gap: 4px;
  }
}
@media print {
  .monaco-learn .calculator-grid {
    grid-template-columns: 1.2fr 1fr;
  }
  .monaco-learn .referral-calculator {
    break-inside: avoid;
  }
  .monaco-learn .calculator-assumptions > * {
    display: block !important;
  }
  .monaco-learn .calculator-assumptions summary {
    display: flex !important;
  }
}
`}</style>;
};

<LearnStyles />

<div className="monaco-learn">
  Sub-accounts are extra margin accounts that sit beside your parent margin account. Each one holds its own collateral and its own positions, all under the same wallet.

  ## Why Use Sub-Accounts

  Sub-accounts are **isolated**. A loss in one sub-account never draws on another, or on your parent margin account.

  Use them to keep a hedge apart from your main book, to run one strategy per account, or to give a bot or agent an account of its own.

  ## Funding A Sub-Account

  | Movement | How it works |
  | - | - |
  | Deposit / withdrawal | On-chain, through your parent margin account only. |
  | Parent → sub-account | Internal transfer. Gasless, with no on-chain transaction. |
  | Sub-account → parent | Internal transfer. Gasless, with no on-chain transaction. |

  <div className="callout"><strong>Withdraw from your parent margin account.</strong><br />To withdraw funds held in a sub-account, transfer them back to your parent margin account first.</div>

  ## Limits

  | Rule | Value |
  | - | - |
  | Open sub-accounts | 10 at the first volume tier, rising with your 14-day trading volume to 50. |
  | Copy sub-accounts | Do not count toward the limit. |
  | Names | Up to 64 letters, digits, `_`, `-`, `.` or `:`. |

  ## Closing A Sub-Account

  A sub-account can be closed once it is **flat**: no open positions and no resting, conditional, or TWAP orders. Its collateral returns to your parent margin account in the same step.

  A sub-account still in liquidation or bad debt cannot be closed.

  ## Agents And Copy Trading

  A delegated agent can be limited to a single sub-account, so it trades only that account.

  Following a lead trader opens a copy sub-account for that leader, named `copy:` followed by the leader's ID. Names starting with `copy:`, in any letter case, are reserved for these accounts. See [Copy Trading](/developers/copy-trading).

  ## Working With Sub-Accounts

  [Perps Collateral](/developers/perps-collateral#margin-sub-accounts) covers creating, funding, reading, and closing sub-accounts through the API and SDK. The [Margin Accounts SDK](/sdk/typescript/margin-accounts) lists every margin account method, and [Positions](/developers/positions) covers position risk.

  <Accordion title="Full Sub-Accounts Reference" id="full-reference" className="learn-reference">
    <h2 id="api-surface">API Surface</h2>

    | Action | REST | TypeScript SDK |
    | - | - | - |
    | Create (or reopen) | `POST /api/v1/margin/sub-accounts` | `createMarginSubAccount({ subaccountKey })` |
    | List | `GET /api/v1/margin/accounts` | `listMarginAccounts()` |
    | Transfer in | `POST /api/v1/margin/sub-accounts/{marginAccountId}/collateral/transfer-in` | `transferCollateralToSubAccount(marginAccountId, amount)` |
    | Transfer out | `POST /api/v1/margin/sub-accounts/{marginAccountId}/collateral/transfer-out` | `transferCollateralFromSubAccount(marginAccountId, amount)` |
    | Close | `POST /api/v1/margin/sub-accounts/{marginAccountId}/close` | `closeMarginSubAccount(marginAccountId)` |

    `POST /api/v1/margin/collateral/transfer` (`transferMarginCollateral`) also moves collateral between any two of your margin accounts. Rows from `listMarginAccounts()` carry `subaccountKey` and `marginAccountState`.

    <h2 id="transfer-rules">Transfer Rules</h2>

    * Creating, closing, and transferring share the per-user movement budget with withdrawals. Exceeding it returns `429` with `retryAfter`.
    * The sub-account transfer routes refuse your parent margin account with `400`; use the parent margin account routes for it.
    * An unknown margin account, or one you do not own, returns `404`.
    * A delegated agent session cannot use the sub-account transfer routes.
  </Accordion>
</div>


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