- Fetches a quote
- Applies slippage protection
- Signs the order (EIP-712)
- Submits it to the order book
- Monitors execution with proper error recovery
This guide builds on the same API flow as the Raw API (cURL) and Python quickstarts. If you have not placed an order before, start there.
Prerequisites
Before starting, make sure your agent has access to:- A private key for an EOA wallet (stored securely — environment variable or secrets manager)
- ETH on the target chain — only needed for token approval transactions, not for order submission
- Tokens to trade — the sell token must already be in the wallet. Any ERC-20 token is tradeable, not just those on the CoW token list (the list is used by the UI for display purposes)
- Token approval for the GPv2VaultRelayer (
0xC92E8bdf79f0507f65a392b0ab4667716BFE0110) to spend the sell token - Python 3.8+ with
requests,web3, andeth-accountinstalled
Want to trade native ETH (not WETH)? You can use Eth-flow to place orders selling native ETH directly, without wrapping to WETH first.
Walkthrough
Agent-specific considerations
Rate limiting
The CoW Protocol API enforces per-IP rate limits. Key limits for agent workflows:
Always implement exponential backoff with jitter for
429 responses. See the full Rate Limits & Quotas reference for details and backoff code examples.
Quote freshness
Quotes reflect current market conditions and expire. For agents:- Re-quote if the agent delays materially between quoting and submission, even if
validTohas not been reached yet. - Re-quote whenever the agent changes any input that affects execution, such as the token pair, amount, or slippage settings.
- Treat quote data as short-lived state: cache it only within the current decision loop and refresh it before signing if conditions have changed.
Error recovery
Your agent should handle these HTTP responses:Idempotency
Order UIDs are deterministic — derived from the order parameters and signer address. Submitting the same signed order twice returns the same UID without creating a duplicate. This means:- Your agent can safely retry a failed submission without risking double-execution.
- If your agent crashes between signing and confirming submission, it can resubmit the same signed payload on restart.
Gas management
CoW Protocol orders are off-chain intents. Submitting and monitoring orders requires zero gas. Your agent only needs ETH for:- Token approvals — a one-time
approve()transaction per sell token for the GPv2VaultRelayer - On-chain cancellations — if you cancel via the settlement contract instead of the API (optional)
Complete example
A minimal Python script that runs the full flow:Next steps
- Rate Limits & Quotas — full rate limit details and backoff strategies
- How Intents Are Formed — understand the fee pipeline and amount calculations
- Signing Schemes — EIP-712,
ethSign, ERC-1271, and PreSign options - TypeScript SDK — higher-level SDK with built-in rate limiting
- cow-py SDK — Python SDK with
swap_tokens()and automatic backoff - API Integration Guide — complete REST API reference