> For the complete documentation index, see [llms.txt](https://convexity-tech-team.gitbook.io/chats-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://convexity-tech-team.gitbook.io/chats-documentation/technical-documentation/api-documentation/authentication.md).

# Authentication

Authentication Management

## Login endpoint into the CHATS platform

<mark style="color:green;">`POST`</mark> `https://staging-api.chats.cash/v1/auth/login`

With this endpoint, users can login as an NGO, Donor, Beneficiary, Field Agent. Each of these stakeholder are identified by the RoleID.&#x20;

Here are the following Roles and their IDs:

SuperAdmin: 1, GodMode: 2, NgoAdmin: 3, NgoSubAdmin: 4, FieldAgent: 5, Beneficiary: 7, Donor: 8,

#### Request Body

| Name                                       | Type   | Description              |
| ------------------------------------------ | ------ | ------------------------ |
| email<mark style="color:red;">\*</mark>    | String | The email of the user    |
| password<mark style="color:red;">\*</mark> | String | The password of the user |

{% tabs %}
{% tab title="200: OK Login successfully" %}

{% endtab %}

{% tab title="401: Unauthorized Invalid login credentials" %}

{% endtab %}
{% endtabs %}

## Vendor Login

<mark style="color:green;">`POST`</mark> `https://staging-api.chats.cash/v1/vendors/auth/login`

The Vendor Login endpoint differs from the regular login because of the body params. The body takes in a Vendor ID, alongside password.

#### Request Body

| Name                                         | Type   | Description     |
| -------------------------------------------- | ------ | --------------- |
| vendor\_id<mark style="color:red;">\*</mark> | String | Vendor Id       |
| password<mark style="color:red;">\*</mark>   | String | Vendor Password |

{% tabs %}
{% tab title="200: OK Login Successful" %}

{% endtab %}

{% tab title="401: Unauthorized Login failed. Please try again later" %}

{% endtab %}
{% endtabs %}

## Donor Login

<mark style="color:green;">`POST`</mark> `https://staging-api.chats.cash/v1/auth/donor-login`

The Donor Login endpoint.

#### Request Body

| Name                                       | Type   | Description       |
| ------------------------------------------ | ------ | ----------------- |
| email<mark style="color:red;">\*</mark>    | String | Email of Donor    |
| password<mark style="color:red;">\*</mark> | String | Password of Donor |

## Admin Login

<mark style="color:green;">`POST`</mark> `https://staging-api.chats.cash/v1/admin/auth/login`

The Admin Login endpoint.

#### Request Body

| Name                                       | Type   | Description       |
| ------------------------------------------ | ------ | ----------------- |
| email<mark style="color:red;">\*</mark>    | String | Email of Admin    |
| password<mark style="color:red;">\*</mark> | String | Password of Admin |

## Request Password Reset

<mark style="color:green;">`POST`</mark> `https://staging-api.chats.cash/v1/auth/password/reset`

This endpoint sends a reset password request to the user who called the endpoint.

#### Request Body

| Name  | Type   | Description      |
| ----- | ------ | ---------------- |
| email | String | If email is used |
| phone | String | If phone is used |

{% tabs %}
{% tab title="200: OK Token generated" %}

{% endtab %}

{% tab title="400: Bad Request Request failed please try again" %}

{% endtab %}
{% endtabs %}

## Password Reset

<mark style="color:orange;">`PUT`</mark> `https://staging-api.chats.cash/v1/auth/password/reset`

This endpoint resets the password of the user who called the endpoint

#### Request Body

| Name                                                | Type   | Description                           |
| --------------------------------------------------- | ------ | ------------------------------------- |
| ref<mark style="color:red;">\*</mark>               | String | Password reset ref from previous step |
| otp<mark style="color:red;">\*</mark>               | String | Password Reset OTP                    |
| password<mark style="color:red;">\*</mark>          | String | New Password                          |
| confirm\_password<mark style="color:red;">\*</mark> | String | Password Confirmation                 |

{% tabs %}
{% tab title="200: OK Password changed" %}

{% endtab %}

{% tab title="400: Bad Request Reset password request failed. Please try again" %}

{% endtab %}
{% endtabs %}
