# Authentication

{% hint style="info" %}
MPush uses some HTTP headers to handle requests. In particular, are used to authenticate and to know which kind of data should expect from the client and vice versa.
{% endhint %}

All used headers are shown in the below table, but they can change based on which API you are calling.

| Header          | Description                                                          |
| --------------- | -------------------------------------------------------------------- |
| Accept          | Should always be `application/json`.                                 |
| Content-Type    | Should always be `application/json`.                                 |
| X-MPush-Token   | Contains the token to authenticate every API call.                   |
| X-MPush-Version | Define the API version you want to use. The minimum and actual is 2. |

### Errors <a href="#errors" id="errors"></a>

MBurger APIs uses the following HTTP error codes:

| Code | Meaning               | Description                                                        |
| ---- | --------------------- | ------------------------------------------------------------------ |
| 400  | Bad Request           | Your request is invalid.                                           |
| 401  | Unauthorized          | Your API key is wrong or not present.                              |
| 403  | Forbidden             | You don't have permission to access this resource.                 |
| 404  | Not Found             | The requested resource can not be found.                           |
| 405  | Method Not Allowed    | You tried to use an invalid method.                                |
| 406  | Not Acceptable        | You requested a format that isn't json.                            |
| 422  | Unprocessable Entity  | You requested did not pass the input validation.                   |
| 429  | Too Many Requests     | You're requesting too many! Slow down!                             |
| 500  | Internal Server Error | We had a problem with our server. Try again later.                 |
| 503  | Service Unavailable   | We're temporarily offline for maintenance. Please try again later. |

Below are reported some examples of them:

On authentication error is returned an HTTP 401 and a JSON like this:

```php
{
  "message": "The project token is not present."
}
```

On permission error is returned an HTTP 403 and a JSON like this:

```php
{
  "message": "This action is unauthorized."
}
```

On validation error is returned an HTTP 422 and a JSON like this:

```php
{
  "message": "The given data was invalid.",
  "errors": {
    "email": [
      "The token field is required."
    ]
  }
}
```


---

# 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.mpush.cloud/api/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.
