> For the complete documentation index, see [llms.txt](https://docs.predicthq.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.predicthq.com/api/overview/authenticating.md).

# Authenticating

All PredictHQ API endpoints require authentication. You can authenticate your request by sending a token in the `Authorization` header of your request. If you try to use an API endpoint without a token or that token has insufficient permissions, you receive a `403 Forbidden` response.

The PredictHQ API is a RESTful API, and you can access it at the `https://api.predicthq.com` URL. The API exchanges all data in JSON by default. These examples send a token in the `Authorization` header:

{% tabs %}
{% tab title="curl" %}

```bash
curl -X GET "https://api.predicthq.com/v1/events/" \
     -H "Authorization: Bearer $API_TOKEN" 
```

{% endtab %}

{% tab title="python" %}

```python
import requests

api_token = "$API_TOKEN"

response = requests.get(
    url="https://api.predicthq.com/v1/events/",
    headers={
      "Authorization": f"Bearer {api_token}"
    }
)

print(response.json())
```

{% endtab %}
{% endtabs %}

## Create an API token

To create a token:

1. In the WebApp, open the [**API Tokens**](https://control.predicthq.com/tokens) page.
2. Enter a name for the token and click **Create Token**.
3. To copy your token to the clipboard, click **Copy Token**. The WebApp doesn't show the token again, so a password or secrets manager is the safest place to keep a copy.

Now you can use the new API Token in the `Authorization` header of your API requests.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.predicthq.com/api/overview/authenticating.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
