# Authentication

All protected endpoints require a valid Bearer token in the `Authorization` header. Obtain a token by calling the `/authenticate` endpoint with your credentials.

## Obtain a Token

{% hint style="info" %}
Tokens are Firebase ID tokens and expire after **1 hour**. Re-authenticate to obtain a new token when yours expires.
{% endhint %}

### Request

```
POST https://api.revolutio.systems/authenticate
```

**Headers**

| Header         | Value              |
| -------------- | ------------------ |
| `Content-Type` | `application/json` |

**Body**

```json
{
  "email": "your-email@example.com",
  "password": "your-password"
}
```

| Field      | Type   | Required | Description                   |
| ---------- | ------ | -------- | ----------------------------- |
| `email`    | string | Yes      | Your registered email address |
| `password` | string | Yes      | Your account password         |

### Response

{% tabs %}
{% tab title="200 OK" %}

```json
{
  "idToken": "eyJhbGciOiJSUzI1NiIs..."
}
```

| Field        | Type   | Description                                 |
| ------------ | ------ | ------------------------------------------- |
| `idToken`    | string | Bearer token to use in subsequent API calls |
| {% endtab %} |        |                                             |

{% tab title="400 Bad Request" %}

```json
{
  "error": "Email and password must be provided"
}
```

{% endtab %}

{% tab title="401 Unauthorized" %}

```json
{
  "error": "INVALID_PASSWORD"
}
```

{% endtab %}

{% tab title="429 Too Many Requests" %}

```json
{
  "error": "Too many attempts. Try again later."
}
```

Returned after 5 failed login attempts within 1 hour for the same email.
{% endtab %}
{% endtabs %}

## Using the Token

Include the token in the `Authorization` header for all subsequent requests:

```
Authorization: Bearer eyJhbGciOiJSUzI1NiIs...
```

### Example (cURL)

```bash
# 1. Authenticate
TOKEN=$(curl -s -X POST https://api.revolutio.systems/authenticate \
  -H "Content-Type: application/json" \
  -d '{"email": "user@example.com", "password": "secret"}' \
  | jq -r '.idToken')

# 2. Use the token
curl -X POST https://api.revolutio.systems/search \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TOKEN" \
  -d '{"identifier": "12345678", "jurisdiction": "GB"}'
```


---

# 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://equinoxe-systems.gitbook.io/revolutio-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.
