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

# Affiliate API Authentication

> Create a personal API key in your affiliate dashboard and use it with your Account ID.

## Credentials

Every request to the Affiliate API needs two values:

1. **API key**: a personal key that you create in your affiliate dashboard. It identifies you as the affiliate.
2. **Account ID**: identifies the affiliate program (the FirstPromoter account) the request is for.

Both are shown on the same page of your affiliate dashboard.

## Get your API key

1. Log in to the affiliate dashboard of the program.
2. Open your **Profile** settings and go to **API & AI tools**.
3. Click **Enable** to create your API key.
4. Copy the **API key** and the **Account ID** shown on the page and store them somewhere safe.

From the same page you can:

* **Copy** the key again whenever you need it.
* **Regenerate** the key. A new key is created and the old one stops working immediately, so update any scripts or AI tools that use it.
* **Disable** API access. The key is deleted and every request made with it is rejected until you enable access again.

> [!NOTE]
>
> The key belongs to your account in **one** program. If you promote several programs on FirstPromoter, you have a separate affiliate account in each one, so you create a separate key in each program's affiliate dashboard and use that program's Account ID with it.

The key does not expire and is not affected by logging out or ending dashboard sessions. It stays valid until you regenerate it or disable API access.

## Making authenticated requests

The base URL is `https://api.firstpromoter.com/api/v2/affiliate`. Send both credentials as request headers:

```
Authorization: Bearer {your_api_key}
Account-ID: {your_account_id}
```

The `Account-ID` header is required on every request. Header names are case-insensitive, so `ACCOUNT-ID` works too.

#### Example request

```bash theme={null}
curl https://api.firstpromoter.com/api/v2/affiliate/commissions \
  -H "Authorization: Bearer {your_api_key}" \
  -H "Account-ID: {your_account_id}"
```

Every endpoint returns only your own data in that program: your referrals, commissions, payouts, links and reports.

## Errors

| Status | Meaning |
| - | - |
| `401 Unauthorized` | The `Account-ID` header is missing, or the API key is missing, wrong, regenerated or disabled. |
| `403 Forbidden` | The key is valid but cannot be used for this request: the Account ID belongs to a different program than the key, your affiliate account is archived, your email is not confirmed yet, or (for some endpoints) you have not finished onboarding in the dashboard. |
| `404 Not Found` | No program matches the Account ID. |

## Security best practices

* Treat the API key like a password: anyone who has it can read your data in the program and change it through the API. That includes adding or deleting referrals, referral links and promo codes, and editing your payout methods and email settings.
* Never put the key in client-side code, public repositories or shared documents.
* Use HTTPS for all requests.
* Regenerate the key if you think it has been exposed, and disable API access when you no longer need it.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.