# 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 will receive a `403 Forbidden` response.

The PredictHQ API is a RESTful API and can be accessed from the `https://api.predicthq.com` URL. All data exchanges are performed using the JSON format by default.

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

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

{% endtab %}

{% tab title="python" %}

```python
import requests

access_token = "ACCESS_TOKEN"

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

print(response.json())
```

{% endtab %}
{% endtabs %}

## Create an API Token

Read a more in-depth guide to [creating a new API Token](https://app.gitbook.com/s/Ri9YaBiPckypV66Jggc2/webapp-overview/how-to-create-an-api-token) or follow the basic steps below:

1. Log into the WebApp and visit the [API Tokens](https://control.predicthq.com/tokens) page under API tools.
2. The first time you create a token - enter the name of the token and click "Create Token". For the second and subsequent times click the "Create New Token" button and enter the name, then click Create Token.
3. Click "Copy Token" to copy your token to the clipboard. You can now paste the token into another application. Keep a copy of your new API Token, as it will not be shown again.

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


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

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

The question should be specific, self-contained, and written in natural language.
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.
