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

# Treasury

> Use StableStack to hold, manage, and deploy stablecoin liquidity across wallets and markets.

## Overview

Treasury teams at fintechs, crypto-native companies, and Web3 businesses need a reliable way to hold stablecoin reserves, distribute liquidity to subsidiaries or partners, and execute fiat off-ramps on demand. StableStack provides a programmable treasury layer — multi-wallet infrastructure, fiat payouts to any bank, and full transaction visibility.

***

## Core Flow

<Steps>
  <Step title="Set up merchant-level wallets for each reserve">
    Create separate merchant wallets for different purposes (e.g., a USDC wallet on ERC20 for operational receipts, a USDC wallet on Polygon as a secondary reserve). No `customer_id` is required for merchant wallets.

    ```http theme={null}
    POST /wallets
    ```

    ```json theme={null}
    {
      "currency": "USDC",
      "network": "erc20",
      "description": "Primary USDC reserve (ERC20)"
    }
    ```

    ```json theme={null}
    {
      "currency": "USDC",
      "network": "polygon",
      "description": "Secondary USDC reserve (Polygon)"
    }
    ```
  </Step>

  <Step title="View all wallets and balances">
    Get a consolidated view of all merchant wallets and their balances for treasury reporting.

    ```http theme={null}
    GET /wallets
    ```
  </Step>

  <Step title="Distribute funds to subsidiaries or partners">
    When disbursing to an entity with a crypto wallet, send directly to their stablecoin address.

    ```http theme={null}
    POST /payouts/wallets
    ```

    ```json theme={null}
    {
      "currency": "USDC",
      "address": "RecipientWalletAddressHere",
      "amount": 50000,
      "network": "erc20",
      "recipient_name": "Partner Entity Ltd"
    }
    ```
  </Step>

  <Step title="Off-ramp to a bank account">
    Convert stablecoin reserves to fiat and pay directly into a bank account — useful for covering local operating expenses or settling invoices.

    ```http theme={null}
    POST /payouts/banks
    ```

    ```json theme={null}
    {
      "currency": "USDC",
      "account_number": "0123456789",
      "bank_name": "Zenith Bank",
      "bank_code": "000015",
      "amount": "10000",
      "recipient_name": "Operations Account",
      "recipient_currency": "NGN",
      "recipient_country": "Nigeria"
    }
    ```
  </Step>

  <Step title="Audit the full transaction history">
    Query all transactions across your merchant account for reconciliation, audits, or reporting.

    ```http theme={null}
    GET /transactions
    ```

    Filter by transaction ID or reference ID for precise lookups:

    ```http theme={null}
    GET /customers/transactions/by_txid/{transaction_id}
    GET /customers/transactions/by_ref_id/{reference_id}
    ```
  </Step>
</Steps>

***

## Treasury Architecture Pattern

A typical StableStack treasury setup uses layered wallets:

```
Merchant Account
├── USDC / ERC20    → Operational reserve (inbound receipts)
├── USDC / Polygon  → Liquidity buffer (outbound payments)
└── NGN / Fiat      → Local operating expenses (bank withdrawals)
```

Each wallet has a dedicated on-chain address. Inbound deposits trigger `wallet.transaction.inbound` webhooks, giving your treasury system real-time visibility.

***

## Key APIs Used

| Endpoint                   | Purpose                               |
| -------------------------- | ------------------------------------- |
| `POST /wallets`            | Create merchant wallets               |
| `GET /wallets`             | View all wallets and balances         |
| `GET /wallets/{wallet_id}` | Get a specific wallet                 |
| `POST /payouts/wallets`    | Send stablecoin to an external wallet |
| `POST /payouts/banks`      | Off-ramp to a local bank account      |
| `GET /transactions`        | Full transaction history              |
| `GET /payouts/fees`        | Pre-check payout fees                 |

***

## Relevant Webhook Events

| Event                         | Trigger                         |
| ----------------------------- | ------------------------------- |
| `wallet.transaction.inbound`  | Funds received into a wallet    |
| `wallet.transaction.outbound` | Funds sent from a wallet        |
| `payout.completed`            | Bank or wallet payout confirmed |
| `payout.failed`               | Payout failed — requires retry  |

***

## Next Steps

* [Authentication](/authentication) — Get your API key
* [Webhook Security](/webhooks/security) — Verify webhook signatures
* [Stablecoin Coverage](/coverage/stablecoins) — Supported networks and assets
