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

# Authentication

### Authenticating with API Keys

To make successful requests to the Agant Platform API, you must authenticate every request by including a valid API key in the request headers. Authentication ensures that only authorised users can access resources and perform actions within your account.

### Generating Agant API Keys <a href="#api-keys" id="api-keys"></a>

You can view and manage your API Keys on the [Agant Dashboard](https://dashboard.agant.io/company/api-tokens).

### Using Agant API Keys <a href="#api-keys" id="api-keys"></a>

All requests require an API key and must use HTTPS. To authenticate your requests, include your API token in the `Authorization` header of the HTTP request.

#### Example Request

The following is an example `GET` request to list all rails with an API Key bearer token:

#### Sample Authenticated Request:

```bash
curl --request GET \
     --url https://sandbox.agant.io/api/v1/rails \
     --header "Authorization: Bearer <api-token>" \
     --header 'accept: application/json'

```

{% hint style="warning" %}

#### Security Considerations

* API keys grant a high level of access to your application. Never share them publicly.
* If you suspect an API key is exposed or misused, generate a new one.
* As a best practice, we recommend rotating your keys once per quarter.
  {% endhint %}

### Handing API Authentication Errors

If there is an issue with the authentication method provided on an API request, the API will respond with a `401 Unauthorized` error. Typically, these occur when the API Key is either invalid or revoked.

```
HTTP/2 401
date: Wed, 01 Jan 2025 00:00:00 GMT
content-type: application/json

{"message":"Unauthenticated."}
```


---

# 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 dynamically by asking a question.

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

```
GET https://docs.agant.io/Y83ivqmfOiUspagNyFg6/overview/authentication.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
