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

# Build a trader app

> Give your traders sign-in, a wallet, connected accounts, a Demo and payouts in your own app, with the route your backend calls for each.

Give your traders everything around the trading screens: a way to sign in, a wallet, their exchange
accounts, a Demo to practise on and a way to ask for a payout. Use this page when you build your own
trader app. [Build a front end](https://docs.trdrs.co/guides/build-a-front-end.md) covers the chart, the order ticket and the
account stream; this page covers the rest.

By the end you know which public route your backend calls for each part, and which routes take a
trdrs session, so your backend can't call them.

## Sign your traders in

Your traders sign in to your app, and your sign-in and its sessions are yours. Your backend calls
trdrs with your Venue key carrying `trader:read` or `trader:trade`, naming the trader in
`x-trdrs-trader`. Your keys stay on your server, and your traders' browsers never hold one.

The trdrs trading platform's own sign-in sessions take the trader's trdrs session from trdrs's own
origin, so your backend can't call them:

| Step | Route |
| - | - |
| List the trader's sessions | `GET /api/sign-in-sessions` |
| Sign out one other session | `POST /api/sign-in-sessions/{sessionId}/revoke` |
| Sign out every other session | `POST /api/sign-in-sessions/revoke-others` |

## Give each trader a wallet

A trader wallet is the trader's own wallet, made on their device in your venue's app on a wallet
platform and owned by them alone. trdrs never signs for it: each money step is prepared by trdrs,
signed by the trader's wallet and checked by trdrs before it goes on. Hyperliquid is the provider a
trader wallet trades today.

You turn trader wallets on by saving your wallet platform login in the back office
([Venue settings](https://docs.trdrs.co/guides/back-office-settings.md)). Then a trader's wallet goes through these steps, in
this order, because Hyperliquid refuses every action of an account that never held money:

1. The trader signs in to your venue's wallet app on their device, which makes the wallet.
2. The wallet is registered, once trdrs has read that the trader alone controls it.
3. The trader sends USDC to the wallet, and the wallet sends it on to Hyperliquid.
4. The wallet approves a trading key, which trades and can never withdraw. The wallet connects as the
   trader's Hyperliquid account, and trades like any connected account.
5. Whenever the trader likes, the wallet signs a withdrawal, which trdrs checks and passes to
   Hyperliquid. No switch on the trader's trading stops a withdrawal.

Each step has its route:

| Step | Route |
| - | - |
| Find the wallet app to sign in to | `GET /api/providers/hyperliquid/wallet/sign-in` |
| Register the wallet | `POST /api/providers/hyperliquid/wallet` |
| Read where its money is and what comes next | `GET /api/providers/hyperliquid/wallet` |
| Prepare the deposit to Hyperliquid | `POST /api/providers/hyperliquid/wallet/deposit` |
| Prepare and send the trading key's approval | `POST /api/providers/hyperliquid/wallet/activate` and `/activate/submit` |
| Prepare and send a withdrawal | `POST /api/providers/hyperliquid/wallet/withdraw` and `/withdraw/submit` |

> [!NOTE]
>
> These routes take the trader's trdrs session, so your own backend can't call them with your Venue
> key today. Your back office lists your traders' wallets under Money.

## Connect your traders' accounts

A trader brings an account they already hold at a provider by signing in to it once, through Connect.
Your backend runs Connect for the trader with your Venue key and `x-trdrs-trader`: it reads the tiles
your back office's Settings > Connect gives them, and sends the trader's login to that provider's own
route, such as `POST /api/providers/binance/connect` with the trader's API key.
[Route your traders' orders](https://docs.trdrs.co/guides/route-your-traders-orders.md) shows each call. trdrs keeps the login
in its vault, and you never build a provider's sign-in.

An account your venue issues by your own id for the trader needs nothing connected: your backend reads
it and routes its orders with `x-trdrs-trader`, as
[Route your traders' orders](https://docs.trdrs.co/guides/route-your-traders-orders.md) shows.

## Offer a Demo

A Demo is an account on the paper book, priced from live data, where a trader practises with nothing to
connect. Your back office sets whether your traders can open one, and the balance it opens with, in
[Venue settings](https://docs.trdrs.co/guides/back-office-settings.md).

The trdrs trading platform opens, resets and removes its signed-in trader's Demos with these routes,
which take the trader's trdrs session, so your backend can't call them:

| Step | Route |
| - | - |
| Open the first Demo, or connect the ones they hold | `POST /api/providers/paper/connect` |
| Open another, up to five | `POST /api/providers/paper/connect` with `{ "new": true }` |
| Reset one to the balance it opened with | `POST /api/providers/paper/reset?account=` |
| Remove one for good | `DELETE /api/providers/paper/account?account=` |
| Take them all off the account list, keeping them on the paper book | `DELETE /api/providers/paper` |

A venue that switched Demos off for its traders gets `403` `demo_off` here. An account your venue issued
is reset only by you, never by its trader.

## Take payout requests

A trader asks for a payout from one of their funded accounts. The payout is quoted by the account's payout
terms when it's asked for, and its gross comes off the account's balance at once, held while an owner
approves it in the back office, which pays it, or rejects it, which gives the money back.

Your own app asks for a payout on the trader's behalf from your backend:

| Step | Route |
| - | - |
| Quote what an account can pay out now | `GET /api/venues/{venueId}/accounts/{accountId}/payout` |
| Ask for a payout | `POST /api/venues/{venueId}/accounts/{accountId}/payout-requests` |
| Read an account's payout requests | `GET /api/venues/{venueId}/accounts/{accountId}/payout-requests` |

Required scope: `account:payout`.

The trdrs trading platform takes its own signed-in trader's payout requests with these routes, which
take the trader's trdrs session, so your backend can't call them:

| Step | Route |
| - | - |
| List the trader's funded accounts, what each can pay out and its requests | `GET /api/instant-funding/accounts` |
| Ask for a payout | `POST /api/instant-funding/accounts/{accountNumber}/payout-requests` |

> [!WARNING]
>
> A payout request takes its gross off the account's balance as soon as it's made. Send each request
> with an `Idempotency-Key`, so a retry never asks twice.

## What stays in the trdrs trading platform

The trdrs trading platform's own features take a trdrs session, so your backend can't call them: its
sign-in, its AI, saved charts and layouts, alerts, the journal, scripts and backtests, bar replay,
copy trading, its own subscriptions and trdrs Admin.

## Test it end to end

1. In the sandbox, read `GET /api/connect/tiles` from your backend for a test trader, and check it
   lists the tiles your Settings > Connect gives them.
2. Issue a test account on the paper book by your own id for a test trader, then read it from your
   backend with `GET /api/account/list` and `x-trdrs-trader`.
3. Issue a funded test account, then ask for a payout on it from your backend and approve it in the
   back office.

## Next steps

> [card] [Build a front end](https://docs.trdrs.co/guides/build-a-front-end.md)
>
> Put your own chart, order ticket and account stream over the API.

> [card] [Route your traders' orders](https://docs.trdrs.co/guides/route-your-traders-orders.md)
>
> Read your traders' accounts and route their orders from your backend with your Venue key.

> [card] [Venue settings](https://docs.trdrs.co/guides/back-office-settings.md)
>
> Set trader wallets, Demos and payouts for your venue in the back office.


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