# Authentication

Our Payments API uses Bearer Authentication to enforce authentication for all its incoming requests. Bearer Authentication
(Token Authentication) is an HTTP authentication mechanism that involves security tokens generated by GrailPay servers.

```txt title="Bearer Authentication"
{
    "Authorization": "Bearer {YOUR_API_KEY}"
}
```

If you have lost an API Key, please connect immediately with our support to block current API Key(s) and generate new one(s).

All API requests must be made over HTTPS. Calls made over HTTP will fail.

### Common Authentication Errors & Warnings

```json title="401 (Unauthorized) — invalid token"
{
    "status": false,
    "message": "Invalid token.",
    "data": null,
    "errors": null,
    "request_id": "2d6a4c39-8fcf-4d80-9189-b4764eac31f2"
}
```

```json title="401 (Unauthorized) — malformed token"
{
    "status": false,
    "message": "Invalid token format. The token should be in the following format: ID|TOKEN_VALUE. Example: 12345|abcdefg",
    "data": null,
    "errors": null,
    "request_id": "2d6a4c39-8fcf-4d80-9189-b4764eac31f2"
}
```

```json title="401 (Unauthorized) — token ID is not an integer"
{
    "status": false,
    "message": "Invalid token format. The ID in the token must be an integer. Example: 12345|abcdefg",
    "data": null,
    "errors": null,
    "request_id": "2d6a4c39-8fcf-4d80-9189-b4764eac31f2"
}
```