Sandbox Flow Simulation
Treasure's API sandbox includes simulation endpoints that enable testing user flows in real time before going live with Treasure's production API. The following sections show how to test the creation, funding, and setting the portfolio allocation of an account, as well as withdrawal flows.
Simulate Account Opening
After creating a business and obtaining a business ID, submit onboarding information via the POST /v1/businesses/{business_id}/onboarding endpoint.
Once submitted, the business remains in a PENDING state until Treasure completes its review. Internal KYB review has three possible outcomes: approved, declined, or needs more information.
- If the review is declined, the account will not be opened.
- If more information is required, Treasure's KYB team will contact your company via an available contact method.
- Use the simulation endpoints to advance through each outcome:
After internal approval, the application is submitted to Treasure's custodian partner for KYB review, which can be simulated via the PUT /v1/businesses/{business_id}/simulate/custodian_submission endpoint.
Custodian review follows the same three outcomes. If declined, the account will not be opened. If more information is required, Treasure's KYB team will again reach out via an available contact method. Simulate custodian outcomes with any of the following:
PUT /v1/businesses/{business_id}/simulate/custodian_approve(reference)PUT /v1/businesses/{business_id}/simulate/custodian_reject(reference)PUT /v1/businesses/{business_id}/simulate/custodian_needsinfo(reference)
Throughout this process, the business.updated webhook fires with status values including Pending, Open, Closed, and Rejected.
Simulate Account Funding & Allocation
When the business.updated webhook indicates the account is open, retrieve wire instructions and simulate funding.
- Simulate official account opening via
PUT /v1/businesses/{business_id}/simulate/account_open(reference) - Retrieve wire instructions via
GET /v1/businesses/{business_id}/wire_instructions(reference) - Simulate transfer creation via
PUT /businesses/{business_id}/transfers/simulate/created(reference)
When simulating the transfer creation, include the memo field exactly as returned, as should be done in real life by the business at their banking provider. Omitting or misstating it may cause wire returns or delays in crediting the account.
Transfer webhooks are sent at key points in the deposit flow:
| Event | When |
|---|---|
transfer.created (reference) |
Custodian acknowledges the transfer; status initially is PENDING. |
transfer.updated (reference) |
Transfer moves from PENDING to COMPLETE (typically the next business day) |
Simulate transfer completion via the PUT /v1/businesses/{business_id}/transfers/{transfer_id}/simulate/completed endpoint.
At the end of this flow, a portfolio.updated webhook fires alongside transfer.updated. At this point, the customer has an open account, a configured portfolio, and funds ready for allocation. In production, funds are allocated automatically at this stage. In sandbox, simulate allocation with the PUT /v1/businesses/{business_id}/portfolio/simulate/rebalance endpoint.
Use the GET /v1/businesses/{business_id}/portfolio endpoint to view portfolio composition. Per-product fund balances are not yet available in sandbox responses.
Simulate a Withdrawal
First, add a bank account via the POST /v1/businesses/{business_id}/bank_accounts endpoint (can be done at any time after business creation). The bank_account.created webhook fires on successful creation, and an existing bank account can be updated with the POST /v1/businesses/{business_id}/bank_accounts/{bank_account_id} endpoint.
Next, initiate a withdrawal via the POST /v1/businesses/{business_id}/transfers endpoint. This sends a transfer.created webhook (including the bank_account object) and, on completion, a transfer.updated webhook. Simulate both with the transfer simulation endpoints shown above.
Bank account and transfer APIs are used for withdrawals only, not deposits.
A withdrawal triggers any necessary asset sales to generate cash, potentially followed by a portfolio rebalance to restore target allocations. Simulate these events with:
PUT /v1/businesses/{business_id}/portfolio/simulate/assets_sold(reference)PUT /v1/businesses/{business_id}/portfolio/simulate/rebalance(reference)
The assets-sold simulation supports partial sales across multiple days, which is useful for simulating edge-case scenarios like selling some assets initially without covering the full transfer amount. A portfolio.updated webhook fires once the portfolio has been rebalanced.
