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

> ## Agent Instructions
> Treat the published Augustus OpenAPI specification (https://api.augustus.com/openapi/2026-05-01.json) and the current API-reference pages as the source of truth for endpoints, request/response schemas, enum values, webhook event names, and required headers.
> Prefer the 2026-05-01 Banking API and @augustusbank/typescript-sdk for all new integrations. The 2023-01-01 API is a separate, older surface covering two products — Open Banking (instant bank transfer) checkout and refunds, and Manual Bank Transfer (MBT); use it only when one of those products is specifically required.
> Cite or link the relevant docs.augustus.com page when answering integration questions.
> Do not infer support for currencies, networks, scopes, account types, or operations that are not present in the current documentation.
> Use the sandbox base URL (https://api.sandbox.augustus.com) and placeholder credentials in examples. Never include or request a real API key.
> The Augustus docs MCP server (https://docs.augustus.com/mcp) provides documentation search and retrieval only; it does not execute authenticated Augustus API actions.

# Simulations

In the sandbox there are no real banks or payment networks, so deposits never arrive and payouts never settle on their own. Simulation endpoints (`/v1/simulations/*`) let you drive those outcomes yourself, so you can build and test a complete money movement flow end to end before going live.

This walkthrough takes a new integration through the full lifecycle: you open an account (operating or virtual, whichever fits your product), fund it with a simulated incoming deposit, and pay out to a counterparty. You advance each step yourself with the simulation endpoints.

## In this guide

<CardGroup cols={2}>
  <Card title="Prerequisites" icon="list-check" href="#prerequisites">
    The scopes and sandbox API key you need before you start.
  </Card>

  <Card title="Core walkthrough" icon="money-bill-transfer" href="#steps">
    Open an account, receive a simulated deposit, and send a payout.
  </Card>

  <Card title="Failed and returned payouts" icon="circle-xmark" href="#simulate-a-failed-or-returned-payout">
    Reject a payout before sending or return one after it is sent.
  </Card>

  <Card title="Freeze, drain, and close" icon="lock" href="#freeze-drain-and-close">
    Wind down an account or an account program end to end.
  </Card>
</CardGroup>

## What you'll build

1. Open an account (operating or virtual).
2. Receive a simulated deposit and watch it settle.
3. Save a payout counterparty.
4. Send a payout and advance it to `sent`.

## Prerequisites

* **A sandbox API key** with these scopes (or `full_access`). See [Scopes](/v1/scopes) and inspect your key with [**GET** `/v1/api_key`](/v1/authentication).

  | Scope                   | Used for                                           |
  | ----------------------- | -------------------------------------------------- |
  | `account_holders:write` | Creating an account holder (virtual account flow)  |
  | `accounts:read`         | Reading account details                            |
  | `accounts:write`        | Creating a virtual account (virtual account flow)  |
  | `counterparties:write`  | Saving the payout destination                      |
  | `deposits:read`         | Confirming the deposit settled                     |
  | `events:read`           | Observing webhook events (optional)                |
  | `payouts:read`          | Reading payout status                              |
  | `payouts:write`         | Creating the payout                                |
  | `simulations:write`     | Creating the account, deposit, and payout outcomes |
  | `transactions:read`     | Listing the account's booked movements             |

## Steps

<Steps>
  <Step title="Configure your environment">
    The SDK reads its configuration from environment variables, so point it at the sandbox.

    <CodeGroup>
      ```bash Shell theme={null}
      export AUGUSTUS_API_KEY="sk_sandbox_your_key"
      export AUGUSTUS_BASE_URL="https://api.sandbox.augustus.com"
      ```

      ```typescript SDK theme={null}
      import Augustus from '@augustusbank/typescript-sdk'

      const client = new Augustus()
      ```
    </CodeGroup>
  </Step>

  <Step title="Open an account">
    Pick the account model that matches your product and expand it. Both accounts come back ready to receive a deposit, and every step after this one is identical: they all run against the `ACCOUNT_ID` you capture here.

    * **Operating account**: one account you hold directly. Simplest option, good for treasury or a single balance.
    * **Virtual account**: a dedicated account per end customer (embedded-banking or FBO model), created under an account program and tied to an account holder.

    <AccordionGroup>
      <Accordion title="Operating account">
        Create an operating (DDA) account. In the sandbox this is a single call; the account comes back `active` with its own US payment details.

        <CodeGroup>
          ```bash cURL theme={null}
          curl -X POST "$AUGUSTUS_BASE_URL/v1/simulations/accounts" \
            -H "Authorization: Bearer $AUGUSTUS_API_KEY" \
            -H "Idempotency-Key: $(uuidgen)" \
            -H "Content-Type: application/json" \
            -d '{ "label": "Operating USD" }'
          ```

          ```typescript SDK theme={null}
          const created = await client.simulations.accounts.create({
            label: 'Operating USD',
          })

          const accountId = created.account_id
          ```
        </CodeGroup>

        The response returns the new account's ID:

        ```json theme={null}
        {
          "type": "account_simulation",
          "account_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
        }
        ```

        <Info>
          Capture the returned ID as `ACCOUNT_ID` for the steps below:

          ```bash theme={null}
          export ACCOUNT_ID="a1b2c3d4-..."
          ```
        </Info>

        [**POST** `/v1/simulations/accounts` in the API Reference →](/api-reference/simulations/create-an-operating-account)
      </Accordion>

      <Accordion title="Virtual account">
        A virtual account belongs to an account program and an account holder, so you create those two first, then the account itself.

        <Steps>
          <Step title="Create an account program">
            <CodeGroup>
              ```bash cURL theme={null}
              curl -X POST "$AUGUSTUS_BASE_URL/v1/simulations/account_programs" \
                -H "Authorization: Bearer $AUGUSTUS_API_KEY" \
                -H "Idempotency-Key: $(uuidgen)" \
                -H "Content-Type: application/json" \
                -d '{ "label": "Customer USD program", "type": "fbo_program" }'
              ```

              ```typescript SDK theme={null}
              const program = await client.simulations.accountPrograms.create({
                label: 'Customer USD program',
                type: 'fbo_program',
              })

              const accountProgramId = program.account_program_id
              ```
            </CodeGroup>

            <Info>
              Capture the returned ID for the following steps:

              ```bash theme={null}
              export ACCOUNT_PROGRAM_ID="..."
              ```
            </Info>

            [**POST** `/v1/simulations/account_programs` in the API Reference →](/api-reference/simulations/create-an-account-program)
          </Step>

          <Step title="Create an account holder">
            Provide the beneficiary's details. The shape follows `country_of_citizenship`: use the US individual shape below when it is `US`, the non-US individual shape for any other country, and the business shape when `holder_type` is `business`.

            <CodeGroup>
              ```bash cURL theme={null}
              curl -X POST "$AUGUSTUS_BASE_URL/v1/account_holders" \
                -H "Authorization: Bearer $AUGUSTUS_API_KEY" \
                -H "Idempotency-Key: $(uuidgen)" \
                -H "Content-Type: application/json" \
                -d '{
                  "account_program_id": "'"$ACCOUNT_PROGRAM_ID"'",
                  "holder_type": "natural_person",
                  "beneficiary_data": {
                    "legal_name": "Jane Doe",
                    "date_of_birth": "1990-01-01",
                    "country_of_citizenship": "US",
                    "residential_address": {
                      "line_1": "123 Main St",
                      "line_2": null,
                      "city": "San Francisco",
                      "state": "CA",
                      "postal_code": "94105",
                      "country_code": "US"
                    },
                    "identification": { "type": "ssn", "value": "123-12-1234" }
                  }
                }'
              ```

              ```typescript SDK theme={null}
              const holder = await client.accountHolders.create({
                account_program_id: accountProgramId,
                holder_type: 'natural_person',
                beneficiary_data: {
                  legal_name: 'Jane Doe',
                  date_of_birth: '1990-01-01',
                  country_of_citizenship: 'US',
                  residential_address: {
                    line_1: '123 Main St',
                    line_2: null,
                    city: 'San Francisco',
                    state: 'CA',
                    postal_code: '94105',
                    country_code: 'US',
                  },
                  identification: { type: 'ssn', value: '123-12-1234' },
                },
              })

              const accountHolderId = holder.id
              ```
            </CodeGroup>

            <Info>
              Capture the returned ID for the following step:

              ```bash theme={null}
              export ACCOUNT_HOLDER_ID="..."
              ```
            </Info>

            Account holders are processed asynchronously. See the full `beneficiary_data` schemas (US individual, non-US individual, business) in the [**POST** `/v1/account_holders` API Reference →](/api-reference/account-holders/create-account-holder).
          </Step>

          <Step title="Create the virtual account">
            <CodeGroup>
              ```bash cURL theme={null}
              curl -X POST "$AUGUSTUS_BASE_URL/v1/accounts" \
                -H "Authorization: Bearer $AUGUSTUS_API_KEY" \
                -H "Idempotency-Key: $(uuidgen)" \
                -H "Content-Type: application/json" \
                -d '{
                  "account_program_id": "'"$ACCOUNT_PROGRAM_ID"'",
                  "account_holder_id": "'"$ACCOUNT_HOLDER_ID"'"
                }'
              ```

              ```typescript SDK theme={null}
              const account = await client.accounts.create({
                account_program_id: accountProgramId,
                account_holder_id: accountHolderId,
              })

              const accountId = account.id
              ```
            </CodeGroup>

            <Info>
              Capture the returned account ID as `ACCOUNT_ID` for the steps below:

              ```bash theme={null}
              export ACCOUNT_ID="..."
              ```
            </Info>

            [**POST** `/v1/accounts` in the API Reference →](/api-reference/accounts/create-account)
          </Step>
        </Steps>

        For the full virtual-accounts model, see [Virtual accounts](/docs/accounts/virtual-accounts).
      </Accordion>
    </AccordionGroup>
  </Step>

  <Step title="Read the account's payment details">
    Retrieve the account to see its ABA payment details (US routing and account number). These are the details a sender would use to pay into the account.

    <CodeGroup>
      ```bash cURL theme={null}
      curl "$AUGUSTUS_BASE_URL/v1/accounts/$ACCOUNT_ID" \
        -H "Authorization: Bearer $AUGUSTUS_API_KEY"
      ```

      ```typescript SDK theme={null}
      const account = await client.accounts.retrieve(accountId)
      ```
    </CodeGroup>

    ```json theme={null}
    {
      "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "type": "account",
      "currency": "USD",
      "status": "active",
      "asset_type": "fiat",
      "label": "Operating USD",
      "financial_addresses": [
        {
          "type": "aba",
          "routing_number": "110000000",
          "account_number": "000123456789",
          "account_holder_name": "Acme Sandbox Ltd."
        }
      ],
      "created_at": "2026-05-01T10:00:00Z",
      "updated_at": "2026-05-01T10:00:00Z"
    }
    ```

    [**GET** `/v1/accounts/{id}` in the API Reference →](/api-reference/accounts/retrieve-account)
  </Step>

  <Step title="Simulate an incoming deposit">
    Simulate a deposit arriving over Fedwire from an external sender. A wire carries the originator's account details, so you provide them as the `counterparty`. The `currency` must match the account currency. Give it an `unstructured_remittance_information` value you can recognize later. You use it to find the settled deposit.

    <Note>
      Deposits and payouts support the `ach`, `fedwire`, and `swift` rails. ACH does not carry the sender's account details, so use `fedwire` when you want to attach a `counterparty`. SWIFT deposit simulations require a counterparty with an `iban` financial address. See [ACH](/docs/rails/ach), [Fedwire](/docs/rails/fedwire), and [SWIFT](/docs/rails/swift).
    </Note>

    <CodeGroup>
      ```bash cURL theme={null}
      curl -X POST "$AUGUSTUS_BASE_URL/v1/simulations/deposits" \
        -H "Authorization: Bearer $AUGUSTUS_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d '{
          "account_id": "'"$ACCOUNT_ID"'",
          "amount": "5000.00",
          "currency": "USD",
          "rail": "fedwire",
          "unstructured_remittance_information": "guide-deposit-001",
          "counterparty": {
            "financial_address": {
              "type": "aba",
              "routing_number": "021000021",
              "account_number": "987654321",
              "account_holder_name": "Payer Inc."
            }
          }
        }'
      ```

      ```typescript SDK theme={null}
      await client.simulations.deposits.create({
        account_id: accountId,
        amount: '5000.00',
        currency: 'USD',
        rail: 'fedwire',
        unstructured_remittance_information: 'guide-deposit-001',
        counterparty: {
          financial_address: {
            type: 'aba',
            routing_number: '021000021',
            account_number: '987654321',
            account_holder_name: 'Payer Inc.',
          },
        },
      })
      ```
    </CodeGroup>

    [**POST** `/v1/simulations/deposits` in the API Reference →](/api-reference/simulations/simulate-an-incoming-deposit)
  </Step>

  <Step title="Confirm the deposit settled">
    Deposits are processed asynchronously and appear once they reach `settled`. Poll the deposits list and match on the remittance information you set.

    <CodeGroup>
      ```bash cURL theme={null}
      curl "$AUGUSTUS_BASE_URL/v1/deposits" \
        -H "Authorization: Bearer $AUGUSTUS_API_KEY"
      ```

      ```typescript SDK theme={null}
      async function waitForDeposit(reference: string) {
        for (let attempt = 0; attempt < 20; attempt++) {
          const page = await client.deposits.list()
          const deposit = page.data.find(
            (d) => d.unstructured_remittance_information === reference,
          )
          if (deposit?.status === 'settled') return deposit
          await new Promise((resolve) => setTimeout(resolve, 500))
        }
        throw new Error('Deposit did not settle in time')
      }

      const deposit = await waitForDeposit('guide-deposit-001')
      ```
    </CodeGroup>

    The settled deposit is credited to your account:

    ```json theme={null}
    {
      "id": "d1e2f3a4-b5c6-7890-abcd-ef1234567890",
      "type": "deposit",
      "status": "settled",
      "account_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "amount": "5000.00",
      "currency": "USD",
      "counterparty_id": "b1c2d3e4-f5a6-7890-abcd-ef1234567890",
      "unstructured_remittance_information": "guide-deposit-001",
      "tracking_reference": null,
      "rail": "fedwire",
      "tx_hash": null,
      "returns": [],
      "settled_at": "2026-05-01T10:01:00Z"
    }
    ```

    [**GET** `/v1/deposits` in the API Reference →](/api-reference/deposits/list-deposits)
  </Step>

  <Step title="Save a payout counterparty">
    A payout is always sent to a saved counterparty, so create one first. For a payout over ACH or Fedwire, use an `aba` financial address.

    <CodeGroup>
      ```bash cURL theme={null}
      curl -X POST "$AUGUSTUS_BASE_URL/v1/counterparties" \
        -H "Authorization: Bearer $AUGUSTUS_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d '{
          "name": "Acme Trading LLC",
          "entity_type": "business",
          "financial_address": {
            "type": "aba",
            "routing_number": "021000021",
            "account_number": "123456789",
            "account_holder_name": "Acme Trading LLC"
          }
        }'
      ```

      ```typescript SDK theme={null}
      const counterparty = await client.counterparties.create({
        name: 'Acme Trading LLC',
        entity_type: 'business',
        financial_address: {
          type: 'aba',
          routing_number: '021000021',
          account_number: '123456789',
          account_holder_name: 'Acme Trading LLC',
        },
      })

      const counterpartyId = counterparty.id
      ```
    </CodeGroup>

    <Info>
      Capture the returned ID for the following step (the create response returns it as `id`):

      ```bash theme={null}
      export COUNTERPARTY_ID="..."
      ```
    </Info>

    [**POST** `/v1/counterparties` in the API Reference →](/api-reference/counterparties/create-counterparty)
  </Step>

  <Step title="Create a payout">
    Debit your account and send funds to the counterparty. Reference the counterparty by `counterparty_id`; the `rail` is validated against the counterparty's financial address and selected automatically when omitted.

    <CodeGroup>
      ```bash cURL theme={null}
      curl -X POST "$AUGUSTUS_BASE_URL/v1/payouts" \
        -H "Authorization: Bearer $AUGUSTUS_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d '{
          "account_id": "'"$ACCOUNT_ID"'",
          "amount": "2500.00",
          "currency": "USD",
          "counterparty_id": "'"$COUNTERPARTY_ID"'",
          "rail": "fedwire",
          "unstructured_remittance_information": "Invoice 1234"
        }'
      ```

      ```typescript SDK theme={null}
      const payout = await client.payouts.create({
        account_id: accountId,
        amount: '2500.00',
        currency: 'USD',
        counterparty_id: counterpartyId,
        rail: 'fedwire',
        unstructured_remittance_information: 'Invoice 1234',
      })

      const payoutId = payout.id
      ```
    </CodeGroup>

    The payout is created as `initiated` and moves to `submitted` while it is in flight.

    <Info>
      Capture the returned ID for the following step (the create response returns it as `id`):

      ```bash theme={null}
      export PAYOUT_ID="..."
      ```
    </Info>

    [**POST** `/v1/payouts` in the API Reference →](/api-reference/payouts/create-payout)
  </Step>

  <Step title="Simulate a successful send">
    In production the payment network settles the payout. In the sandbox you advance it yourself. Simulate a successful send.

    <CodeGroup>
      ```bash cURL theme={null}
      curl -X POST "$AUGUSTUS_BASE_URL/v1/simulations/payouts/$PAYOUT_ID/send" \
        -H "Authorization: Bearer $AUGUSTUS_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)"
      ```

      ```typescript SDK theme={null}
      await client.simulations.payouts.send(payoutId)
      ```
    </CodeGroup>

    [**POST** `/v1/simulations/payouts/{id}/send` in the API Reference →](/api-reference/simulations/send-a-payout)
  </Step>

  <Step title="Poll until the payout is sent">
    Retrieve the payout until its status reaches `sent`.

    <CodeGroup>
      ```bash cURL theme={null}
      curl "$AUGUSTUS_BASE_URL/v1/payouts/$PAYOUT_ID" \
        -H "Authorization: Bearer $AUGUSTUS_API_KEY"
      ```

      ```typescript SDK theme={null}
      async function waitForPayoutSent(id: string) {
        for (let attempt = 0; attempt < 20; attempt++) {
          const current = await client.payouts.retrieve(id)
          if (current.status === 'sent') return current
          await new Promise((resolve) => setTimeout(resolve, 500))
        }
        throw new Error('Payout did not reach sent in time')
      }

      const sent = await waitForPayoutSent(payoutId)
      ```
    </CodeGroup>

    [**GET** `/v1/payouts/{id}` in the API Reference →](/api-reference/payouts/retrieve-payout)
  </Step>

  <Step title="Review the account's transactions">
    Every settled movement is recorded as a transaction. List them for your account to see the full ledger: the incoming deposit as a `credit` and the outgoing payout as a `debit`. Each transaction's `source` links back to the deposit or payout that created it (`null` when it does not map to a retrievable resource). `account_id` is required. Narrow the results with the optional `booked_at.gte` and `booked_at.lte` filters.

    <CodeGroup>
      ```bash cURL theme={null}
      curl "$AUGUSTUS_BASE_URL/v1/transactions?account_id=$ACCOUNT_ID" \
        -H "Authorization: Bearer $AUGUSTUS_API_KEY"
      ```

      ```typescript SDK theme={null}
      const transactions = await client.transactions.list({ account_id: accountId })
      ```
    </CodeGroup>

    ```json theme={null}
    {
      "data": [
        {
          "id": "f1a2b3c4-d5e6-7890-abcd-ef1234567890",
          "type": "transaction",
          "side": "debit",
          "status": "booked",
          "amount": "2500.00",
          "currency": "USD",
          "account_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
          "source": {
            "type": "payout",
            "id": "c3d4e5f6-a7b8-9012-cdef-123456789012"
          },
          "counterparty": {
            "financial_address": {
              "type": "aba",
              "routing_number": "021000021",
              "account_number": "123456789",
              "account_holder_name": "Acme Trading LLC"
            },
            "physical_address": null
          },
          "counterparty_id": "b2c3d4e5-f6a7-8901-bcde-f23456789012",
          "unstructured_remittance_information": "Invoice 1234",
          "tracking_reference": null,
          "rail": "fedwire",
          "tx_hash": null,
          "booked_at": "2026-05-01T10:02:00Z"
        },
        {
          "id": "e9d8c7b6-a5f4-7890-abcd-ef1234567890",
          "type": "transaction",
          "side": "credit",
          "status": "booked",
          "amount": "5000.00",
          "currency": "USD",
          "account_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
          "source": {
            "type": "deposit",
            "id": "d1e2f3a4-b5c6-7890-abcd-ef1234567890"
          },
          "counterparty": {
            "financial_address": {
              "type": "aba",
              "routing_number": "021000021",
              "account_number": "987654321",
              "account_holder_name": "Payer Inc."
            },
            "physical_address": null
          },
          "counterparty_id": "b1c2d3e4-f5a6-7890-abcd-ef1234567890",
          "unstructured_remittance_information": "guide-deposit-001",
          "tracking_reference": null,
          "rail": "fedwire",
          "tx_hash": null,
          "booked_at": "2026-05-01T10:01:00Z"
        }
      ],
      "has_more": false,
      "next_cursor": null
    }
    ```

    You've now completed the full lifecycle end to end: account, deposit, payout, and the transactions that record them.

    [**GET** `/v1/transactions` in the API Reference →](/api-reference/transactions/list-transactions)
  </Step>
</Steps>

## Simulate a failed or returned payout

Beyond the happy path, you can drive failure outcomes to test how your integration reacts.

<AccordionGroup>
  <Accordion title="Reject a payout before it is sent">
    While a payout is still `submitted` (before you simulate a send), simulate the network rejecting it. The payout moves to `failed` and the funds are released back to your account. Use `invalid_routing_number` for domestic rails or `invalid_account_format` for a SWIFT rejection.

    <CodeGroup>
      ```bash cURL theme={null}
      curl -X POST "$AUGUSTUS_BASE_URL/v1/simulations/payouts/$PAYOUT_ID/reject" \
        -H "Authorization: Bearer $AUGUSTUS_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d '{ "reason": "invalid_routing_number" }'
      ```

      ```typescript SDK theme={null}
      await client.simulations.payouts.reject(payoutId, {
        reason: 'invalid_routing_number',
      })
      ```
    </CodeGroup>

    [**POST** `/v1/simulations/payouts/{id}/reject` in the API Reference →](/api-reference/simulations/reject-a-payout)
  </Accordion>

  <Accordion title="Return a payout after it is sent">
    After a payout reaches `sent`, simulate the receiving bank returning it. The original payout stays `sent`; the returned funds arrive as a new standalone deposit (a `credit` transaction) on your account. Valid reasons are `account_closed`, `invalid_account_format`, `invalid_routing_number`, `account_blocked`, and `unknown`.

    <CodeGroup>
      ```bash cURL theme={null}
      curl -X POST "$AUGUSTUS_BASE_URL/v1/simulations/payouts/$PAYOUT_ID/return" \
        -H "Authorization: Bearer $AUGUSTUS_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d '{ "reason": "account_closed" }'
      ```

      ```typescript SDK theme={null}
      await client.simulations.payouts.return(payoutId, {
        reason: 'account_closed',
      })
      ```
    </CodeGroup>

    [**POST** `/v1/simulations/payouts/{id}/return` in the API Reference →](/api-reference/simulations/return-a-settled-payout)

    The returned funds show up as a new deposit rather than a change to the payout. List your deposits to find it:

    <CodeGroup>
      ```bash cURL theme={null}
      curl "$AUGUSTUS_BASE_URL/v1/deposits" \
        -H "Authorization: Bearer $AUGUSTUS_API_KEY"
      ```

      ```typescript SDK theme={null}
      const deposits = await client.deposits.list()
      ```
    </CodeGroup>

    [**GET** `/v1/deposits` in the API Reference →](/api-reference/deposits/list-deposits)
  </Accordion>
</AccordionGroup>

## Freeze, drain, and close

Winding down an account or an account program follows the same sequence: freeze it, drain the residual balance to an external destination, settle the drain payout(s), then close it. A frozen account or program can be reactivated with the matching `unfreeze` endpoint before you close it.

<AccordionGroup>
  <Accordion title="Close an operating account">
    <Steps>
      <Step title="Freeze the account">
        Freezing stops new movements and is required before draining.

        <CodeGroup>
          ```bash cURL theme={null}
          curl -X POST "$AUGUSTUS_BASE_URL/v1/simulations/accounts/$ACCOUNT_ID/freeze" \
            -H "Authorization: Bearer $AUGUSTUS_API_KEY" \
            -H "Idempotency-Key: $(uuidgen)"
          ```

          ```typescript SDK theme={null}
          await client.simulations.accounts.freeze(accountId)
          ```
        </CodeGroup>

        [**POST** `/v1/simulations/accounts/{id}/freeze` in the API Reference →](/api-reference/simulations/freeze-an-operating-account)

        Changed your mind before closing? Reactivate the account with `unfreeze`:

        <CodeGroup>
          ```bash cURL theme={null}
          curl -X POST "$AUGUSTUS_BASE_URL/v1/simulations/accounts/$ACCOUNT_ID/unfreeze" \
            -H "Authorization: Bearer $AUGUSTUS_API_KEY" \
            -H "Idempotency-Key: $(uuidgen)"
          ```

          ```typescript SDK theme={null}
          await client.simulations.accounts.unfreeze(accountId)
          ```
        </CodeGroup>

        [**POST** `/v1/simulations/accounts/{id}/unfreeze` in the API Reference →](/api-reference/simulations/unfreeze-an-operating-account)
      </Step>

      <Step title="Drain the residual balance">
        Drain sends the remaining balance to an external destination and returns the payout that carries it. Use an `aba` financial address for a USD destination.

        <CodeGroup>
          ```bash cURL theme={null}
          curl -X POST "$AUGUSTUS_BASE_URL/v1/simulations/accounts/$ACCOUNT_ID/drain" \
            -H "Authorization: Bearer $AUGUSTUS_API_KEY" \
            -H "Idempotency-Key: $(uuidgen)" \
            -H "Content-Type: application/json" \
            -d '{
              "destination": {
                "type": "aba",
                "routing_number": "021000021",
                "account_number": "123456789",
                "account_holder_name": "Acme Trading LLC"
              }
            }'
          ```

          ```typescript SDK theme={null}
          const drain = await client.simulations.accounts.drain(accountId, {
            destination: {
              type: 'aba',
              routing_number: '021000021',
              account_number: '123456789',
              account_holder_name: 'Acme Trading LLC',
            },
          })

          const drainPayoutId = drain.payout_id
          ```
        </CodeGroup>

        The response returns the drain payout's ID:

        ```json theme={null}
        {
          "type": "account_simulation",
          "account_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
          "payout_id": "c3d4e5f6-a7b8-9012-cdef-123456789012"
        }
        ```

        <Info>
          Capture the returned ID to settle it in the next step:

          ```bash theme={null}
          export DRAIN_PAYOUT_ID="..."
          ```
        </Info>

        [**POST** `/v1/simulations/accounts/{id}/drain` in the API Reference →](/api-reference/simulations/drain-an-operating-account)
      </Step>

      <Step title="Settle the drain payout">
        Send the drain payout so the balance reaches zero, the same way you settle any payout.

        <CodeGroup>
          ```bash cURL theme={null}
          curl -X POST "$AUGUSTUS_BASE_URL/v1/simulations/payouts/$DRAIN_PAYOUT_ID/send" \
            -H "Authorization: Bearer $AUGUSTUS_API_KEY" \
            -H "Idempotency-Key: $(uuidgen)"
          ```

          ```typescript SDK theme={null}
          await client.simulations.payouts.send(drainPayoutId)
          ```
        </CodeGroup>

        [**POST** `/v1/simulations/payouts/{id}/send` in the API Reference →](/api-reference/simulations/send-a-payout)
      </Step>

      <Step title="Close the account">
        With the balance at zero you can close the account. Valid reasons are `client_request` and `aml_risk_fraud`.

        <CodeGroup>
          ```bash cURL theme={null}
          curl -X POST "$AUGUSTUS_BASE_URL/v1/simulations/accounts/$ACCOUNT_ID/close" \
            -H "Authorization: Bearer $AUGUSTUS_API_KEY" \
            -H "Idempotency-Key: $(uuidgen)" \
            -H "Content-Type: application/json" \
            -d '{ "reason": "client_request" }'
          ```

          ```typescript SDK theme={null}
          await client.simulations.accounts.close(accountId, {
            reason: 'client_request',
          })
          ```
        </CodeGroup>

        [**POST** `/v1/simulations/accounts/{id}/close` in the API Reference →](/api-reference/simulations/close-an-operating-account)
      </Step>
    </Steps>
  </Accordion>

  <Accordion title="Close an account program">
    Closing a program winds down every virtual account under it. Drain returns one payout per funded account, so settle each returned ID.

    <Steps>
      <Step title="Freeze the program">
        <CodeGroup>
          ```bash cURL theme={null}
          curl -X POST "$AUGUSTUS_BASE_URL/v1/simulations/account_programs/$ACCOUNT_PROGRAM_ID/freeze" \
            -H "Authorization: Bearer $AUGUSTUS_API_KEY" \
            -H "Idempotency-Key: $(uuidgen)"
          ```

          ```typescript SDK theme={null}
          await client.simulations.accountPrograms.freeze(accountProgramId)
          ```
        </CodeGroup>

        [**POST** `/v1/simulations/account_programs/{id}/freeze` in the API Reference →](/api-reference/simulations/freeze-an-account-program)

        Changed your mind before closing? Reactivate the program and its accounts with `unfreeze`:

        <CodeGroup>
          ```bash cURL theme={null}
          curl -X POST "$AUGUSTUS_BASE_URL/v1/simulations/account_programs/$ACCOUNT_PROGRAM_ID/unfreeze" \
            -H "Authorization: Bearer $AUGUSTUS_API_KEY" \
            -H "Idempotency-Key: $(uuidgen)"
          ```

          ```typescript SDK theme={null}
          await client.simulations.accountPrograms.unfreeze(accountProgramId)
          ```
        </CodeGroup>

        [**POST** `/v1/simulations/account_programs/{id}/unfreeze` in the API Reference →](/api-reference/simulations/unfreeze-an-account-program)
      </Step>

      <Step title="Drain the program">
        Drain every frozen account under the program to an external destination. The response returns one payout ID per funded account.

        <CodeGroup>
          ```bash cURL theme={null}
          curl -X POST "$AUGUSTUS_BASE_URL/v1/simulations/account_programs/$ACCOUNT_PROGRAM_ID/drain" \
            -H "Authorization: Bearer $AUGUSTUS_API_KEY" \
            -H "Idempotency-Key: $(uuidgen)" \
            -H "Content-Type: application/json" \
            -d '{
              "destination": {
                "type": "aba",
                "routing_number": "021000021",
                "account_number": "123456789",
                "account_holder_name": "Acme Trading LLC"
              }
            }'
          ```

          ```typescript SDK theme={null}
          const drain = await client.simulations.accountPrograms.drain(accountProgramId, {
            destination: {
              type: 'aba',
              routing_number: '021000021',
              account_number: '123456789',
              account_holder_name: 'Acme Trading LLC',
            },
          })

          const drainPayoutIds = drain.payout_ids
          ```
        </CodeGroup>

        The response returns one payout ID per funded account:

        ```json theme={null}
        {
          "type": "account_program_simulation",
          "account_program_id": "e5f6a7b8-c9d0-1234-ef01-234567890123",
          "payout_ids": [
            "c3d4e5f6-a7b8-9012-cdef-123456789012"
          ]
        }
        ```

        [**POST** `/v1/simulations/account_programs/{id}/drain` in the API Reference →](/api-reference/simulations/drain-an-account-program)
      </Step>

      <Step title="Settle each drain payout">
        Send every payout returned by the drain so each account balance reaches zero.

        <CodeGroup>
          ```bash cURL theme={null}
          curl -X POST "$AUGUSTUS_BASE_URL/v1/simulations/payouts/$DRAIN_PAYOUT_ID/send" \
            -H "Authorization: Bearer $AUGUSTUS_API_KEY" \
            -H "Idempotency-Key: $(uuidgen)"
          ```

          ```typescript SDK theme={null}
          for (const id of drainPayoutIds) {
            await client.simulations.payouts.send(id)
          }
          ```
        </CodeGroup>

        [**POST** `/v1/simulations/payouts/{id}/send` in the API Reference →](/api-reference/simulations/send-a-payout)
      </Step>

      <Step title="Close the program">
        <CodeGroup>
          ```bash cURL theme={null}
          curl -X POST "$AUGUSTUS_BASE_URL/v1/simulations/account_programs/$ACCOUNT_PROGRAM_ID/close" \
            -H "Authorization: Bearer $AUGUSTUS_API_KEY" \
            -H "Idempotency-Key: $(uuidgen)" \
            -H "Content-Type: application/json" \
            -d '{ "reason": "client_request" }'
          ```

          ```typescript SDK theme={null}
          await client.simulations.accountPrograms.close(accountProgramId, {
            reason: 'client_request',
          })
          ```
        </CodeGroup>

        [**POST** `/v1/simulations/account_programs/{id}/close` in the API Reference →](/api-reference/simulations/close-an-account-program)
      </Step>
    </Steps>
  </Accordion>
</AccordionGroup>
