# Common

## Ping

<mark style="color:blue;">`GET`</mark> `/`

{% tabs %}
{% tab title="200: OK Access to Cookies XSRF\_TOKEN" %}

```
- Body
    - **name** `string` Host, pod name
    - **ip** `string` Real IP
    - **now** `date` Current time
    - **values** `object` The node is runtime configured and returned when Mode != release
```

{% endtab %}

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

```
- Body
    - **message** `string`
```

{% endtab %}
{% endtabs %}

## Login

<mark style="color:green;">`POST`</mark> `/login`

#### Request Body

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

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

{% endtab %}

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

```
- Body
    - **message** `string`
```

{% endtab %}
{% endtabs %}

## SMS Login Code

<mark style="color:blue;">`GET`</mark> `/login/sms`

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

{% endtab %}

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

```
- Body
    - **message** `string`
```

{% endtab %}
{% endtabs %}

## SMS Login

<mark style="color:green;">`POST`</mark> `/login/sms`

#### Request Body

| Name                                    | Type   | Description    |
| --------------------------------------- | ------ | -------------- |
| phone<mark style="color:red;">\*</mark> | String |                |
| code<mark style="color:red;">\*</mark>  | String | sms login code |

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

{% endtab %}

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

```
- Body
    - **message** `string`
```

{% endtab %}
{% endtabs %}

## TOTP Login

<mark style="color:green;">`POST`</mark> `/login/totp`

#### Request Body

| Name                                    | Type   | Description |
| --------------------------------------- | ------ | ----------- |
| email<mark style="color:red;">\*</mark> | String |             |
| code<mark style="color:red;">\*</mark>  | String | Totp Code   |

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

{% endtab %}

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

```
- Body
    - **message** `string`
```

{% endtab %}
{% endtabs %}

## Reset Password Code

<mark style="color:blue;">`GET`</mark> `/forget_code`

#### Query Parameters

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

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

{% endtab %}

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

```
- Body
  - **message** `string`
```

{% endtab %}
{% endtabs %}

## Reset Password

<mark style="color:green;">`POST`</mark> `/forget_reset`

#### Request Body

| Name                                       | Type   | Description         |
| ------------------------------------------ | ------ | ------------------- |
| email<mark style="color:red;">\*</mark>    | String |                     |
| code<mark style="color:red;">\*</mark>     | String | Reset password code |
| password<mark style="color:red;">\*</mark> | String | Reset password      |

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

{% endtab %}

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

```
- Body
  - **message** `string`
```

{% endtab %}
{% endtabs %}

## Verify

<mark style="color:blue;">`GET`</mark> `/verify`

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

{% endtab %}

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

```
- Body
    - **message** `string`
```

{% endtab %}

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

```
- Body
    - **code** `string` Business code
    - **message** `string`
```

{% endtab %}
{% endtabs %}

## Token Refresh Code

<mark style="color:blue;">`GET`</mark> `/refresh_code`

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

```
- Body
    - **code** `string`
```

{% endtab %}

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

```
- Body
    - **message** `string`
```

{% endtab %}
{% endtabs %}

## Refresh Token

<mark style="color:blue;">`GET`</mark> `/refresh_token`

#### Request Body

| Name                                   | Type   | Description        |
| -------------------------------------- | ------ | ------------------ |
| code<mark style="color:red;">\*</mark> | String | Token refresh code |

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

{% endtab %}

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

```
- Body
    - **message** `string`
```

{% endtab %}
{% endtabs %}

## Logout

<mark style="color:green;">`POST`</mark> `/logout`

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

{% endtab %}
{% endtabs %}

## User Info

<mark style="color:blue;">`GET`</mark> `/user`

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

```
- Body
    - **_id** `string` User ID
    - **email** `string` User email
    - **name** `string` User name
    - **avatar** `string` User avatar
    - **phone** `string` Phone settings status
    - **sessions** `number` Total number of sessions
    - **history** `object` Recent login history
    - **totp** `string` TOTP settings status
    - **lark** `object` Lark info
    - **status** `bool` User status
    - **create_time** `date`
    - **update_time** `date`
```

{% endtab %}

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

```
- Body
    - **message** `string`
```

{% endtab %}
{% endtabs %}

## Set User

<mark style="color:purple;">`PATCH`</mark> `/user`

#### Request Body

| Name                                  | Type   | Description                                 |
| ------------------------------------- | ------ | ------------------------------------------- |
| key<mark style="color:red;">\*</mark> | String | `Email\|Name\|Avatar` Specify updated field |
| email                                 | String | RequiredIf: key=Email                       |
| name                                  | String | RequiredIf: key=Name                        |
| avatar                                | String | RequiredIf: key=Avatar                      |

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

{% endtab %}

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

```
- Body
    - **message** `string`
```

{% endtab %}
{% endtabs %}

## Set Password

<mark style="color:green;">`POST`</mark> `/user/password`

#### Request Body

| Name                                       | Type   | Description  |
| ------------------------------------------ | ------ | ------------ |
| old<mark style="color:red;">\*</mark>      | String | Old password |
| password<mark style="color:red;">\*</mark> | String | New password |

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

{% endtab %}

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

```
- Body
    - **message** `string`
```

{% endtab %}
{% endtabs %}

## User SMS Code

<mark style="color:blue;">`GET`</mark> `/user/phone_code`

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

{% endtab %}

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

```
- Body
    - **message** `string`
```

{% endtab %}
{% endtabs %}

## Bind User's Phone

<mark style="color:green;">`POST`</mark> `/user/phone`

#### Request Body

| Name                                    | Type   | Description  |
| --------------------------------------- | ------ | ------------ |
| phone<mark style="color:red;">\*</mark> | String | Phone number |
| code<mark style="color:red;">\*</mark>  | String | SMS code     |

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

{% endtab %}

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

```
- Body
    - **message** `string`
```

{% endtab %}
{% endtabs %}

## Generate TOTP URL

<mark style="color:blue;">`GET`</mark> `/user/totp`

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

```
- Body
    - **totp** `string` TOTP URL
```

{% endtab %}

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

```
- Body
    - **message** `string`
```

{% endtab %}
{% endtabs %}

## Bind TOTP

<mark style="color:green;">`POST`</mark> `/user/totp`

#### Request Body

| Name                                   | Type      | Description          |
| -------------------------------------- | --------- | -------------------- |
| totp<mark style="color:red;">\*</mark> | String    | TOTP URL             |
| tss<mark style="color:red;">\*</mark>  | String\[] | Two consecutive code |

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

{% endtab %}

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

```
- Body
    - **message** `string`
```

{% endtab %}
{% endtabs %}

## Unset User

<mark style="color:red;">`DELETE`</mark> `/user/:key`

#### Path Parameters

| Name                                  | Type   | Description                               |
| ------------------------------------- | ------ | ----------------------------------------- |
| key<mark style="color:red;">\*</mark> | String | `phone\|totp\|lark` Specify updated field |

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

{% endtab %}

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

```
- Body
    - **message** `string`
```

{% endtab %}
{% endtabs %}

## Load Option

<mark style="color:blue;">`GET`</mark> `/options`

#### Query Parameters

| Name                                   | Type   | Description                                         |
| -------------------------------------- | ------ | --------------------------------------------------- |
| type<mark style="color:red;">\*</mark> | String | Type, include: upload、collaboration、generate-secret |

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

{% endtab %}

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

```
- Body
    - **message** `string`
```

{% endtab %}
{% endtabs %}
