# Authentication

## Login

<mark style="color:green;">`POST`</mark> `https://example.com/api/login`

This endpoint allows you to authenticate a user using **email** and **password**.\
\
After **successful authentication**, you will receive an **access token** which you can use for authentication of other endpoints

#### Headers

| Name   | Type   | Description      |
| ------ | ------ | ---------------- |
| Accept | string | application/json |

#### Request Body

| Name     | Type   | Description      |
| -------- | ------ | ---------------- |
| email    | string | Email of user    |
| password | string | Password of user |

{% tabs %}
{% tab title="202 Success fully authenticated" %}

```javascript
{
    "accessToken": "7|vC2gUQC8ajaMOa2juAnaiE4ZLgmH5dcbCDY8Hwsy"
}
```

{% endtab %}

{% tab title="400 Incorrect password" %}

```javascript
{
    "message": "Incorrect password"
}
```

{% endtab %}

{% tab title="404 Email does not exist" %}

```javascript
{
    "message": "User not found"
}
```

{% endtab %}

{% tab title="422 missing fields" %}

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

{% endtab %}
{% endtabs %}

## Logout

<mark style="color:green;">`POST`</mark> `https://example.com/api/logout`

This endpoint will destroy the token for the current user in the server so that any future request with the same token cannot be made.&#x20;

#### Headers

| Name          | Type   | Description                                        |
| ------------- | ------ | -------------------------------------------------- |
| Authorization | string | Bearer 7\|vC2gUQC8ajaMOa2juAnaiE4ZLgmH5dcbCDY8Hwsy |
| Accept        | string | application/json                                   |

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

```javascript
{
    "message": "logged out successfully"
}
```

{% endtab %}

{% tab title="401 Invalid token or token not provided" %}

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

{% endtab %}
{% endtabs %}


---

# 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://arbrelms-api.arbre.in/master.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.
