# End-to-end Example

{% hint style="info" %}
To token gate an article, your users first need to hold the right NFT. If you want to create this NFT and send it to them, please check our [Airdrop an NFT](/developer-guides/mint/end-to-end-example.md) example above!
{% endhint %}

## 1. Get your API keys

Create a [3mint](https://app.3mint.io) account and find your API key on the Settings page.

<figure><img src="/files/qb7SOd68Dh54YKk7iCyx" alt=""><figcaption><p>The key displayed is for demonstration purposes only and will not work in production</p></figcaption></figure>

Your API requests are authenticated using API keys. Any request that doesn't include an API key will return an error.

**The key received should remain secret, which means it should only be accessed on the back end**. Authorization to the API is performed via the X-API-KEY header.&#x20;

## 2. Check Ownership

To verify whether a user has the right NFT, send an authenticated request to the tokenGate endpoint from your website. If you would like to add over parameters (length of time held, quantity held, metadata attributes, please check our [Token Gating](broken://pages/Rtm0fhxsPd6k8R1gnMzM) guide)

{% hint style="info" %}
Every API request must include Content-Type and X-API-KEY headers.
{% endhint %}

{% tabs %}
{% tab title="curl" %}
{% code lineNumbers="true" %}

```json
curl -X POST https://api.3mint.io/api/v1/tokenGate   
   -H "Content-Type: application/json"
   -H "X-API-KEY: [YOUR_API_KEY]"
   -d '{"walletAddress": "[WALLET_OF_USER]",
       "chain": "ethereum",
       "network": "mainnet",
       "requirements": [
           {
               "type": "erc721",
               "contractAddress": "[PROJECT_CONTRACT_ADDRESS]",
               "minBalance": 1,
           }
         ] 
       }'
```

{% endcode %}
{% endtab %}

{% tab title="Axios (JS)" %}
{% code lineNumbers="true" %}

```javascript
import axios from 'axios';

// replace with your 3mint api key
const apiKey = 'demo';
const url = 'https://api.3mint.io/api/v1/tokenGate';

// Include conditions to verify
const ownerAddress = '[WALLET_OF_USER]'
const contractAddress = '[PROJECT_CONTRACT_ADDRESS]'

var requestOptions = {
  method: 'POST',
  url: `${url}`,
  headers: {
    'Content-Type': 'application/json',
    'X-API-KEY': `${apiKey}`
  },
  data: {
    'walletAddress': `${ownerAddress}`,
    'chain': 'ethereum',
    'network': 'mainnet',
    'requirements': [
         {
             'type': 'erc721',
             'contractAddress': `${contractAddress}`,
             'minBalance': 1,
         }
     ]
   }
};

axios(config)
.then(response => console.log(response))
.catch(error => console.log(error));
```

{% endcode %}
{% endtab %}

{% tab title="Fetch (JS)" %}
{% code lineNumbers="true" %}

```javascript
import fetch from 'node-fetch';

// replace with your 3mint api key
const apiKey = 'demo';
const fetchURL = 'https://api.3mint.io/api/v1/tokenGate';

// Include conditions to verify
const ownerAddress = '[WALLET_OF_USER]'
const contractAddress = '[PROJECT_CONTRACT_ADDRESS]'

var requestBody = JSON.stringify({
  'walletAddress': `${ownerAddress}`,
  'chain': 'ethereum',
  'network': 'mainnet',
  'requirements': [
         {
             'type': 'erc721',
             'contractAddress': `${contractAddress}`,
             'minBalance': 1,
         }
     ]
});

var requestOptions = {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-API-KEY': `${apiKey}`
  },
  body: requestBody,
};

// Make the request and print the formatted response:
fetch(fetchURL, requestOptions)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(error => console.log('error', error));
```

{% endcode %}
{% endtab %}
{% endtabs %}

#### Response (by default)

{% code overflow="wrap" lineNumbers="true" %}

```json
{ "result" : true }
```

{% endcode %}


---

# 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://docs.3mint.io/developer-guides/token-gating/end-to-end-example.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.
