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

# Authentication

> Set up API key authentication for the Publive CDS and CMS APIs. Covers credential format, required headers, and handling auth errors in your frontend.

All Publive API requests require authentication via HTTP Basic Auth. Both the Content Delivery Service (CDS) and Content Management Service (CMS) use the same method.

## How to Get Your API Credentials

1. Navigate to [Publive Dashboard](https://dashboard.thepublive.com/v2/).
2. Go to [Configurations](https://dashboard.thepublive.com/v2/configurations)
3. Click on [API Developer Hub](https://dashboard.thepublive.com/v2/configurations/api-developer-hub)
4. Click the **View API credentials** button.
5. Your **API Key** is the username for Basic Auth.
6. Your **API Secret** is the password for Basic Auth.
7. Your **Publisher ID** is visible here.

If you don't have login credentials for the dashboard, please contact us at [thepublive.com/contact-us](https://thepublive.com/contact-us).

## How Does Publive Authentication Work?

You authenticate by sending an `Authorization` header with every request. The value is the word `Basic` followed by a Base64-encoded string of your API Key and API Secret joined by a colon.

```
Authorization: Basic <BASE64_AUTH_TOKEN>
```

## Generate your token

Encode your credentials using the command line:

```bash theme={null}
echo -n 'YOUR_API_KEY:YOUR_API_SECRET' | base64
```

This outputs a token like `<BASE64_AUTH_TOKEN>`. Use this value in your requests.

<Tip>
  You can also try API calls directly from these docs — the interactive playground on every API page lets you enter your API Key and API Secret, and it constructs the `Authorization` header for you automatically.
</Tip>

## Example request

```bash theme={null}
curl -X GET \
  'https://cds.thepublive.com/publisher/<PUBLISHER_ID>/posts/' \
  -H 'Authorization: Basic <BASE64_AUTH_TOKEN>'
```

For CMS API requests that send data, also include the `Content-Type` header:

```bash theme={null}
curl -X POST \
  'https://cms.thepublive.com/publisher/<PUBLISHER_ID>/category/' \
  -H 'Authorization: Basic <BASE64_AUTH_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{"name": "Technology", "english_name": "Technology"}'
```

## Authentication errors

If authentication fails, the API returns a `401 Unauthorized` response:

```json theme={null}
{
  "detail": "Invalid Auth Credentials"
}
```

Common causes:

* Missing `Authorization` header
* Incorrectly encoded Base64 token
* Invalid or expired API credentials

<Warning>
  **Security best practices:**

  * Never expose API credentials in client-side JavaScript
  * Use environment variables to store credentials
  * Rotate API keys periodically
  * Use the CDS API (read-only) for public-facing applications and reserve CMS API access for server-side operations
</Warning>

## API users and team membership

API users are members with access to the **API Developer Hub**. They do **not** appear in the team member listing under **Settings → Team** and cannot be selected in contributor fields or any other member selector across the dashboard.

## Publisher ID

Every API endpoint requires your `<PUBLISHER_ID>` in the URL path:

```
https://cds.thepublive.com/publisher/<PUBLISHER_ID>/posts/
https://cms.thepublive.com/publisher/<PUBLISHER_ID>/post/
```

Your Publisher ID is a unique numeric identifier assigned to your organization. You can find it in your Publive Dashboard URL.
