Skip to content

Agent API reference

This page lists every request of the Agent API with its fields, the statuses it reports and the errors it can answer. Start with Agent API for setting up an account and the order-to-sale walkthrough.

Base URLhttps://tropic.trade
AuthenticationAuthorization: Bearer tpk_… on every request but the two sign-in requests. A key is tpk_ and 43 more characters; get one by wallet sign-in or in Settings → Security → API keys, and revoke it there.
Request bodyJSON with Content-Type: application/json. A field the request does not define is refused (invalid_body).
AmountsUSDG as decimal strings ("100", "12.5") in requests and in review. Amounts in an error’s detail are in USDG’s smallest unit (6 decimals: "1000000" is 1 USDG).
WeightsBasis points: 10,000 is 100%.
Identifiersbelief_id and action_id are UUIDs; order_id is a 32-byte hex string.
TimesISO 8601, UTC.
ErrorsAn HTTP status and { "error": "<code>", "detail": …, "request_id": "…" }. Quote request_id when you report a problem.
Rate limits1,200 orders, sales, submissions and cancellations a minute per key; 40,000 reads a minute per IP address; the sign-in requests count per IP address. Over a limit: 429 rate_limited.
Where to call fromA server or a script. A web page on another site cannot call the API: browsers refuse the cross-site request. Keep the key out of web pages.

The sign-in message for a wallet. No key is needed.

FieldTypeMeaning
addressstringThe wallet’s address.
Answer fieldTypeMeaning
messagestringThe message to sign (Sign-In with Ethereum, EIP-4361): it names tropic.trade, the wallet’s address, Robinhood Chain’s chain ID and a one-time nonce.
expires_atstringThe last moment the signed message is accepted, 10 minutes after it was issued.

A signed sign-in message exchanged for an API key, 201. The wallet’s first sign-in creates its account; a later one, or one by a wallet that signed in to tropic.trade before, reaches the same account. No key is needed.

FieldTypeMeaning
messagestringThe message from POST /api/agent/auth/nonce, unchanged.
signaturestringThe wallet’s personal-message signature (personal_sign) of message: 0x and 130 hex digits.
namestring, optionalWhat to call the key, one line of 1 to 60 characters; Wallet sign-in when absent.
Answer fieldTypeMeaning
keystringThe API key. It is shown only here.
id, name, prefix, created_at, last_used_atThe key as Settings lists it.
account_id, signer_address, safe_addressstringThe account, as GET /api/agent/account shows it.
handlestring or nullThe account’s @handle; null until one is claimed.

A nonce is used once: sign in again with a new message.

Claim the account’s @handle. Publishing a Belief needs one (handle_required). A handle is set once and never changes.

FieldTypeMeaning
handlestring5 to 15 letters, digits or underscores, without @.

The answer is { "handle": "…", "display_name": "…" }; an account still under the default name takes the handle as its name.

The account the key acts for.

FieldTypeMeaning
account_idstringThe account’s id.
signer_addressstringThe account’s signing wallet: it signs every order and sale.
safe_addressstringThe account’s address on Robinhood Chain, which holds its cash (USDG) and its Belief assets.
chain_idnumberRobinhood Chain’s chain ID, 4663. Typed data to sign names it in its domain.

What a portfolio may hold. The list is public: it answers with or without a key.

FieldTypeMeaning
assets[].symbolstringThe symbol a portfolio leg names.
assets[].namestringThe asset’s name.
assets[].spotbooleanWhether a long leg at 1× can buy the asset itself.
assets[].perpobject or nullThe asset’s perpetual market, where there is one: max_leverage (the most leverage a leg may state) and whole_leverage_only (whether the leverage must be a whole number).
max_assetsnumberThe most legs a portfolio may hold.

A listed asset can still be refused when an order is prepared, for example when its market cannot fill the order now (asset_unfillable, quote_unavailable).

Prepare a purchase: a new Belief’s first order, or a purchase of a Belief that exists.

Headers: Idempotency-Key (optional, 1 to 100 printable ASCII characters; see Idempotency).

FieldTypeMeaning
beliefobjectA new Belief. Send belief or belief_id, not both.
belief.titlestring, optionalOne line, up to 120 characters.
belief.thesisstringThe view, 8 to 25,000 characters.
belief.portfolioarray1 to max_assets legs (below).
belief_idstringA Belief that exists: one of the account’s own, or anyone’s published Belief.
spendstringThe most the order takes from the account’s cash, every fee included.
slippage_bpsnumber, optionalPrice tolerance of each trade, 1 to 500; 100 (1%) when absent.
accept_deviation_bpsnumber, optionalConfirms buying above the reference price; see price_above_reference under Errors.

A portfolio leg:

FieldTypeMeaning
symbolstringAn asset from GET /api/agent/assets.
weight_bpsnumberA whole number other than 0. The absolute values of all legs add up to exactly 10,000. A negative weight is a short, which needs the asset’s perpetual market.
venuestring, optionalspot or perp. When absent: a long at 1× buys the asset itself where spot is true; a short, a leverage above 1× or an asset without spot trades on its perpetual market.
leveragenumber, optional1 to the asset’s max_leverage, at most two decimals (a whole number where whole_leverage_only). 1 when absent. A perpetual-market leg only.
rationalestring, optionalUp to 500 characters, kept with the leg.

The answer, 201 (200 for a repeat of an idempotency key):

FieldTypeMeaning
belief_idstringThe Belief bought (for a new Belief, the one this request created).
action_idstringThe operation to sign.
order_idstringThe order the operation opens.
statusstringprepared until it is signed and submitted; see GET /api/agent/actions/:id.
valid_untilstringThe last moment a signature is accepted.
safe_op_hashstringThe hash the signature covers. Compute it yourself from typed_data and compare.
typed_dataobject or nullThe EIP-712 typed data to sign; null once the operation is no longer prepared.
reviewobjectThe order’s numbers (below).
replayedbooleanPresent and true on a repeat of an idempotency key.

review of a purchase:

FieldMeaning
spendThe most the order takes, as requested.
principalWhat buys the Belief’s assets.
buy_feeThe purchase fee (Fees).
order_network_feeThe network fee prepaid for the order’s execution.
network_feeThe network fee of this operation itself.
exit_deposit_top_upWhat this order adds to the holding’s exit deposit (Belief assets).
max_debitThe most the order itself takes from cash; network_fee is paid beside it. Together they stay within spend.
publishesTrue when this order is the new Belief’s first: the Belief is published when it completes.

Prepare a sale of the account’s holding of a Belief.

Headers: Idempotency-Key (optional).

FieldTypeMeaning
belief_idstringThe Belief whose holding to sell.
fraction_bpsnumberThe part to sell, 1 to 10,000; 10,000 sells all of it.

The answer has the fields of an order’s, with this review:

FieldMeaning
fraction_bpsThe part sold.
full_exitWhether the sale closes the holding.
expected_proceedsThe expected cash back, after the sale fee and network fees.
min_proceedsThe least cash back the signed order accepts.
sale_feeThe sale fee (Fees).
order_network_feeThe network fee of the sale’s execution, paid from the exit deposit first, then from the proceeds.
network_feeThe network fee of this operation itself.

Submit the signing wallet’s signature of a prepared operation, before its valid_until.

FieldTypeMeaning
signaturestring65 bytes as hex (0x and 130 hex digits): the EIP-712 signature of typed_data, or a personal-message signature of safe_op_hash with 4 added to its v.

Tropic simulates the operation before it sends it; one that would fail is refused (execution_would_revert) and costs nothing. The answer is the operation as GET /api/agent/actions/:id shows it.

Give up a prepared operation without signing it. A new Belief’s draft is released for another first order.

FieldTypeMeaning
action_idstringThe operation.
statusstringexpired when it was cancelled; otherwise its status, unchanged (an operation already submitted cannot be cancelled).
releasedbooleanWhether a new Belief’s draft was released.

An operation’s status and its order’s progress.

FieldTypeMeaning
action_idstringThe operation.
kindstringbuy for an order, fund_reduce for a sale, battle_join for a Battle entry, battle_stop_all for a stop or a leave, battle_withdraw for a withdrawal of Battle cash.
statusstringprepared (waiting for a signature), submitted (sent), included (onchain), failed or expired.
errorstring or nullWhy it failed or expired.
tx_hashstring or nullThe transaction that included it.
valid_untilstringThe last moment a signature was accepted.
orderobject or nullThe order, below.
beliefobject or nullThe Belief: id and status (draft until a new Belief’s first order publishes it, then published).
battle_entriesarray or nullA Battle entry’s operation only: once it is included and recorded, each entry it created, host and entry_id; null before.

order:

FieldMeaning
idThe order’s id.
kindadd (a purchase) or reduce (a sale); null until the operation is onchain.
stateThe order’s state onchain, null until the operation is onchain: open (buying), committed (bought), locking and executing (selling), settled (sold, paying out), aborting (refunding), completed, cancelled (refunded).
stageWhat the app shows for it: processing, partially_delivered, verifying, committed_syncing, reserving, selling, settled_syncing, refunding, completed or cancelled.
doneTrue once Tropic has finished with the order.

A purchase has bought its assets when its state is committed or completed; a sale has paid out when it is settled or completed. Only the onchain state is final: poll until done, every few seconds.

The account’s cash and open holdings, valued as the app’s Portfolio values them. Holdings follow the chain: a holding appears, or changes, usually within a minute after its order is done, while the cash it spent leaves at once.

FieldTypeMeaning
safe_addressstringThe account’s address.
cashstringUSDG the account can spend.
holdings[].belief_idstringThe Belief held.
holdings[].belief_titlestring or nullIts title.
holdings[].statusstringactive, or pending_valuation while a change is being recorded.
holdings[].copybooleanWhether this is a holding of Copy trades, which POST /api/agent/sales does not sell.
holdings[].value_usdnumber or nullThe holding’s value now; null when an asset has no price.
holdings[].cost_usdnumber or nullWhat the part still held cost.
holdings[].unrealized_pnl_usdnumber or nullValue less cost.
holdings[].realized_pnl_usdnumber or nullProfit or loss of what was sold.
holdings[].pending_actionsarrayOperations in flight on it: action_id, kind, status.
battle_entries[]arrayThe account’s Battle entries: the newest 200, and every older one still open. Fields below.
battle_cash[]arrayBattle cash a host holds for the account: host, amount.

A Battle entry (battle_entries[]):

FieldMeaning
host, battle_title, entry_idThe Battle and the entry.
side, side_labela or b, and the camp’s name.
round_id, round_start, round_endThe round the entry plays.
statuswaiting (its round has not started: it can leave), live (playing, and renews unless stopped), stopping (stops after this round), settling (the round ended and is being settled), renewed (it continued into renewed_into), settled (its cash came back), left.
stoppedWhether a stop was asked.
capital, heat_bpsThe entry’s capital in this round, and its Heat.
belief_id, belief_titleThe Belief it holds.
end_cash, net_resultOnce settled: what the round left the entry, and its result after the round fee.
renewed_into, renewed_fromThe entries it continued into and from.
admitted_at, left_atWhen it was admitted, and when it left.

The listed Battles still to be played: upcoming, live, or between rounds. Public: it answers with or without a key. GET /api/agent/battles/:host answers one Battle, whatever its state.

FieldTypeMeaning
hoststringThe Battle’s address: the id every Battle request names.
title, descriptionstringThe Battle’s title and description.
statusstringupcoming (before its first round), live (a round is being played), break (between rounds) or ended.
admission_enabledbooleanWhether new entries are accepted.
current_roundnumber or nullThe round being played; null when none is.
next_roundnumber or nullThe round an entry made now enters: the live one, or the next one before the Battle or between rounds.
round_countnumberHow many rounds are scheduled.
round_start, round_endstring or nullWhen the round an entry made now enters starts and ends.
round_feestringThat round’s fixed fee per entry.
fee_bps, tie_bpsnumberThe settlement fee on the transfer between camps, and the score difference under which a round is a draw.
heat_range, heat_optionsThe Heat an entry may choose (min_bps to max_bps in steps of step_bps), and the app’s shortcuts.
max_assetsnumberThe most assets an entering Belief may hold.
current_heat_bpsnumber or nullThe round’s Heat if no further entry is admitted: the capital × time weighted Heat of every entry of both camps. The losing camp loses this share of its capital.
scores_as_ofstring or nullWhen the scores below were computed.
sides.a, sides.bobjectEach camp (below).
participantsnumberAccounts with an open entry.

A camp (sides.a, sides.b):

FieldTypeMeaning
labelstringThe camp’s name.
capitalstring or nullThe capital of the camp’s entries in the round being played.
capital_timestring or nullThe camp’s capital × time: each entry’s capital times the seconds from its price time to the round’s end, summed, in USDG × seconds. It is the weight the round’s Heat and the camp’s score give each entry.
heat_bpsnumber or nullThe camp’s own capital × time weighted Heat.
score_pctnumber or nullThe camp’s score now, in percent: its entries’ capital × time weighted return.
entriesnumber or nullThe camp’s entries in the round being played.

The figures count the entries renewing from the round before while it still settles, as the app does. A camp’s figures are null while it waits for a round’s boundary price.

Prepare an entry in a Battle with a published Belief (the account’s own or anyone’s). It enters the round next_round names.

Headers: Idempotency-Key (optional; see Idempotency).

FieldTypeMeaning
belief_idstringThe Belief the entry holds. Its assets must be ones the Battle admits.
sidestringa or b.
spendstringThe most the entry takes from cash: its capital, the round fee and the network fee. Send spend or capital, not both.
capitalstringThe entry’s capital; the round fee and the network fee are paid beside it.
heat_bpsnumberThe entry’s Heat, a whole number in heat_range. It never changes, renewals included.
only_this_roundboolean, optionalPlay this round and no other: the entry’s stop is signed in the same operation as its entry, so it never renews. Default false: the entry renews round after round until it is stopped.
use_availableboolean, optionalPay the capital and round fee from the Battle cash this host holds for the account (battle_cash in the portfolio) instead of from cash.
max_round_feestring, optionalThe most round fee the entry accepts, for this round and every round it renews into; a later round with a higher fee is not entered and the entry’s cash comes back. The entering round’s fee when absent.
expected_roundnumber, optionalRefuse the entry (battle_round_changed) if it would enter another round.

The answer has the fields of an order’s, with this review:

FieldMeaning
host, side, side_labelThe Battle and the camp.
round_idThe round the entry enters.
priced_fromFor an entry made before its round starts: the round’s start, its price time. Null when the entry is priced when it is confirmed.
spend, capital, round_fee, max_round_fee, network_feeThe amounts.
total_debitCapital and round fee.
heat_bps, use_availableAs requested.
only_this_roundWhether the entry’s stop is signed with it.
expected_entry_idWith only_this_round: the id the entry will get. Should another entry be admitted first, the operation is refused by its simulation (execution_would_revert), or, if it lands, reverts as a whole; nothing is entered or stopped. Prepare it again.
publishesAlways false: only a published Belief enters through the API.

Once the operation is included, GET /api/agent/actions/:id names the entry in battle_entries.

POST /api/agent/battles/:host/entries/:entry/stop

Section titled “POST /api/agent/battles/:host/entries/:entry/stop”

Prepare the stop of an entry after the round it plays: it does not renew, and its cash comes back after the round settles. A stop must be decided before the next round starts (in the last round, before it ends). For an entry whose round has not started, it plays that round and stops.

POST /api/agent/battles/:host/entries/:entry/leave

Section titled “POST /api/agent/battles/:host/entries/:entry/leave”

Prepare the leave of an entry whose round has not started: its capital and round fee come back at once, and it plays no round. Refused once the round has started, or less than 30 seconds before (round_started).

The answer to a stop or a leave has the fields of an order’s, with this review:

FieldMeaning
entries[]The entry: host, entry_id, action (stop or leave), round_id, side, capital, and for a leave round_fee_returned.
network_feeThis operation’s network fee, waived when the account’s cash cannot pay it.

Prepare the withdrawal of the Battle cash this host holds for the account (battle_cash in the portfolio) to the account’s cash.

FieldTypeMeaning
amountstring, optionalHow much; all of it when absent.

review: host, amount, network_fee.

A settled entry’s cash comes back to the account’s cash by itself. Battle cash stays with the host only when that transfer failed; it can then be withdrawn, or used for another entry of the same Battle (use_available).

A request with an Idempotency-Key prepares at most once. The first request with a key records it with the account; a repeat with the same key and the same body answers what the first prepared, replayed: true, and prepares nothing new. The key is kept for good: to order again, use a new key.

CaseAnswer
A repeat while the first request is still preparing409 idempotency_key_in_progress: retry in a few seconds.
The same key with a different body422 idempotency_key_reused.
The first request failed before it prepared anythingThe same request with the same key tries again; a new Belief’s draft from the first attempt is reused.
StatusCodeWhenWhat to do
401unauthorizedNo Authorization header.Send the key.
401invalid_api_keyThe key is malformed, unknown or revoked.Create a new key.
401key_refusedA key was sent to a route outside /api/agent/.Use the Agent API’s routes only.
400invalid_addressaddress is not a wallet address.Fix the address.
400invalid_messageThe message is not one POST /api/agent/auth/nonce issued for this site and chain, was changed, or is more than 10 minutes old (detail.problem: malformed, site, chain, statement, address or expired).Ask for a new message and sign it unchanged.
400signature_mismatchThe signature is not by the address the message names.Sign with that wallet.
401wallet_sign_in_refusedThe sign-in was refused: the nonce was already used or has expired.Ask for a new message.
503wallet_sign_in_unavailableThe sign-in service did not answer.Retry in a minute.
409wallet_not_signer, signer_changedThe wallet is linked to an account whose signing wallet is another one, so it could not sign that account’s orders (detail.signer_address).Use the account’s signing wallet.
400invalid_handle, handle_reservedThe handle breaks the rule above, or is reserved.Pick another.
409handle_taken, handle_immutableAnother account has the handle, or this account already has a different one.Pick another, or keep the one it has.
409handle_requiredA new Belief’s first order was asked for an account without a handle; nothing is written.Claim one with PUT /api/agent/handle, then send the same request again.
429rate_limitedOver a rate limit.Wait a minute.
400invalid_json, invalid_bodyThe body is not JSON, or breaks the fields above (detail lists the problems).Fix the request.
400invalid_idempotency_key, invalid_action_idA malformed header or path.Fix the request.
409idempotency_key_in_progressSee Idempotency.Retry shortly.
422idempotency_key_reusedSee Idempotency.Use a new key.
400weights_must_sum_10000The weights’ absolute values do not add up to 10,000.Fix the weights.
400unknown_symbolA symbol is not in GET /api/agent/assets.Pick a listed asset.
400spot_unavailable, spot_requires_longA leg asks for spot where the asset has none, or shorts on spot.Use perp, or another asset.
400short_requires_perp, perp_unavailableA short or a perpetual-market leg on an asset without that market.Use another asset.
400leverage_invalid, leverage_above_max, leverage_not_wholeThe leverage is outside 1 to max_leverage, has more than two decimals, or is not whole where it must be.Fix the leverage.
400event_legs_unsupportedA leg names a prediction market outcome.Buy such Beliefs in the app.
404belief_not_foundbelief_id names no Belief the account can buy.Check the id.
409insufficient_balanceCash is below what the order takes (detail.balance, detail.amount).Add USDG, or spend less.
400amount_too_smallThe order cannot buy every leg’s minimum (detail.min_principal).Spend more, or use fewer legs.
409core_launch_minimumA new Belief’s first order is below its minimum ($50 of principal).Spend more.
409belief_launch_pendingAn earlier first order of this Belief is still open.Wait for it, or cancel it.
409price_above_referenceA leg’s price is above its reference price by more than the limit (detail.worst_bps, detail.legs).Send the same order again with accept_deviation_bps at least detail.worst_bps to accept the price, or wait.
409asset_unfillable, asset_not_transferable, quote_unavailableAn asset cannot be bought now (detail.symbol).Retry later, or pick other assets.
409fund_busyAnother order on this Belief’s holding is still open.Wait for it.
404holding_not_foundThe account holds no part of that Belief.Check belief_id.
409holding_busy, holding_empty, proceeds_below_network_feeA sale is already in flight, nothing is left to sell, or the proceeds would not cover the network fee.Wait, or sell a larger part.
400invalid_host, invalid_entry_idA malformed Battle address or entry id in the path.Fix the request.
404battle_not_foundNo Battle has that address.Check host.
409battle_not_open, battle_round_changedThe Battle accepts no entry now, or the entry would enter another round than expected_round (detail.round, detail.status).Read the Battle again.
400invalid_heatThe Heat is outside heat_range.Fix the Heat.
409asset_not_in_battle, too_many_assets, asset_unpricedThe Belief holds an asset the Battle does not admit or cannot price now, or more assets than max_assets.Use another Belief, or wait.
409round_fee_changedThe round’s fee is above max_round_fee (detail.round_fee).Accept the fee with max_round_fee, or wait.
409battle_capacity_reached, platform_frozenThe Battle holds all the capital it may, or entries are paused.Wait.
409insufficient_available_cashThe host holds less Battle cash than the entry or the withdrawal needs (detail.available).Pay from cash, or withdraw less.
409battle_settlingAn only_this_round entry while the round before is still being settled (its renewals take entry ids).Retry in a few minutes, or enter without only_this_round.
404entry_not_foundThe account has no entry with that id in that Battle.Check the id.
409entry_not_liveThe entry already settled or renewed into another.Stop the entry it renewed into (renewed_into).
409already_stoppedA stop was already asked.Nothing to do.
409round_startedA leave once the entry’s round has started (detail.round_start).Stop it instead.
409battle_round_endingA stop or leave less than 30 seconds before its deadline (detail.round_end).After the round settles, stop the entry it renewed into.
404action_not_foundNo operation of this account has that id.Check the id.
409action_not_prepared, action_expiredThe operation was already submitted, cancelled, replaced by a newer one or past valid_until.Prepare a new one.
400invalid_signature, signature_not_ownerThe signature is malformed, or not by the account’s signing wallet (detail.recovered).Sign with the signing wallet.
409execution_would_revertThe simulation shows the operation would fail onchain; nothing was sent.Prepare a new one.
429too_many_failed_operationsThree operations failed within 10 minutes.Wait 10 minutes.

Preparing an operation replaces the account’s other operations that are not signed yet (they expire), so prepare one at a time per account.