Skip to content

Generate your Agent API Key

Every plan can generate an Agent API Key. A key made here reads signals (signals:read) and places paper trades (mock:trade). To let your agent place real trades, create the key in Profile and turn on trade:execute. Free keys have 200 MCP requests/day; Elite adds full agent write access.

PolyTrackers API (External + AI Agent Guide)

Agent authentication discovery: /auth.md describes human-issued Agent API Keys. A rejected POST /api/mcp returns its existing JSON-RPC 401 error with WWW-Authenticate: Bearer realm="PolyTrackers API", resource_metadata="https://polytrackers.com/.well-known/oauth-protected-resource/api/mcp". The metadata binds to the challenged resource. This is API-key discovery, not OAuth delegation or anonymous agent registration.

This is the production-facing API guide for external developers and AI agents.

Published trader grade

GET /api/recommendations returns trader_grade on each candidate. GET /api/trader-lookup returns it beside resolvedTrader; username lookup uses that canonical wallet address. MCP pt_recommendations_get preserves it in full and compact projections. pt_trader_profile_get returns it at the top level and in lookup.trader_grade; lookup/profile batch projections also retain it. These remain authenticated Free-tier reads. Candidate ranking, copy actionability and trading permission do not change.

trader_grade is an object with grade (A–F), confidence (high, medium, low), component_scores and scored_at (ISO timestamp). It is returned only for wallets already published by the curated_traders public-read policy, using a matching latest non-excluded score. Unpublished, unscored, mismatched or unavailable evidence returns null without a reason; internal verdicts, exclusion reasons and provenance are never exposed.

The nine component_scores keys are alive, cadence, mm_bot, real_edge, track_record, favorite_heavy, time_to_payoff, liquidity_fit and forward_shadow. Values are 0–100 or null for unknown, never a fabricated zero. The inputs are realized return on settled bets (180 days, or 90 days when unavailable), recent activity, market-maker and bot screens, trade frequency, track-record sample size, a heavy-favorite penalty, time to payout, trade-size fit and a completed 14-day forward paper window. The copy backtest is a separate admission check, not an input to this grade. The grade describes past evidence, not a forecast. The calibration table in the curated surface Measurement Plan is not built; no later-results validation is claimed.

See the public trader-grade method for weights and limitations. Scoring, the UI kill switch, holdout and /copy-trading sign-in gate are unchanged.

Platform copy backtest

GET /api/recommendations returns copy_backtest on each candidate, beside trader_grade. GET /api/trader-lookup returns it beside trader_grade. MCP pt_recommendations_get (full and compact), pt_trader_lookup and pt_trader_profile_get return the same object. These remain authenticated Free-tier reads. Candidate ranking, copy actionability and trading permission do not change.

copy_backtest is the platform copy backtest of a published trader, the same for every caller: the canonical copy backtest (flat 100 USD stake, 1,000 USD simulated bankroll, measured copy slippage and entry fees, positions held to settlement) over 90 days, or over 180 days when the 90-day run has incomplete data or fewer than 20 entered trades. An hourly job refreshes each listed trader one time in 24 hours.

FieldMeasuredNot measured
statusmeasurednot_measured
reasonnullno_run, stale or insufficient_coverage
roi_pctCopy return after costs, percent of the bankrollnull
window_days90 or 180null
entered_tradesTrades entered by the replay (20 or more)null
holdout_window_days30null
holdout_roi_pctReturn of the last 30 days; null with no entrynull
holdout_entered_tradesTrades entered in the last 30 daysnull
run_atTime of the runTime of the last run, or null

A result is published for 7 days from run_at; an older run is stale. A not_measured result is never zero. copy_backtest is null when the wallet has no published grade or the read is not available.

The result is a model on past entries, not a forecast. It starts from the trader's recorded entry prices; it does not replay a follower's order-book fills, mirrored exits, exit costs or market impact. It is not an input of the grade, and it does not replace the caller's own canonical copy backtest (POST /api/backtest, pt_backtest_run) for copy admission. Method: copy return after costs.


Scope

This guide/spec covers the full AI agent surface:

  • Auth: /api/auth/refresh
  • Account/Tier: /api/account, /api/account/stats, /api/account/streak, /api/account/risk-profile
  • Discovery: /api/markets, /api/markets/end-dates, /api/market-signals, /api/leaderboard, /api/leaderboard/internal, /api/leaderboard/internal/me, /api/clob/price, /api/clob/prices, /api/clob/price-history, /api/clob/fee-info, /api/trader-lookup
  • Anomalies: /api/anomalies, /api/anomalies/{id}, /api/anomalies/by-market, /api/anomalies/performance, /api/receipts/recent, /api/scan/trigger, /api/scan/run
  • Backtesting: /api/backtest
  • Recommendations, activity & feedback: /api/recommendations, /api/bets/sync, /api/feedback
  • Agent API Keys: /api/keys, /api/keys/generate, plus public feeds
  • Trading: /api/trades, /api/trade/execute, /api/trade/history, /api/trade/ledger, /api/trade/money-summary, /api/trade/orders*
  • Alerts & webhooks: /api/alerts/preferences, /api/webhooks*
  • Sportsbook gap scanner: /api/sports/gaps, /api/sports/gaps/monitors, /api/sports/gaps/monitors/{id}, /api/sports/gaps/paper-trade, /api/sports/gaps/rule-test (section)
  • Whale service + ingest webhooks: wallets/roster/whale control + /api/whale/webhook*
  • Health: /api/health (anonymous, unmetered liveness + database probe)

Excluded intentionally:

  • /api/mock/* internal/MCP-only simulation helpers (use the registered pt_mock_* tools)
  • /api/sports/gaps/view, the website's signed-in analytics beacon
  • /api/cron/* scheduled internal jobs
  • /api/admin/*, /api/stripe/*, /api/telegram/*, /api/onboarding/* and other UI/operator-only routes

The MCP-only pt_whale_forward_returns_get read accepts 1–50 arbitrary wallet entries with exact per-wallet since timestamps and a shared as_of cutoff. It returns one request-ordered row per entry with bounded fill coverage, gross/post-cost capital-accounting ROI, unresolved capital, resolution provenance, and isolated ok|partial|error state. Its Data API and Gamma calls use the low-priority backfill request budget and are counted in _budget. For both cohorts, combined post-cost fees, P&L and ROI are null if any resolved BUY lacks a verified fill-time venue fee. Report covered and uncovered fill counts and exclude null ROI from post-cost medians. Builder and known venue fee subtotals remain available. Zero resolved capital produces null ROI; compute cohort medians client-side over non-null rows. Re-runs at the same cutoff may incorporate later authoritative Gamma outcome/closedTime evidence as corrected upstream data.

The Elite, read-only pt_copy_replication_aggregates_get tool is MCP-only, operator-allowlisted through ADMIN_EMAILS, and has no public REST or browser route. Ordinary customer keys fail closed. It requires one exact whale, fixes the service-role Copy Receipt V1 RPC limit at one, and uses index-backed lookup with a caller-side five-second deadline that aborts the PostgREST request. Scored metrics stay null below 20 distinct settled conditions and high confidence still requires 40+ conditions with at least 75% complete receipts. Do not present it as a public copy score or recommendation.

GET /api/recommendations includes the stored botLikeness aggregate. A high tier adds a copy-fill-lag warning and demotes matchScore; the response never includes raw Polymarket trade history. Rows also include tradingStyle, a deduped BUY entry-price distribution with sample/window metadata. Its badge classification is withheld below 20 fills; sufficiently sampled distributions also contribute to deterministic risk-fit scoring. Recommendation rows also expose name_source (tracked_alias, leaderboard, or address_fallback), name_as_of, and Polymarket's rename-stable pseudonym when available. Address-prefixed legacy aliases are treated as absent; wallet address remains the identity key.

GET /api/leaderboard and GET /api/recommendations include upstream metadata for the shared Polymarket leaderboard fetch. Check its per-timeframe outcomes plus degraded and stale before interpreting an empty candidate pool. A stale response is explicitly labeled, retains the original fetchedAt timestamp, and is bounded to the latest fully healthy snapshot from the prior 24 hours. staleExpiresAt is the absolute cutoff; public, REST, and MCP response layers do not cache leaderboard payloads beyond the durable 10-minute Redis cadence, and each response revalidates after downstream enrichment so an embedded fallback is removed at that cutoff. Candidate actionability also distinguishes known dormancy from missing ingestion coverage: zero local activity inside the warning window for an untracked, newly tracked, or recently resumed wallet returns warning-only ACTIVITY_COVERAGE_UNKNOWN plus recent_activity.source/coverage metadata, never DORMANT_WHALE. Discovery rows expose bankroll ROI, arithmetic average per-trade return, entered/used counts, source truncation, and first/last loaded signal as separately named capital-accounting fields. Truncated or fewer-than-20-entry canonical runs are reporting-only insufficient_coverage; a shorter complete diagnostic does not clear the 90- or 180-day admission gate. MCP capability revisions are whale-coverage-honesty-v11 for the leaderboard, whale-coverage-honesty-v9 for recommendations, copy-digest-entry-fill-v18 for the copy-trading digest, and whale-coverage-honesty-v4 for the backtest tool. Wallet-shaped suggestion/trader rows use the canonical recent-flow majority predicate, filter majority-ephemeral and unknown-coverage rows under durable_only, retain dormant wallets, and expose bounded durability_profile provenance.

Recommendation and digest-suggestion rows expose previously_removed_by_caller by normalized wallet address. It is null or contains { count, last_removed_at, last_reason }, where count covers currently inactive assignments across the caller's mock wallets rather than lifetime removal cycles. These candidates remain visible with a warning by default. REST accepts exclude_previously_removed=true|false; direct MCP accepts the boolean exclude_previously_removed and binds it to continuation cursors. Filtered counts appear as omitted_by_prior_removal_filter.

On an existing assignment, send copyEnabled: false to PATCH /api/roster/{address} for watch-only mode. Send true to allow eligible signals to be copied. Omit the field on an in-place edit to keep the current setting. A non-boolean value rejects the entire patch with HTTP 400. Change this setting separately from reactivation or a wallet move. Verify the returned whale.walletId and whale.copyEnabled. Reactivating an inactive assignment with PATCH and no daily cap can enable copying. To restore it as watch-only, POST to /api/roster with the same wallet and address and copyEnabled: false, then verify the returned assignment.

PATCH /api/roster/{address} treats fromWalletId as the source-assignment selector. If one address has active assignments on multiple visible wallets, an address-only write fails with HTTP 409, code AMBIGUOUS_ASSIGNMENT, and candidate_wallet_ids rather than changing an arbitrary row. Cookie-authenticated PATCH requests and POST /api/whale/roster-assign requests return HTTP 403 when browser origin headers indicate a cross-site write. The WHALE_SERVICE_SHARED_SECRET path for PATCH is unaffected.

POST /api/roster accepts any exact Polymarket whale wallet address; the whale does not need to appear in leaderboard or recommendation results. The walletId may select a caller-owned paper roster or dedicated real-money copy roster returned by GET /api/wallets. name is optional, and copyEnabled:false stages the assignment watch-only. When starting from a username, resolve and review the exact address with GET /api/trader-lookup before creating the assignment. Username resolution uses Polymarket's public profile search, then fetches and validates trades for only that canonical wallet; trade pages are never used to infer username ownership.

Roster rows also expose maxMirrorsPerDay (and max_mirrors_per_day). POST /api/roster, POST /api/whale/roster-assign, and PATCH /api/roster/{address} accept an optional integer from 0 to 100000; 0 is the default and means unlimited. The cap is scoped to one wallet and whale, counts original copy BUY entries in the current UTC day, and does not count partial SELL activity. A positive mock cap is enforced by the atomic trade insert; real copy reads use real_trades.whale_address for advisory evaluation. Set fromWalletId when patching an address assigned to multiple wallets.


Auth modes

Most user-scoped agent endpoints accept authenticated user context via:

  • Supabase session cookie (sb-* managed cookies)
  • Authorization: Bearer <supabase-jwt-access-token>

2) JWT-only bearer

POST /api/keys/generate strictly verifies Supabase JWT bearer identity.

3) Agent API Key bearer

Agent API Keys are prefixed ptk_ and are passed as Authorization: Bearer <agent-api-key>. The same key works for PolyTrackers MCP server access and direct REST/API requests when it has the required scopes:

  • signals:read — read-only data, including caller-owned private account/trade receipts on supported MCP tools (not a public-data-only scope)
  • agent:scan — scan trigger where allowed (Pro and Elite)
  • mock:trade — committed paper trades on the caller's own mock wallets, through MCP tools and the sportsbook-gap POST /api/sports/gaps/paper-trade route; no other REST endpoint accepts it. Paper-only: it never moves real funds and cannot write to the real-money wallet. Every plan.
  • trade:execute — real trade execution only, after readiness and preflight gates pass. Every plan through MCP pt_trade_execute; Pro and Elite for direct REST POST /api/trade/execute.
  • monitors:write — create, edit, pause, resume and delete the caller's own sportsbook-gap monitors (/api/sports/gaps/monitors* and the pt_sports_gap_monitor_* tools). Owner-scoped and alert-only. Pro and Elite; a Free key cannot hold it.
  • agent:full — full agent/write/trade access (currently Elite-only for Agent API Keys)

Every key holds signals:read. Every other scope is opt-in: it is granted only when the key request names it, and a key keeps the scopes it was made with. See the 2026-11-09 decision and, for monitors:write, decision 0036.

Endpoints that accept Agent API Keys:

EndpointRequired scopeDirect REST tier
GET /api/anomaliessignals:readPro+
GET /api/tradessignals:readPro+
GET /api/leaderboardsignals:readPro+
POST /api/backtestsignals:readFree+ (fixed demo config on Free)
GET /api/anomalies/performancesignals:readPro+
GET /api/public/whale-signalssignals:readElite
GET /api/public/copy-signalssignals:readElite
POST /api/trade/executetrade:executePro+
GET /api/trade/historyagent:fullPro+ (Elite for new full keys)
GET /api/trade/ledgeragent:fullPro+ (Elite for new full keys)
GET /api/trade/money-summaryagent:fullPro+ (Elite for new full keys)
GET /api/trade/orders, GET /api/trade/orders/{id}agent:fullElite
DELETE /api/trade/orders/{id}agent:fullPro+
POST /api/feedbackagent:fullElite

The direct REST tier applies only when the bearer is a ptk_ Agent API Key; session-authenticated callers follow the tier behavior below. Free Agent API Keys work on POST /api/backtest, but only with the fixed demo configuration, and the returned trade list is capped at 5 rows. Every other row requires current Pro or Elite access: the key validator rejects a Free key before the handler runs, so GET /api/trades answers a Free key with a plain 401 ({ "error": "Unauthorized" }), not TIER_UPGRADE_REQUIRED. Free-tier agents read mock and real trade history through MCP pt_trades_list (signals:read, Free) instead of GET /api/trades. New agent:full keys are normally issued only to Elite accounts; the Pro+ cancellation tier allows an existing agent:full key to keep reducing exposure after an account downgrade.

POST /api/trade/execute keeps its Pro floor for Agent API Keys even though a Free key can hold trade:execute since 2026-11-09. The REST lane has no signed preflight proof, so a Free agent places real trades through MCP (pt_trade_preflight, then pt_trade_execute), where every order carries one. A Free ptk_ key on this route gets the same plain 401 as on the other rows.

GET /api/trade/history keeps its existing REST Agent API Key gate: agent:full plus the validator's current Pro/Elite access check. Browser/Supabase JWT users can read their own receipts at every tier without an Agent API Key. For least-privilege agent reads, use MCP pt_trade_history_get with signals:read at any tier; do not add write scopes to a key just to read history. Both interfaces fence the same real_trades projection to the authenticated user, regardless of extra owner/wallet query parameters. See the trade-history permission contract for the fields, compatibility rationale and authorization tests.

The sportsbook-gap scanner routes also accept Agent API Keys, but their key validation lets Free keys through: the plan is enforced by the scanner itself, and the scan read needs no paid scan permission. A bearer shaped like an Agent API Key is judged by the key alone, with no fallback to a session cookie.

EndpointRequired scopePlan
GET /api/sports/gapssignals:readEvery plan (Free: the top 3 results per search)
GET /api/sports/gaps/monitorssignals:readEvery plan
POST /api/sports/gaps/paper-trademock:trade (dry_run: true: signals:read)Every plan
POST /api/sports/gaps/monitorsmonitors:writePro and Elite
PATCH, DELETE /api/sports/gaps/monitors/{id}monitors:writePro and Elite
POST /api/sports/gaps/rule-testsignals:readPro and Elite (Free: 403 TIER_UPGRADE_REQUIRED)

A key without the route's scope gets 403 with code: "AUTH_SCOPE_MISSING" and requiredScope, and a missing or invalid credential gets 401 { "error": "Unauthorized", "code": "AUTH_REQUIRED" }. A Free key cannot hold monitors:write, so on the monitor writes it gets 403 TIER_UPGRADE_REQUIRED, the same answer as a signed-in Free browser session and as the MCP tools. With an Agent API Key, every scanner route spends the same per-tool and daily buckets as its MCP tool (see Sportsbook gap scanner).

4) Service auth

For whale-service control endpoints:

  • x-whale-service-secret: <secret> or
  • Authorization: Bearer <WHALE_SERVICE_SHARED_SECRET>

5) Scan secret

POST /api/scan/run also accepts x-scan-secret: <SCAN_SECRET> (bypasses the tier gate; used by cron/internal automation).

6) Webhook signature auth

POST /api/whale/webhook requires:

  • x-alchemy-signature = HMAC_SHA256(raw_body, ALCHEMY_WEBHOOK_SIGNING_KEY)

When a registration has a secret, outbound deliveries from /api/webhooks* include X-Webhook-Signature with the value sha256=<HMAC_SHA256(raw_body, secret)>. Compute the HMAC over the raw request body before parsing it.


Tier gating (important)

Effective tier resolution: a user on free with an active trial (trial_ends_at > now) is treated as pro. Tier failures return TIER_UPGRADE_REQUIRED with the required tier and an upgradeUrl.

Free

  • GET /api/trades: 7-day mock history plus full-depth own real-trade receipts.
  • GET /api/anomalies: current published Anomaly 2.0 population from the same Free-tier Anomalies-page gate; max 5 rows per request with bounded offset continuation through the canonical 100-row source window.
  • POST /api/scan/trigger: not allowed (403).
  • /api/keys + POST /api/keys/generate: allowed; generated keys get signals:read, plus mock:trade (committed paper trades over MCP) and trade:execute (one-off real trades over MCP) when the request names them. Requested agent:scan, monitors:write and agent:full are stripped. Limit: 1 active Agent API Key per user; rotate by revoking the old key, then generating a replacement. MCP usage is capped at 10 requests/min per tool and 200 requests/day total.
  • GET /api/sports/gaps: allowed with signals:read; returns the top 3 qualifying results per search, with no next page (plan.truncated says when more qualified). Same data, freshness and calculation as paid plans. Zero active monitors and no rule tests (403 TIER_UPGRADE_REQUIRED).
  • POST /api/trade/execute: session callers can execute only when manual trading-readiness checks pass. A Free Agent API Key with trade:execute executes through MCP pt_trade_execute (signed preflight plus the owner's AI agent authorization); the direct REST route rejects Free keys with 401.
  • Session callers can read their own /api/trade/history, /api/trade/ledger, and /api/trade/money-summary; direct Agent API Key calls still require agent:full. Order listing/detail remain unavailable. DELETE /api/trade/orders/{id} may cancel the signed-in user's own resting order because cancellation reduces exposure.
  • /api/webhooks (create): not allowed (403).
  • /api/public/whale-signals, /api/public/copy-signals: not allowed. A Free Agent API Key never reaches the Elite gate: the key validator rejects it before either handler runs, so the response is 401 { "error": "Invalid API key" }, not 403. The 403 TIER_UPGRADE_REQUIRED body is reached only by a Pro key.

Pro

  • GET /api/trades: 90-day mock history plus full-depth own real-trade receipts.
  • GET /api/anomalies: current published Anomaly 2.0 population; max 100 rows per request.
  • POST /api/scan/trigger: allowed, rate limited to 2/hour.
  • /api/keys + POST /api/keys/generate: allowed; scopes default to signals:read, with optional mock:trade for committed paper trades over MCP, optional trade:execute for real trade execution, agent:scan for scan automation where allowed, and monitors:write for the caller's own sportsbook-gap monitors. Limit: 1 active Agent API Key per user; rotate by revoking the old key, then generating a replacement.
  • /api/webhooks (create): up to 5 active webhooks.
  • /api/sports/gaps*: every qualifying result with cursor pagination (25 per page by default, at most 100), up to 5 active monitors (separate from the webhook limit), and rule tests over 90 days of collected history.
  • /api/public/whale-signals, /api/public/copy-signals: not allowed (403 TIER_UPGRADE_REQUIRED with requiredTier: "elite"; Elite only).
  • POST /api/trade/execute: session callers can execute only when manual trading-readiness checks pass. Agent API Key/MCP execution requires trade:execute scope.
  • Session callers can read their own /api/trade/history, /api/trade/ledger, and /api/trade/money-summary; direct Agent API Key calls still require agent:full. Order listing/detail remain unavailable. DELETE /api/trade/orders/{id} may cancel the signed-in user's own resting order.

Elite

  • GET /api/trades returns full-depth mock and own real-trade history.
  • GET /api/anomalies: current published Anomaly 2.0 population; max 100 rows (the shared canonical page-feed bound).
  • POST /api/scan/trigger: allowed, rate limited to 10/hour.
  • /api/keys + POST /api/keys/generate: scopes may include signals:read, mock:trade, trade:execute, agent:scan, monitors:write, and/or agent:full. Limit: 1 active Agent API Key per user; rotate by revoking the old key, then generating a replacement.
  • /api/sports/gaps*: every qualifying result with cursor pagination, up to 50 active monitors, and rule tests over 365 days of collected history.
  • /api/trade/execute, /api/trade/history, /api/trade/ledger, /api/trade/money-summary, and /api/trade/orders*: allowed where the route-specific readiness checks pass (trade:execute or agent:full for execute API-key auth). Browser/session order cancellation is allowed for the signed-in user's own resting order regardless of tier.
  • /api/public/whale-signals, /api/public/copy-signals: allowed.
  • /api/webhooks (create): up to 50 active webhooks.

Rate limits

Agent API Key REST limits use the scope shown below; MCP separately applies per-identity/per-tool and aggregate request buckets (see MCP rate limits). Session requests are limited per user, while the public discovery and refresh limits are per IP.

EndpointLimitScope
POST /api/auth/refresh30/minuteIP
Anonymous discovery GETsshared 60/minute anonymous budgetIP
POST /api/scan/triggerPro: 2/hour, Elite: 10/houruser
POST /api/keys/generate5/hour per useruser
POST /api/trade/execute10/minute per user + 20/minute per API keyuser + key
GET /api/clob/price-history60/minute in-route, on top of the proxy default 30/minute read bucketIP
GET /api/markets/end-dates420/minute + 20,000 condition IDs/minute in-route, on top of the shared 60/minute discovery bucketuser
GET /api/public/whale-signals120/minute per API keyAPI key
GET /api/public/copy-signals120/minute per API keyAPI key

The shared anonymous discovery budget covers GET /api/markets, GET /api/events, GET /api/home-snapshot, and GET /api/market-signals. One anonymous caller consumes the same IP-scoped 60-request bucket across all four routes.

Rate limit response headers

Every rate-limited response — a success as well as a 429 — carries the RFC RateLimit-* quota view for the bucket that governed it. Read it and pace yourself; do not discover the ceiling by being refused.

HeaderMeaning
RateLimit-LimitEffective ceiling for this caller, after tier multipliers (Pro x2, Elite x5).
RateLimit-RemainingRequests left in the current window.
RateLimit-ResetDelta-seconds until the quota refills. Never a unix timestamp.
RateLimit-Policy"bucket";q=<limit>;w=<window seconds> — endpoints sharing a bucket share one budget.
bash
curl -si https://polytrackers.com/api/markets | grep -i '^ratelimit-'
RateLimit-Limit: 60 RateLimit-Remaining: 59 RateLimit-Reset: 60 RateLimit-Policy: "public-market-read";q=60;w=60

Rules a client can rely on:

  • On a 429, Retry-After stays the authoritative back-off signal, and RateLimit-Reset is never smaller than it. Sleeping for RateLimit-Reset is therefore always safe.
  • RateLimit-Reset rounds up, so it never expires early.
  • Paths with no limiter behind them omit the headers entirely rather than advertise a quota nobody enforces: /api/health, /api/cron/*, the signed provider webhooks, and the cached GET /api/mcp capability probe.
  • POST /api/auth/refresh is metered only in-route (30/minute per IP), so its 429 carries Retry-After (which an upstream-proxied 429 may omit) and no quota view.
  • Three endpoints add an in-route limiter on top of the proxy bucket. The RateLimit-* view on their responses describes the proxy bucket only, never the in-route limiter, so pace on the view but still honor Retry-After on their 429s:
    • POST /api/trade/execute — proxy write bucket (30/minute per user before tier multipliers); in-route 10/minute per user and 20/minute per API key. The per-key 429 also sends legacy X-RateLimit-Limit / X-RateLimit-Remaining.
    • GET /api/clob/price-history — proxy default bucket (30/minute, keyed by IP for anonymous callers); in-route 60/minute per IP, Retry-After only.
    • GET /api/markets/end-dates — proxy public-market-read bucket (60/minute per user before tier multipliers); in-route 420 requests/minute and a weighted 20,000 condition IDs/minute budget per user. The request budget is published as legacy X-RateLimit-Limit / X-RateLimit-Remaining and the ID budget as X-Market-Resolution-ID-Limit / X-Market-Resolution-ID-Remaining.
  • The sportsbook-gap routes under /api/sports/gaps follow the same rule when called with an Agent API Key. The RateLimit-* view on those responses describes a per-IP backstop of 300/minute, not the key's own budget. The key is metered in-route against the per-tool and daily buckets of the matching MCP tool (see MCP rate limits), and rule tests have a further budget of 6/minute per account. A blocked call returns 429 with code: "RATE_LIMITED", retry_after_seconds and Retry-After.
  • Treat a missing quota view as "unknown budget", never as "unlimited".
  • The MCP per-user/per-tool buckets are metered in-route and report retry_after_seconds inside the JSON-RPC error payload; the RateLimit-* headers on /api/mcp describe the per-IP transport cap only.

MCP rate limits

MCP (POST /api/mcp) is metered separately from the REST limits above, in three per-user layers plus one transport cap. All apply at the same time; the tightest one binds.

BucketFreeProEliteScope
Per-tool tools/call10/minute60/minute300/minuteuser, per tool name
Daily tools/call quota (all tools)200/dayno daily capno daily capuser
All JSON-RPC requests (setup + listings)120/minute600/minute1800/minuteuser

Transport caps on /api/mcp apply per IP before authentication, regardless of tier: 300/minute for authenticated traffic and 60/minute for credential-less requests under the /api/mcp prefix (anonymous POST /api/mcp handshakes, /api/mcp/events, and the documentation server at /api/mcp/docs). The cached GET /api/mcp health probe is the one exception: it returns before any limiter and is not metered.

  • The per-tool bucket is keyed by tool name, so a burst on one tool does not consume another tool's budget. Blocked calls return RATE_LIMITED with retry_after_seconds.
  • The daily quota is consumed only after the per-minute bucket allows the call, so minute-throttled calls do not burn the daily budget.
  • The sportsbook-gap REST routes under /api/sports/gaps spend the per-tool and daily buckets of their MCP tools when called with an Agent API Key, so REST and MCP share one quota there. Rule tests also have a budget of 6 per minute per account.
  • The request bucket charges every authenticated POST one setup unit, plus one extra unit for catalog listings and resource/prompt reads. tools/call, initialize, ping, and notifications/* pay only the setup unit.
  • The transport IP caps are enforced before JSON-RPC handling and may return a non-JSON 429; treat any raw 429 as RATE_LIMITED and back off.

The same figures are published machine-readably in the polytrackers://mcp/capabilities resource (rate_limit_per_minute, rate_limit_per_day, transport_rate_limits.streamable_http).

404 response shape (unknown paths)

Any /api/** path that matches no endpoint returns HTTP 404 with a JSON body. It is never the HTML app shell, so a client can branch on the payload:

json
{
  "error": "Not Found",
  "code": "NOT_FOUND",
  "message": "No PolyTrackers API endpoint matches GET /api/nope. The OpenAPI contract lists every documented path.",
  "documentation": {
    "openapi": "https://polytrackers.com/openapi.json",
    "apiDocs": "https://polytrackers.com/docs/api",
    "llmsTxt": "https://polytrackers.com/llms.txt",
    "agentSkill": "https://polytrackers.com/skill.md",
    "mcp": "https://polytrackers.com/api/mcp"
  }
}

Send Accept: text/markdown for the same recovery links as a short markdown document. Both variants set Vary: Accept. NOT_FOUND is not retryable — re-read the OpenAPI contract instead of backing off.

Page (non-/api) paths keep serving the regular HTML 404 page.

Markdown content negotiation (public pages)

A curated set of public pages answers Accept: text/markdown with a short machine-readable summary instead of HTML — the page title, its description, and the discovery links to read next. The set is every static public page — the homepage, the documentation hub and API reference, the guides, the comparison pages, and the policy pages — reachable either by sending the header or by appending .md to the path (/docs -> /docs.md). Live-data pages (the leaderboard, anomalies, wallet tracker, analytics, search, and copy trading) are excluded on purpose: a summary of a continuously refreshed page would carry none of its data. public/llms.txt publishes the live list.

bash
curl -s -H 'Accept: text/markdown' https://polytrackers.com/docs/api

Rules:

  • The markdown body is a summary, not a transcription. Fetch the canonical HTML URL it names when you need the full document.
  • Both representations set Vary: Accept, so a shared cache cannot mix them.
  • Ranking honors q-values. text/markdown must outrank text/html; a tie serves HTML, because a client that accepts both can render the page.
  • An Accept that matches neither representation and carries no wildcard gets 406 Not Acceptable. A missing or wildcard Accept gets HTML.
  • Every other path ignores the header and serves HTML exactly as before.

429 response shape

Every 429 body includes "error" (string). The Retry-After header (seconds) is the authoritative back-off signal — it is present on all rate-limited responses (the one exception: 429s proxied from the upstream auth provider on POST /api/auth/refresh may omit it). Other body fields vary by endpoint, so treat them as optional:

Endpoint / limiter429 body
GET /api/public/whale-signals{ error }
GET /api/public/copy-signals{ error }
POST /api/trade/execute (per API key){ error, code: "API_KEY_RATE_LIMITED", retryAfter, docsUrl }
POST /api/trade/execute (per user){ error, code: "RATE_LIMITED" }
POST /api/keys/generate{ error, code: "RATE_LIMITED" }
POST /api/auth/refresh{ error, code: "RATE_LIMITED" }
POST /api/scan/trigger{ error }

The fullest shape — returned by the /api/trade/execute per-API-key limiter:

json
{
  "error": "This API key has exceeded its trade execution rate limit. …",
  "code": "API_KEY_RATE_LIMITED",
  "retryAfter": 7,
  "docsUrl": "https://polytrackers.com/docs/api"
}

Protocol identity for real orders

Manual and agent POST /api/trade/execute return HTTP 422 MARKET_IDENTITY_UNSUPPORTED when fresh Gamma identity is unavailable, inconsistent, or unsupported. details.reason is a bounded reason such as version_unavailable, identity_mismatch, or v2_execution_unavailable. Copy execution records the corresponding market-identity-unsupported skip. Rejection precedes credential creation, wallet provisioning, approvals, signing, and financial reservation. Protocol V2 markets can be displayed and priced; new financial execution stays closed pending ledger/receipt/trading integration. Existing positions remain visible. Public field names such as token_id remain compatibility aliases for the version-selected asset ID, never a synthetic or alternate-field fallback. Historical resolution displays may retain outcomes with null asset IDs when identity is unknown.

Idempotency for /api/trade/execute

Session-authenticated trade execution enforces the configured site origin: Sec-Fetch-Site: cross-site or a mismatching Origin returns HTTP 403 with code TRADE_EXECUTE_CROSS_ORIGIN, before body parsing, idempotency locking, or trade execution. Requests without either browser origin header retain existing behavior. Agent API Key requests are exempt from this session check.

Trade execution is idempotent when you supply an Idempotency-Key header. For Agent API Key requests the header is required (400 IDEMPOTENCY_KEY_REQUIRED otherwise); session requests may still pass idempotencyKey in the body. Every /api/trade/execute body must also include regionCertification: true to certify the caller is permitted to trade in their jurisdiction and is not in a restricted or prohibited Polymarket trading region.

  • Accepted formats: UUIDv4 (preferred) or any 8–256 printable-ASCII token.

  • Retrying the same key replays the original trade result (200 with idempotencyReused: true) instead of re-executing. The replay window is indefinite — keys never expire. Generate one fresh key for each new trade intent. Reuse that same key for every retry or reconciliation attempt for that intent, including after an uncertain timeout or a TRADE_IN_FLIGHT response; never reuse the key for a different trade intent.

  • Two concurrent requests with the same key return 409 TRADE_IN_FLIGHT for the loser:

    json
    {
      "error": "trade_in_flight",
      "code": "TRADE_IN_FLIGHT",
      "idempotencyKey": "agent-trade-2026-04-20-001",
      "retryAfter": 5
    }

Lifecycle contradictions and order-book indicators

Agent API and MCP clients must treat Gamma lifecycle fields as conservative write gates. When pt_mock_price_get or a composed market-intel/copy-desk workflow reports PAST_END_DATE_BUT_MARKET_APPEARS_LIVE, that is contradiction evidence only; it is not permission to place, mirror, or override by default. Live CLOB/order-book indicators, bid/ask/spread rows, recent trades, or enableOrderBook signals do not override MARKET_PAST_END_DATE, MARKET_CLOSED, auth, tier, anti-IDOR, preflight/idempotency, wallet-readiness, region, or real-money execution safeguards.

Resolved markets are separately readable for settlement. When Gamma has one unique terminal 0/1 outcome, pt_mock_price_get adds an optional resolution block with winning_outcome, winning_token_id, ordered outcome/token/payout rows, and resolved_at. When the live CLOB book is unavailable but its market metadata marks one winning token, pt_clob_price_get returns status:"resolved" with that winner instead of a generic unavailable result. This is settlement evidence only: priceable and all entry/write gates remain unchanged, and open or ambiguous markets expose no winner.

Marking an existing position uses the same stale-date predicate as copy execution: explicit closed: false and acceptingOrders: true, with no archived, inactive or resolved state, means the scheduled date is stale. Coherent two-sided Gamma prices can value those positions even months after end_date; there is no daily-market or 36-hour restriction. Missing or negative lifecycle flags do not qualify. lifecycle.end_date_stale records this evidence and analytics position marks retain end_date_stale: true. Quote freshness is separate (source_stale); an old or absent Gamma update timestamp does not establish closure. Explicitly closed markets retain MARKET_CLOSED. lifecycle_reason still reports MARKET_PAST_END_DATE for manual entry guards; priceability does not authorize a new trade.

A future manual Agent API/MCP write exception must prove the Gamma lifecycle field is stale, require explicit user/operator approval for the exact action, write an audit log, and must not broaden default Agent API/MCP write privileges.

Copy execution (paper and real) does not infer closure from Gamma's scheduled end date. For a past-date market, explicit closed: false and acceptingOrders: true, with no resolved/archived/inactive state, permits the ordinary copy risk path. Lifecycle evidence records end_date_stale: true; closed or non-accepting markets still emit MIRROR_SKIPPED_MARKET_PAST_END. Missing flags remain lifecycle-unknown. Existing priceability, CLOB order, authorization and wallet risk checks still apply.

Activity metadata includes bounded marketLifecycle evidence: reason, source, checkedAt, endDate, end_date_stale, active, closed, archived, acceptingOrders, and umaResolutionStatus. Digest lifecycle summaries preserve the checked time and stale-date marker and do not infer a past-end verdict from the schedule when that stored observation confirms an open market. Cursor/byte-compacted rows retain marketLifecycle. This is historical decision evidence, not a current quote or permission to place a new trade; legacy rows and explicit priceability/closure warnings keep their existing conservative interpretation.

Bot challenge (403)

Session traffic that BotID flags as automated receives:

json
{
  "error": "bot_challenge_failed",
  "reason": "automated_traffic_detected",
  "suggestedAction": "authenticate_with_api_key",
  "docsUrl": "https://polytrackers.com/docs/api"
}

Valid Authorization: Bearer ptk_… requests bypass BotID entirely — see llms.txt. The browser lane of the sportsbook-gap write routes (POST /api/sports/gaps/paper-trade, POST /api/sports/gaps/monitors, PATCH and DELETE on /api/sports/gaps/monitors/{id}, and POST /api/sports/gaps/rule-test) is checked the same way as the other session write routes.


Quickstart (agent flow)

1) Sign in and obtain a session

PolyTrackers auth is passwordless. Create an account or sign in through the web app at /register or /login using Google OAuth or an emailed magic link (Terms of Service and Privacy Policy acceptance is captured during sign-up). This yields a Supabase session — a session cookie plus an access_token / refresh_token pair you can pass as a bearer token.

Exchange a refresh token for a fresh session pair when the access token nears expiry:

bash
curl -X POST "https://polytrackers.com/api/auth/refresh" \
  -H "Content-Type: application/json" \
  -d '{"refresh_token":"'"$REFRESH_TOKEN"'"}'

Response includes:

  • access_token
  • refresh_token
  • token_type
  • expires_in

2) Read account + tier

bash
curl "https://polytrackers.com/api/account" \
  -H "Authorization: Bearer $ACCESS_TOKEN"

Returns tier (effective tier, honoring active trial), trialEndsAt, apiKeysCount, walletsCount, onboarding + wallet-link status.

3) Discover markets

bash
curl "https://polytrackers.com/api/markets?query=btc&status=open&sort=volume&limit=25"

To decorate public market cards with coarse recent signal evidence, pass up to 100 comma-separated condition IDs. The response contains only 24-hour whale and anomaly booleans—no wallet, trade-size, price, or execution data:

bash
curl "https://polytrackers.com/api/market-signals?conditionIds=0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"

The grouped GET /api/events feed includes CTF and Protocol V2 events in one ranking, including sports and esports. Pass category=sports to narrow it to events tagged Sports. Continue with direct_scan.next_cursor even if the page is empty. Keep the same filters and pass the cursor unchanged. If a saved V1-only cursor returns gamma_cursor_contract_changed, restart without after_cursor.

For one market or event, the anonymous detail endpoints return more than the list rows do. GET /api/markets/{slug} includes the full resolution-rules description plus a heuristic resolutionRisk score; GET /api/events/{slug} returns the event's complete outcome ladder (every priced leg, not just the legs on a paginated list page); GET /api/events/featured returns the current featured multi-outcome event, or {"event": null} when none qualifies:

bash
curl "https://polytrackers.com/api/markets/some-market-slug"
curl "https://polytrackers.com/api/events/some-event-slug"
curl "https://polytrackers.com/api/events/featured"

Anonymous requests to /api/markets, /api/events, /api/home-snapshot, and /api/market-signals share one 60 requests/minute per IP discovery budget. Pace discovery loops across the group and honor Retry-After on 429. The {slug} detail endpoints are metered separately: each has its own 60 requests/minute per IP bucket, and both can return 503 with reason: "upstream_request_budget_deferred" when the shared upstream request budget defers the fetch — honor retryAfterMs before retrying.

4) Refresh anomaly results (Pro/Elite)

bash
curl -X POST "https://polytrackers.com/api/scan/trigger" \
  -H "Authorization: Bearer $ACCESS_TOKEN"

The endpoint keeps the existing authentication, tier gates, per-user limits (Pro 2/hour; Elite 10/hour), and profile bankroll/Kelly sizing behavior. Always inspect the returned source object:

  • source.mode: "on_demand_detection" is the default legacy behavior. The request ran the original detector, persisted its rows and returned freshly detected visible anomalies.
  • source.mode: "published_feed_snapshot" is the staged Anomaly 2.0 behavior. It reads at most 100 currently published, tier-eligible signals from the same strict population as the Anomalies page. It does not force the scheduled screening/publication pipeline, does not write those rows into legacy history, and returns scan_performed: false, tradesAnalyzed: 0, and timestamp_semantics: "snapshot_loaded_at".

Snapshot rows retain their actual detected_at and published_at. Missing source title, outcome, amount, price, transaction, or lifecycle facts remain null; a caller-specific bet recommendation is computed only when the source published a price. Treat latest_published_at as the newest source publication in the response, not as proof that this request detected a new trade.

5) Read anomalies

Session, or a Pro+ Agent API Key (signals:read):

bash
curl "https://polytrackers.com/api/anomalies?limit=50&severity=high" \
  -H "Authorization: Bearer $ACCESS_TOKEN"

The response is the current strict published Anomaly 2.0 population used by the Anomalies page. Every row carries version: "2.0", source.name: "anomaly2", stable candidate identity, and a canonical page_url. Resolved, exited, discarded, rejected, hidden and otherwise ineligible candidates are absent; source-null financial/lifecycle facts remain null. The canonical source is bounded to 100 rows in (published_at DESC, id ASC) order. Free returns at most 5 rows per request; Pro/Elite return at most 100. Continue with offset=0..99 and identical filters. Direct REST access with an Agent API Key preserves the signals:read scope check.

Bounds: list, detail, by-market, pt_anomalies_list, and pt_anomalies_get invoke the strict canonical feed loader once per uncached request and filter in memory; they make no per-row reads or paid AI/provider calls. A non-empty 100-candidate canonical load uses at most nine bounded Supabase reads (one candidate page, three at-most-100-row joins, and five feed-summary reads), or ten only when the existing additive-column compatibility retry is needed. pt_anomalies_list may make one additional bounded read for the already-generated Anomaly 2.0 editorial snapshot; it does not invoke a model. No route-specific maxDuration or new application timeout is introduced, so the existing platform request deadline remains authoritative. HTTP list and by-market results retain the existing 30-second private cache / 120-second SWR posture.

6) Read anomaly detector performance

Aggregate win-rate, average return, and P&L for historical legacy Anomaly 1.0 detections. Backed by the anomaly_performance_daily view. The response source is legacy_anomaly_logs and is explicitly not performance evidence for current Anomaly 2.0 rows.

bash
curl "https://polytrackers.com/api/anomalies/performance?since=2026-01-01T00:00:00Z&until=2026-04-01T00:00:00Z&group_by=month&anomaly_type=WHALE_TRADE" \
  -H "Authorization: Bearer $ACCESS_TOKEN"

Query parameters:

  • since, until — ISO-8601 datetimes. Defaults to the last 30 days; the window is capped at 365 days.
  • group_by — one of day (default), month, anomaly_type, severity, detector_version, category, all.
  • anomaly_type, severity — optional filters passed straight through to the view.
  • detector_version — optional legacy detector label (for example v2). When omitted, Anomaly 2.0 (v3) receipts are excluded from the blended population; passing v3 returns 400 because that cohort is not available on this public endpoint.
  • category — optional market category: sports, oil-energy, politics-elections, crypto, economics, or other.

Response body:

  • window — { since, until } echoing the resolved window (ISO-8601).
  • totals — aggregate { flagged, resolved, wins, losses, voids, winRate, avgReturnPct, totalPnlUsd, equalDollarPnlPer100 } across the window.
  • series — same shape as totals but keyed by cohort (the group_by bucket), sorted ascending.
  • coverage — resolved / flagged for the window (0–1).
  • coverageThreshold — the coverage at which the cohort is considered mature enough to surface headline numbers (currently 0.5).
  • minDecidedForHeadline — the absolute number of decided outcomes (wins + losses) that is, on its own, enough to surface headline numbers (currently 20).
  • headlineReliable — coverage >= coverageThreshold || (wins + losses) >= minDecidedForHeadline. Because markets resolve long after detection, a window can have low coverage while still holding a large, meaningful sample of decided outcomes; either condition makes the win rate reliable.

equalDollarPnlPer100 is a simulation: $100 flat-staked on every decided anomaly in the cohort, expressed as total dollars of P&L.

Accepts session auth (cookie/JWT) or a Pro+ Agent API Key with signals:read scope. Responses are cached privately with s-maxage=60, stale-while-revalidate=300.

7) Read unified trade history

bash
curl "https://polytrackers.com/api/trades?type=all&status=all&sort=newest&limit=25&offset=0" \
  -H "Authorization: Bearer $ACCESS_TOKEN"

Response body includes tier and historyDepthDays; the latter is the mock history window (7 for Free, 90 for Pro, null for Elite). Own real-trade receipts are full-depth at every tier. For real rows, status describes the position: a filled BUY remains open until resolution or exit accounting is recorded. rawStatus keeps the order lifecycle, and closedAt is only an actual resolution/settlement time—never a bookkeeping updated_at value. Real rows also carry failureReason and failureDetail explaining why a failed/cancelled attempt terminated; both are null on healthy rows. fillAmount, requestedShares, and price expose the durable execution facts; isDustFill is derived when filled shares are below the applicable market share minimum, executed notional is below $1, or the fill is under 10% of requested shares. Execution reuses live market/book metadata; bounded list and metric reads use the centralized conservative fallback and make no per-row provider calls. Dust remains real P&L but is excluded from win-rate and mock↔real parity grading. payoutReconciliationStatus carries the receipt-backed payout state, while modeledPayout is the deterministic binary/SPLIT estimate used during reconciliation and must not be presented as observed spendable cash.

A type=real&status=executed response also includes realWalletStats. That object is aggregated server-side over every matching executed real-trade row, independent of limit/offset, and reports realized P&L, all-time decided-BUY cost basis/ROI inputs, open positions, and resolved rows still awaiting P&L attribution. The trades array remains paginated.

conditionId narrows the feed to one exact Polymarket condition ID. Offset pagination is reliable only before offset 1000 because PostgREST caps each source window. A page that reaches that boundary returns its reachable prefix as an explicit terminal page with pagination.depthLimited: true, depthLimit: 1000, and depthLimitReason: "postgrest_max_rows"; narrow by type, status, wallet, or condition instead of continuing.

When the wallet-scope integrity tripwire drops a foreign raw row, the returned trade rows remain verified against the requested wallet but count metadata cannot be proven from the same suspect result set. The response therefore adds pagination.degraded: true, degradedReason: "wallet_scope_invariant_violated", degradedFields: ["total", "hasMore"], and droppedRows. Treat total and hasMore as untrusted for that incident response; normal-path pagination is unchanged.

Direct REST access with an Agent API Key requires signals:read plus current Pro or Elite access; a Free key gets 401. The 7-day Free history depth applies to session callers. Free-tier agents use MCP pt_trades_list (signals:read, Free) for the same feed.

8) Run a historical backtest

Free Agent API Keys can run the fixed demo configuration with signals:read; the returned trade list is capped at 5 rows. Pro and Elite keys can customize the configuration within their tier's window limits. costModel: "leader" (default) uses the request's flat slippageBps and feeBps. For a whale-copy admission run, use costModel: "copy": the server applies the daily copy-receipt slippage bucket for each entry and charges the measured entry-fee rate on every trade. The response labels the calibration source and timestamp; missing receipt evidence falls back to documented non-zero conservative costs.

bash
curl -X POST "https://polytrackers.com/api/backtest" \
  -H "Authorization: Bearer $AGENT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "source":{"kind":"anomalies","minSeverity":"HIGH"},
    "stake":{"mode":"flat","amountUsd":100},
    "startingBankrollUsd":1000,
    "windowDays":30,
    "costModel":"leader",
    "slippageBps":50,
    "feeBps":0
  }'

The copy-actionability gate recommends the same shape with a whale source, windowDays 90 or 180, and costModel: "copy". Its old leader-cost runs do not satisfy the gate. A canonical whale run returns outOfSampleValidation: the requested window is split into a pre-holdout selection slice and an independently replayed trailing 30-day holdout. Both slices must enter at least one trade, avoid bankroll bust, and have positive copy-cost capital-accounting ROI. The full requested-window result remains reporting evidence, but it cannot clear admission when either disjoint slice fails; leaderboard and recommendation actionability then expose OUT_OF_SAMPLE_VALIDATION_FAILED.

Every REST result includes strategy.stats_by_entry_price_bucket. It always contains the five copy-calibration entry-odds buckets (<0.10, 0.10-0.35, 0.35-0.65, 0.65-0.90, >=0.90), including explicit zero-trade rows. Each row reports trades, wins, losses, splits, entryCostUsd, totalPnlUsd, capital-weighted roiPct, and arithmetic avgReturnPct. The aggregation is computed from the existing settled trade log and adds no query or stored data.

9) Readiness-gated real trade execution

Session auth requires manual trading readiness: trading wallet/signing setup, wallet funding, wallet risk config, circuit-breaker state, idempotency, reservations, region certification, and audit logging.

Session auth:

bash
curl -X POST "https://polytrackers.com/api/trade/execute" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "conditionId":"0xconditionid",
    "side":"YES",
    "amount":20,
    "limitPrice":0.5,
    "idempotencyKey":"agent-trade-2026-04-16-001",
    "regionCertification":true
  }'

Agent API Key with trade:execute scope:

bash
curl -X POST "https://polytrackers.com/api/trade/execute" \
  -H "Authorization: Bearer $AGENT_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 7c2b7f9e-47b8-4ad2-95b5-8f8d5f2f6a3c" \
  -d '{"conditionId":"0x...","side":"YES","amount":20,"regionCertification":true}'

CDP delegated-wallet browser users must submit explicit limit orders until the SDK adapter supports cap-priced immediate-or-cancel market orders. Non-CDP market buys retain the server-side slippage-cap path.

10) Cancel an own resting real order

Session callers can cancel their own resting order even when their tier cannot list all CLOB orders:

bash
curl -X DELETE "https://polytrackers.com/api/trade/orders/$ORDER_ID" \
  -H "Authorization: Bearer $ACCESS_TOKEN"

The two programmatic paths have different gates: direct REST bearer calls to GET /api/trade/history, GET /api/trade/ledger, GET /api/trade/money-summary, and GET /api/trade/orders* require agent:full. MCP pt_trade_history_get requires signals:read at every tier, while pt_trade_orders_list and pt_trade_orders_get require signals:read plus the Elite tier.


Sportsbook gap scanner

For NBA, NFL and NHL full-game winner markets, the scanner compares the sportsbook consensus probability with the all-in Polymarket price for a given purchase size, after fees. The difference, less a tie allowance for a game that can end tied, is the sportsbook gap, in percentage points:

text
net_gap_pp = 100 × (consensus_probability − all_in_price_per_net_share) − tie.allowance_pp
all_in_price_per_net_share = total_spent_usd / net_shares

The last term applies only when the result's tie is set. The server takes the allowance off the consensus first, so a gap recomputed from the published fields equals net_gap_pp to floating-point precision. The consensus is the median margin-free probability across at least three distinct fresh sportsbooks; exchanges never count. The size is the total budget, estimated fees included; the all-in price walks the ask depth and counts the Polymarket fee and the PolyTrackers fee once each. Filtering and ranking use the unrounded gap. A 58% consensus and $100 for 180 net shares is 55.56¢ and 2.44 points, which fails a 3-point filter even when the best ask alone would pass.

NFL regular-season games can end tied: a two-way sportsbook moneyline returns the stake, and Polymarket resolves the game 50-50. They compare with a tie allowance, tie.allowance_pp = 100 × tie.probability_ceiling × max(0, consensus_probability − 0.5), so only a favorite's gap is lowered (0.25 points for a 75% favorite at the NFL's 0.01 ceiling). While a tie is likely (in overtime, with a level or unreadable fourth-quarter score, or in a live period the scanner does not recognize) the game is excluded as suppressed_tie_risk. An NFL game outside a configured season window, such as a preseason game, still reports settlement_mismatch. Method, freshness limits and coverage: feature doc. Tie allowance: decision 0038.

NBA and NFL games are compared before the game and in play. NHL games are compared before the game only. An NHL game in play has no comparison: every live read excludes it as in_play_not_compared until it ends, also with state=live, and never as stale_quote. Every NHL game has a winner (overtime, then a shootout), and both sides settle on it, so tie is null. Before the game the NHL sportsbook lines are read every hour, and every 5 minutes in the last 30 minutes before the start; for NBA and NFL the 5-minute readings start 2 hours before. The reason is the odds vendor's credit limit: decision 0042.

A game that is paused now (suspended, delayed, past its start time and not live yet, or postponed) is excluded as suppressed_game_state on every live read, whatever its last capture says. This applies to every league.

The scan reads shared observations that a scheduled job collects. No request triggers a vendor poll. Every plan gets the same data, freshness and calculation; the plan sets how many results return. No individual sportsbook's price is ever returned. Auth and plans per route are in the Agent API Key section.

Scan: GET /api/sports/gaps

Query parameterUnit and rangeDefault
leaguesComma-separated league keys: nba, nfl, nhl (all means every enabled league)All enabled
stateall, pregame or live (an NHL game in play has no result: see above)all
window_hoursWhole hours, 1 to 168: games starting within this window; games in play always count24
min_gap_ppPercentage points, 0 to 503
size_usdUS dollars, 5 to 25,000: the total purchase budget with estimated fees included (rounded to cents)100
max_quote_age_secondsWhole seconds, 30 to 4,800; it can only tighten the freshness limit for the game stateThe state limit
limitResults per page, 1 to 100 (Free always returns at most 3)25
cursorOpaque pagination.next_cursor from the previous page—

The Markets page's short names (league, window, minGap, size, maxAge) are accepted as aliases, so a shared /markets?view=sportsbook-gap link and an API call describe the same search.

The 200 body is { filters, generated_at, status, summary, coverage, results, pagination, plan, methodology_url }:

  • filters echoes the normalized search with unit-named keys. Pass it to POST /api/sports/gaps/monitors to save the exact search.
  • status separates a real zero from missing data: ok, no_scheduled_games, incomplete_coverage or data_unavailable.
  • coverage counts games_scheduled, games_checked, games_qualifying, games_below_threshold, games_excluded and games_not_comparable (both by reason), outcomes_qualifying, the newest data times and per-league vendor status. summary says it in one sentence, for example "11 games checked, 2 excluded for insufficient depth, 0 qualify." A game hidden while a tie is likely counts under games_excluded.suppressed_tie_risk ("13 games checked, 1 excluded for a possible tie, 2 qualify."). An NHL game in play counts under games_excluded.in_play_not_compared ("3 games checked, 2 excluded for a game in play that is compared before its start only, 1 qualifies.").
  • below_threshold is website only: a browser session also gets one row for each checked game under the minimum gap (its better outcome, closest first, cut to the plan). An Agent API Key response does not have the field. coverage.games_below_threshold gives the count on every surface.
  • Each result has a stable id (<game id>:<outcome index>), observation_id, event, market (with a first-party url), outcome (label, token_id, and paper_outcome for the paper tools), size_usd, net_gap_pp, tie, sportsbook (consensus_probability, book_count, and books as source names with timestamps only), polymarket (all_in_price_per_net_share, net_shares, total_spent_usd, fees, depth and fill details) and quote_age_seconds. A signed-in browser session also gets the website-only context exchange quote; Agent API Key responses never include it.
  • tie is always present. It is null when the game cannot end tied. For an NFL regular-season game it is, for a 75% favorite, { "rule": "polymarket_split_sportsbook_refund", "probability_ceiling": 0.01, "allowance_pp": 0.25 }: allowance_pp is the points already taken off this outcome's net_gap_pp (0 for an underdog). sportsbook.consensus_probability stays the raw median, with no allowance folded in.
  • pagination is { limit, returned, total_qualifying, has_more, next_cursor }. The cursor is an offset into the list ranked at request time; shared data can refresh between pages, so keep the same filters and treat pages as a fresh read, not a snapshot.
  • plan is { tier, max_results_per_search, truncated }. On Free, max_results_per_search is 3 and truncated is true when more qualified.

Example (Agent API Key; values are illustrative and trimmed to one result):

bash
curl "https://polytrackers.com/api/sports/gaps?leagues=nba&min_gap_pp=3&size_usd=100&window_hours=12" \
  -H "Authorization: Bearer ptk_..."
json
{
  "filters": {
    "leagues": ["nba"],
    "state": "all",
    "window_hours": 12,
    "min_gap_pp": 3,
    "size_usd": 100,
    "max_quote_age_seconds": null
  },
  "status": "ok",
  "summary": "6 games checked, 1 excluded for insufficient depth, 1 qualifies.",
  "results": [
    {
      "id": "0b9f6c7e-1c2d-4e5f-8a9b-0c1d2e3f4a5b:1",
      "event": {
        "title": "Phoenix Suns vs. Los Angeles Lakers",
        "start_time": "2026-11-16T03:30:00.000Z",
        "status": "scheduled"
      },
      "outcome": { "label": "Lakers", "side": "home", "paper_outcome": "NO" },
      "size_usd": 100,
      "net_gap_pp": 3.4823818,
      "tie": null,
      "sportsbook": { "consensus_probability": 0.612, "book_count": 7 },
      "polymarket": {
        "all_in_price_per_net_share": 0.5771762,
        "net_shares": 173.24,
        "total_spent_usd": 99.99,
        "fees": {
          "total_usd": 0.39,
          "polytrackers_usd": 0.25,
          "polymarket_usd": 0.14
        }
      },
      "quote_age_seconds": 212
    }
  ],
  "pagination": {
    "limit": 25,
    "returned": 1,
    "total_qualifying": 1,
    "has_more": false,
    "next_cursor": null
  },
  "plan": { "tier": "pro", "max_results_per_search": null, "truncated": false }
}

The same search over MCP:

json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "pt_sports_gaps_list",
    "arguments": {
      "leagues": ["nba"],
      "min_gap_pp": 3,
      "size_usd": 100,
      "window_hours": 12
    }
  }
}

Quotas and errors

  • With an Agent API Key, each scanner route spends the same per-tool and daily buckets as its MCP tool (pt_sports_gaps_list, pt_sports_gap_paper_trade, pt_sports_gap_rule_test, pt_sports_gap_monitors_list, pt_sports_gap_monitor_create, pt_sports_gap_monitor_update, pt_sports_gap_monitor_delete), so REST and MCP share one quota. Free: 10 requests per minute per tool and 200 per day across all tools. A browser session is not charged. When a bucket is spent the route answers 429 { "error", "code": "RATE_LIMITED", "retry_after_seconds", "scope" } (scope is minute or day) with a Retry-After header.
  • Key-authenticated scanner calls also have a coarse edge limit of 300 requests per minute per IP address, shared by every key behind that address. It answers with the same 429 body (scope: "minute") and the RateLimit-* headers. A browser session keeps the general API limits.
  • 400 INPUT_INVALID: a filter is out of range or the JSON body is invalid; errors[] names each field with its unit. 413: a body over 16 KB.
  • 401 AUTH_REQUIRED, 403 AUTH_SCOPE_MISSING (with requiredScope), 403 TIER_UPGRADE_REQUIRED (with requiredTier, currentTier and upgradeUrl).
  • 503 UNAVAILABLE: scanner storage could not be read. A database without the scanner tables answers the scan with 200 and status: "data_unavailable".

Monitors: /api/sports/gaps/monitors

A monitor is a saved search that alerts its owner on each new threshold crossing, even when no agent is running. Pro runs up to 5 active monitors and Elite up to 50, separate from the webhook limit.

  • GET /api/sports/gaps/monitors (signals:read) returns { monitors, count, limits, alerts }. limits is { tier, max_active_monitors, active_monitors, history_days }. alerts is { ready, channels, missing }: the owner's alert channels as they are now (null when unknown); while ready is false a monitor that uses alert channels and names no webhook cannot deliver. Each monitor has id, name, status (active or paused), effective, ineffective_reason (paused, plan_limit or plan_required), filters, delivery (alert_channels, webhook_ids), created_via, timestamps, last_alerted_at and url (the same search on the Markets page).
  • POST /api/sports/gaps/monitors (monitors:write) takes { filters, name?, delivery? }. filters uses the scan's unit-named keys; pass a scan's filters object to save the exact search. delivery is { alert_channels?: boolean (default true), webhook_ids?: uuid[] (at most 10, your own active webhooks) }. It answers 201 { monitor, limits, delivery }. The response delivery is { ready, channels, missing, setup_url }: when ready is false, missing is no_alert_channel or alerts_disabled and setup_url is a first-party link where the owner finishes channel setup in a browser.
  • PATCH /api/sports/gaps/monitors/{id} (monitors:write) takes any of name, filters, delivery and status (active or paused). New filters or a resume start a fresh watch: outcomes that already qualify do not alert until they clear and cross again.
  • DELETE /api/sports/gaps/monitors/{id} (monitors:write) answers { deleted: true, id }.
  • Errors: 403 TIER_UPGRADE_REQUIRED (no monitors on Free), 403 MONITOR_LIMIT_REACHED (with limits; pause or delete one first), 404 NOT_FOUND (no such monitor on this account), 400 INPUT_INVALID.

After a downgrade nothing is deleted: the oldest active monitors inside the new cap stay effective and the rest report ineffective_reason. Ownership and the plan are checked again at every create, resume, edit, read and delivery.

Monitor alerts go through the owner's existing alert channels (email, Telegram, Discord) and any webhooks named on the monitor. A webhook delivery is signed like other outbound webhooks (X-Webhook-Signature) and carries:

json
{
  "event": "sports_gap.threshold_crossed",
  "timestamp": "2026-11-16T02:58:00.000Z",
  "delivery_id": "6f1e2d3c-4b5a-4968-8776-655443322110",
  "monitor": {
    "id": "8a7b6c5d-4e3f-4a1b-9c8d-7e6f5a4b3c2d",
    "name": "NBA, 3+ pts at $100",
    "filters": {
      "leagues": ["nba"],
      "state": "all",
      "window_hours": 24,
      "min_gap_pp": 3,
      "size_usd": 100,
      "max_quote_age_seconds": null
    }
  },
  "result": {
    "id": "0b9f6c7e-1c2d-4e5f-8a9b-0c1d2e3f4a5b:1",
    "net_gap_pp": 3.4823818
  }
}

result has the same shape as a scan result (shown trimmed), tie included, without the exchange context. When the result's tie.allowance_pp is above 0, the email, Telegram and Discord text add one line stating the tie allowance the gap includes; the subject does not change. Delivery is at least once: drop a repeated delivery_id. A failed delivery is retried after 60 seconds, 5 minutes and 30 minutes (4 attempts in all). A retried job never creates a second delivery for the same crossing.

Paper trade: POST /api/sports/gaps/paper-trade

Requotes one scan result against the live Polymarket book and fee parameters, then places a paper trade through the existing paper-trade flow. Body: { result_id, size_usd, wallet_id?, max_all_in_price?, dry_run? }. size_usd is the total budget with fees (5 to 25,000); max_all_in_price (0 to 1) refuses the trade, dry run included, when the requoted all-in price is above it; wallet_id defaults to the caller's first paper wallet. Committing needs mock:trade; dry_run: true needs only signals:read.

The 200 body is { committed, result_id, league, event, market, outcome, observed_comparison, simulated_fill, net_gap_pp_at_requote, wallet_id?, trade? }. observed_comparison (what the scan showed) and simulated_fill (what the paper trade got) are separate blocks, and the trade record stores both. observed_comparison.tie is the scan's tie object or null. observed_comparison.status is ok or the reason the scan gives, for example suppressed_tie_risk (a tie is likely), suppressed_game_state (the game is paused now), in_play_not_compared (the game is in play and its league is compared before the game only) or awaiting_first_observation (the game needs a tie allowance and its reading has none yet; then net_gap_pp, all_in_price_per_net_share, tie and net_gap_pp_at_requote are all null). net_gap_pp_at_requote is 100 × (consensus_probability − requoted all-in price) − tie.allowance_pp. It is null whenever the sportsbook side is not current: the game is hidden, the game is in play and not compared, the quotes are stale, or sportsbook lines are missing or too few. A hidden comparison does not block the paper trade. Errors: 403 AUTH_SCOPE_MISSING (committing without mock:trade; send dry_run: true to requote only), 404 RESULT_NOT_FOUND / WALLET_NOT_FOUND, 409 MARKET_NOT_TRADABLE, 409 QUOTE_UNAVAILABLE (the book cannot fill the size; reason says why), 409 PRICE_MOVED (with the new simulated_fill), 503 QUOTE_UNAVAILABLE (the book could not be read), 400 or 502 TRADE_REJECTED (the paper-trade core refused the trade). A paper write aimed at the real-money wallet fails with 400 INPUT_INVALID, as on the other paper tools.

Rule test: POST /api/sports/gaps/rule-test

Pro and Elite (signals:read). Replays a saved monitor's criteria (monitor_id) or a filters object over collected history, days 1 to 365 (capped by the plan: Pro 90, Elite 365). Each observation is judged as of its own capture. The answer carries the real window in coverage (collection_started_at, from, to, observations, games, truncated, history_shorter_than_requested), crossings_total, games_with_crossing, unsupported (observations that could not support the size or fee calculation, never guessed; unsupported.other counts every other reason by name, for example suppressed_tie_risk for a capture taken while a tie was likely; in_play_not_compared is not among them, because a league that is compared before the game only stores no reading in play), settled paper outcomes (won, lost, split, unresolved; a tied game settles as split, 50 cents a share) and up to 50 crossings, each with the result's tie (or null). Collection started when the scanner launched, so early answers cover little history. One account may start 6 rule tests per minute across REST and MCP; over that it gets 429 RATE_LIMITED with Retry-After. Errors: 403 TIER_UPGRADE_REQUIRED (Free), 404 NOT_FOUND (no such monitor), 400 INPUT_INVALID.


Agent API Key lifecycle

Generate Agent API Key (JWT bearer only)

Callers on every plan can generate Agent API Keys. Every key holds signals:read; every other scope is opt-in and is granted only when the request names it. Free callers may request the narrow mock:trade scope (committed paper trades over MCP) and the narrow trade:execute scope (one-off real trades over MCP); MCP usage is capped at 200 requests/day. Pro callers may request those and the narrow agent:scan scope; Elite callers may additionally request agent:full. The app's own key screens request mock:trade for a new Free or Pro key by default and trade:execute only when the owner switches it on. Accounts keep 1 active Agent API Key; rotate by revoking the old key, then generating a replacement and updating clients and agents (409 API_KEY_LIMIT_REACHED when the cap is reached).

bash
curl -X POST "https://polytrackers.com/api/keys/generate" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"nickname":"Agent API Key","expiresInDays":90,"scopes":["signals:read"]}'
  • expiresInDays: 1–365, defaults to 90.
  • scopes: defaults to ["signals:read"], so a request without scopes returns a read-only key. Add mock:trade to let an agent commit paper trades. Add trade:execute only when intentionally creating a real-trading key. Free-tier requests for agent:scan and agent:full are stripped; Pro-tier requests for agent:full are stripped. Paid-tier validation still applies to direct REST bearer routes. A key keeps the scopes it was made with: to change them, revoke the key and generate a new one.
  • The raw api_key is returned once in the response — store it securely.

List keys

bash
curl "https://polytrackers.com/api/keys" \
  -H "Authorization: Bearer $ACCESS_TOKEN"

Use Agent API Key for public whale feed (Elite)

bash
curl "https://polytrackers.com/api/public/whale-signals?limit=25" \
  -H "Authorization: Bearer $AGENT_API_KEY"

Outbound webhooks (Pro/Elite)

Create, list, delete, and test delivery endpoints live under /api/webhooks*:

  • GET /api/webhooks — list your registrations.
  • POST /api/webhooks — register a new URL with optional filters (minScore, severity[], anomalyTypes[], marketCategories[]) and a secret. Capped at 5 (Pro) / 50 (Elite); over-limit returns WEBHOOK_LIMIT_REACHED.
  • DELETE /api/webhooks/{id} — soft-delete a registration. The row is retained for audit (with deleted_at stamped and status=paused), it will stop receiving future deliveries, and historical delivery_log entries remain queryable.
  • GET /api/webhooks/{id}/deliveries — recent delivery logs.
  • POST /api/webhooks/{id}/test — fire a test payload.

Webhook delivery contract

Matching anomaly alerts are delivered as anomaly.detected JSON:

json
{
  "event": "anomaly.detected",
  "timestamp": "2026-07-20T14:30:00.000Z",
  "anomaly": {
    "id": "anomaly-id",
    "score": 82,
    "market_title": "Will BTC reach $150k in 2026?",
    "market_slug": "will-btc-reach-150k-in-2026",
    "market_url": "https://polymarket.com/event/will-btc-reach-150k-in-2026",
    "current_price": 0.64,
    "anomaly_type": "WHALE_ANOMALY",
    "severity": "HIGH",
    "side": "BUY",
    "outcome": "YES",
    "bet_recommendation": {
      "recommendedBet": 100
    },
    "whale_flag": true
  }
}
  • Delivery targets must be public HTTPS URLs. Redirects are treated as failures and are not followed.
  • Any 2xx response completes delivery. A failed initial attempt is retried after 30 seconds, then 5 minutes, then 30 minutes: 4 total delivery attempts.
  • Each registration is capped at 100 delivery attempts per rolling hour, including retries.
  • When the registration has a secret, verify X-Webhook-Signature against sha256=<HMAC_SHA256(raw_body, secret)> before parsing the JSON.

X-Webhook-Signature signs outbound user deliveries. It is distinct from the inbound x-alchemy-signature required by /api/whale/webhook.

Anomaly 2.0 webhook contract (version 2.0)

Legacy routing remains the default. After a reviewed coordinated Anomaly 2.0 cutover, the event name remains anomaly.detected, but version: "2.0" explicitly distinguishes these source-labelled signals from the unversioned legacy shape above. Receivers must branch on version, not interpret a candidate ID as an old anomaly UUID.

json
{
  "event": "anomaly.detected",
  "version": "2.0",
  "id": "anomaly2:candidate-id",
  "timestamp": "2026-11-23T14:00:00.000Z",
  "source": {
    "name": "anomaly2",
    "id": "candidate-id",
    "created_at": "2026-11-23T14:00:00.000Z"
  },
  "anomaly": {
    "id": "candidate-id",
    "signal_type": "published_insider_signal",
    "score": 84,
    "severity": "HIGH",
    "reasons": ["Published signal rationale"],
    "page_url": "https://polytrackers.com/polymarket-anomalies?market_slug=market-slug&condition_id=condition-id&utm_source=webhook&utm_medium=api&utm_campaign=anomaly_alert",
    "market": {
      "condition_id": "condition-id",
      "title": "Market title",
      "slug": "market-slug",
      "event_slug": "event-slug",
      "category": "politics-elections",
      "polymarket_url": "https://polymarket.com/event/event-slug"
    },
    "trade": {
      "wallet": "0x...",
      "side": "BUY",
      "outcome": null,
      "size_usd": null,
      "price": null,
      "transaction_hash": null,
      "occurred_at": null
    }
  }
}
  • The event ID and original admitted JSON are stable across retries. Headers X-Webhook-Event-Id and X-Webhook-Delivery-Id identify the source event and durable recipient delivery respectively. Deduplicate by the source event ID.
  • HMAC still covers the exact raw JSON bytes using the current registration secret; altered JSON must fail signature verification. Secret rotation, public-HTTPS/DNS validation, redirect rejection, tier requirements, filters, health state and delivery history remain supported.
  • score, severity and reasons are the page adapter's admission snapshot. source.created_at/timestamp use the canonical signal's createdAt eligibility boundary, not the HTTP attempt time or a claim about dossier completion. Missing source trade facts remain null, even where the UI displays a fallback. No legacy current_price, bet_recommendation, confidence, P&L or fake anomaly_logs row is synthesized.
  • page_url opens the canonical market/condition filter, subject to current login, tier and lifecycle. A later withdrawal or resolution may leave that page without an actionable signal; the stored payload is a historical snapshot.
  • Delivery history adds nullable source, eventId, sourceId and payloadVersion. V2 has anomalyId: null; legacy history preserves its original anomalyId. Terminal ineligibility is represented by failed, no next retry, and an explicit terminal_ineligible: reason, not a fake send.
  • Four attempted-delivery leases maximum; provider attempts are persisted before I/O. A lost response can still cause a duplicate HTTP request. Current source/lifecycle/recipient state is checked again before each retry wave.

See the rollout and capacity gate before enabling this version. This release does not change production routing.


Mock-wallet unrealized P&L freshness

GET /api/wallets exposes mock-wallet unrealizedPnl as a persisted point-in-time snapshot, not a continuously priced equity value. unrealizedPnlMarkedAt records the pricing-pass timestamp; null means no trustworthy mark timestamp exists. The companion unrealizedPnlIsSnapshot, unrealizedPnlCaveat, and unrealizedPnlAuthority fields keep this contract machine-readable.

For current equity decisions, use pt_mock_analytics_get.wallet_mark_to_market.preferred_unrealized_pnl and inspect live_pricing_status. A complete analytics pricing pass refreshes the persisted snapshot after the read returns. A nonzero partial pass can initialize an unmarked wallet or replace strictly lower known persisted coverage under atomic timestamp/quality guards. Complete and unknown-quality marks remain protected. Partial pricing covering at least 90% of open positions or improving known stored coverage becomes the preferred live value, with unpriced legs held at cost basis; other reads fall back to the timestamped snapshot. Analytics returns coverage_ratio, persisted_coverage_ratio, and price_lookup_deferred_conditions together in wallet_mark_to_market. Large books can briefly wait for normal-priority Gamma tokens without raising shared rate limits or caching wallet state. Reconcile still persists only complete marks and records coverage 1; incomplete reconcile preserves stored coverage.

The reserved real-money-copy row is never accepted by mock analytics and never receives its write-behind. In normalized /api/wallets and GET|POST /api/trade/real-wallet responses, its mark timestamp is null and its provenance instead points to real_trades for position P&L and /api/trade/wallet-funds for spendable funds.

GET /api/wallets derives current-day realized P&L from get_wallet_daily_copy_stats. dailyPnl and the backward-compatible daily_pnl alias always carry the same UTC-day value. If the projection fails, both are null and dailyPnlDegraded:true / dailyPnlStatus:"degraded" make the partial response explicit; the route never substitutes the denormalized mock-wallet counter. Reserved real-wallet legacy performance aliases are projected from real_trades. A reserved real wallet whose risk configuration is missing or does not select the real lane makes the daily projection fail closed instead of reading mock_trades.

GET /api/trade/wallet-funds also returns equityIdentity for the authenticated real wallet. Its complete identity is:

supportedStablecoinValue + openMarkedValue + pendingRedemptionValue - netDeposits = lifetimePnl

supportedStablecoinValue sums the selected funding wallet's pUSD, native USDC and USDC.e at the ledger's nominal $1-per-token basis. spendablePusd remains pUSD only; unconvertedStablecoinValue is USDC plus USDC.e, which require conversion before trading. The sum already includes spendable pUSD: do not add it again. Token conversions are not new capital or profit. These three token reads bypass caches and share one Polygon block. Invalid, missing, cached, wrong-wallet or older-than-60-second token evidence returns a degraded identity with null stablecoin totals and lifetime P&L. A failed chain snapshot returns 502, not a verified zero. This endpoint uses nominal parity, not market depeg quotes. Account ROI is lifetime P&L / positive net deposits, distinct from cumulative trade-efficiency ROI.

Capital still comes from the existing user-wide ledger and holdings from the selected funding address; historical multi-wallet capital allocation remains unresolved. The token snapshot does not synchronize the venue positions or ledger, so in-flight transfers/redemption indexing can temporarily differ.

pendingRedemptionValue comes from the bounded Polymarket Data API positions read and includes only positions marked redeemable. The separate modeledPendingRedemptionValue is the unresolved-payout-row projection for operations diagnostics only: it never enters lifetimePnl, and its absence alone does not degrade the identity. netDeposits is the signed sum of deposit and withdrawal ledger entries, while openMarkedValue excludes redeemable venue positions so pending winnings are not double-counted. If the positions read or another required component is unavailable, status: "degraded" and lifetimePnl: null fail closed; callers must not reconstruct or display a partial lifetime P&L as complete.


Deletion & audit retention

PolyTrackers favors soft deletion for user-owned resources so that reporting, billing, copy-trading analytics, and security audits remain reliable. The behavior per-resource is:

ResourceEndpoint(s)Behavior
Agent API KeysDELETE /api/keys?id=…Soft-revoke: is_active=false, revoked_at=now(). Authentication is rejected immediately; row is retained for audit.
Mock walletsDELETE /api/wallets, DELETE /api/mock/wallet/{id}Soft-delete: is_active=false, deleted_at=now(). Whale assignments are detached (active=false, removed_at=now()). mock_trades, whale_activity, and whale_decision_traces are preserved. Wallet names can be reused.
Outbound webhook registrationsDELETE /api/webhooks/{id}Soft-delete: deleted_at=now(), status=paused. No future deliveries fire; historical delivery_log remains queryable via GET /api/webhooks/{id}/deliveries.
Alert preferencesDELETE /api/alerts/preferencesHard reset of the preferences row.
Roster (whale) assignmentsDELETE /api/roster/{address}Detach: row retained, active=false, removed_at=now().
Trade ordersDELETE /api/trade/orders/{id}Cancels the live order at the CLOB; hard-removes the queued row.

Mock trades are not user-deletable by design once placed — open, closed, and resolved rows feed the leaderboard, copy-trading scoring, and tier-history analytics. To exit an open mock position, close it through POST /api/mock/resolve; this records the terminal state and preserves the trade row for history.


Whale service + inbound webhooks

Existing whale-service endpoints remain supported and documented in OpenAPI:

  • Wallet/roster management (/api/wallets, /api/roster*)
  • Service status/config/control (/api/whale/*)
  • Webhook ingest/events/replay (/api/whale/webhook*)

For replay automation, use dryRun: true first, then replay live once validated.


Discovery endpoints

Anonymous, CDN-cached, and safe to fetch before you have a key. Every one of them describes a surface documented in this file:

PathMedia typeWhat it is
/openapi.jsonapplication/jsonThe OpenAPI 3.1 contract for the REST API. /api/openapi.json is a 301 alias.
/.well-known/api-catalogapplication/linkset+jsonRFC 9727 API catalog: a linkset naming the REST, MCP, and documentation MCP entry points, each with its service-desc (machine-readable description), service-doc (human documentation), and service-meta (metadata) links. The one URL to fetch when you want the developer resources and nothing else.
/.well-known/mcpapplication/jsonMCP handshake manifest (alias /.well-known/mcp.json).
/.well-known/mcp/server-card.jsonapplication/mcp-server-card+jsonMCP server card: the full MCP tool and resource surface, each entry with its required scope, required tier, and read-only or destructive hints.
/.well-known/mcp/docs-server-card.jsonapplication/mcp-server-card+jsonThe pre-connection card for the documentation MCP server at /api/mcp/docs, the read-only server that takes no API key.
/.well-known/ai-catalog.jsonapplication/ai-catalog+jsonAgentic Resource Discovery capability manifest, written for registries that index by capability.
/.well-known/agent-skills/index.jsonapplication/jsonAgent Skills discovery index: it names /skill.md and publishes its sha256 digest, so you can verify the bytes you fetched.
/llms.txttext/plainAgent instructions: when to use PolyTrackers, automation-safe lanes, error shapes, and the crawl policy.
/skill.mdtext/markdownThe official agent skill — tool catalog, scopes, and workflows.
/docs/llms.txttext/plainThe documentation hub as an llms.txt index: reference pages, machine-readable artifacts, and markdown variants.
/docs/api/llms.txttext/plainThe REST and MCP reference as an llms.txt index: contracts first, then the human docs that explain them.

MCP server

PolyTrackers exposes a stateless MCP endpoint for agent clients:

  • GET /api/mcp — unauthenticated health/capability probe.
  • GET /.well-known/mcp (alias GET /.well-known/mcp.json) — unauthenticated manifest describing this server: transport URL, advertised protocol versions, capabilities, auth scheme, and the stdio bridge package. Generated from the same constants the server itself uses, so it cannot drift.
  • POST /api/mcp — JSON-RPC 2.0 over Streamable HTTP. Send Authorization: Bearer <agent-api-key> — use the same ptk_... key as your REST/API examples.
  • GET /api/mcp/events — optional authenticated SSE notifications for anomalies, whale_signals, copy_signals, and scan_progress, with : keepalive every 15s. Send Authorization: Bearer ptk_.... The whale_signals and copy_signals topics are Elite-only; requests for them from Free or Pro keys are silently dropped while the 200 stream remains live for permitted topics. Optional severity (comma-separated, case-insensitive) and market_slug (exact match) query parameters narrow delivery to events whose payload carries a matching field; events without that field are dropped.
  • GET / POST /api/mcp/docs — the anonymous documentation MCP server: a separate, read-only Streamable HTTP server that takes no API key and reads no Authorization header. GET is a CDN-cacheable health probe (it reports authentication: "none"); POST is stateless JSON-RPC serving three read-only tools — docs_list, docs_search, docs_get — plus the same documents as MCP resources, over the published .md page twins and section llms.txt indexes and the bundled public /skill.md guide (docs_get document /skill.md, resource https://polytrackers.com/skill.md). It serves no live market, whale, or account data. Both operations are in the OpenAPI contract at /openapi.json; the pre-connection card is /.well-known/mcp/docs-server-card.json.

SSE connections last at most 800 seconds (~13 minutes), so reconnect when the server closes the stream. There is no Last-Event-ID resumption: each reconnect starts at the current Redis position ($), so events published while disconnected are permanently missed.

When the client supports Streamable HTTP, point it at https://polytrackers.com/api/mcp with Authorization: Bearer <agent-api-key>.

For stdio-only MCP hosts, run the published bridge with npx -y @polytrackers/mcp-stdio; it relays stdio JSON-RPC to that endpoint. It reads POLYTRACKERS_API_KEY (required), POLYTRACKERS_MCP_URL (optional, defaults to the endpoint above), POLYTRACKERS_MCP_ALLOWED_HOSTS (optional host allowlist), and POLYTRACKERS_MCP_TIMEOUT_MS (optional). Full hosted and stdio setup examples are published in /skill.md.

To test strategies programmatically with no real money — the mock (paper) trading tool flow, free-tier reads, and going-live fees — see the Polymarket Mock Trading API guide.

Agent skill distribution

Install the PolyTrackers agent skill (which bundles this MCP setup) with one command: npx skills add polytrackers/polymarket-copy-trading-skill. Official distribution channels:

Scopes:

  • signals:read — read-only tool/resource catalog for Free+; free keys are shaped by 7-day base anomaly history (up to 28 days with activated referral rewards), top-5 delayed anomalies, and the 200 requests/day MCP quota.
  • mock:trade — permits committed paper writes for Free+: pt_mock_wallet_create, pt_mock_trade_place, pt_mock_resolve_run, pt_mock_reconcile_run, pt_mock_experiment_run, and pt_sports_gap_paper_trade. Dry runs need only signals:read. A key without agent:full cannot write to the real-money wallet (INPUT_INVALID, details.reason: "REAL_WALLET_NOT_ALLOWED").
  • trade:execute — permits pt_trade_execute for Free+ after pt_trade_preflight approval and the owner's AI agent authorization (Settings → Wallet).
  • agent:scan — permits pt_scan_trigger for Pro+ without granting broader writes.
  • monitors:write — permits pt_sports_gap_monitor_create, pt_sports_gap_monitor_update, and pt_sports_gap_monitor_delete for Pro+: owner-scoped, alert-only writes on the caller's own scanner monitors. The sportsbook-gap scan pt_sports_gaps_list and pt_sports_gap_monitors_list need only signals:read on every plan; pt_sports_gap_rule_test needs signals:read on Pro+.
  • agent:full — current Elite write/execution superset. Still required for webhooks, alert preferences, roster and copy settings, pt_mock_wallet_delete, pt_mock_auto_trade_set, and order cancellation.

Versioning & changes

  • 2026-11-22: The sportsbook-gap scanner covers NHL full-game winners, before the game only (section, decision 0042). nhl is a new value of leagues and of each result's league, and it is part of the default search. A search saved before this date keeps the leagues it was saved with. An NHL game in play has no comparison and reports the new exclusion reason in_play_not_compared in coverage.games_excluded and in a paper trade's observed_comparison.status; net_gap_pp_at_requote is then null. NHL results carry tie: null. NBA and NFL results do not change. Additive, so the contract version stays 2.0.0.

  • 2026-11-16: The sportsbook-gap scanner compares NFL regular-season games with a tie allowance instead of reporting them as settlement_mismatch (section, decision 0038). Every scan result, monitor webhook result, rule-test crossing and paper-trade observed_comparison gained tie (null when the game cannot end tied). net_gap_pp and net_gap_pp_at_requote take off tie.allowance_pp, which only a favorite pays; sportsbook.consensus_probability is unchanged. A game hidden while a tie is likely reports the new exclusion reason suppressed_tie_risk in coverage.games_excluded, in a rule test's unsupported.other and in observed_comparison.status. No existing gap changes value: these games were not compared before. The same release fixes, for every league, a game that is paused now: it is hidden as suppressed_game_state on every live read instead of showing its last live price until the next capture. That is a fix, not a contract change. Additive, so the contract version stays 2.0.0.

  • 2026-11-15: Added the sportsbook-gap scanner (section, feature doc). New REST routes: GET /api/sports/gaps, GET and POST /api/sports/gaps/monitors, PATCH and DELETE /api/sports/gaps/monitors/{id}, POST /api/sports/gaps/paper-trade and POST /api/sports/gaps/rule-test, plus seven MCP tools (catalog: 84 tools). A Free signals:read key can scan (top 3 results per search). Added the narrow monitors:write scope (Pro and Elite, opt-in at key creation, on by default for a new Pro key made in the app; agent:full covers it). POST /api/sports/gaps/paper-trade is the one REST route that accepts mock:trade. Monitors can deliver the sports_gap.threshold_crossed webhook event. Existing keys keep their scopes, and no existing tool changed tier or scope. Additive, so the contract version stays 2.0.0.

  • 2026-11-09: Agent API Key scopes changed for every plan (owner ruling, decision record). Added the paper-only mock:trade scope: a key on any plan, Free included, can commit paper trades through pt_mock_wallet_create, pt_mock_trade_place, pt_mock_resolve_run, pt_mock_reconcile_run, and pt_mock_experiment_run. These tools previously required the Elite-issued agent:full. pt_trade_preflight and pt_trade_execute are now Free-tier MCP tools: a Free key may hold trade:execute, and preflight no longer returns the tier_requires_pro blocking reason. Every real-money guard is unchanged. POST /api/keys/generate grants both scopes only when the request names them, so existing keys and requests without scopes are unaffected. Direct REST POST /api/trade/execute keeps its Pro floor for Agent API Keys. scopes_supported in /.well-known/oauth-protected-resource lists the new scope.

  • 2026-10-26: Wallet-risk REST and mock/real MCP config expose shortHorizonHours and sameDaySportsHours (numeric, 1 to 8,760 hours inclusive, fractional hours accepted, default 24 for every existing wallet). GET /api/whale/config returns both; PUT /api/whale/config, pt_mock_wallet_copy_config_update, and pt_real_wallet_copy_config_update accept both. A non-numeric value is rejected with 400. The existing excludeShortHorizonMarkets and excludeSameDaySports switches still decide whether each BUY filter runs; the hours fields only set the window that filter uses, so the 2026-10-12 and 2026-09-28 "24 hours" notes below now describe the default rather than a fixed value. SELLs are unaffected. Real updates still require confirm_real_money: true.

  • 2026-10-14: Paper and real-copy wallet risk config now exposes smallOrderPolicy (scale-up by default, or skip) through PUT /api/whale/config and both guarded MCP config writers, and new wallets default minTradeSize to $1. The minimum copy size is the larger of $1, the enabled minTradeSize, and (real wallets) the signed minPerTrade; it applies after fixed or percentage sizing and before final risk validation and reservation. In scale-up mode a positive copy below the minimum is raised to it when every risk, authorization, balance, fee, and venue gate allows, which can exceed the strategy-sized cost; otherwise it is skipped with a reason. Real scaling still needs a signed minPerTrade: null/0 authorizations keep skip behavior until the owner changes them, and stored custom minimums are retained. skip never enlarges a copy, and SELL quantities and actual partial fills are never enlarged. This supersedes the 2026-08-10 minPerTrade note below.

  • 2026-10-01: Real-wallet copy controls now reflect mandatory authorization pauses. Expired signing or inactive copy authorization returns fully_paused, an actionable authorizationPause, and the preserved savedMode. Resume attempts return 409 until signing and copy authorization are restored. Paper wallets and whale assignments are unchanged; an existing manual pause still applies after reauthorization.

The current REST/OpenAPI contract version is 2.0.0, sourced from the canonical OpenAPI document and served at /openapi.json. The hosted MCP server version is 0.2.0, sourced from the server package version and returned by the MCP initialize response and each tool response's _meta.server_version. Additive endpoints and tools may ship without a version bump.

Version header

The REST contract is versioned in a response header, not in the URL path. Every /api/* response carries:

HeaderMeaning
API-VersionContract version that produced this response, e.g. 2.0.0. Matches info.version in the OpenAPI document.

Assert on it at startup and fail loudly on an unexpected major, rather than discovering a change through a parse error later. The header is response-only: no request header changes how a route behaves, so there is nothing here that can be pinned to and later withdrawn. Paths outside the proxy's matcher (/api/cron/*, /api/whale/webhook, /api/goldsky/shadow) are machine-to-machine and omit it.

The OpenAPI document declares this header on every response it describes, as $ref: "#/components/headers/ApiVersion" — so a generated client sees it without reading this page, and a spec parser can detect the versioning strategy. The four POST /api/whale/webhook responses deliberately carry no such declaration, because that path is outside the matcher. A contract test holds both halves in place against the matcher in proxy.ts.

How the number moves:

  • Patch/minor — additive only. New endpoints, new optional request fields, and new response fields ship without a major bump, so clients must ignore response fields they do not recognise.
  • Major — anything that could break a correct client: a removed or renamed field, a narrowed type, a changed status code, or a retired endpoint. A major is always preceded by the deprecation signal below.

Deprecation and sunset headers

A retired endpoint announces itself on the wire, not only in this document:

HeaderMeaning
DeprecationRFC 9745 structured-field date — @<epoch seconds> — for when the deprecation was announced.
SunsetRFC 8594 HTTP-date for when the endpoint stops serving. A date in the past means it is already gone.
Linkrel="successor-version" pointing at the replacement, plus rel="deprecation" pointing at this page.

POST /api/whale/trade is the current example: retired on 2026-02-27, it answers 410 Gone and carries all three headers pointing at POST /api/whale/webhook. Poll Deprecation on the endpoints you depend on — it is the earliest machine-readable warning available, and it is set long before the Sunset date arrives.

Compatibility and deprecation policy:

  • Breaking REST contract changes are recorded in this section when they ship.
  • MCP tool additions, removals, and renames are recorded in the polytrackers://changelog resource. Its current catalog count and fingerprint are checked against the registered catalog in CI.
  • Breaking MCP changes bump the server minor version. A renamed tool remains available for one minor version with deprecated: true and a replacement in its description before removal.
  • The MCP HTTP transport does not emit a Deprecation response header for tool changes; the REST headers above cover REST endpoints only. For MCP, consult this section and polytrackers://changelog.

Change log:

  • 2026-09-11: Agent alert-preference updates now redact stored Discord webhook tokens from their response. pt_mock_experiment_run no longer accepts the ineffective fund_amount input and uses the caller tier's standard balance when it creates a wallet. Webhook registration rejects URL credentials and custom HTTPS ports, while POST /api/wallets bounds its body to 64 KiB and enforces the established 100-character name and 20-character color limits.

  • 2026-10-12: Wallet-risk REST and mock/real MCP config expose excludeShortHorizonMarkets (strict boolean, default false). When enabled, BUYs within 24 hours are skipped across all categories with MIRROR_SKIPPED_SHORT_HORIZON; sports use game/event start and non-sports use market resolution time. Recognized short-window crypto/daily-price markets with unknown timing also skip. SELLs are unaffected. Paper atomic execution repeats the check; config import to a real wallet preserves the policy.

  • 2026-09-28: GET /api/markets/end-dates in-route limiter raised from 12 to 420 requests/minute per user, with a new weighted budget of 20,000 condition IDs/minute per user (each request costs the number of unique ids it carries). Both answer 429 with Retry-After; the request budget is published as legacy X-RateLimit-Limit / X-RateLimit-Remaining and the ID budget as X-Market-Resolution-ID-Limit / X-Market-Resolution-ID-Remaining. The proxy's shared public-market-read bucket still applies first. (Recorded here on 2026-11-03.)

  • 2026-09-28: Wallet-risk config, REST, and mock/real MCP tools expose an optional inclusive copied-BUY entry band (minEntryPrice 0 by default, maxEntryPrice 1 by default) and excludeSameDaySports (false by default). The latter skips sports-like markets ending within 24 hours or with an unknown end date. Mock fills check final VWAP atomically; real BUYs check the observed executable price before reservation because final fill VWAP is unavailable there. SELL exits remain unchanged.

  • 2026-09-08: Wallet-risk updates now apply the existing $10,000,000 absolute ceiling to hourlyLossLimit and dailyLossLimit across the dashboard, REST endpoint, and both guarded MCP config writers. Unexpected PUT /api/whale/config failures retain full server-side logs but return a fixed message instead of exposing raw infrastructure details.

  • 2026-09-07: The Elite read-only pt_real_wallet_copy_config_get projection now includes effective signed copy-trading authorizationLimits.maxPerTrade and authorizationLimits.dailyLossLimit. Null means a ceiling is unavailable; both remain distinct from same-named wallet-risk fields under config, and no write path or signing material was added.

  • 2026-08-23: The OpenAPI document now declares API-Version on every response it describes, instead of only defining the header component and describing it in prose. Documentation only — the header itself has shipped on the wire since earlier the same day, and no endpoint's status, body, or media type changed.

  • 2026-08-23: Every /api/* response now carries API-Version, and the retired POST /api/whale/trade additionally carries Deprecation, Sunset, and a successor Link. Additive headers only — no status code, body, or cache directive changed, and page routes are untouched. Every OpenAPI operation also now has a description; a contract test fails the build if one ships without.

  • 2026-08-14: Wallet copy pause is now a three-state REST/MCP contract: copying, buys_paused, or fully_paused. Buys-only mode blocks new BUY mirroring with WALLET_COPY_BUYS_PAUSED while paper and real SELL exits keep flowing. The v2 MCP setter prefers mode and retains legacy copyPaused:true|false; every live transition remains atomically audited, with explicit confirmation and a best-effort security email for real wallets.

  • 2026-08-14: Added the operator-allowlisted, Elite, read-only, MCP-only pt_copy_replication_aggregates_get internal evidence tool over the service-role Copy Receipt V1 aggregate RPC. It requires one exact whale, fixes the RPC limit at one, and adds index-backed lookup plus a caller-side five-second PostgREST request deadline. Database-owned 20/40-condition confidence floors and below-floor null metrics are unchanged; ordinary customer keys fail closed and no REST or browser surface was added.

  • 2026-08-18: Paper and dedicated real-copy wallets now expose fixedStakeUsd. Zero preserves conviction/percentage sizing; a positive value of at least $1 requests the same USD amount for every copied BUY and bypasses the copy multiplier. Kelly, position, max-bet, balance, authorization, breaker, reservation, and venue gates remain authoritative. The dashboard plus both guarded MCP config writers can read, preview, and update the wallet-scoped field; existing wallets default to off.

  • 2026-09-07: Paper and real-copy risk config now exposes default-on nettingProtection and opposingSideProtection toggles. Owners may opt out per wallet. Disabled netting activates maxConditionExposureUsd, which caps total open BUY cost across both outcomes plus the proposed copy, defaults to three times maxPerTrade, stays at or above that per-trade limit, and is bounded to $10,000,000. Real protection opt-outs remain atomically audited and emit copy_protection_disabled.

  • 2026-08-11: Added the free read-only MCP tool pt_whale_forward_returns_get for bounded forward-return counterfactuals across arbitrary wallet cohorts. It preserves one row per request entry, enforces exact decision/cutoff windows, and exposes unresolved, truncation, fee, resolution-source, and vendor-call-budget evidence.

  • 2026-08-10: Dedicated real-copy wallets now persist a guarded 0–10% realCopySlippageTolerance, exposed through the real-wallet MCP config tools. Where the venue ceiling permits, BUY FAK caps retain at least one market tick of headroom above the observed ask, and deterministic signed-cap rejections are no longer replayed through Goldsky promotion recovery.

  • 2026-08-10: Recommendation and digest-suggestion rows now expose display-name source/time plus Polymarket's stable pseudonym. Legacy aliases beginning with a wallet address no longer override the current leaderboard name, and compact/byte-capped/cursor-replayed shapes retain the provenance.

  • 2026-08-07: Rollout-eligible dedicated real-copy wallets can now set a 1–2x owner-only sizing multiplier through the authenticated dashboard. The server gate fails closed to 1x, all existing caps remain authoritative, and MCP real-wallet writes continue to exclude the field.

  • 2026-08-10: Real-wallet dashboard and Elite MCP config surfaces now read, preview, and write authorization-scoped minPerTrade. Null/0 disables the floor; positive values are bounded to $1 through the signed copy-trading authorization's maxPerTrade, restore only percentage-reduced dust, and never exceed the strategy-sized cost. The floor applies only when fixedStakeUsd is off and is explicitly distinct from risk-rule maxPerTrade and minTradeSize. Superseded on 2026-10-14: the floor now applies after fixed or percentage sizing and can exceed the strategy-sized cost when smallOrderPolicy is scale-up (see that entry above).

  • 2026-08-07: Session-authenticated PUT /api/whale/config now routes real-wallet risk changes through the atomic config-plus-audit RPC and sends the owner security email. Real-wallet requests reject executionMode; paper-wallet behavior is unchanged.

  • 2026-08-07: Whale-edge loads are now batch-independent under deterministic per-wallet caps. coverageTruncated is wallet-specific, SPLIT/non-directional evidence is exposed through nonDirectionalSampleCount*, and roi_provenance includes the capital used by each ROI window.

  • 2026-08-07: Leaderboard, recommendation, and digest-suggestion rows now share canonical ROI/sample projections and a roi_provenance block across full, compact, and replayed snapshot shapes. Bare sampleCount means the directional edge-row count; recommendation admission evidence is separately named. Explicit edge-load fallback uses labeled 365-day receipts-only counts with null ROI.

  • 2026-08-04: pt_recommendations_get now returns snapshot-pinned opaque continuation cursors plus explicit total/returned/has-more counts. Continue with the same projection and settled-sample filter when the byte cap trims a page; min_settled_samples narrows the population and is not continuation.

  • 2026-08-03: Added Elite agent:full pt_real_wallet_copy_config_get / pt_real_wallet_copy_config_update and pt_real_wallet_breaker_resume / pt_real_wallet_breaker_kill. Every real-money preview or write requires confirm_real_money:true; live changes append an audit event and send a best-effort security email. The strict config writer excludes executionMode and copySizingMultiplier.

  • 2026-07-31: Added Elite agent:full pt_mock_wallet_copy_config_get / pt_mock_wallet_copy_config_update for full caller-owned paper-wallet risk reads and guarded dry-run/live updates. The strict write schema excludes executionMode, real-wallet rows are unreachable, and zero-value warnings are returned with the preview.

  • 2026-07-26: Added GET /api/trade/money-summary (user-scoped real-money totals/counts aggregate; session or agent:full, same auth semantics as GET /api/trade/ledger).

  • 2026-07-21: Added the paper-only wallet copy-sizing multiplier to the wallet risk-config contract and pt_mock_wallet_copy_sizing_update; the MCP catalog baseline was then 65 tools and real-copy sizing was 1x. The 2026-08-07 owner-dashboard 1–2x rollout supersedes that historical behavior.

  • 2026-07-20: Published the version/deprecation policy and recorded the 2.0.0 OpenAPI contract plus the then-current 64-tool MCP catalog baseline.


Reliability notes

  • Handle 429 on all rate-limited endpoints and respect Retry-After.
  • Treat trade execution as idempotent when you provide idempotencyKey (idempotent replays return 200 with idempotencyReused: true).
  • POST /api/keys/generate returns the raw key once — store it securely. Each account keeps one active Agent API Key; rotate by revoking the old key, then generating a replacement and updating clients/agents.
  • /api/anomalies/{id} may return 404 when a record falls outside your tier window.
  • TIER_UPGRADE_REQUIRED responses include requiredTier, currentTier, and upgradeUrl — surface these to the user/agent verbatim.

Historical sports durability compares trade time with event timing, independently of query age. Missing/conflicting timing stays unknown. Discovery actionability recent_activity.durability_evidence and digest wallet durability_profile.durability_evidence retain timing-basis counts, known-notional coverage and shares, majority basis, and the capped loaded window through compact and cursor responses. Per-trade activity_profile retains timing basis and uncertainty. See historical flow durability for the 24-hour horizon, conservative slug calendar envelope, 90% notional-coverage rule, 1,000-row disclosure, and denominator semantics. No new execution veto is added.

Leaderboard backtest population and market-specific discovery

backtestable_only vets usable coverage within the returned Polymarket leaderboard population. It narrows discovery; missing or unavailable coverage is not a negative profitability or category verdict. A new or untracked wallet can lack evidence even when it has useful trades. This filter is separate from the canonical capital-accounting backtest admission gate.

Resolved-position scope enrolls the top 50 leaderboard wallets selected by whale edge plus active wallet_whale_assignments roster wallets. Ingestion requires copyable classification; high-fill-rate market makers are excluded from that lane. Bounded Data API backfills add historical fills for scoped wallets, and coverage/backtests union those positions with legacy resolved_receipts joined by anomaly_logs.wallet, deduplicating conditions. Missing resolved-position coverage retains receipt-based diagnostics; inspect per-row backtestCoverage, roi_provenance, truncation and fallback fields. Enrollment alone guarantees neither complete history nor current freshness.

REST /api/leaderboard and MCP pt_leaderboard_get return the explanation in omission_metadata.backtestable_scope with either filter setting and in full, compact and continued responses. Existing omission counts and continuation semantics remain unchanged. Unknown coverage does not become proof of poor performance or an absence of durable-category traders.

For market-specific discovery, obtain a condition id with pt_markets_search, then call Pro+ pt_market_trades_get to find recent public trading wallets. That tool reads at most 100 source rows, has no cursor, and reports omissions; it does not enroll wallets or create backtest evidence. Follow candidates with pt_trader_profile_get for coverage and pt_whale_activity_get for ingestion/timing evidence, then pt_backtest_run for modeled copy-cost validation. One market sample guarantees neither durable flow nor profitable whales, and a passing backtest remains screening evidence rather than proof of live copy profitability.

Roster session POST/PATCH/DELETE requests enforce the configured site origin and reject cross-site browser writes; adding an arbitrary bearer header cannot bypass this check. Verified whale-service secrets keep their programmatic access, and scoped Agent API Keys keep the MCP roster tools. REST roster-add name accepts a string of at most 100 UTF-16 code units before normal display name sanitization, matching MCP's length contract. Unexpected roster database errors return fixed operation-specific messages while server logs retain the underlying failure.

Session writes to PATCH /api/whale/copy-pause, PUT /api/whale/config, and POST/PATCH /api/trade/copy-trading enforce the configured site origin before authentication, body parsing, or mutation. Cross-site fetch metadata or a mismatching Origin returns HTTP 403 with { "error": "Cross-origin requests are not allowed." }. Adding a bearer header does not bypass the origin guard. Headerless clients retain existing authentication requirements, and scoped Agent API Key MCP tools are unchanged.

Data API v2 bet sync adds optional historyComplete to POST /api/bets/sync and its bets_sync_trigger MCP projection. false means successful sync of a bounded recent sample, not complete wallet history. A failed source is an error, not an empty/up-to-date result. The server-only history rollout entry can pause the sync; it has no other mode.

Mock position outcomes

GET /api/mock/analytics and pt_mock_analytics_get report W/L and win rate for completed original BUY lots (win_rate_basis: completed_original_buy_lots). Partial SELL fragments join only through explicit closeSourceTradeId lineage; partial exits and unavailable roots do not count as completed outcomes. position_counts distinguishes completed, partial, lineage_unavailable and realized groups. Raw openTrades, closedTrades, exports and MCP trade_counts remain execution rows; totalPnL still includes realized partial exits. Consumers must not infer position counts from raw row-array lengths.

Per-whale copy size

Paper and real wallet copy configuration exposes copySizeScalePct (0.01–100, default 100). PATCH /api/roster/{address} accepts the same field as an optional nullable override: a percentage replaces the wallet default, null restores inheritance, and omission preserves it. Supply fromWalletId to identify the assignment. Roster GETs return the nullable override. Scale edits must be separate from reactivation or wallet reassignment. Copy BUYs require at least $1 after scaling and must still fit existing risk and authorization limits; SELLs are unaffected. Agent tools use the same semantics and support dry runs.

Copy exit policies

Paper and real copy wallets expose exitPolicy through GET and PUT /api/whale/config and through their MCP copy-config tools. The default is mirror. Omit the field to preserve the wallet setting. Wallet defaults require one of these values.

ValueNew whale SELL behavior
mirrorApply the usual whale exit rules, including the existing near-resolution hold.
hold_to_resolutionKeep positions open for ordinary market settlement without mirroring the sale.
mirror_full_exits_onlyMirror a verified full close. Partial sells, dust remainders, and uncertain evidence keep the position open.

Roster GETs return the assignment override. PATCH /api/roster/{address} with fromWalletId and exitPolicy to set it. Use null to inherit the wallet default or omit the field to preserve it. Set it separately from reactivation or reassignment. The policy at the time a new sale is processed applies to both existing and new positions. The wallet activity feed records policy skips as exit-policy-hold or exit-policy-evidence-unavailable.

Minimum whale bet

minWhaleBetUsd accepts 0–1,000,000 USD. The wallet defaults to $5. A null whale override inherits it. Values below $5 use the platform minimum of $5. New BUYs accumulate on the same market side for 15 minutes before sizing. SELLs are unaffected. Set the wallet value through its copy-config update. Set or clear a whale override with pt_roster_update and fromWalletId. Omission preserves the setting. The activity feed records whale-bet-below-floor for a pending custom floor. With a $100 minimum, three $40 BUY fills within the window release one $120 signal. Normal wallet sizing and limits apply.

Skip-outcome report

Use pt_whale_activity_get with summary:"skip_outcomes" to review what a copy rule skipped. Pass one owned paper walletId and inclusive since and until timestamps spanning at most 31 days. Set group_by_whale:true to split each reason by whale (default false), or use whale to filter one address. The Free feed's five-whale scope and 24-hour decision delay apply.

The report models one BUY held to resolution per condition in each group, using the earliest retained decision (ties use the activity ID). It cannot replay fills. Entry uses the receipt's verified whale price, the stored copy stake or current wallet fixed stake, and the backtest copy model's entry slippage and fee. The report reads the last saved calibration and shows its timestamp and effective rates. Missing calibration uses the backtest defaults.

summary.by_reason gives skipped decisions, distinct conditions, resolved share (0–1), open and unknown counts, and missing entry prices, exit prices and stakes. resolved and marked_open each give valued conditions, cost, value, P&L in USD and ROI percent. Marks are read at report time. Only priced conditions with known stakes contribute to returns. An empty valued sample has null P&L and ROI. A condition can appear under several reasons or whales, so adding groups can count the same market twice. Narrow the window or filter by whale if the report exceeds the response budget.