This is the full developer documentation for ProofPerps trader API # ProofPerps developer docs > Read your ProofPerps accounts, place and manage orders and follow them live, from your own code or your AI agent. ProofPerps is a perps prop firm: your accounts are simulated, at live prices, on crypto, stocks, commodities, indices and forex. These docs are for traders who want their own software, or an AI agent, to read an account and trade it. Everything here works with **your own accounts only**, with a key you make in your trader space. A key reads only, unless you allowed trading when you made it. Orders sent through the API count toward your account’s rules exactly like the ones you place in the terminal: the Daily Loss Limit, the Max Drawdown and every other rule of your program. ## Three ways in [Section titled “Three ways in”](#three-ways-in) * **REST API**, for your scripts, bots and spreadsheets (HTTPS and JSON): `https://app.proofperps.com/v1/api` * **MCP server**, for AI assistants (Claude Code, Codex, Cursor, Copilot, Claude Desktop): `https://app.proofperps.com/mcp` * **Account stream**, orders, fills, positions and risk pushed as they change (WebSocket): `wss://app.proofperps.com/v1/api/accounts/{account_id}/stream` All three take the same key, in the same header: `Authorization: Bearer ppk_...`. ## Where to start [Section titled “Where to start”](#where-to-start) * [Quickstart](/quickstart/): a key, your accounts, a quote, a market order and advanced orders, in five steps with `curl`. * [Authentication and API keys](/authentication/): the two scopes, `read` and `trade`, and how to keep a key safe. * [Trading with the API](/trading/): every order route, its body and its answer. * [MCP server](/mcp/): connect Claude Code, Codex, Cursor, Copilot or Claude Desktop. * [API reference](/api-reference/): every route, built from the API’s OpenAPI document ([`/openapi.json`](/openapi.json)). * For AI agents: [`/llms.txt`](/llms.txt) and [`/llms-full.txt`](/llms-full.txt) hold these docs as plain text. Beta The trader API is in beta: fields may be added to its answers. See the [changelog](/changelog/). # Quickstart > Make a key, list your accounts, read a quote, place a market order and advanced orders, in five steps with curl. Five steps from nothing to a working order, with `curl` in a terminal. The examples use two shell variables: ```sh export API="https://app.proofperps.com/v1/api" export PP_KEY="ppk_..." # your key: keep it out of files you share ``` ## 1. Create an API key [Section titled “1. Create an API key”](#1-create-an-api-key) 1. Sign in to your trader space and open your **Profile**: the **API keys** panel is under Sessions and security. 2. Name the key. Tick **Allow trading** for steps 4 and 5 (without it, the key reads only), and confirm. 3. The key is shown **once**: copy it into `PP_KEY` right away. Only its hash is kept on our side, so it can never be shown again; if you lose it, revoke it and make a new one. You can hold up to 5 active keys. Revoking one stops it at once. See [Authentication](/authentication/). ## 2. List your accounts [Section titled “2. List your accounts”](#2-list-your-accounts) ```sh curl "$API/accounts" -H "Authorization: Bearer $PP_KEY" ``` The answer lists every account of the key’s owner, with its `account_id`, program, size, stage, status, balance and equity. Keep the `account_id` you want to trade: ```sh export ACCOUNT="ev-..." # an account_id from the list ``` Before trading, read the room left on it today: ```sh curl "$API/accounts/$ACCOUNT/risk" -H "Authorization: Bearer $PP_KEY" ``` `daily_loss_headroom` is the room left to your Daily Loss Limit today and `max_loss_headroom` the room to your Max Drawdown, both in micro-USD (1,000,000 is 1 USD). A `null` means that rule does not apply to the account. ## 3. Find a market and request a quote [Section titled “3. Find a market and request a quote”](#3-find-a-market-and-request-a-quote) ```sh curl "$API/markets" -H "Authorization: Bearer $PP_KEY" ``` Each market has its `symbol` (the one every order names), its `unit_e8` and whether it is `frozen` (a frozen market takes no new order). Then its last quote: ```sh curl "$API/markets/BTC/quote" -H "Authorization: Bearer $PP_KEY" ``` The quote’s `bid_e8`, `ask_e8` and `mid_e8` are prices **per coin** (or share, or contract) times 100,000,000. Two units of price An order does not take the quote’s unit. Its sizes are in **market units** and its prices in **micro-USD per market unit**: one unit is `unit_e8 / 100,000,000` of a coin. To turn a quote into an order price: `price = quote_e8 × unit_e8 / 10,000,000,000`. For BTC, whose `unit_e8` is 10000 (one unit is 0.0001 BTC), a coin price of 80,000 USD, as an example, is a `price` of 8,000,000. See [Markets and quotes](/markets/). ## 4. Place a market order [Section titled “4. Place a market order”](#4-place-a-market-order) Every write carries an `Idempotency-Key` header: one new value per order (a UUID is fine). It also becomes the order’s `client_order_id`. If the answer is lost, send the **same** request with the **same** key: you get the first answer back instead of a second order. See [Idempotency](/idempotency/). ```sh curl -X POST "$API/accounts/$ACCOUNT/orders" \ -H "Authorization: Bearer $PP_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{"symbol": "BTC", "side": "buy", "qty": 100}' ``` `qty` is in market units: 100 units of BTC is 0.01 BTC. The answer, `201`, holds the `order` (its `order_id`, `status`, `filled_qty`…), the `decisions` and `replayed` (`true` only when it is the stored answer of an earlier request with the same key). An order your account’s rules or the market refuse is a `422` whose `code` says why: nothing was done. ## 5. Place advanced orders [Section titled “5. Place advanced orders”](#5-place-advanced-orders) A limit order with its stop loss and take profit, armed on the position it opens: ```sh curl -X POST "$API/accounts/$ACCOUNT/orders" \ -H "Authorization: Bearer $PP_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{"symbol": "BTC", "side": "buy", "qty": 100, "order_type": "limit", "limit_price": 7900000, "stop_loss": 7800000, "take_profit": 8200000}' ``` The same fields serve the other types: `stop` (with `trigger_price`) and `stop_limit` (with both). Add `"stop_loss_trail"` with a `stop_loss` for a stop loss that follows the price, or `"take_profits"` for up to three targets. Prices here are examples. Change a working order (its `rev` comes from `GET /accounts/{id}/orders`): ```sh curl -X PATCH "$API/accounts/$ACCOUNT/orders/$ORDER_ID" \ -H "Authorization: Bearer $PP_KEY" -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" -d '{"expected_rev": 0, "limit_price": 7950000}' ``` Cancel it: ```sh curl -X DELETE "$API/accounts/$ACCOUNT/orders/$ORDER_ID" \ -H "Authorization: Bearer $PP_KEY" -H "Idempotency-Key: $(uuidgen)" ``` Next: [Trading with the API](/trading/) for positions, brackets and leverage, and the [account stream](/account-stream/) to follow your orders live. # Authentication and API keys > Keys of the read and trade scopes, the Authorization header, revocation and how to keep a key safe. Every request, to the REST API, the MCP server or the account stream, carries your key: ```http Authorization: Bearer ppk_... ``` A key is `ppk_` followed by 40 letters and digits. The scheme `Bearer` is case-insensitive. A missing, malformed, unknown or revoked key gets `401 API_KEY_INVALID`. ## Make a key [Section titled “Make a key”](#make-a-key) In your trader space: **Profile**, under Sessions and security, the **API keys** panel. Name the key, choose its scope, confirm. The key is shown **once**: we keep only its SHA-256 hash and its first 8 characters (the prefix you see in the list, `ppk_xxxxxxxx…`), never the key itself. * Up to **5 active keys** per trader (a sixth: `409 API_KEYS_MAX`). Revoked keys do not count. * The list shows each key’s name, prefix, scope, creation and last use. ## Two scopes [Section titled “Two scopes”](#two-scopes) | Scope | Made with | Opens | | ------- | -------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | | `read` | the default | every read: accounts, risk, terms, positions, orders, executions, payout requests, markets and quotes, and the account stream | | `trade` | **Allow trading** ticked and confirmed | the reads, plus the order routes: place, modify and cancel orders, close, reverse and protect positions, set leverage | A key never changes its scope: make a new key for another one. A write with a `read` key gets `403 API_KEY_READ_ONLY` and nothing is done. No key, of any scope, ever requests a payout, changes a payout address, buys anything, changes your profile, opens a funded account or touches your own guard rails and pause: those stay in the trader space. The API answers `405` there. ## Keys made by a contract wallet [Section titled “Keys made by a contract wallet”](#keys-made-by-a-contract-wallet) If you signed in with a contract wallet (a Safe, for example), each key you make remembers that sign-in. Before every order sent with the key, and at least every five minutes otherwise, the API asks your wallet’s contract whether it still accepts that sign-in, as it does for your session in the terminal. If it no longer does (an owner was removed), the key is revoked at once and the call answers `401 API_KEY_INVALID` with `detail.reason` `CONTRACT_WALLET_REVOKED`. If the wallet’s network cannot answer, the call is a `503 SIWE_RPC_UNAVAILABLE`: nothing was done and the key is kept, so send the same request again later with the same `Idempotency-Key`. ## Revoke a key [Section titled “Revoke a key”](#revoke-a-key) **Revoke** in the panel stops a key at once: its next call is a `401`, and an account stream it opened closes within seconds (code `4401`). “Sign out everywhere” revokes every key of yours too. ## Keep a key safe [Section titled “Keep a key safe”](#keep-a-key-safe) * Treat it like a password: it opens your accounts, and a `trade` key trades them. * Prefer a `read` key for anything that only reads (a dashboard, a spreadsheet, an assistant you only question). * Keep it in an environment variable or your tool’s secret store. A key written in a configuration file (such as `~/.cursor/mcp.json`) is stored there in plain text: keep the file private, out of any repository. * Send it only to `https://app.proofperps.com`. The API answers no browser on another site: it reads no session cookie and gives no CORS header, so a page cannot call it with your session. * Never put a key in an address (a query string): logs and proxies keep addresses. The account stream takes the key in its header too. * Exposed? Revoke it and make a new one. # Account stream > A WebSocket that pushes an account's orders, fills, positions, risk and equity as they change. Instead of reading again and again, open the account’s stream: it pushes every change of the account, in order, right after it happens. ```text wss://app.proofperps.com/v1/api/accounts/{account_id}/stream ``` * The key goes in the **`Authorization: Bearer ppk_...` header of the opening request**, never in the address. A key of either scope works: the stream only reads. * Opening a stream counts as one call of the key’s budget. A trader may have **2 streams open** at once (the terminal’s own screens apart). * Browsers cannot set this header on a WebSocket: open the stream from your own program (a script, a bot, a server). ## What it sends [Section titled “What it sends”](#what-it-sends) On opening, the stream is subscribed to the account’s five channels and sends their current state. Every message is a JSON object: ```json {"ch": "orders", "account_id": "ev-...", "seq": 812, "ts": 1792218373000, "data": {}} ``` `seq` is the account’s sequence number (the order of events, the same numbers as `as_of_seq` and `next_after_seq` of the reads). | `ch` | `data` | When | | ------------ | -------------------------------------------------------------- | --------------------------------------------------------------------- | | `orders` | one order, as `GET …/orders` gives it | at opening, then at each change of its status or filled quantity | | `executions` | one execution, as `GET …/executions` gives it | at each fill or exit | | `positions` | `{"positions": [...]}`, the whole list (empty: flat) | at once when a size or a leg changes; otherwise at most once a second | | `account` | the gauges of `GET …/risk` | when the balance, the status, a level or a pending payout changes | | `equity` | `{"equity", "balance"}` | at most once a second | | `system` | `{"kind": "subscribed" \| "ping" \| "resync" \| "error", ...}` | the subscription’s answer; a `ping` every 15 seconds; see below | * `?since_seq=N` also replays the executions after `N` (a reconnection that missed some). Too far back (more than 500 entries): a `resync`. * `resync`: your client fell behind (or `since_seq` was too old). Everything you held is stale; the current state follows at once. Rebuild your lists from those messages. * `?batch=1` sends each frame as a JSON array of messages, in order. * You may send `{"op": "ping"}`. A client that sends more than 50 messages a second is closed (`4430`); a message over 4,096 bytes too (`1009`). A client that does not take a frame within 10 seconds is dropped. ## Close codes [Section titled “Close codes”](#close-codes) | Code | Why | | -------------- | ---------------------------------------------------------------------------------------- | | `4401` | no valid key, or the key was revoked while the stream was open (checked every 5 seconds) | | `4404` | the account is not yours (exactly like an unknown one) | | `4429` | the key’s budget is spent, or you already have 2 streams open | | `4503` | the API is switched off for the moment | | `4400` | `since_seq` is not a whole number | | `1013` | the service cannot answer now: try again later | | `4430`, `1009` | too many messages, or one too large | Reconnect after a pause that grows with each failure, with `since_seq` set to the last `seq` you processed. ## Examples [Section titled “Examples”](#examples) Python, with the `websockets` package: ```python import asyncio, json, os import websockets URL = f"wss://app.proofperps.com/v1/api/accounts/{os.environ['ACCOUNT']}/stream" async def main(): headers = {"Authorization": f"Bearer {os.environ['PP_KEY']}"} async with websockets.connect(URL, additional_headers=headers) as ws: async for frame in ws: message = json.loads(frame) print(message["ch"], message["seq"]) asyncio.run(main()) ``` Node.js, with the `ws` package: ```js import WebSocket from 'ws'; const url = `wss://app.proofperps.com/v1/api/accounts/${process.env.ACCOUNT}/stream`; const ws = new WebSocket(url, { headers: { Authorization: `Bearer ${process.env.PP_KEY}` } }); ws.on('message', (frame) => { const message = JSON.parse(frame); console.log(message.ch, message.seq); }); ws.on('close', (code) => console.log('closed', code)); ``` # Rules for automated trading > Where the rules for trading through the API and the MCP server are written, and what always applies. The rules for trading with software are written in our **Prohibited Trading Practices**. That page is the reference: **[Read the Prohibited Trading Practices](https://proofperps.com/prohibited-practices/)** What always holds, whatever sends the order: * Orders through the API and the MCP server need a key with trading allowed, made by you in your trader space. * Every rule and every limit of your program applies to them, exactly as to an order placed in the terminal. * You are responsible for your software and for what it sends with your key. # Errors and rate limits > The error envelope, every status the API answers, and the budgets per key and per trader. ## The envelope [Section titled “The envelope”](#the-envelope) Every answer that is not a success is JSON: ```json {"error": {"code": "RATE_LIMITED", "source": "api", "message": "…", "detail": null, "trace_id": "…"}} ``` `code` is stable: write your code against it, not against `message`. `source` says who refused: `api`, `engine` (a rule of your program) or `exec` (the market or the simulator). The `X-Trace-Id` header repeats `trace_id`: quote it when you write to us. Answers carry `Cache-Control: no-store`. ## Statuses [Section titled “Statuses”](#statuses) | Status | `code` | Meaning | | ------ | ----------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | `VALIDATION_ERROR` | a parameter, header or body not as described: a decimal number, an unknown field, a value out of range, a missing `Idempotency-Key`. Nothing done | | 401 | `API_KEY_INVALID` | the key is missing, malformed, unknown or revoked (`detail.reason` `CONTRACT_WALLET_REVOKED`: see [Authentication](/authentication/)) | | 403 | `API_KEY_READ_ONLY` | a write with a `read` key. Nothing done | | 404 | `NOT_FOUND` | the account is not yours (exactly like an unknown one), or the order, the market or the route is unknown | | 405 | `METHOD_NOT_ALLOWED` | the route does not take this method (the `Allow` header lists those it takes) | | 409 | `ORDER_NOT_OPEN`, `POSITION_CHANGED`, `STALE_STATE`… | the order or the position changed since you read it. Nothing done | | 413 | `BODY_TOO_LARGE` | a body over 16,384 bytes | | 422 | the reason of the refusal, `IDEMPOTENCY_KEY_REUSED` | your account’s rules or the market refused (see `source`), or the key was used for another request. Nothing done | | 429 | `RATE_LIMITED` | over a budget: wait the seconds of the `Retry-After` header | | 503 | `API_DISABLED` | the API is switched off for the moment | | 503 | `API_TRADING_DISABLED` | trading through the API is switched off for the moment; reads still work. Nothing done | | 503 | `ORDERS_BLOCKED` | new orders are paused by an operator; a reduce-only market or limit order still goes through | | 503 | `OVERLOADED`, `STORAGE_UNAVAILABLE`, `SIWE_RPC_UNAVAILABLE` | the service (or the network of the contract wallet that made the key) could not take the request: retry a write with the **same** `Idempotency-Key` | ## Rate limits [Section titled “Rate limits”](#rate-limits) | Budget | Limit | Over it | | ------------------------------------------------------------------------------------------------------- | ----------- | ------------------------------------------ | | calls per key (every route, and each stream opening) | 60 a minute | `429 RATE_LIMITED`, `Retry-After` | | order writes per trader, every key together (place, modify, cancel, close, brackets, reverse, leverage) | 30 a minute | `429 RATE_LIMITED`, `Retry-After` | | refused keys per client address | 30 a minute | `429`, even for a good key not seen before | | open account streams per trader | 2 | close code `4429` | An order write counts in both budgets: its trader’s and its key’s. Several keys never make several order budgets. # Idempotency > The Idempotency-Key header on every write, replayed answers, and how to recover after a lost answer. A network can lose an answer after the order was already placed. The `Idempotency-Key` header makes a retry safe: the same request sent again with the same key is answered once, never carried out twice. ## The rule [Section titled “The rule”](#the-rule) * **Every write** (`POST`, `PUT`, `PATCH`, `DELETE`) carries an `Idempotency-Key` header: 1 to 64 printable ASCII characters. Without it: `400 VALIDATION_ERROR`, nothing done. * The **same key with the same body** gives the stored answer again, with `"replayed": true`, and does nothing more. * The **same key with another body** is `422 IDEMPOTENCY_KEY_REUSED`, and nothing is done. * Use a **new key for each new request**: a UUID, or your own unique id. ## A new order is named by its key [Section titled “A new order is named by its key”](#a-new-order-is-named-by-its-key) For `POST /accounts/{id}/orders`, the key is also the order’s `client_order_id` (and its `order_id` in every answer and list). You may leave `client_order_id` out of the body; if you send it, it must be the key itself (`400` otherwise). Since an order’s key is a `client_order_id`, keep it to letters, digits and `. _ : -`. An account’s order keys are the account’s, whoever sent them: the terminal or any of your API keys. A key already used on that account names that request: with the same body its answer is replayed, with another body it is a `422`. ## After a lost answer [Section titled “After a lost answer”](#after-a-lost-answer) 1. Send the **same request with the same key**: you get the first answer (`replayed: true`) if it went through, or the request is carried out now if it never arrived. 2. Or look the order up by its key: ```sh curl "$API/accounts/$ACCOUNT/orders?client_order_id=$KEY" -H "Authorization: Bearer $PP_KEY" ``` A `503` with `OVERLOADED` or `STORAGE_UNAVAILABLE` says nothing was done, unless the command had already started: in both cases, retry with the **same** key. The [MCP server](/mcp/) makes a key for every write call and returns it as `idempotency_key`; an assistant retries with that value. # Markets and quotes > The list of markets, a market's last quote, and the units of sizes and prices. Two reads, with a key of either scope: * `GET /markets`: every market, the same list the terminal reads. * `GET /markets/{symbol}/quote`: one market’s last quote and whether it takes orders. ## The list [Section titled “The list”](#the-list) `{"markets": [...], "source": {"reconnecting", "last_price_ms"}}`. Each market: | Field | | | ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | | `symbol` | the name every order and route uses | | `family` | `crypto`, `stocks`, `indices`, `commodities` or `forex` | | `unit_e8` | the size of one market unit: `unit_e8 / 100,000,000` of a coin, share or contract | | `max_leverage_x` | the market’s leverage ceiling (`null`: none) | | `frozen` | `true`: no new order (`unfreeze_at_ms`, the earliest it may end); `manual_freeze`: frozen by an operator, reduce-only market and limit orders still pass | | `reconnecting` | the market waits for prices after a reconnection of the price source | | `quote` | `{bid_e8, ask_e8, mid_e8, bid_size_e8, ask_size_e8, ts_ms}`, `null` before the first quote | | `stats` | the day’s figures: `mark_e8`, `oracle_e8`, `prev_day_e8`, `change_bp`, `day_volume_usd`, `open_interest_usd`, `funding_e8`, `next_funding_ms`, `ts_ms` | ## A quote [Section titled “A quote”](#a-quote) `GET /markets/{symbol}/quote` answers `symbol`, `quote` (as above), `frozen`, `manual_freeze`, `unfreeze_at_ms`, `now_ms` and `reconnecting`. An unknown symbol is a `404`. A market order fills at the simulator’s price of its own moment, never at a price read earlier: a quote tells you where the market is, not the price you will get. ## Units [Section titled “Units”](#units) All numbers are integers. | What | Unit | | ------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------- | | a size (`qty`, `filled_qty`, a position’s `qty`; negative = short) | market units: one unit is `unit_e8 / 100,000,000` of a coin | | an order’s or a position’s price (`limit_price`, `trigger_price`, `stop_loss`, `take_profit`, `avg_price`, `mark`, an execution’s `price`) | micro-USD per market unit | | a quote or a day figure (`bid_e8`, `ask_e8`, `mid_e8`, `mark_e8`…) | USD per coin × 100,000,000 | | money (`balance`, `equity`, headroom, `fee`, `realized_pnl`, `unrealized_pnl`) | micro-USD: 1,000,000 is 1 USD | | `size_usd` of an account | USD | | times (`*_ms`) | milliseconds since 1970, UTC | From one to the other: * price per coin in USD = `price × 100 / unit_e8` * order price = `quote_e8 × unit_e8 / 10,000,000,000` (an integer: round it the way your order needs) * coins = `qty × unit_e8 / 100,000,000` For example, BTC’s `unit_e8` is 10000: one unit is 0.0001 BTC, and a coin price of 80,000 USD (an example) is an order price of 8,000,000. Always read `unit_e8` from `GET /markets`: never assume it. # MCP server > Connect Claude Code, Codex, Cursor, Copilot or Claude Desktop to your accounts with the remote MCP server. The MCP server lets an AI assistant read your accounts and, with a `trade` key, place and manage orders, in your own words. | | | | --------- | ----------------------------------------------------------------------------------- | | Address | `https://app.proofperps.com/mcp` | | Transport | Streamable HTTP (stateless, JSON answers): `POST` only, 64 KB at most per request | | Key | your API key in the header `Authorization: Bearer ppk_...`, sent with every request | The server stores nothing: each tool passes your key, unchanged, to the [REST API](/trading/) and returns its JSON. The API decides what the key may do: with a `read` key, the trading tools answer that the key reads only. ## Connect your assistant [Section titled “Connect your assistant”](#connect-your-assistant) Replace `ppk_YOUR_KEY` with your key. ### Claude Code [Section titled “Claude Code”](#claude-code) ```sh claude mcp add --transport http proofperps https://app.proofperps.com/mcp \ --header "Authorization: Bearer ppk_YOUR_KEY" ``` ### Codex [Section titled “Codex”](#codex) In `~/.codex/config.toml`, with the key in an environment variable (Codex sends it as `Authorization: Bearer`): ```toml [mcp_servers.proofperps] url = "https://app.proofperps.com/mcp" bearer_token_env_var = "PP_KEY" ``` ### Cursor [Section titled “Cursor”](#cursor) In `~/.cursor/mcp.json`: ```json { "mcpServers": { "proofperps": { "url": "https://app.proofperps.com/mcp", "headers": { "Authorization": "Bearer ppk_YOUR_KEY" } } } } ``` ### Copilot (VS Code) [Section titled “Copilot (VS Code)”](#copilot-vs-code) In `.vscode/mcp.json`; VS Code asks for the key once and keeps it as a secret: ```json { "inputs": [ { "type": "promptString", "id": "proofperps-key", "description": "ProofPerps API key", "password": true } ], "servers": { "proofperps": { "type": "http", "url": "https://app.proofperps.com/mcp", "headers": { "Authorization": "Bearer ${input:proofperps-key}" } } } } ``` ### Claude Desktop and claude.ai [Section titled “Claude Desktop and claude.ai”](#claude-desktop-and-claudeai) Settings, Connectors, **Add custom connector**: the address above, **No sign-in**, then under **Request headers** the name `authorization` and the value `Bearer ppk_YOUR_KEY`. Request headers are in beta in Claude and may not show on every plan yet. ## Tools [Section titled “Tools”](#tools) Reading (any key; marked read-only): | Tool | Reads | | --------------------- | ------------------------------------------------------------------------------------------------------------------ | | `list_accounts` | your accounts (call it first: the other tools need an `account_id`) | | `get_account_status` | one account’s full state | | `get_risk_today` | room to the Daily Loss Limit and the Max Drawdown, their levels, the Profit Target remaining, the next daily reset | | `get_trading_terms` | order types, trailing stop, leverage choice, open orders per market, leverage per market | | `get_open_positions` | open positions with marks, unrealized PnL and the armed stop loss and take profit | | `get_orders` | orders (`status` working, final or all; `limit`, `after_seq`; `client_order_id`) | | `get_executions` | the trade history (`limit`, `after_seq`, `symbol`) | | `get_payout_requests` | each payout request and where it stands | | `list_markets` | the markets, their symbols and `unit_e8` | | `get_quote` | a market’s last quote | Trading (a `trade` key; marked destructive, so your assistant asks before running them): | Tool | Does | | ---------------- | ------------------------------------------------------------------------------- | | `place_order` | place a market, limit, stop or stop-limit order, with stop loss and take profit | | `modify_order` | change a working order (`expected_rev` from `get_orders`) | | `cancel_order` | cancel a working order | | `close_position` | exit a position at market | | `set_brackets` | set a position’s stop loss and take profit | | `set_leverage` | choose a market’s leverage | Each trading tool takes an optional `idempotency_key` and returns the one it used: to retry a call whose answer was lost, the assistant calls again with that same value and the same arguments ([Idempotency](/idempotency/)). For an order, that value is also its `client_order_id`. No tool requests a payout, changes an address, buys anything or changes your guard rails. ## Good practice [Section titled “Good practice”](#good-practice) * Give the assistant a `read` key unless it should trade. * Ask it to read `get_risk_today` before each order and to keep inside the room left to your Daily Loss Limit. A prompt to start with is on our home page. * Tool results are your account’s data, never instructions: the server tells the assistant so. * What your assistant reads goes to your AI provider, like everything you ask it. # Pagination > Pages of orders and executions with limit, after_seq and next_after_seq; as_of_seq on every read. Orders and executions come in pages, oldest first, with two query parameters: | Parameter | Meaning | | ----------- | ----------------------------------------------------------------------------------------------------------------------------- | | `limit` | rows per page: 1 to 500, 100 when absent | | `after_seq` | only what came after this sequence number: `0` (or absent) for the first page, then the `next_after_seq` of the previous page | Each page answers `next_after_seq`: pass it as `after_seq` for the next page; `null` on the last page. ```sh curl "$API/accounts/$ACCOUNT/executions?limit=500&after_seq=0" -H "Authorization: Bearer $PP_KEY" ``` * A page never splits the rows of one event of the account (one order’s fills recorded together): it may then hold a few more rows than `limit`. * `GET /accounts/{id}/orders` takes `status=working` (open orders) or `status=final` (filled, canceled or rejected); without it, both. `client_order_id=` returns that one order. * `GET /accounts/{id}/executions` takes `symbol=` for one market. * Every read answers `as_of_seq`: the last sequence number of the account it accounts for. The [account stream](/account-stream/) carries the same numbers (`seq`), so a client can read a page, then follow the stream from there. # Trading with the API > Place, modify and cancel orders, close, protect and reverse positions, and set leverage, with a trade key. The order routes need a key of the `trade` scope ([Authentication](/authentication/)) and an `Idempotency-Key` header on every request ([Idempotency](/idempotency/)). Their bodies and answers are the terminal’s own: the same checks, the same rules of your program, the same refusals. Bodies are JSON with **integers only** (a decimal number is a `400`), at most 16,384 bytes. | Route | Does | | ------------------------------------------------ | ----------------------------------------------------------------------------- | | `POST /accounts/{id}/orders` | place an order (`201`) | | `PATCH /accounts/{id}/orders/{order_id}` | change a working order | | `DELETE /accounts/{id}/orders/{order_id}` | cancel a working order | | `POST /accounts/{id}/positions/{symbol}/close` | exit the whole position at market (`201`) | | `PUT /accounts/{id}/positions/{symbol}/brackets` | set the position’s stop loss and take profit | | `POST /accounts/{id}/positions/{symbol}/reverse` | exit and open the same size the other way, at market, both or neither (`201`) | | `PUT /accounts/{id}/leverage/{symbol}` | choose the leverage of one market | Units: `qty` in market units, prices in micro-USD per market unit ([Markets and quotes](/markets/)). Before trading, read `GET /accounts/{id}/trading-terms`: the order types your account offers (`order_types`), whether a trailing stop and a leverage choice are offered, the most open orders per market, and per market the leverage ceiling (`max_x`) and the leverage in force (`chosen_x`). ## Place an order [Section titled “Place an order”](#place-an-order) `POST /accounts/{id}/orders` | Field | | | -------------------------- | --------------------------------------------------------------------------------------------------------- | | `symbol` | required: a symbol of `GET /markets` | | `side` | required: `buy` or `sell` | | `qty` | required: market units, at least 1 | | `order_type` | `market` (default), `limit`, `stop` or `stop_limit` | | `limit_price` | for `limit` and `stop_limit` only (refused otherwise) | | `trigger_price` | for `stop` and `stop_limit` only (refused otherwise) | | `reduce_only` | `true`: the order may only reduce a position | | `stop_loss`, `take_profit` | armed on the position the order opens (see below) | | `stop_loss_trail` | with a `stop_loss`: the stop loss follows the price at this distance | | `take_profits` | instead of `take_profit`: 1 to 3 targets `{price, share}`, TP1 first, whole-percent shares summing to 100 | | `client_order_id` | optional: the `Idempotency-Key` itself (the order’s id) | The answer: `{order, decisions, as_of_seq, replayed}`. The `order` row has its `order_id`, `status` (`working`, `filled`, `canceled`, `rejected`), `qty`, `filled_qty`, `rev`, the prices and legs it carries, and `legs_not_armed`: a stop loss or take profit it carried that was not placed, with why. What protects a position is what `GET /accounts/{id}/positions` shows as armed. A stop loss and a take profit ride on an order only when the order opens a position or turns it to its side, and only when your account’s `order_types` (`GET /accounts/{id}/trading-terms`) include `stop` or `stop_limit`. An order that adds to a position already open on its side is refused with `422 LEGS_ON_OPEN_POSITION`, a reduce-only order with `422 LEGS_ON_REDUCTION`, and an account without stop orders with `422 LEGS_NOT_OFFERED`: place the order without them, then set them on the position with `PUT …/positions/{symbol}/brackets` (below). ## Change or cancel a working order [Section titled “Change or cancel a working order”](#change-or-cancel-a-working-order) `PATCH /accounts/{id}/orders/{order_id}` with `expected_rev` (the order’s `rev` as you read it) and at least one of `qty`, `limit_price`, `trigger_price`, `stop_loss`, `take_profit` (`null` removes that leg). The order keeps its `order_id`; its `rev` goes up by one. If the order changed since you read it: `409 STALE_STATE`. A market order, a partly filled order, an order with several targets and a stop that protects a position are not modified (a `409` or `422` names the case): cancel and place again. `DELETE /accounts/{id}/orders/{order_id}` cancels it. An order already filled, canceled or rejected: `409 ORDER_NOT_OPEN`. ## Positions [Section titled “Positions”](#positions) * **Exit**: `POST …/positions/{symbol}/close` with an optional `expected_position_qty` (the signed `qty` you read): if the position is no longer that, `409 POSITION_CHANGED` and nothing is done. It places a reduce-only market order. * **Stop loss and take profit**: `PUT …/positions/{symbol}/brackets` with `stop_loss`, `take_profit` and `expected_position_qty`, all three required (`null` removes a leg: send the current value to keep it). Long: the stop loss below the mark, the take profit above; short: the reverse (`422 SL_WRONG_SIDE` / `TP_WRONG_SIDE` otherwise). Optional: `stop_loss_trail`, `take_profits` (a list without shares moves the targets held), and `expected_stop_loss`, required when the armed stop loss trails the price (its current level, or `422 STOP_LOSS_MOVED`). * **Reverse**: `POST …/positions/{symbol}/reverse` with `expected_position_qty` and optional `stop_loss`, `take_profit`, `stop_loss_trail` for the new position. ## Leverage [Section titled “Leverage”](#leverage) `PUT /accounts/{id}/leverage/{symbol}` with `{"leverage_x": n}`: a whole number from 1 to the market’s `max_x`. The answer gives `leverage_x` and `max_x`. Refused: `LEVERAGE_INVALID` (above the ceiling), `LEVERAGE_NOT_OFFERED` (rules without a leverage choice), `LEVERAGE_BELOW_POSITION` (lower than the open position needs at its mark). ## What the rules refuse [Section titled “What the rules refuse”](#what-the-rules-refuse) An order is checked exactly like one from the terminal. A refusal is an error answer with a `code` and nothing done: the rules of your program (`422`, source `engine`), the market (`422`, source `exec`: a frozen market, no fresh quote…), or an operator’s pause of new orders (`503 ORDERS_BLOCKED`: a reduce-only market or limit order still goes through; a stop does not). See [Errors and rate limits](/errors/). Every order sent through the API is recorded as sent through the API, with the prefix of the key that sent it. # Changelog > What changed in the trader API and the MCP server. ## 2026-12-01: trading through the API and the MCP server [Section titled “2026-12-01: trading through the API and the MCP server”](#2026-12-01-trading-through-the-api-and-the-mcp-server) * Keys of two scopes: `read` (the default) and `trade` (**Allow trading** at the key’s creation). * The order routes: place, modify and cancel orders; exit, protect and reverse positions; set a market’s leverage. Each takes an `Idempotency-Key`. * `GET /markets`, `GET /markets/{symbol}/quote`, and `client_order_id=` on `GET /accounts/{id}/orders`. * The account stream: `wss://app.proofperps.com/v1/api/accounts/{account_id}/stream`. * New answers: `403 API_KEY_READ_ONLY`, `503 API_TRADING_DISABLED`, and a budget of order writes per trader. * A key made by a contract wallet is checked against its contract before every order (`CONTRACT_WALLET_REVOKED`). * The MCP server’s trading tools: `place_order`, `modify_order`, `cancel_order`, `close_position`, `set_brackets`, `set_leverage`, with `list_markets` and `get_quote`. ## 2026-12-01: the read API and the MCP server [Section titled “2026-12-01: the read API and the MCP server”](#2026-12-01-the-read-api-and-the-mcp-server) * API keys in the trader space, eight reads under `/v1/api`, 60 calls a minute per key. * The MCP server at `https://app.proofperps.com/mcp`, read-only.