Skip to main content
A delegated agent is a separate signer wallet (bot, execution or AI agent) that trades for an owner account under a policy. The owner keeps custody, withdrawals, collateral movement, and delegation management.

How It Works

  1. The owner (or master account) registers the agent wallet with a policy. The agent never receives the owner’s private key.
  2. The agent logs in with its own wallet; it has no separate delegated account.
  3. listDelegatedOwners returns the ownerUserId of each delegating owner.
  4. loginAsDelegatedOwner(ownerUserId) opens an owner-scoped delegated session.
  5. 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.
  6. Accepted orders mutate the owner’s spot or perps account; collateral, positions, PnL, risk, liquidation state, fees, and fills are the owner’s.
Orders carry the owner’s user ID and wallet, so self-trade prevention and TraderCodes referral rewards treat them as the owner’s. Order history does not record the agent: store the 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

  • listDelegatedOwners returns only the agent wallet’s non-revoked, non-expired delegations.
  • loginAsDelegatedOwner generates 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. createDelegatedSession registers 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 by marginAccountId 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:
  • BUY max = reference × (1 + toleranceBps / 10000), rounded down to tickSize.
  • SELL min = reference × (1 − toleranceBps / 10000), rounded up to tickSize.
  • Round quantity down to quantityStepSize within base-asset precision, then check min/max order size and limitPrice × quantity <= maxOrderNotional. Send human-readable decimal strings, not raw token units.
A BUY reference of 60000 with 100 bps gives 60600; at 0.0001 base units the requested notional is 6.06:
Check 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 with RFQ_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 in allowedTradingPairIds (when listed). A quote’s sides are checked like orders: listed markets and margin accounts, maxLeverage, LIMIT/GTC against the type and time-in-force allowlists, and each side’s price × capacity against maxRfqQuoteNotional. An IMPROVE is held to the cap too; with margin accounts listed, an IMPROVE is refused (it names no account). A withdrawal (.../withdraw) or REJECT (.../last-look) needs RFQ_MAKER and the RFQ’s market in scope, but no margin account or cap: it only takes risk off. An IMPROVE re-places the quote at its own leverage, so under maxLeverage it 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, with CANCEL_ORDER on 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 rfq and receives the owner’s pushes. Only a session whose delegation lists RFQ_MAKER also 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, lowering maxRfqQuoteNotional, 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.