> For the complete documentation index, see [llms.txt](https://eohelp.weaver.com.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://eohelp.weaver.com.co/open-api/1-overview.md).

# 1 Overview

Please follow the following rules and combine the actual environment of OA, assemble the Api to call the complete path and initiate the request.

> Full path example: <http://127.0.0.1:8010/eoffice/server/public/api/open-api/get-token>

## Token Validatiion

`OPTIONS` `{eoffice addreee}eoffice/server/public/{api_url}`

For APIs that require token verification, it is necessary to additionally pass the token verification from the header or pass the parameter through api\_token; for the transfer method, refer to the following header and param parameter passing example.

#### Headers

| Name                                            | Type   | Description                                                                                                                                  |
| ----------------------------------------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Pass the api\_token, which is the unique token for accessing the api, and splice 'Bearer' in front of the api\_token as shown in the example |

#### Request Body

| Name       | Type   | Description                          |
| ---------- | ------ | ------------------------------------ |
| api\_token | String | A unique token for accessing the api |

## Get token

<mark style="color:green;">`POST`</mark> `api/open-api/get-token`

In the \[Integration ] \[Open Platform] menu, create a new application, enter the application details through the edit button, and obtain the AgentId and Secret of this application as the input parameters of this interface;

The token returned by this route is a required parameter for subsequent route requests.

#### Request Body

| Name                                        | Type   | Description                                                                                                                                                                                                                              |
| ------------------------------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| agent\_id<mark style="color:red;">\*</mark> | string | The value of the AgentId field on an application details page in the open platform menu                                                                                                                                                  |
| secret<mark style="color:red;">\*</mark>    | string | In the open platform menu, on an application details page, the value of the Secret field                                                                                                                                                 |
| user<mark style="color:red;">\*</mark>      | string | User identity information identification basis; according to the "user identification field" configured by an application, a dynamic value is passed in, associated with the OA user, and a token corresponding to the user is generated |
| local                                       | string | Multilingual encoding; please pass in the internationalization management module, the encoding of the effective language pack in the language pack list                                                                                  |

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

| Field                       | Type   | Description                                                                   |
| --------------------------- | ------ | ----------------------------------------------------------------------------- |
| user                        | string | User ID                                                                       |
| refresh\_token              | string | refresh\_token                                                                |
| token                       | string | Authentication token for accessing the api                                    |
| expired\_in                 | string | The valid time of the verification token for accessing the API (unit: second) |
| refresh\_token\_expired\_in | string | refresh\_token valid time (unit: second)                                      |
| {% endtab %}                |        |                                                                               |

{% tab title="Example" %}

```json
{
    "status": 1,
    "data": {
        "token": "7d4bd6736c8f29b70126c9e5984c7239bcd51fdd031e...",
        "user": "admin",
        "refresh_token": "6d53dbb78499978d6c840ecfaf70b19864f14a...",
        "expired_in": 3600,
        "refresh_token_expired_in": 7200
    },
    "runtime": "0.245"
}
```

{% endtab %}
{% endtabs %}
{% endtab %}
{% endtabs %}

## List API

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

The common parameters that need to be passed by the list API are as follows param.

#### Request Body

| Name      | Type  | Description                                                                     |
| --------- | ----- | ------------------------------------------------------------------------------- |
| PAGE      | int   | The number of pages to be paginated (when page is passed 0, it means no paging) |
| limit     | int   | Items per page                                                                  |
| order\_by | array | sort arry                                                                       |

{% tabs %}
{% tab title="200: OK Paging" %}
{% tabs %}
{% tab title="Return result(Paging)" %}

```json
{
 "total":10,
 "list":[
     {"user_id":"admin","user_name":"Sysadmin", ...},
     {"user_id":"admin1","user_name":"Syadmin1", ...},
     ...
 ]
}
```

{% endtab %}

{% tab title="Return result(No paging)" %}

```json
[
     {"user_id":"admin","user_name":"Sysadmin", ...},
     {"user_id":"admin1","user_name":"Sysadmin1", ...},
     ...
 ]
```

{% endtab %}
{% endtabs %}
{% endtab %}
{% endtabs %}

## Request to return public section GET

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

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

| Field        | Type   | Description           |
| ------------ | ------ | --------------------- |
| status       | int    | return success status |
| data         | Object | return value          |
| {% endtab %} |        |                       |

{% tab title="Successful (with value)" %}

```json
{
 "status":1,//successful status
 "data":{
     ...
 }//return value
}
```

{% endtab %}

{% tab title="Successful (w/o valye)" %}

```json
{
    "status": 1
}
```

{% endtab %}
{% endtabs %}
{% endtab %}

{% tab title="400: Bad Request Bad request" %}
{% tabs %}
{% tab title="Result" %}

| Name         | Type  | Description            |
| ------------ | ----- | ---------------------- |
| status       | int   | return failure status  |
| errors       | array | return failure message |
| {% endtab %} |       |                        |

{% tab title="Failure return(with error message" %}

```json
{
  "status":0,//failure status
  "errors":[
     {
         "code": "0x003024",//error code
         "message": "该用户未开启动态令牌验证"//error message
     }
  ]
}
```

{% endtab %}

{% tab title="Failure return(w/o error message)" %}

```json
{
  "status":0,//Failure status
}
```

{% endtab %}
{% endtabs %}
{% endtab %}
{% endtabs %}

## Custom Query Criteria

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

#### Headers

| Name   | Type | Description                                                                                                                                                                                                                                                                                               |
| ------ | ---- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| search | json | <p>Query conditions, custom fields Freely configure query conditions according to the form modeling field list</p><p></p><p>{ "search": { "field\_1": \[ 1, "=" ], "field\_2": \[ \[ 1, 2 ], "in" ], "field\_3": \[ "name", "like" ], "field\_4": \[ \[ "2020-01-01", "2020-12-30" ], "between" ] } }</p> |

## pass in refresh\_token to refresh the token

<mark style="color:green;">`POST`</mark> `api/open-api/refresh-token`

#### Request Body

| Name                                             | Type   | Description                                            |
| ------------------------------------------------ | ------ | ------------------------------------------------------ |
| token<mark style="color:red;">\*</mark>          | string | Authentication token for accessing the api             |
| refresh\_token<mark style="color:red;">\*</mark> | string | Get the refresh\_token returned by the token interface |

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

| Field        | Type   | Description                                                                   |
| ------------ | ------ | ----------------------------------------------------------------------------- |
| token        | string | Authentication token for accessing the api                                    |
| expired\_in  | string | The valid time of the verification token for accessing the API (unit: second) |
| {% endtab %} |        |                                                                               |

{% tab title="Successful return value" %}

```json
{
    "status": 1,
    "data": {
        "token": "5925324b80604039d394c1451abff4ccd0eb4fd400de...",
        "expired_in": 3600
    },
    "runtime": "0.245"
}
```

{% endtab %}
{% endtabs %}
{% endtab %}
{% endtabs %}

## Get the user information corresponding to the token and refresh the token

<mark style="color:blue;">`GET`</mark> `api/auth/login-info/refresh`

#### Request Body

| Name                                    | Type   | Description                                                                                                                                              |
| --------------------------------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| token<mark style="color:red;">\*</mark> | string | Authentication token for accessing the api                                                                                                               |
| refresh\_new\_token                     | string | By default, only the user information corresponding to the current token is returned; if "true" is passed in, a new token will be generated and returned |

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

| Field         | Type   | Description                                                                                                                            |
| ------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------- |
| current\_user | string | User information corresponding to the current token                                                                                    |
| token         | string | If the refresh parameter is passed in, the new token is returned here, otherwise, the original token is returned with a refresh\_token |

* <br>

{% endtab %}

{% tab title="Example" %}

```json
{
  "status": 1,
  "data": {
      "current_user": {
          "user_id": "admin", // User ID
          "user_name": "System Admin", // username
          "user_accounts": "admin", // user system account
          "dept_id": 2, // Department ID
          "dept_name": "IT Department", // Department Name
          "phone_number": "15601931531", // Mobile
          ...
      },
      ...
      "token": "5f3a3be8d1e89f5d97c2f0f3d917dfb3dd916a424057...",
      "refresh_token": true
  },
  "runtime": "0.750"
}
```

{% endtab %}
{% endtabs %}
{% endtab %}
{% endtabs %}
