> ## Documentation Index
> Fetch the complete documentation index at: https://guides.affiliate.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Authenticate your requests to the Affiliate.com API

> Create an API token at app.affiliate.com and include it as a Bearer token in the Authorization header on every API request you make.

Every request to the Affiliate.com API must include an API token. You create and manage tokens at [app.affiliate.com](https://app.affiliate.com/). Tokens are scoped to your team account, so all members of your team share the same rate limits.

## Pass your token

Include your token in the `Authorization` header as a Bearer token:

```http theme={null}
Authorization: Bearer YOUR_API_TOKEN
```

For example, a complete request looks like this:

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET https://api.affiliate.com/v1/networks \
    -H "Authorization: Bearer YOUR_API_TOKEN"
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.affiliate.com/v1/networks', {
    headers: {
      'Authorization': 'Bearer YOUR_API_TOKEN'
    }
  });
  ```

  ```python Python theme={null}
  import requests

  response = requests.get(
      'https://api.affiliate.com/v1/networks',
      headers={'Authorization': 'Bearer YOUR_API_TOKEN'}
  )
  ```
</CodeGroup>

<Warning>
  Keep your API token secure. Never expose it in client-side code, browser-accessible JavaScript, or public code repositories. If a token is compromised, rotate it immediately from [app.affiliate.com](https://app.affiliate.com/).
</Warning>

## Authentication errors

If your token is missing, malformed, or invalid, the API returns:

```
HTTP 401 Unauthorized
```

Check that you're including the `Authorization` header and that the token value is correct.

## Rate limit errors

| Code                       | Cause                                                         |
| -------------------------- | ------------------------------------------------------------- |
| `429 Too Many Requests`    | You exceeded the requests-per-minute limit for your API key   |
| `422 Unprocessable Entity` | You exceeded the total usage limit for your subscription plan |

Rate limits are measured per API key. Your per-minute limit depends on your subscription. If you receive a `429`, wait before retrying. If you receive a `422`, you've exhausted your plan's request quota.

## Network-specific credentials

Some affiliate networks require additional parameters beyond your API token to return affiliate links. You supply these inside the `networks` object when calling the product search endpoint. If you provide a network object but omit required fields, the API returns a `422` error listing the missing items.

| Network               | Required parameter(s)                             |
| --------------------- | ------------------------------------------------- |
| Adservice             | `mid`                                             |
| The Affiliate Gateway | `sid`                                             |
| Belboon               | `adspace_id`                                      |
| Effiliation           | `api_key`                                         |
| Partnerize            | `application_key`, `user_api_key`, `publisher_id` |

Here's how to supply network credentials in a product search request:

<CodeGroup>
  ```json Adservice theme={null}
  {
    "networks": {
      "1200": {
        "affiliate_id": "your_affiliate_id",
        "sub_id": "your_sub_id",
        "mid": "your_mid"
      }
    }
  }
  ```

  ```json The Affiliate Gateway theme={null}
  {
    "networks": {
      "650": {
        "affiliate_id": "your_affiliate_id",
        "sub_id": "your_sub_id",
        "sid": "your_site_id"
      }
    }
  }
  ```

  ```json Belboon theme={null}
  {
    "networks": {
      "253": {
        "affiliate_id": "your_affiliate_id",
        "sub_id": "your_sub_id",
        "adspace_id": "your_adspace_id"
      }
    }
  }
  ```

  ```json Effiliation theme={null}
  {
    "networks": {
      "805": {
        "affiliate_id": "your_affiliate_id",
        "sub_id": "your_sub_id",
        "api_key": "your_api_key"
      }
    }
  }
  ```

  ```json Partnerize theme={null}
  {
    "networks": {
      "811": {
        "affiliate_id": "your_affiliate_id",
        "sub_id": "your_sub_id",
        "application_key": "your_application_key",
        "user_api_key": "your_user_api_key",
        "publisher_id": "your_publisher_id"
      }
    }
  }
  ```
</CodeGroup>

For most other networks, you only need to supply `affiliate_id` and optionally `sub_id`.
