How It Works
- The owner (or master account) registers the agent wallet with a policy. The agent never receives the owner’s private key.
- The agent logs in with its own wallet; it has no separate delegated account.
listDelegatedOwnersreturns theownerUserIdof each delegating owner.loginAsDelegatedOwner(ownerUserId)opens an owner-scoped delegated session.- Before every create, cancel, replace, or close-position, Monaco reloads the delegation for
(ownerUserId, agentAddress)and rejects the request if it is revoked, inactive, expired, missing, or outside policy. - Accepted orders mutate the owner’s spot or perps account; collateral, positions, PnL, risk, liquidation state, fees, and fills are the owner’s.
delegationId (from listDelegatedOwners or createDelegatedSession) with the order IDs it places. A single create response returns delegationId; batch create results do not.
An owner holds at most 10 active, unexpired agents; registering another is rejected until one is revoked or expires.
Register an Agent
The owner creates or updates the policy:- Omitting either required array returns
400 Invalid JSON payload. Optional arrays accept omission,null, or[]over REST; omission or[]in the SDK. - Upsert replaces the whole policy: omitting
expiresAt, even on an update, sets expiry to 14 days from the call.
Policy Fields
Scope matching. Every listed scope must match: an account-bound agent trades only that account (and only its listed markets, if any); a market-only agent trades its markets in every margin account; both empty denies all orders. Scopes do not filter reads.
IP allowlist. Checked only at session creation; a source address outside every range gets
403. Existing sessions work from any address until expiry or revocation, so revoke after narrowing the list. Entries read back as CIDR (/32 IPv4, /128 IPv6).
Open a Delegated Session
listDelegatedOwnersreturns only the agent wallet’s non-revoked, non-expired delegations.loginAsDelegatedOwnergenerates an Ed25519 session keypair locally, sends only the public key, and installs the session (account mode delegated, withdrawals disabled) as the SDK’s active auth state.createDelegatedSessionregisters a session without switching to it, so calls would still act on the agent’s account.- Adopting replaces the instance’s auth state; keep the agent’s own login in a separate instance or credential store.
Expiry and Revocation
- A session expires no later than its delegation. Every signed request, including reads and
refreshAuth(), needs an active, unexpired delegation;refreshAuth()cannot extend past the grant’s expiry. - After grant expiry the owner renews the grant; an expired session needs a new delegated session from the agent’s wallet login.
- Grant expiry blocks but does not revoke session keys: after reauthorization an unexpired session may work again, including one issued before the grant was shortened.
- Revoking marks the agent’s sessions revoked; renewing does not revive them. Reconcile a failed revocation before reauthorizing.
- Shortening or revoking ends access for existing sessions; connected WebSockets enforce it at the next revalidation (currently every 60 seconds). Existing orders are not canceled.
Permissions
Trading
An order names its margin account bymarginAccountId or by its sub-account key as strategyKey; naming neither uses the owner’s default margin account. Monaco resolves or creates the risk bucket for the market.
Immediate Execution Under maxOrderNotional
A capped MARKET order without a price is rejected with Delegated agent maxOrderNotional requires a limit price; slippageToleranceBps does not supply it. Use LIMIT + timeInForce: "IOC" (the grant must allow CREATE_ORDER, the market or account, LIMIT, and IOC), without postOnly or slippageToleranceBps. IOC fills at the limit or better and cancels the remainder. Derive the limit from a fresh reference price with decimal arithmetic:
BUYmax = reference × (1 + toleranceBps / 10000), rounded down totickSize.SELLmin = reference × (1 − toleranceBps / 10000), rounded up totickSize.- Round quantity down to
quantityStepSizewithin base-asset precision, then check min/max order size andlimitPrice × quantity <= maxOrderNotional. Send human-readable decimal strings, not raw token units.
60000 with 100 bps gives 60600; at 0.0001 base units the requested notional is 6.06:
matchResult.status, totalFilled, remainingQuantity: partial fill is CANCELLED with nonzero totalFilled; no liquidity is REJECTED. Reconcile fills before resending the remainder.
maxOrderNotional checks the full requested price × quantity at admission; it is not an exposure, collateral, or fee budget, and SELL proceeds can exceed it. Fees and margin checks still apply; a stale reference can mean a partial fill or none. For margin orders, simulate the risk bucket order first; a preview reserves nothing, so keep its margin amounts as decimals and do not round away a positive shortfall. Admission still requires actual funding.
RFQ as a Delegated Maker
An agent withRFQ_MAKER can run the owner’s RFQ quoting without a key that can withdraw funds:
- What it may do. Quote and re-quote (
PUT /api/v1/rfqs/{rfqId}/quote) and improve in last look only on an RFQ whose market is inallowedTradingPairIds(when listed). A quote’s sides are checked like orders: listed markets and margin accounts,maxLeverage,LIMIT/GTCagainst the type and time-in-force allowlists, and each side’s price × capacity againstmaxRfqQuoteNotional. AnIMPROVEis held to the cap too; with margin accounts listed, anIMPROVEis refused (it names no account). A withdrawal (.../withdraw) orREJECT(.../last-look) needsRFQ_MAKERand the RFQ’s market in scope, but no margin account or cap: it only takes risk off. AnIMPROVEre-places the quote at its own leverage, so undermaxLeverageit is refused too. Fills land on the owner’s account. - What it may not do. Create, accept or cancel an RFQ: taker writes stay
403. A cancel-all or cancel-all-after from a delegated session (always pair-scoped, withCANCEL_ORDERon the pair) withdraws the owner’s RFQ quotes on that pair along with its orders: a kill switch only takes risk off. - Signing. The agent signs each request with its own delegated session key, the same way it signs orders. The RFQ service verifies that signature against the session key it stores with the quote (again for a silent fill at last look), and records the delegation that admitted the request beside it, so a disputed fill traces to the delegation and the owner who granted it.
- Connection. Any delegated session may subscribe to
rfqand receives the owner’s pushes. Only a session whose delegation listsRFQ_MAKERalso keeps the owner’s quotes alive under the disconnect rule: dropping it withdraws them after 5 seconds, and a read-only key never keeps them alive. Maker rights are checked again at each session revalidation (currently every 60 seconds). - Revocation. Revoking the delegation, or narrowing it to drop
RFQ_MAKER, stops new writes at once and withdraws the quotes it placed in RFQs still collecting quotes, through any application, within a few seconds; an RFQ the taker already accepted runs its last look. If the RFQ service cannot be reached then, those quotes stay firm until they expire (60 s at most), are withdrawn, or the RFQ ends. Narrowing the market or margin-account scope, loweringmaxRfqQuoteNotional, or letting the delegation expire leaves quotes already standing until they expire: withdraw them first, or revoke.
UI Guidance
Show the authorized wallet, policy, expiry, and market restrictions near agent status; make revocation obvious; default bots to narrow market and notional limits.Related
- Market-Maker Runbook for running a quoting loop
- TypeScript delegated agents for the SDK reference
- MCP Server for AI-agent integrations

