Access controls

IP Geofencing API for Sanctioned Countries

An IP geofencing API — geofencing by IP address rather than device location — for geofencing to block sanctioned countries or restrict users by jurisdiction: geolocate the calling client or any IP address to city, region and country, with an OFAC sanctioned-country flag in the same response. If you need device-level geofences that fire when a phone enters or leaves a radius, you want a mobile location SDK, not this.

GET /api/v1/geo/{ip}

# Omit the IP to geolocate the calling client
curl https://api.compliapi.com/api/v1/geo/91.218.114.206 \
  -H "Authorization: Bearer $COMPLIAPI_TOKEN"

Response

{
  "ip": "91.218.114.206",
  "city": "Moscow",
  "region": "Moscow",
  "country": "RU",
  "sanctioned": true,
  "source_url": "..."
}

Sanctioned-country flag built in

Geolocation results are checked against CompliAPI's curated list of OFAC country sanction designations — comprehensive, targeted and military.

City and region granularity

Responses include city and region, supporting rules like different handling for New York State users.

Caller or arbitrary IP

Call the endpoint with no argument to evaluate the requesting client, or pass any IP address explicitly.

One structured response

A single JSON object your access-control logic can branch on — no separate geo provider and sanctions list to join.

What the geofencing API response returns

One GET returns a single JSON object your access-control logic can branch on. Location fields are derived from IP data and are estimates; the sanctioned flag is a lookup against CompliAPI's curated OFAC country designations.

FieldWhat it holdsNature
ipThe address evaluated — the calling client's, or the one you passedexact
cityBest-estimate city for the IPprobabilistic
regionState or province (e.g. New York) — the field state-level rules key onprobabilistic
countryISO 3166-1 alpha-2 country codeprobabilistic
sanctionedtrue when that country carries an OFAC sanctions designationlookup
source_urlThe official OFAC program page behind the designation, when sanctionedlookup

Sanctioned-country flag built in: what sanctioned: true means

OFAC does not publish a single official list of sanctioned countries — it administers programs. The flag is CompliAPI's curated mapping of those programs to countries and regions, in three categories: comprehensive embargoes (Cuba, Iran, North Korea, and the Crimea, Donetsk and Luhansk regions of Ukraine, with Russia treated as comprehensive in practice), targeted country programs that restrict named sectors or officials without embargoing the country, and arms-embargo jurisdictions. Every flagged response carries the official program URL so a reviewer can read the designation behind it.

The mapping is maintained by hand against ofac.treasury.gov, re-synced to the API daily, and published in full — with its verification date — on the sanctioned countries reference page. Two limits to design around: an IP in a flagged country says nothing about whether a specific person or company is designated (that is what SDN screening is for), and a user behind a VPN can present an IP from a permitted country, which is why the flag pairs with VPN detection.

Where jurisdiction geofencing is applied

Exchanges and brokerages apply it at signup and per session, so accounts are not opened or traded from embargoed jurisdictions. DeFi front-ends check the requesting client before a wallet is allowed to interact with contracts. Stablecoin issuers and payment processors check on payment initiation and partner onboarding. And US products with state-level obligations use the region field to treat New York (and other states their policy names) differently from the rest of the country.

In each case the API supplies the location and the sanctions context; which jurisdictions to restrict, and whether to block, limit features or route to review, remains the operator's policy — the endpoint never enforces anything on its own.

Geo-blocking API: country-based access restrictions by IP

A geo-blocking API — an IP country block API, in this context — is a lookup your middleware or edge function calls once per request or session: it returns the country the request appears to come from and — here — whether that country carries an OFAC sanctions designation. The allow, restrict or deny decision is made in your code. The endpoint never enforces anything on its own, which is deliberate: which jurisdictions you block, and what a blocked user sees, is policy, and it belongs with you.

The pattern most teams implement has three branches, keyed on the fields in the response above. Deny when sanctioned is true, and keep the program URL from source_url with the decision so a reviewer can see why. Restrict or route to review when region is a jurisdiction your policy treats separately — New York State is the usual example. Step up verification rather than silently allowing when the same IP comes back from the VPN detection endpoint as true or "unknown". Otherwise allow, and log.

Two practical notes. The status code defined for a response withheld for legal reasons is HTTP 451 Unavailable For Legal Reasons (RFC 7725, February 2016); returning it for a sanctioned-country deny tells clients and proxies the block is deliberate rather than a fault. And which countries are flagged is not something you maintain: the sanctioned flag comes from CompliAPI's curated mapping of OFAC programs, published in full on the sanctioned countries reference page, and the free API key's 100 requests a month cover the /geo endpoint, so a geo-blocking rule can be built and tested without a plan.

ConditionWhat to doWhy
sanctioned is trueDeny; record source_url with the decision (HTTP 451 is the conventional status)The country carries an OFAC designation — the program page says which
region is on your policy list (e.g. New York)Restrict features or route to reviewState-level rules differ from the national rule
VPN endpoint returns true or "unknown" for the same IPStep-up verification, not a silent allowThe location signal deserves less trust
Anything elseAllow and logThe request log is your evidence the check ran

Geofencing vs VPN detection: why you need both

IP geofencing answers "which jurisdiction does this request appear to come from?". It cannot answer "is that appearance trustworthy?" — a user in an embargoed country who connects through a VPN exit node in a permitted country passes every country rule silently. The VPN detection API answers the second question with a true / false / unknown signal for the same IP, so a jurisdiction decision can be weighted by how much the location result deserves to be trusted. Most teams call both: geolocation for the rule, VPN detection for the confidence.

Jurisdiction rules without stitching providers together

Geofencing a crypto app usually means integrating a geolocation provider, separately working out which countries and regions your policy restricts, mapping OFAC sanctions programs to country codes yourself, and keeping that mapping current.

CompliAPI combines the lookup and the sanctions context in one request. You get the location and a sanctioned flag together — at signup, on wallet connect, or per session — and your application decides what to do with it: block, restrict features, or log.

CompliAPI returns location signals and sanctions context; it does not decide or enforce your access policy, and no IP-based location signal should be treated as infallible.

How it works

  1. Send a request

    Call /geo to evaluate the calling client's IP, or /geo/{ip} for any address your systems have observed.

  2. CompliAPI geolocates and checks sanctions designations

    The IP is geolocated to city, region and country, and the country is checked against curated OFAC sanction designations.

  3. Apply your policy

    Your application branches on the structured result — block, geo-restrict features, require review, or proceed.

What you can screen

  • The calling client's IP (no argument needed)
  • Any public IPv4 or IPv6 address

Where teams use it

Restricted-jurisdiction gating

Check the requesting client before a DeFi frontend lets a wallet interact with your contracts.

US state-level rules

Use the region field to apply different handling for users in New York State or other jurisdictions your policy treats separately.

Signup screening

Flag registrations from comprehensively sanctioned countries for blocking or review.

Feature availability

Serve different product experiences by country where regulatory treatment differs.

Pairing with VPN detection

Combine with the VPN endpoint to judge how much weight to give a location signal.

Scope and limitations

Geofencing signals support access-control decisions; they don't make them. Keep these boundaries in mind:

IP geolocation is probabilistic

Location derived from an IP address is an estimate. It is useful evidence, not proof of where a user is.

Users can obscure location

VPNs and proxies can shift apparent location. Pair geofencing with VPN detection when that matters to your policy.

You own the policy

CompliAPI reports where a request appears to come from and whether that country carries OFAC designations. Which jurisdictions you restrict, and how, is your organization's decision.

Curated country designations

OFAC does not publish a single official list of sanctioned countries. CompliAPI curates designations across comprehensive, targeted and military programs, with a source link for each.

Frequently asked questions

Is this a mobile geofencing SDK?

No. Mobile geofencing SDKs (Android's GeofencingClient, Apple Core Location regions, and location-platform SDKs) fire events when a device enters or leaves a geographic area, using the device's own GPS. This API works on the other side: it takes an IP address from a request your servers already see and returns the jurisdiction it appears to come from, plus an OFAC sanctioned-country flag. It is for access control by jurisdiction, not for proximity features.

Can location be found by IP address?

Approximately. An IP address maps to a country reliably and to a region or city only as an estimate, because the mapping comes from IP-range data rather than from the device — it never yields a street address or identifies a person. A VPN or proxy also moves the apparent location to wherever the exit node is. That is why this API returns the country, region and city as estimates with an OFAC sanctioned-country flag beside them, and why the flag is a control signal to pair with the VPN detection endpoint rather than proof of where someone is.

Is there a free geofencing API tier?

Yes. A free API key includes 100 requests per month across all endpoints, geolocation included, and requests can also be paid per call with x402 USDC micropayments without an account. Paid plans raise the monthly quota.

Which countries are flagged as sanctioned?

Countries and regions under OFAC sanctions programs, curated by CompliAPI across comprehensive, targeted and military designations. Each flag includes a source_url so you can review the underlying program.

Can I apply state-level rules like New York?

Yes — responses include city and region alongside country, so your application can implement rules such as special handling for New York State users.

Do I have to pass an IP address?

No. Calling GET /api/v1/geo with no argument evaluates the calling client's public IP. You can also pass any public IP explicitly, for example from your own request logs.

What is a Geolocation API?

An HTTP endpoint that maps an IP address to location fields — country, region and city — from IP-range data, so every location field is an estimate rather than a fact. This one returns those fields plus an OFAC sanctioned-country flag and the official program URL in a single JSON object. Treat the result as a control signal for access decisions, not as proof of where a person is; pair it with VPN detection when the location matters.

Related

Add geofencing to your application

Get a free API key and make your first request in minutes.

Free tier: 100 requests a month. No credit card required.

CompliAPI provides data and tools that support compliance workflows. It does not provide legal advice, and organizations should determine their obligations with qualified counsel.