# Blocking Users by Country

This example shows you how to restrict your content from a list of countries.

We use the ISO 3166 ALPHA-2 Country Codes. You can curate a blacklist or whitelist of your own by looking up the countries you'd like to include at [ISO 3166 Alpha-2](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes).

```javascript
// List of countries we want to block
// To see this in action add your country code to the array
var blacklist = ['ZM', 'CA', 'CH', 'IN']

// Getting the country code from the user's IP
$.get("https://ipforensics.net/api/v1/origin?apikey=APIKEY", function (response) {

  // Checking if the user's country code is in the blacklist
  // You could inverse the logic here to use a whitelist instead
  if (blacklist.includes(response.meta_data.geolocation.code)) {
    alert('This content is not available at your location.');
  } else {
    alert("You're allowed to see this!")
  }
}, "jsonp");
```

This simple example shows an alert with **This content is not available at your location** if the user is from a country in the blacklist.\
Alternatively it shows an alert with **You're allowed to see this!** for users that are not from the countries in the blacklist.

{% hint style="success" %}
**Always reference the** [**API endpoint**](/ipforensics/api/ip-and-threat-intelligence-api.md) **for complete response result**
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ipforensics.gitbook.io/ipforensics/code-implantation/blocking-users-by-country.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
