> For the complete documentation index, see [llms.txt](https://docs.nekoya.moe.team/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nekoya.moe.team/reference/api-reference/authentication.md).

# Authentication

## Register

<mark style="color:green;">`POST`</mark> `https://nekoya.moe.team/api/register`

#### Headers

| Name                                           | Type   | Description                       |
| ---------------------------------------------- | ------ | --------------------------------- |
| Content-Type<mark style="color:red;">\*</mark> | String | application/x-www-form-urlencoded |

#### Request Body

| Name                                          | Type   | Description              |
| --------------------------------------------- | ------ | ------------------------ |
| email<mark style="color:red;">\*</mark>       | String | <xxx@example.com>        |
| password<mark style="color:red;">\*</mark>    | String | 1 - 64 string characters |
| first\_name<mark style="color:red;">\*</mark> | String | First Name               |
| last\_name<mark style="color:red;">\*</mark>  | String | Last Name                |

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

```javascript
{
    "message": "Register Verification Sent ~"
}
```

{% endtab %}

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

```javascript
{
    "message": "Bad Request"
}
```

{% endtab %}
{% endtabs %}

## Login

## Account without 2FA Enabled

<mark style="color:green;">`POST`</mark> `https://nekoya.moe.team/api/login`

#### Headers

| Name                                           | Type   | Description                       |
| ---------------------------------------------- | ------ | --------------------------------- |
| Content-Type<mark style="color:red;">\*</mark> | String | application/x-www-form-urlencoded |

#### Request Body

| Name                                       | Type   | Description              |
| ------------------------------------------ | ------ | ------------------------ |
| email<mark style="color:red;">\*</mark>    | String | <xxx@example.com>        |
| password<mark style="color:red;">\*</mark> | String | 1 - 64 string characters |
| ua                                         | String | User Agent               |
| ip                                         | String | IP Address               |

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

```javascript
{
    "id": 29,
    "first_name": "Celia",
    "last_name": "Claire",
    "email": "celia@moe.team",
    "verify": true,
    "otp": false,
    "session_token": "2RBHSp3I8jjDzjuKaXXDWadJqRkJ1M3Q8nTmF9mioAL73OVZO8zc73sg4VBCVLQeXQRtbXZ6gQ5r1vjupkzoZP1HiRBXgHw74O7eKki6SPHIDYuxVfAdn6jPZ76HRRqI1jR1aKOdhwMq5RgOK7eMB5HEUKNu6gHIQkncoxRxz1eh5QGwGa9vYPW7TE3izEDbkGEqlIbnGf6O9foTty5HiJilPLtgVFvHUSoN6t7yDMXy2NjI0a4bKu5Pb6de0inh"
}
```

{% endtab %}

{% tab title="205: Reset Content " %}

```javascript
{
    "message": "Sorry Your email is not registered in our system"
}
```

{% endtab %}

{% tab title="204: No Content " %}

```javascript
{
    "message": "Sorry You haven't verified your email"
}
```

{% endtab %}

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

```javascript
{
    "message": "Bad Request"
}
```

{% endtab %}

{% tab title="401: Unauthorized " %}

```javascript
{
    "message": "Unauthorized"
}
```

{% endtab %}
{% endtabs %}

## Account with 2FA Enabled

<mark style="color:green;">`POST`</mark> `https://nekoya.moe.team/api/login`

#### Headers

| Name                                           | Type   | Description                       |
| ---------------------------------------------- | ------ | --------------------------------- |
| Content-Type<mark style="color:red;">\*</mark> | String | application/x-www-form-urlencoded |

#### Request Body

| Name                                       | Type   | Description              |
| ------------------------------------------ | ------ | ------------------------ |
| email<mark style="color:red;">\*</mark>    | String | <xxx@example.com>        |
| password<mark style="color:red;">\*</mark> | String | 1 - 64 string characters |
| ua                                         | String | User Agent               |
| ip                                         | String | IP Address               |

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

```javascript
{
    "message": "OTP Verification Sent ~",
    "otp": true,
    "token": "Xb5VNMMfoWZyHf22EMS3MjmgFdjDnAPTM3OoCh3CYP8sF6ospVzAaTjCPVM5FM5c"
}
```

{% endtab %}

{% tab title="204: No Content " %}

```javascript
{
    "message": "Sorry You haven't verified your email"
}
```

{% endtab %}

{% tab title="205: Reset Content " %}

```javascript
{
    "message": "Sorry Your email is not registered in our system"
}
```

{% endtab %}

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

```javascript
{
    "message": "Bad Request"
}
```

{% endtab %}

{% tab title="401: Unauthorized " %}

```javascript
{
    "message": "Unauthorized"
}
```

{% endtab %}
{% endtabs %}

## OTP

## Submit OTP

<mark style="color:green;">`POST`</mark> `https://nekoya.moe.team/api/otp-submit`

#### Headers

| Name                                           | Type   | Description                       |
| ---------------------------------------------- | ------ | --------------------------------- |
| Content-Type<mark style="color:red;">\*</mark> | String | application/x-www-form-urlencoded |

#### Request Body

| Name                                    | Type   | Description        |
| --------------------------------------- | ------ | ------------------ |
| token<mark style="color:red;">\*</mark> | String | Encrypted String   |
| code<mark style="color:red;">\*</mark>  |        | OTP Code (6 digit) |

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

```javascript
{
    "id": 29,
    "first_name": "Celia",
    "last_name": "Claire",
    "email": "celia@moe.team",
    "verify": true,
    "otp": true,
    "session_token": "2RBHSp3I8jjDzjuKaXXDWadJqRkJ1M3Q8nTmF9mioAL73OVZO8zc73sg4VBCVLQeXQRtbXZ6gQ5r1vjupkzoZP1HiRBXgHw74O7eKki6SPHIDYuxVfAdn6jPZ76HRRqI1jR1aKOdhwMq5RgOK7eMB5HEUKNu6gHIQkncoxRxz1eh5QGwGa9vYPW7TE3izEDbkGEqlIbnGf6O9foTty5HiJilPLtgVFvHUSoN6t7yDMXy2NjI0a4bKu5Pb6de0inh"
}
```

{% endtab %}

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

```javascript
{
    "message": "Bad Request"
}
```

{% endtab %}

{% tab title="403: Forbidden " %}

```javascript
{
    "message": "Invalid OTP Code"
}
```

{% endtab %}
{% endtabs %}

## Enable / Disable OTP

<mark style="color:green;">`POST`</mark> `https://nekoya.moe.team/api/otp-toggle`

#### Query Parameters

| Name                                  | Type   | Description      |
| ------------------------------------- | ------ | ---------------- |
| key<mark style="color:red;">\*</mark> | String | Encrypted String |

#### Headers

| Name                                           | Type   | Description                       |
| ---------------------------------------------- | ------ | --------------------------------- |
| Content-Type<mark style="color:red;">\*</mark> | String | application/x-www-form-urlencoded |

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

```javascript
{
    "message": "Success set OTP to true",
    "otp": true
}
```

{% endtab %}

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

```javascript
{
    "message": "Bad Request"
}
```

{% endtab %}

{% tab title="401: Unauthorized " %}

```javascript
{
    "message": "Unauthorized"
}
```

{% endtab %}
{% endtabs %}

## Verify Account (Mail)

<mark style="color:green;">`POST`</mark> `https://nekoya.moe.team/api/verify-mail`

#### Headers

| Name                                           | Type   | Description                       |
| ---------------------------------------------- | ------ | --------------------------------- |
| Content-Type<mark style="color:red;">\*</mark> | String | application/x-www-form-urlencoded |

#### Request Body

| Name                                    | Type   | Description      |
| --------------------------------------- | ------ | ---------------- |
| token<mark style="color:red;">\*</mark> | String | Encrypted String |

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

```javascript
{
    "message": "Verified ~"
}
```

{% endtab %}

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

```javascript
{
    "message": "Bad Request"
}
```

{% endtab %}

{% tab title="403: Forbidden " %}

```javascript
{
    "message": "Forbidden"
}
```

{% endtab %}
{% endtabs %}

## Reset Password

<mark style="color:green;">`POST`</mark> `https://nekoya.moe.team/api/request-reset-password`

#### Headers

| Name                                           | Type   | Description                       |
| ---------------------------------------------- | ------ | --------------------------------- |
| Content-Type<mark style="color:red;">\*</mark> | String | application/x-www-form-urlencoded |

#### Request Body

| Name                                    | Type   | Description       |
| --------------------------------------- | ------ | ----------------- |
| email<mark style="color:red;">\*</mark> | String | <xxx@example.com> |

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

```javascript
{
    "message": "Reset Password Verification Sent ~"
}
```

{% endtab %}

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

```javascript
{
    "message": "Bad Request"
}
```

{% endtab %}

{% tab title="205: Reset Content " %}

```javascript
{
    "message": "Sorry Your email is not registered in our system"
}
```

{% endtab %}
{% endtabs %}

<mark style="color:green;">`POST`</mark> `https://nekoya.moe.team/api/reset-password`

#### Query Parameters

| Name                                    | Type   | Description      |
| --------------------------------------- | ------ | ---------------- |
| token<mark style="color:red;">\*</mark> | String | Encrypted String |

#### Headers

| Name                                           | Type   | Description                       |
| ---------------------------------------------- | ------ | --------------------------------- |
| Content-Type<mark style="color:red;">\*</mark> | String | application/x-www-form-urlencoded |

#### Request Body

| Name                                       | Type   | Description              |
| ------------------------------------------ | ------ | ------------------------ |
| password<mark style="color:red;">\*</mark> | String | 1 - 64 string characters |

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

```javascript
{
    "message": "Success Reset Password ~"
}
```

{% endtab %}

{% tab title="401: Unauthorized " %}

```javascript
{
    "message": "Unauthorized"
}
```

{% endtab %}

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

```javascript
{
    "message": "Bad Request"
}
```

{% endtab %}
{% endtabs %}

## Active Sessions

## Get All of Active Sessions

<mark style="color:green;">`POST`</mark> `https://nekoya.moe.team/api/sessions`

#### Query Parameters

| Name                                  | Type   | Description      |
| ------------------------------------- | ------ | ---------------- |
| key<mark style="color:red;">\*</mark> | String | Encrypted String |

#### Headers

| Name                                           | Type   | Description                       |
| ---------------------------------------------- | ------ | --------------------------------- |
| Content-Type<mark style="color:red;">\*</mark> | String | application/x-www-form-urlencoded |

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

```javascript
[
    {
        "user_agent": "Mozilla/5.0 (Linux; Android 12; M2012K11AG) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.41 Mobile Safari/537.36",
        "ip": "12.26.220.109",
        "session": "5ES9v6ekrGuuuKEDOpk2COGlmchHldplY10PnIIOuMUVpw32FsJy9aniQyX7RzeVan3muRWlKf02pWnIua127PKF0uPLxEccic8x5VFlN3OsyNFeJM8mdKAduRhwCIcID57vBanPrrYQ5vqv0FGbWcl29rtXk40YDUFvYoqy2VtBx5Us2sW1HYMT5EFrwC7H0T75kyRqL1ZmSJLMLKgPoUkhxOa1AMqqdy2dbSke8pOLQo20B7bgvEmxxyKcrV9C"
    }
]
```

{% endtab %}

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

```javascript
{
    "message": "Bad Request"
}
```

{% endtab %}

{% tab title="401: Unauthorized " %}

```javascript
{
    "message": "Unauthorized"
}
```

{% endtab %}
{% endtabs %}
