# Authentication

## Authentication

There are several ways to send authenticated HTTP requests:

* Send a HTTP header `Api-Token: {api_token}`, where `{api_token}` is your API token
* Send a HTTP header `Authorization: Bearer {api_token}`, where `{api_token}` is your API token (more info: [Token Access Authentication](https://datatracker.ietf.org/doc/html/rfc6750))

You can manage your API token on the [API Tokens](https://mailtrap.io/settings/api-tokens) page. API token does not have an expiration date, you may reset it manually.

{% hint style="info" %}
All requests must be sent over HTTPS protocol.
{% endhint %}

## HTTP Methods

Allowed HTTP requests include:

| Method   | Description                           |
| -------- | ------------------------------------- |
| `POST`   | Create a resource                     |
| `PATCH`  | Update a resource                     |
| `PUT`    | Replace a resource                    |
| `GET`    | Get a resource or a list of resources |
| `DELETE` | Delete a resource                     |

## Response Codes

Here is the description of common server responses:

| Code  | Status               | Description                                                                                      |
| ----- | -------------------- | ------------------------------------------------------------------------------------------------ |
| `200` | OK                   | The request was successful (some API calls may return 201 instead)                               |
| `204` | No Content           | The request was successful but there is no representation to return (i.e. the response is empty) |
| `401` | Unauthorized         | Authentication failed or user doesn't have permissions for requested operation                   |
| `403` | Forbidden            | Access denied                                                                                    |
| `404` | Not Found            | Resource was not found                                                                           |
| `422` | Unprocessable Entity | Requested data contain invalid values                                                            |
| `429` | Too Many Requests    | Rate limit exceeded. Reduce request frequency and retry later                                    |


---

# 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.mailtrap.io/developers/authentication.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.
