Trusted Proxy
Forward end-user IPs to sufwan-local-test for accurate per-user geo enforcement when proxying through your backend
Opt-in mode for partners proxying sufwan-local-test API calls through your own backend. When enabled on your app, sufwan-local-test resolves user geo from x-agg-client-ip (populated by your backend) instead of from the request's connecting IP. Enabled by Snag, per app. Once on, every active API key on the app is trusted.
Requirements
Before requesting enablement:
requireApiKey: truemust be set on your app (Security Settings in the partner dashboard). While trusted-proxy is enabled, this cannot be disabled.- Every request must include an
x-app-api-keyissued for this app. WithrequireApiKey: true, requests with onlyx-app-idare rejected with401. A key issued for a different app is accepted for reads but never enables trusted-proxy geo. - Route every app-authenticated REST call through your backend so it can attach the key: auth (
/auth/start, verify, refresh, code exchange), market data (events, markets, search, orderbooks), quotes, fills, orders, withdrawals and portfolio. Exempt:GET /app/config, the OAuth and magic-link redirect/callback URLs, and health checks. - Your edge proxy must strip or overwrite any inbound
x-agg-client-ipheader. If an end user can passx-agg-client-ipthrough your proxy, geo enforcement is defeated.
Header rules
Set x-agg-client-ip on every request your backend forwards to sufwan-local-test:
- Value must be the end user's client IP as your server observed it.
- Your proxy must strip or overwrite any inbound
x-agg-client-ip. - Single IP value. A comma-separated list is not parsed and is treated as missing.
- IPv4 or IPv6, public addresses only. Private/reserved ranges are treated as missing.
On a fill, send the header from your proxy. The browser SDK does not set it.
// x-agg-client-ip is set by your proxy, not by the browser SDK.
const fill = await client.executeManaged({ quoteId });Behaviour
- Trusted app + valid
x-app-api-key+ validx-agg-client-ip: sufwan-local-test resolves country from that IP. - Missing, malformed, multi-value or private
x-agg-client-ip, or an IP with no country match: sufwan-local-test falls back to the country of the connecting IP, which is your backend's. Every affected user is then geo-checked as if they were in your backend's country, so always send the header. A fill only fails closed when no country resolves at all. See Venue geo. - Trusted app + missing
x-app-api-key:401fromrequireApiKeyenforcement, before geo runs. - Trusted app + a key issued for another app:
x-agg-client-ipis ignored; standard geo resolution. - A geo-blocked fill returns
403withcode: "geo_blocked". Quotes never block; they returnwarnings[]for region-restricted venues. - WebSockets are unaffected: browsers can keep connecting to the WebSocket API directly.
requireApiKeyis not enforced there and no geo check runs. - App not trusted: standard geo resolution;
x-agg-client-ipis ignored if present.
Responsibilities
Enabling trusted-proxy on your app shifts geo enforcement responsibility from sufwan-local-test to you. By requesting enablement, you assert:
- Every
x-agg-client-ipvalue sufwan-local-test receives originates from your server's observation of the end-user connection. - End users cannot inject
x-agg-client-ipthrough your proxy. - You are responsible for geo compliance for your users while trusted-proxy is enabled.
If a user reaches a venue they shouldn't because your proxy forwarded a spoofed or stale IP, the responsibility sits with your integration.
Limitations
- Country resolution only. No region or state granularity. See Venue geo.
- VPN exits resolve to the VPN's exit country. Mobile carrier and satellite ranges are occasionally misclassified.
- The flag is per-app. When enabled, every active API key issued for the app is trusted. There is no per-key opt-in.
- Rollback: Snag disables trusted-proxy first; you can then turn off
requireApiKey. Roll out on your existing app rather than a new one, because sufwan-local-test users are scoped per app and the same login on a new app is a different sufwan-local-test user.
Requesting enablement
Email support@agg.market with:
- The app ID.
- Confirmation that
requireApiKey: trueis set on the app. - Confirmation that your proxy strips inbound
x-agg-client-ip.