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

# Authentication

> Send your API key as a Bearer token on every request.

Every request needs an API key in the `Authorization` header. Without a valid key, the answer is `401`.

## Get a key

**1. Open API keys**

In the Followr app, go to [**Settings > API keys**](https://app.followr.ai/settings/api-keys).

**2. Create a key**

Name it after where it runs, for example `Production CMS sync`.

**3. Copy it right away**

The key is shown only once. Keep it in a secret manager or an environment variable.

You can create keys when your plan includes the API. If yours doesn't, you can still create one as an **owner** or **admin** of a company whose owner's plan includes it.

A key looks like `4821|v7QmZ0x3cJk9...`. The number before the `|` is its ID. Treat the whole string as a secret.

## Send the key

Add it as a Bearer token, with `Accept: application/json`:

```bash cURL theme={null}
curl https://api.followr.ai/api/users/me \
  --header "Authorization: Bearer $FOLLOWR_API_KEY" \
  --header "Accept: application/json"
```

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

response = requests.get(
    "https://api.followr.ai/api/users/me",
    headers={
        "Authorization": f"Bearer {os.environ['FOLLOWR_API_KEY']}",
        "Accept": "application/json",
    },
    timeout=30,
)
response.raise_for_status()
print(response.json()["data"]["email"])
```

```javascript JavaScript theme={null}
const response = await fetch("https://api.followr.ai/api/users/me", {
  headers: {
    Authorization: `Bearer ${process.env.FOLLOWR_API_KEY}`,
    Accept: "application/json",
  },
});

if (!response.ok) {
  throw new Error(`Followr API error ${response.status}: ${await response.text()}`);
}

const { data } = await response.json();
console.log(data.email);
```

```php PHP theme={null}
<?php

$ch = curl_init('https://api.followr.ai/api/users/me');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('FOLLOWR_API_KEY'),
        'Accept: application/json',
    ],
]);

$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
curl_close($ch);

if ($status !== 200) {
    throw new RuntimeException("Followr API error {$status}: {$body}");
}

echo json_decode($body, true)['data']['email'], PHP_EOL;
```

> [!WARNING]
>
> Never put a key in a URL. URLs end up in logs and browser history.

## What a key can do

A key acts as the user who created it.

| | |
| - | - |
| **Companies** | Every company the user belongs to. Pick one by ID in the path, for example `GET /companies/1287/postGroups`. |
| **Permissions** | The user's role in each company: `owner`, `admin`, `user` or `client`. Anything the role can't do gets `403`. See [Companies and teams](https://docs.followr.ai/guides/companies-and-teams.md). |
| **Usage** | Credits and AI words come from the same balances as in the app. |

A key gets `402` with `"entity": "api"` when the plan behind it drops the API. A key backed by a company owner's plan also stops when its user is no longer an owner or admin there. It works again as soon as that is fixed. Some plans also cap keys and monthly posts: see [Plans and usage](https://docs.followr.ai/api/plans-and-usage.md).

## Revoke a key

Revoke it in **Settings > API keys**, or with the API:

```bash cURL theme={null}
curl --request PUT https://api.followr.ai/api/personalAccessTokens/4821 \
  --header "Authorization: Bearer $FOLLOWR_API_KEY" \
  --header "Accept: application/json" \
  --header "Content-Type: application/json" \
  --data '{"revoke": true}'
```

Revoking is immediate and permanent. Keys never expire on their own, so revoke the ones you no longer use.

## Errors

| Status | Body | Cause |
| - | - | - |
| `401` | `{"message": "Unauthenticated."}` | The key is missing, malformed or unknown. |
| `401` | `{"message": "Token revoked"}` | The key was revoked. |
| `402` | `{"entity": "api", ...}` | The plan behind the key no longer includes the API. |
| `403` | `{"message": "Your account is banned"}` | The user's account is suspended. Contact support. |

## Keep keys safe

* **One key per integration and environment**, so you can revoke one without breaking the rest.
* **Server side only.** Never ship a key in a browser bundle or a mobile app.
* **Rotate without downtime.** Create a new key, deploy it, check its **Last used** date in the app, then revoke the old one.

> [!NOTE]
>
> AI assistants use MCP keys, which are separate from API keys. See [MCP authentication](https://docs.followr.ai/mcp/authentication.md).


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