NeuroQ: Anylink Cloud Rest API

The token authentication of the following APIs adds support for Authorization: Bearer [token] in http/https request header. At the same time, it also continues to support the way of carrying tokens in the request body. If both the request body and the header contain a token, the one in the header shall prevail.

The old way of carrying tokens in the request body will be deprecated in the future releases, please switch to the new way of using bearer header token in your new releases.

The following image shows how to add a Authorization: Bearer [token] in the header when using postman to call the interface:
image-20220212121738282image-20220212121738282

1. Get token for AnylinkCloud UI

This token is for the following APIs only, for all other APIs, please use 2. Get token for AnylinkCloud API instead :

In AnyLink Cloud, there're two type of users, one is tenant user, which is used to login into the AnyLink cloud system via web UI, the other is API user, which is used to make API calls into AnyLink Cloud. And the user name here is tenant user name not AnyLink Cloud API user name.

The token is valid for 10 hours. After the timeout, you need to obtain a new token.

Request type: POST

url: /user/getToken

Parameters: JSON

ParametersTypeRequiredComment
tenantEnameStringYesTenant name
nameStringYesTenant user name
passwordStringYesPassword
hashStringYesUse ‘tetrascience’

Return value: JSON

ParametersTypeComment
statusStringreturn code:
100: successful
103: invalid parameter
107: tenant name not exist
unknown username
115: this user is locked
116: error password
111:other errors
msgStringDetail error message
dataStringToken value

Sample request:

{
    "tenantEname": "tetrascience",
    "name": "admin",
    "password": "123456",
    "hash": "tetrascience"
}

Sample response:

{
    "status":"100",
    "data":"dc91c34b-6a11-437a-ab8e-fa6fdc3e547b"
}

2. Get token for AnylinkCloud API

Function: This token is used to call Anylink Cloud APIs.
The token is valid for 10 hours. After the timeout, you need to obtain a new token.

Request type: POST

url: /user/login

Parameters:

ParametersTypeRequiredComment
nameStringyesAnyLink cloud API User name
hashStringyeshash code. Use ‘tetrascience’
passwordStringyesAnyLink cloud API password
{
    "name": "apiuser",
    "password": "123456",
    "hash": "tetrascience"
}

Return value: JSON

ParametersTypeComment
statusStringreturn code:
100: successful
103: parameter error
107: There will be the following two situations:
username or password is error
username does not exist
111: For some other errors, refer to the "msg" value.
msgStringerror message
dataStringtoken
{
    "status": "100",
    "data":"dc91c34b-6a11-437a-ab8e-fa6fdc3e547b"
}

3. Change AnylinkCloud API password

Function: Change the password for AnylinkCloud API user(The token can be obtained through the interface '/user/login' of AnylinkCloudAPI).

Request type: PUT

url: /user/password

Parameters:

ParametersTypeRequiredComment
tokenStringyesUser token, this token is obtained through /user/login
hashStringyeshash code
passwordStringyesnew password

Sample request: /user/password?token=dc91c34b-6a11-437a-ab8e-fa6fdc3e547b&hash=test&password=1234567

Return value: JSON

ParametersTypeComment
statusStringreturn code:
100: successful
101: Please use system administrator account
103: parameter error
104: invalid token
111: For some other errors, refer to the "msg" value.
msgStringerror message
{
    "status":"100"
}

4. Get AnylinkCloud deviceId by serialnumber and device name

Function: Get AnylinkCloud deviceId by serialnumber and device name

Request type: GET

url: /devicelist/getDeviceID

Parameters:

ParametersTypeRequiredComment
tokenStringyesUser token
hashStringyeshash (use ‘tetrascience’)
deviceNameStringyesdevice name
agentIDIntegeryesserialnumber

Return value: JSON

ParametersTypeComment
statusStringreturn code:
100: successful
103: parameter error
104: invalid token
111: For some other errors, refer to the "msg" value.
msgStringerror message
dataIntegerAnylink device id

Sample request:

/devicelist/getDeviceID?token=08a67a16-9e96-4bfd-8492-3f415585639c&hash=tetrascience&deviceName=test&agentID=1700631

Sample response:

{
    "status": "100",
    "data": 1228801025,
}

5. Send ASCII command to RS232

Function: Send ASCII command to RS232 on a specified device

Request type: POST

url: /control/device

Parameters: JSON

ParametersSub ParametersTypeRequiredComment
tokenStringyesUser token. Both types of tokens are available
hashStringyeshash is not used for now(use ‘tetrascience’ as example and null is OK too)
serialNumberIntegeryesAnyLink box serial number
deviceIdIntegeryesAnylink cloud device id. This value must be configured with libTetraSerialCmd driver.
driverNameStringyesDriver name, the value is libTetraSerialCmd, cannot be other values.
cmdsJSONArray array of commands, multiple commands are allowed
indexIntegeryesA unique index of commands, used to distinguish different commands
serialStringyesSemicolon separated Serial port communication parameters: "portNo;baudRate;parity;dataBit;stopBit;timeout". For example: "485_1;9600;N;8;1;5000" timeout is in milliseconds
typeStringyesData type, default to ascii
cmdStringyesContent of command, base64 encoded utf-8 characters.
res_lenIntegeryesExpected max return length. res_len is a required parameter, if res_len is not specified, the driver does not respond until timeout.
If res_len <= 0 , the driver will not accept the data value returned by any device, and directly return success after writing the command, and return the empty value( "res_data": "", "res_len": 0,)
If res_len > 0, the driver will enter listening state according to the timeout parameter after writing the command and wait for the response of the device. If the device data received within the timeout is longer than res_len, exit listening in advance. After exiting listening, the driver will return the device data to the API.
If res_len is too large, the driver will wait until it receives enough data or time out.
If res_len is too small, the driver will cut the data returned by device.

Return value: JSON

ParametersSub ParametersTypeComment
statusStringreturn code:
100: successful
102: REST API call timeout
103: parameter error, such as "cmd cannot be empty", "invalid base64 encoding"
104: invalid token
111: For some other errors, refer to the "msg" value.
125: Anylink box is offline
msgString
respsJSONArrayResponses from commands
indexIntegercommand index
res_dataStringContent of command response, base64 encoded utf-8 characters.
res_errorStringError message from the agent, i.e. "Can't Open Serial Port!" when USB cable is unplugged from the IoT box
res_lenIntegerLength of command response
rsIntegerCommand result: 0: success -1: failure 7: Driver not found
useridStringIdentification code used to obtain control results via API /control/result.

Sample request:

{
    "token":"f53073f3-ef67-4bb5-a152-eab3f3139331",
    "hash":"1234",
    "serialNumber":1700631,
    "deviceId":1741446148,
    "driverName":"libTetraSerialCmd",
    "cmds":[
        {
            "index":1,
            "serial":"/dev/ttyUSB0;9600;None;8;1;5000",
            "type":"ascii",
            "cmd":"VGhpcyBpcyBhIHJlcXVlc3QgdGVzdA==",
            "res_len":10
        }
    ]
}

"serial":"/dev/ttyUSB0;9600;None;8;1;5000" The last value is the timeout (time in ms)

Sample response:

{
    "resps": [
        {
            "index": 1,
            "res_data": "dGhpcyBpcyBhIHJlc3BvbnNlIHRlc3Qh",
            "res_len": 24,
            "rs": 0,
            "userid": "1609836987877325"
        }
    ],
    "status": "100"
}
{
    "msg": "Anylink box is offline",
    "status": "125"
}
{
    "msg": "cmd cannot be empty",
    "status": "103"
}
{
    "msg": "Get command response timeout.",
    "status": "102"
}

6. How to configure Device for RS232

Here’s the sample configuration for device in the AnyLink box:

<model n="Http2Serial" id="1">
    <device n="Http2Serial1" id="1" ip="192.168.1.1" type="test">
        <driver n="IDrv.Custom:libTetraSerialCmd" config="">
            <commDataItems/>
        </driver>
    </device>
</model>

If the driver to be upgraded is task driver, you should add the driver both in task driver and model/device/driver. Dont forget the version attribute. The configuration is as follows:

<task>
    <TaskDriver>
      <driver config="test" id="1" n="T.IDrv.Task:libTUsbtenki" version="1.0.2"/>
    </TaskDriver>
</task>
<model config="test" d="T.IDrv.Task:libTUsbtenki" id="1" n="task">
    <device id="1" ip="192.168.1.1" n="DIP-production-tetrascience-1701354-1" type="test">
      <driver config="" id="1" n="T.IDrv.Task:libTUsbtenki" version="1.0.2">
        <commDataItems>
          <dataItem alias="temperature" config="0" freq="60000" id="1" n="temp" report="1" rw="1" type="a"/>
        </commDataItems>
      </driver>
    </device>
</model>

7. Get AnyLink IoT agent firmware version

Function: Get firmware versions for agent, web, script from AnyLink IoT box

Request type: GET

url: /anylinkAttribute

Parameters:

ParametersTypeRequiredComment
tokenStringyesUser token. Both types of tokens are available
serialNumberIntegeryesAnyLink box serial number

Response: JSON

ParametersTypeComment
statusStringreturn code:
100: successful
103: parameter error
104: invalid token
111: For some other errors, refer to the "msg" value.
msgStringerror message
dataJSONObject
agentVersionStringagent version
scriptVersionStringscript version
webVersionStringweb for Anylink configuration
serialNumberIntegerAnyLink box serial number

Sample request:

{
    "token":"96acfbae-e27b-48ee-b3be-f6c3363feee1",
    "serialNumber": 1700630,
}

Sample response:

{
    "status":"100",
    "data":{
        "agentVersion":"3.7.16",
        "scriptVersion":"2.6.6",
        "serialNumber":1700630,
        "webVersion":"3.5.4"
    }
}

8. Gets the historical data of a dataitem

Function: Get the historical data of a dataitem

Request type: GET

url: /historydata

Parameters:

ParametersTypeRequiredComment
tokenStringyesUser token.
hashStringyeshash(use ‘tetrascience’)
deviceidIntegeryesAnylinkCloud device id
dataitemidStringyesAnylinkCloud dataitem id
stimeLongnoStart time, UTC timestamp in milliseconds. If this value is empty, the default value is 12 hours before the current time.
etimeLongnoEnd time, UTC timestamp in milliseconds. If this value is empty, the default value is current time.

Return value: JSON

ParametersTypeComment
statusStringreturn code:
100: successful
103: parameter error
104: invalid token
111: For some other errors, refer to the "msg" value.
msgStringerror message
dataarray
devidStringAnylinkCloud device id
itemidStringDataitem id
itemnameStringDataitem name
aliasStringDataitem alias
valStringHistory value
htimeStringUTC timestamp string
datatypeStringdata type, e.g 'a', 'b', 's'
readOnlyBooleantrue: read-only, false: writable

Sample request: /historydata?token=fd361aec-6173-4518-8b89-09c21565af52&deviceid=1435394049&dataitemid=1&hash=test&stime=1536570000000&etime=1536573600000

Sample Response:

{
    "status":"100",
    "data":[
        {
            "alias":"channel0",
            "datatype":"a",
            "datatypeName":"decimal",
            "devName":"SHT31",
            "devid":"1435394049",
            "htime":"2018-09-10 05:42:33.0",
            "itemid":"1",
            "itemname":"channel0",
            "readOnly":true,
            "val":"3465.041748046875"
        },
        {
            "alias":"channel0",
            "datatype":"a",
            "datatypeName":"decimal",
            "devName":"SHT31",
            "devid":"1435394049",
            "htime":"2018-09-10 05:42:23.0",
            "itemid":"1",
            "itemname":"channel0",
            "readOnly":true,
            "val":"99518.921875"
        }
    ]
} 

The following APIs(9-13) are the remote configuration of WiFi

9. Issue command to the agent, and the agent uploads the configuration file

Function: Issue the control command to the agent, and the agent uploads the configuration file

Request type: PUT

url: /remoteAgent/uploadCmd

Parameters:

ParametersTypeRequiredComment
tokenStringyesUser token. Both types of tokens are available
hashStringyeshash(use ‘tetrascience’)
filetypeStringyesType of file to upload: anylink_xml(for WIFI config), idinfo_xml alldevicedriver_xml, config_xml
serialnumberIntegeryesAnyLink box serial number

Return value: JSON

ParametersTypeComment
statusStringreturn code:
100: successful
103: parameter error, such as "File type must be one of the following: anylink_xml, idinfo_xml, alldevicedriver_xml, config_xml"
104: invalid token
99: failed to send command to agent. Failure reason: refer to "msg" value
111: For some other errors, refer to the "msg" value.
msgStringerror message
dataStringIdentification code used to obtain control results
{
    "status": "100",
    "data": 1415844000000
}

10. Get the result for a command

Function: Get the result for the command (you need to loop until you get the result). Now the timeout is 90s, if there's no response when timeout is triggered, API will consider it as timeout. The result from /control/result will be

{
    "status":100,
    "data":"3"
}

3 means timeout.

Request type: GET

url: /control/result

Parameters:

ParametersTypeRequireComment
tokenStringyesUser token. Both types of tokens are available
hashStringyeshash(use ‘tetrascience’)
signStringyesGet the result for the command,this is the data value from API "/remoteAgent/uploadCmd"

Return value: JSON

ParameterTypeComments
statusStringreturn code:
100: successful
103: parameter error
104: invalid token
111: For some other errors, refer to the "msg" value.
msgStringerror message
dataStringResult(0:success,3:overtime,others:failed)
{
    "status":"100",
    "data":"0"
}

11. Get the Agent Configuration XML file for a specific IoT box

Function: Get the XML file that Anylink uploaded. Before calling this API, you must first issue a command to the agent through the interface /remoteagent/uploadcmd to let the agent upload the configuration file to the server.

Request type: GET

url: /device/readAnylinkXml

Parameters: JSON

ParametersValueRequiredComments
tokenStringyesUser token. Both types of tokens are available
hashStringyeshash(use ‘tetrascience’)
xmlTypeStringyesXML file type: anylink_xml(for WIFI config), config_xml
serialNumberIntegeryesAnyLink box serial number

Return value: JSON

ParametersValueComments
statusStringreturn code:
100: successful
103: parameter error
104: invalid token
111: For some other errors, refer to the "msg" value.
dataStringResult
msgStringError message

Response example:

{
    "status":"100",
    "data":"<AnyLink><BasicInfo><HardwareModel>AnyLink 200</HardwareModel><AgentVersion>V3.6.6</AgentVersion><SoftVersion>DA-3.3.77</SoftVersion><SerialNumber>1400032</SerialNumber></BasicInfo>.......<NetworkInfo muti="YES" hostname="id0032"><Mode>gateway</Mode><Model>simcom</Model><WAN dhcp="NO" mask="255.255.255.0" gateway="192.168.100.1" dns="114.114.114.114" ip="192.168.100.215"/><LAN dhcp="NO" mask="255.255.255.0" gateway="192.168.101.1" dns="114.114.114.114" ip="192.168.101.204"/></NetworkInfo><VPN display="YES"/><Wifi><W_Modestatus>start</W_Modestatus><W_SSID>redbudtek-Guest</W_SSID><W_Password/><W_Status>COMPLETED</W_Status><W_IP>192.168.1.113</W_IP><W_DHCP>YES</W_DHCP><W_GATEWAY>0.0.0.0</W_GATEWAY><W_STRONG>-79</W_STRONG><W_NETMASK>255.255.255.0</W_NETMASK></Wifi>......</AnyLink>"
}

12. Send Agent configuration file (Anylink.xml or ModuleConfig.xml) to agent

Function: Send configuration file to agent

Request type: POST

url: /remoteAgent/sendAnylinkXML

Parameters:

ParametersValueRequiredComments
tokenStringyesUser token. Both types of tokens are available
hashStringyeshash(use ‘tetrascience’)
filetypeStringyesXML file type: anylink_xml(for WIFI config), config_xml (ModuleConfig.xml for agent)
serialnumberIntegeryesAnyLink box serial number
anylinkTypeStringnoFor WIFI configuration,filetype=”anylink_xml”, anylinkType="WIFI", otherwise leave this empty
contentStringyesSend content

Example for WIFI configuration:

{
     "token":"8fa07284-661c-4aec-99ad-38e894c8ebe0",
     "filetype":"anylink_xml",
     "serialnumber":1401868,
     "anylinkType": "WIFI",
     "content": "<AnyLink>......</AnyLink>"
}

Example for config_xml:

{
     "filetype":"config_xml",
     "serialnumber":1401868,
     "token":"8fa07284-661c-4aec-99ad-38e894c8ebe0",
     "content":"<agent ......</agent>"
}

Reponse value:

ParametersTypeComments
statusStringreturn code:
100: successful
103: parameter error, such as "For file type anylink_xml, anylinkType is required, and the value can be one of the following: SYNC, LANIP, WIFI", "Invalid XML content."
104: invalid token
99: Configuration file can only be uploaded when Anylink box is online.
111: For some other errors, refer to the "msg" value.
dataLongThe register ID of this distribution operation is used when calling the interface to get the registration result (/agent/register)
msgStringError message
{
    "status":"100",
    "data":"1534311799247"
}
{
    "status": "99",
    "msg": "Configuration file can only be uploaded when Anylink box is online."
}

Anylink.xml structure:

<AnyLink> 
  <BasicInfo> 
    <HardwareModel>AnyLink 100</HardwareModel>  
    <AgentVersion>V3.6.7</AgentVersion>  
    <SoftVersion>DA-3.4.7</SoftVersion>  
    <SerialNumber>1401561</SerialNumber> 
  </BasicInfo>  
  <ZigbeeInfo> 
    <Type>0</Type>  
    <NetNumber>50</NetNumber>  
    <NetAddress>0</NetAddress>  
    <Physchannel>19</Physchannel> 
  </ZigbeeInfo>  
  <LoraInfo> 
    <g_baudrate>9600</g_baudrate>  
    <g_parity>NONE</g_parity>  
    <g_RF_freq>443</g_RF_freq>  
    <g_RF_factor>10</g_RF_factor>  
    <g_RF_mode>normal</g_RF_mode>  
    <g_RF_BW>125K</g_RF_BW>  
    <g_ID_H>0</g_ID_H>  
    <g_ID_L>0</g_ID_L>  
    <g_net_ID>0</g_net_ID>  
    <g_power>20db</g_power> 
  </LoraInfo>  
  <NetworkInfo muti="YES" hostname="id1561"> 
    <Mode>gateway</Mode>  
    <Model>simcom</Model>  
    <WAN mac="C4:F3:12:F2:F2:B3" dns="114.114.114.114" ip="192.168.100.220" dhcp="NO" mask="255.255.255.0" gateway="192.168.100.1"/>  
    <LAN mac="C4:F3:12:F2:F2:B5" dns="114.114.114.114" ip="192.168.101.204" dhcp="NO" mask="255.255.255.0" gateway="192.168.101.1"/> 
  </NetworkInfo>  
  <VPN display="YES"/>  
  <Wifi> 
    <W_Modestatus>start</W_Modestatus>  
    <W_SSID>redbudtek-Guest</W_SSID>  
    <W_Password>82602929</W_Password>  
    <W_Status>COMPLETED</W_Status>  
    <W_IP>192.168.1.113</W_IP>  
    <W_DHCP>YES</W_DHCP>  
    <W_GATEWAY>0.0.0.0</W_GATEWAY>  
    <W_MAC>EC:3D:FD:30:91:50</W_MAC>  
    <W_STRONG>-83</W_STRONG>  
    <W_NETMASK>255.255.255.0</W_NETMASK>  
    <!-- Fill in here when sending multiple WiFi messages remotely -->  
    <W_Remote> 
      <W_List> 
        <W_Info> 
          <W_SSID>ssid1</W_SSID>  
          <W_Password>password1</W_Password> 
        </W_Info>  
        <W_Info> 
          <W_SSID>ssid1</W_SSID>  
          <W_Password>password1</W_Password> 
        </W_Info> 
      </W_List> 
    </W_Remote> 
  </Wifi>  
  <CloudInfo> 
    <Address>s1.anylinkcloud.com:8686</Address> 
  </CloudInfo>  
  <ApnInfo> 
    <IsAuto>0</IsAuto>  
    <Apn/>  
    <Proxy/>  
    <Port/>  
    <Username/>  
    <Password/> 
  </ApnInfo>  
  <TimeZoneInfo> 
    <TimeZone>UTC</TimeZone> 
  </TimeZoneInfo>  
  <AgentConfig> 
    <AgentMode>0</AgentMode>  
    <UploadType>1</UploadType>  
    <RegRetryCount>100</RegRetryCount>  
    <QueueSize>1</QueueSize>  
    <Protocol>mqtt</Protocol>  
    <LogPath/>  
    <AlarmMode>0</AlarmMode>  
    <DBEnable>1</DBEnable>  
    <DBSize>10000</DBSize>  
    <DBScanTime>3</DBScanTime>  
    <BadDataMode>0</BadDataMode> 
  </AgentConfig> 
</AnyLink>
ElementCommentsValue
W_ModestatusWifi modestart,stop
W_SSIDWifi name
W_PasswordWifi password
W_StatusDeprecatedDeprecated
W_IPWifi ip addressAutomatic acquisition
W_MACMAC address of WiFi moduleAutomatic acquisition
W_DHCPWhether WiFi automatically obtains IPAt present, it can only be set to YES. Only automatic acquisition is supported, and manual modification is not supported.
W_GATEWAYWifi gatewayAutomatic acquisition
W_STRONGWifi signal strengthAutomatic acquisition
W_NETMASKWiFi subnet maskAutomatic acquisition
W_RemoteHidden WiFi listFill in here when sending multiple WiFi messages remotely

Multi-WiFi settings:

(1)The WiFi module will select the available WiFi with the best signal in the W_List to connect

(2)When the WiFi list sent to Anylink, it will be completely overwritten, that is, all the old WiFi lists will be deleted. If you want to retain the old wifi, you also need to keep them in the new configuration

ModuleConfig.xml structure:

<agent flag="SET-TASKS" id="{{IoTBox-SerialNumber}}" n="{{Agent-Name}}" port="-1" script="1.1.0" sdmwebs="1.1.0" timezone="UTC"> 
  <model n="{{Model-Name}}"> 
    <device n="DeviceName" id="3" ip="192.168.1.1" type="test"> 
      <driver config="1;0" id="3" n="T.IDrv.Task:libTModbus" version="1.4.3"> 
        <commDataItems> 
          <dataItem n="A1" alias="A1_alias" config="" freq="60000" id="34" report="1" rw="0" type="a"/>  
          <dataItem n="A2" alias="A2_alias" config="" freq="60000" id="35" report="1" rw="0" type="b"/> 
        </commDataItems> 
      </driver> 
    </device> 
  </model>  
  <task> 
    <TaskDriver> 
      <driver config="10001" n="T.IDrv.Task:libcontrol"/> 
    </TaskDriver>  
    <TaskDriver> 
      <driver config="NULL;115200;8;N;1;0;1;0;0;localhost;10001;6;60;1;10000;3" n="T.IDrv.Task:libzigbee"/> 
    </TaskDriver>  
    <TaskDriver> 
      <driver config="us-s1.anylink.io;8883;us-s1.anylink.io;8883;60;2;0;0;;;;1;-1" n="T.IDrv.Task:libkmqtt"/> 
    </TaskDriver>  
    <TaskDriver>AnyLink LLC Page 3 | 3 
      <driver config="1" n="T.IDrv.Task:libtremoteplc"/> 
    </TaskDriver>  
    <TaskDriver> 
      <driver config="rtu;/dev/ttymxc2;9600;Even;7;1;STANDARD;200;100;20" id="3" n="T.IDrv.Task:libTModbus" version="1.4.3"/> 
    </TaskDriver> 
  </task>  
  <model n="ra-model"> 
    <device id="1023" ip="127.0.0.1" n="ra-device"> 
      <driver config="1;wlan0;" n="T.IDrv.Task:libtremoteplc"> 
        <commDataItems> 
          <dataItem addr="" config="" freq="120000" id="1" n="CSQ" report="1" rw="0" type="a" vtype=""/>  
          <dataItem addr="" config="" freq="120000" id="2" n="NET-TYPE" report="1" rw="0" type="s" vtype=""/>  
          <dataItem addr="" config="" freq="120000" id="3" n="WAN-IP" report="1" rw="0" type="s" vtype=""/>  
          <dataItem addr="" config="" freq="120000" id="4" n="WAN-MAC" report="1" rw="0" type="s" vtype=""/>  
          <dataItem addr="" config="" freq="120000" id="5" n="WIFI-LIST" report="1" rw="0" type="s" vtype=""/>  
          <dataItem addr="" config="" freq="120000" id="6" n="WIFI-IP" report="1" rw="0" type="s" vtype=""/>  
          <dataItem addr="" config="" freq="120000" id="7" n="WIFI-MAC" report="1" rw="0" type="s" vtype=""/>  
          <dataItem addr="" config="" freq="120000" id="8" n="WIFI-SSID" report="1" rw="0" type="s" vtype=""/>  
          <dataItem addr="" config="" freq="120000" id="9" n="WIFI-STRONG" report="1" rw="0" type="s" vtype=""/>  
          <dataItem addr="" config="" freq="120000" id="10" n="WIFI-DHCP" report="1" rw="0" type="s" vtype=""/>  
          <dataItem addr="" config="" freq="120000" id="11" n="UPTIME" report="1" rw="0" type="s" vtype=""/>  
          <dataItem addr="" config="" freq="120000" id="12" n="WIFI-BSSID" report="1" rw="0" type="s" vtype=""/>  
          <dataItem addr="" config="" freq="120000" id="13" n="USB-DEVS" report="1" rw="0" type="s" vtype=""/>  
          <dataItem addr="" config="" freq="120000" id="14" n="GPS-MCC" report="1" rw="0" type="s" vtype=""/>  
          <dataItem addr="" config="" freq="120000" id="15" n="GPS-MNC" report="1" rw="0" type="s" vtype=""/>  
          <dataItem addr="" config="" freq="120000" id="16" n="GPS-LAC" report="1" rw="0" type="a" vtype=""/>  
          <dataItem addr="" config="" freq="120000" id="17" n="GPS-CID" report="1" rw="0" type="a" vtype=""/>  
          <dataItem addr="" config="" freq="120000" id="18" n="MEMORY" report="1" rw="0" type="s" vtype=""/>  
          <dataItem addr="" config="" freq="120000" id="19" n="STORAGE" report="1" rw="0" type="s" vtype=""/>  
          <dataItem addr="" config="" freq="120000" id="20" n="GPS-LONGITUDE" report="1" rw="0" type="s" vtype=""/>  
          <dataItem addr="" config="" freq="120000" id="21" n="GPS-LATITUDE" report="1" rw="0" type="s" vtype=""/>  
          <dataItem addr="" config="" freq="120000" id="22" n="WIFI-TYPE" report="1" rw="0" type="s" vtype=""/>  
          <dataItem addr="" config="" freq="120000" id="23" n="WIFI-HIDDEN" report="1" rw="0" type="s" vtype=""/> 
        </commDataItems> 
      </driver> 
    </device> 
  </model> 
</agent>
ElementAttributeRequiredDescription
agentidYesAgent Serial Number
nYesAgent name: letters, numbers and '-', '+' are allowed
portYesReserved, default is -1
scriptYesScript version
sdmwebsYesLocal web UI version
timezoneYesAgent timezone
FlagYesReserved, default is SET-TASKS
agent/task/TaskDriver/drivernYesTask driver name: file name of driver without file extention
configYesTask driver config string
idNoTask driver id, if task driver is used in the device element, the driver id's in the&lt;TaskDriver&gt; and &lt;device&gt; must match.
versionNoTask driver version
agent/modelnYesDevice model name
agent/model/deviceidYesDevice ID,ra-device must have id as 1023
nYesDevice name: letters, numbers and '-', '+' are allowed
ipYesReserved attribute, default to 192.168.1.1
agent/model/device/drivernYesDriver name
configYesDriver config string: usually defines how driver communicates with data source. Thisis driver specific, please refer each driver document for detail.
versionNoDriver version.
idNoTask driver id, if task driver is used in the device element, the driver id's in the&lt;TaskDriver&gt; and &lt;device&gt; must match.
agent/model/device/driver/commDataItems/dataItemidYesData item id
nYesData item name
aliasNoData item name alias
configYesReserved.
freqYesData item upload frequency
reportYesWhether to upload this data item, 1: upload, 0: not upload
rwYesWhether this data item value is writable from cloud,1: writable
typeYesData item type,'a' is numerical value, 'b' is Boolean, 's' is string
vtypeYesReserved

dataitem.type

ValueCommentsCorresponding data type
anumerical valueBYTE, WORD, DWORD, FLOAT, uint8, int8, uint16, int16, uint32, int32
bbooleanBOOLEAN
sStringSTRING

dataitem.config

IndexlibDModbus
1Slave address
2Function code
3Data address
4Operation mode
5Data type
6Now this is invalid
71—Small end alignment,0—Big end alignment
8Lora network ID,-1 means invalid

MQTT configuration

<TaskDriver>
    <driver n="T.IDrv.Task:libkmqtt" config="192.168.100.102;8883;192.168.100.102;8883;60;2;0;0;admin;public;;1;" />
</TaskDriver>

The items in config are as follows:

phost;pport;shost;sport;keepalive;qos;retain;bencode;user;password;bindaddr;btls;

CommentsRecommended value
phostMQTT server address
pportMQTT server portSSL:8883
Non SSL:1883
shostMQTT server address
sportMQTT server portSSL:8883
Non SSL:1883
keepalivetime(use default value)60
qosMessage quality (use default value)2
retainRetain value of MQTT message0
bencodeUser name and password encryption,0-None,1-base640
userSSL username
passwordSSL password
bindaddrNull valueNull value
btlsWhether open TLS1 -- SSL
0 -- tcp

13. Query the result of sending XML file

Function: After send the configuration file to Anylink box, the agent will register to again. This interface is used to obtain the registration result.

Request type GET

url: /agent/register

Prameters: JSON

ParametersTypeRequiredComment
tokenStringyesUser token. Both types of tokens are available
serialNumberIntegeryesAnyLink box serial number
registerIDLongyesThe value is the data from /remoteAgent/sendAnylinkXML

Response: JSON

ParametersTypeComments
statusStringreturn code:
100: successful,
102: Timeout
103: parameter error,
104: invalid token
122: AnyLink box is waiting to register.
123: Registration failed
125: Get status failed because AnyLink box is offline.
126: Registering
111: For some other errors, refer to the "msg" value.
msgStringError message

14. Upload OTA upgrade file

Function: Uplaod OTA upgrade file to AnylinkCloud. oldVersion + newVersion is the unique index, if this record exist, it will be covered by new file, otherwise new file will be added.

Request type: POST

url: /ota/addOTAVersion

Prameters: form-data

ParametersTypeRequiredComment
tokenStringyesUser token. Both types of tokens are available
oldVersionStringyesThe agent version for which the upgrade package is applicable. Multiple version numbers are separated by commas, e.g. "3.7.0,3.7.1".
newVersionStringyesUpgraded version
fileNameStringyesFile name of upgrade file
fileStreamFileyesFile stream of upgrade file

Response: JSON

ParametersTypeComments
statusStringreturn code:
100: successful
103: parameter error
104: invalid token
111: For some other errors, refer to the "msg" value.
133: otaUpgradeFilePath is null
msgStringError message

15. Add Driver Version

Function: Upload driver upgrade file to AnylinkCloud.

Request type: POST

url: /addDriverVersion

Prameters: form-data

ParametersTypeRequiredComment
tokenStringYesUser token. Both types of tokens are available
agentVersionStringYesThe agent version for which the upgrade package is applicable. Multiple version numbers are separated by commas, e.g. "3.7.0,3.7.1". You can also fill in the version range, separated by "-", e.g. "3.0.1-3.2.0".
driverNameStringYesDriver name
driverVersionStringYesDriver version
fileNameStringYesFile name of upgrade file, and correct suffix is required.
fileStreamFileYesFile stream of upgrade file
anylinkModelStringYesAnylink model, such as DA, IE, IE Pro, WINDOWS
descriptionStringNoYou can add some useful description information for the driver.
remarkStringNo

Response: JSON

ParametersTypeComments
statusStringreturn code:
100: successful
103: parameter error
104: invalid token
111: For some other errors, refer to the "msg" value.
133: rddUpgradeFilePath is null
msgStringError message

16. Get driver list

Function: Get the driver list uploaded to AnylinkCloud.

Request type: GET

url: /rdd/rddVersionList

Prameters:

ParametersTypeRequiredComment
tokenStringYesUser token. Both types of tokens are available
pageIntegerNoPage number, starting from 1. Default value is "1"
perPageIntegerNoNumber of data per page. Default value is "10"
driverVersionStringNoDriver version
driverNameStringNoDriver name
agentVersionStringNoThe agent version for which the upgrade package is applicable.
anylinkModelStringNoAnylink model, such as DA, IE, IE Pro, WINDOWS

Response: JSON

{
    "status": "100",
    "data": [
        {
            "id": 1,
            "anylinkModel": "IE",
            "anylinkVersion": "3.7.21",
            "driverName": "libddemo1",
            "driverVersion": "1.1.1",
            "fileName": "libddemo1_IE_1.1.1_3.7.21.zip",
            "filePath": "/usr/apps/sdmconfig-new/rdd/IE/libddemo1_IE_1.1.1_3.7.21.zip",
            "description": "test",
            "remark": "test",
            "createTime": 1622693107060,
            "updateTime": 1622693107060
        }
    ]
}

17. Delete driver file

Function: Delete one driver file uploaded to AnylinkCloud

Request type: DELETE

url: /rdd/deleteRddVersion

Prameters:

ParametersTypeRequiredComment
tokenStringYesUser token. Both types of tokens are available
idStringYes

Response JSON:

ParametersTypeComments
statusStringreturn code:
100: successful,
103: parameter error
104: invalid token
111: For some other errors, refer to the "msg" value.
msgStringError message
{    "status": "100"}

18. API to get AnyLink IoT box online/offline status

Function: Get current online/offline status of IoT boxes

Request type: POST

url: /agentList/condition

Prameters:

ParametersTypeRequiredComment
tokenStringYesUser token. Both types of tokens are available
agentIdsJSONArrayYesAn Array of IoT boxes' Serial Numbers

Sample request:

{
    "token": "805b2b68-0f3b-47c2-a57a-0401d2f2b95c",
    "agentIds":[
        1701354,
        1701178
    ]
}

Response JSON:

ParametersTypeComments
statusStringreturn code:
100: successful
103: parameter error
104: invalid token
111: For some other errors, refer to the "msg" value.
msgStringError message
dataJSONArrayagentid: serialnumber, condition: 0--offline, 1--online
{
    "status": "100",
    "data": [
        {
            "agentid": 1701178,
            "condition": 0
        },
        {
            "agentid": 1701354,
            "condition": 1
        }
    ]
}

19. Get list of agents (IoT boxes' serial numbers) and devices for a specific user

Function: Get agent and device list

Request type: GET

url: /agentList

Prameters:

ParametersTypeRequiredComment
tokenStringYesUser token. Both types of tokens are available

Response JSON:

ParametersTypeComments
statusStringreturn code:
100: successful,
103: parameter error
104: invalid token
111: For some other errors, refer to the "msg" value.
msgStringError message
dataJSONArrayagentCondition: online/offline status,
0--offline
1--online
deviceList: devices that belong to the gateway
serialNumber: agent serial number
{
    "status":"100",
    "data":[
        {
            "agentCondition":0,
            "deviceList":[
                {
                    "condition":0,
                    "deviceId":1437705215,
                    "deviceName":"ra-device",
                    "serialNumber":"1404008"
                }
            ],
            "protocol":"mqtt",
            "serialNumber":1404008
        }
    ]
}

20. Get agent configuration

Function: Get the configuration information of gateway registration

Request type: GET

url: /agent

Prameters:

ParametersTypeRequiredComment
tokenStringYesUser token. Both types of tokens are available
serialNumberIntegerYes

Response JSON:

ParametersTypeComments
statusStringreturn code:
100: successful,
103: parameter error
104: invalid token
111: For some other errors, refer to the "msg" value.
msgStringError message
dataJSONArrayagent_name: agent name
agentxml: ModuleConfig.xml content agent uploads when it register to AnylinkCLoud. Detailed introduction of ModuleConfig.xml configuration click here
condition: online/offline status, 0--offline, 1--online
createtime: The first time(ms) agent registered to AnylinkCloud
id: serial number
protocol: Data transmission protocol, e.g "http", "mqtt"
updatetime:The last time(ms) agent registered to AnylinkCloud
version_detail: agent version
{
    "status":"100",
    "data":{
        "agent_name":"Agent-1701178",
        "agentxml":"<agent>......</agent>",
        "anylink_model":"DA",
        "condition":0,
        "createtime":1609294261277,
        "id":1701178,
        "protocol":"mqtt",
        "updatetime":1627177971998,
        "version_detail":"3.7.17"
    }
}

The following are device-user related API (21, 22, 23)

You should use 1. Get token for AnylinkCloud UI to get the token when call the following APIs:

21. Get device list of a user

Function: Get device list bound to a user

Request type: GET

url: /userDevice/listByPagination

Prameters:

ParametersTypeRequiredComment
tokenStringYesUser token (AnylinkCloud UI token)
userIdIntegerNoThe userId to get the device list. If userId is null, it will be the id of the user corresponding to the token.
serialNumberIntegerNoAnylink serial number
deviceNameStringNodevice name
pageIntegerYesPage number, starting from 1
perPageIntegerYesNumber of data per page

Response JSON:

ParametersTypeComments
statusStringreturn code:
100: successful,
103: parameter error
104: invalid token
111: For some other errors, refer to the "msg" value.
msgStringError message
resultJSONObjectpageInfo
page Page number, starting from 1
perPage Number of data per page
total Total number of data pieces
data JSONArray
id
device_id AnylinkCloud device id
name Device name
serialnumber Anylink serial number
{
    "status": "100",
    "result": {
        "pageInfo": {
            "page": 1,
            "perPage": 10,
            "total": 3
        },
        "data": [
            {
                "id": 3,
                "device_id": 1535998977,
                "name": "Monitor_Test",
                "serialnumber": "1499999"
            }
        ]
    }
}

22. Associate devices to a user

Function: Associate devices to a user

Request type: POST

url: /userDevice/add

Prameters:

ParametersTypeRequiredComment
tokenStringYesUser token (AnylinkCloud UI token)
userIdIntegerYesThe userId to bind the device list.
deviceIdsStringYesAnylinkCloud device id. Multiple values are separated by commas.

Response JSON:

ParametersTypeComments
statusStringreturn code:
100: successful
103: parameter error
104: invalid token
111: For some other errors, refer to the "msg" value.
msgStringResult message
dataIntegerWhen the number of bound devices is greater than 10, it indicates the number of successfully bound devices.
{
    "status": "100",
    "data": "15"
}

23. Remove device from user

Function: Remove device from a user

Request type: GET

url: /userDevice/deleteByUserIdAndDeviceId

Prameters:

ParametersTypeRequiredComment
tokenStringYesUser token (AnylinkCloud UI token)
userIdIntegerYesThe userId to bind the device list.
deviceIdIntegerYesAnylinkCloud device id.

Response JSON:

ParametersTypeComments
statusStringreturn code:
100: successful
103: parameter error
104: invalid token
111: For some other errors, refer to the "msg" value.
msgStringError message
dataIntegerNumber of devices successfully unbound
{
    "status": "100",
    "data": "1"
}

24. Get device list

Function: Get device list

Request type: GET

url: /devicelist

Prameters:

ParametersTypeRequiredComment
tokenStringYesUser token. Both types of tokens are available
hashStringNo'tetrascience'
serialNumberIntegerNoAnyLink box serial number. If it is null, API will return all the devices in permission of this token.

Response JSON:

ParametersTypeComments
statusStringreturn code:
100: successful
103: parameter error
104: invalid token
111: For some other errors, refer to the "msg" value.
dataJSONArrayid: device ID
name: device name
serialNumber: device serial number
deviceAttributes device attributes
lastContact: last contact time, time string(GMT-4)
lastRegister: agent last registration time, time string(GMT-4)
pingRate not in use
deviceCondition: device condition,1--device is uploading data,0/null--device is not uploading data within "5*data frequency"
description some description infomation
channel device channel for Anylink SE
channelName device channel name for Anylink SE
isActive not in use
protocol not in use
userGroupName not in use
userGroupId not in use
version: agent version
vpnVersion: vpn version supported in the agent
deviceModel:
id: device model ID
name: device model name
alias: device model alias
manufacturer: not in use
description: some description infomation
{
    status: "100",
    data: [
       {
            "id": 1441802239,
            "name": "Kallyope-014-system",
            "serialNumber": "1408009",
            "deviceAttributes": null,
            "lastContact": "2020-09-25 17:50:00.0",
            "lastRegister": "2020-09-25 17:26:59.632027",
            "pingRate": 0,
            "deviceCondition": 0,
            "description": null,
            "channel": null,
            "channelName": null,
            "isActive": 1,
            "protocol": null,
            "userGroupName": null,
            "userGroupId": null,
            "version": "3.7.5",
            "deviceModel": {
                "id": 2,
                "name": "ra-model",
                "alias": null,
                "manufacturer": null,
                "description": null
            }
        },
        …
      ]
   }

25. Get user ID by user name

Function: Get user ID

Request type: GET

url: /user/findByUsername

Prameters:

ParametersTypeRequiredComment
tokenStringYesUser token, got from API /user/getToken (AnylinkCloud UI token)
tenantEnameStringYestenant name
loginNameStringYesuser name

Response JSON:

ParametersTypeComments
statusStringreturn code:
100: successful
103: parameter error
104: invalid token
109: username does not exist
111: For some other errors, refer to the "msg" value.
dataJSONObjectcellphone: celphone number
created_by: creator ID
created_on: created time: Unix time in ms
email: email
id: userId
isadmin: 1: administrator,2: maintenance user,0: regulator user
last_login_time: last login time in Unix time in ms
real_name: full name
status: status,1 is active,0 is disabled
tenant_name: tenant name
type: 0 is user,1 is department
updated_by: updator ID
updated_on: updated time in Unix time in ms
user_name: user name
   {
       "status": "100",
       "data": {
           
       }
   }
   {
       "status": "100",
       "data": {
           "cellphone": "1234",
           "created_by": 1,
           "created_on": 1597680000000,
           "email": "test",
           "id": 2,
           "isadmin": 1,
           "last_login_time": 1633536000000,
           "real_name": "test",
           "status": 1,
           "tenant_name": "AnyLink",
           "type": 0,
           "updated_by": 1,
           "updated_on": 1597680000000,
           "user_name": "test"
       }
   }

26. Get OTA file list

Function: Get OTA file list uploaded to AnylinkCloud

Request type: GET

url: /ota/OTAVersionList

Prameters:

ParametersTypeRequiredComment
tokenStringYesUser token. Both types of tokens are available

Response JSON:

ParametersTypeComments
statusStringreturn code:
100: successful
103: parameter error
104: invalid token
111: For some other errors, refer to the "msg" value.
msgStringError message
dataJSONArraycurrentVersion The version of agent before OTA upgrade
newVersion Version number of agent after OTA upgrade
fileName File name of OTA upgrade package
fsign MD5 hash value of file of OTA upgrade package
createTime Creation time (UNIX time in ms) of this data
updateTime Last update time (UNIX time in ms)
{
    "status": "100", 
    "data": [
        {
            "createTime": 1556446121094,
            "currentVersion": "3.7.4",
            "fileName": "agent-hf-3.7.4.zip",
            "fsign": "ZRhLoZDbflPiRyYelX0f4w==",
            "id": 1,
            "newVersion": "3.7.4",
            "updateTime": 1556446121094
        }
    ]
}

27. OTA Pre-Check

Function: Before initiating OTA, check whether the gateway supports OTA

Request type: POST

url: /ota/preCheck

Parameters:

ParametersTypeRequiredComment
tokenStringYesUser token. Both types of tokens are available
serialNumbersJSONArrayYesAnylink serial numbers

Request parameter example:

{
    "token": "",
    "serialNumbers":[1200001,1200002]
}

Response JSON:

ParametersTypeComments
statusStringreturn code:
100: successful
103: parameter error
104: invalid token
111: For some other errors, refer to the "msg" value.
msgStringError message
dataJSONObjectNO Not meeting OTA upgrade conditions
reason The reason why OTA cannot be performed. It will be null if the Anylink can perform OTA
condition 0--AnylinkBox online, 1--AnylinkBox offline
serialNumber Anylink serial number
anylinkModel Anylink model, such as DA SE IE IE Pro
currentVersion Current version of agent
OK List that have passed the pre-check
{
    "status":100,
    "data":{
        "OK":[
            {
                "serialNumber":1200001,
                "currentVersion":"3.1.6",
                "anylinkModel":"DA",
                "condition":1
            }
        ],
        "NO":[
            {
                "serialNumber":1200003,
                "currentVersion":"3.1.6",
                "anylinkModel":"DA",
                "condition":0,
                "reason":"OTA is supported since Agent 3.7.4"
            }
        ]
    }
}

28. Get the list of upgradeable versions

Function: Get the list of upgradeable versions

Request type: GET

url: /ota/optionalVersions

Parameters:

ParametersTypeRequiredComment
tokenStringYesUser token. Both types of tokens are available
serialNumberIntegerNoAnylink serial number. If it is null, API will return all optional versions that have uploaded to server.

Request parameter example:

{
    "token": "",
    "serialNumber": 1200001
}

Response JSON:

ParametersTypeComments
statusStringreturn code:
100: successful
103: parameter error
104: invalid token
111: For some other errors, refer to the "msg" value.
msgStringError message
dataJSONArraycurrentVersion The version of agent before OTA upgrade
newVersion Version number of agent after OTA upgrade
{
    "status":"100",
    "data":[
        {
            "currentVersion":"3.7.4",
            "newVersion":"3.7.5"
        },
        {
            "currentVersion":"3.7.4",
            "newVersion":"3.7.6"
        },
        {
            "newVersion":"latest"
        }
    ]
}

29. Start OTA for an AnylinkBox

Function: Start OTA for an AnylinkBox

Request type: POST

url: /ota/startOTA

Parameters:

ParametersTypeRequiredComment
tokenStringYesUser token. Both types of tokens are available
serialNumberIntegerYesAnylink serial number
targetVersionStringYesTarget version number to upgrade to via OTA

Request parameter example:

{
    "token":"b06b512b-c377-48a4-b3fd-d59bb033bb9d",
    "serialNumbers":[
        {
            "serialNumber": 1500001,
            "targetVersion": "3.7.20"
        }
    ]
}

Response JSON:

ParametersTypeComments
statusStringreturn code:
100: successful
103: parameter error
104: invalid token
111: For some other errors, refer to the "msg" value.
msgStringError message
dataJSONObjectNO Not meeting OTA upgrade conditions
OK Ota is successfully initiated and the value is sessionid
{
    "status": "100",
    "data": {
        "NO": {
            "1400219": false
        },
        "OK": {
            "1400218": "1636342247983"
        }
    }
}

30. Get OTA status

Function: Get OTA status

Request type: GET

url: /ota/downloadStatus

Parameters:

ParametersTypeRequiredComment
tokenStringYesUser token. Both types of tokens are available
serialNumberIntegerYesAnylink serial number
sessionidStringYessessionid returned by /ota/startOTA API

Response JSON:

ParametersTypeComments
statusStringreturn code:
99: This OTA instance is not exist.
100: successful
103: parameter error
104: invalid token
111: For some other errors, refer to the "msg" value.
msgStringError message
dataJSONObjectserialNumber Anylink serial number
oldVersion The version of agent before OTA upgrade
sessionid returned by /ota/startOTA API
startTime OTA start time
cmd The command sent to agent
newVersion Version number of agent after OTA upgrade
status Current OTA status
statusCode Current OTA status code
{
    "status": "100",
    "data": {
        "serialNumber": 1400219,
        "oldVersion": "3.7.20",
        "sessionid": "1636351404453",
        "startTime": 1636351406348,
        "cmd": "{\"fsign\":\"7acxVMKd2cK7NwvamX5Edw==\",\"file\":\"OTA-DA-Agent-3.7.21.zip\",\"nblock\":149,\"fsize\":2432576,\"csign\":\"L73XQWVbI2+TdPcoc91td7gRj9mAG2zTFbLUGSuoSeCDqG0Yly29AcT2V/KLsc/t4pOMWiXRq93pu9dPZDiGQVW5N1YpgPaerrt12tLQvPQetDNwF2Zy0FwUIUgkrolrqOTJ2vbgjbPtHwmcgN2OnDudCoos5oAwa5PIURja0uw=\",\"sessionid\":\"1636351404453\",\"type\":0}",
        "newVersion": "3.7.21",
        "status": "OTA_DOWNLOAD_CMD_PUBLISHED",
        "statusCode": 1
    }
}

OTA status code:

codestatus
0AGENT_OTA_STATUS_WAITINGThe OTA command is waiting to sent
1OTA_DOWNLOAD_CMD_PUBLISHEDThe OTA command has been sent to agent
2AGENT_OTA_UPDATEThe agent has returned the status of whether it can be updated
3AGENT_OTA_DOWNLOADING_FILEOTA file blocks are being sent
4AGENT_OTA_DOWNLOAD_FINISHED_WAITING_CHECKOTA file distribution is completed, waiting for agent verification
5AGENT_OTA_DOWNLOAD_FINISHEDOTA file verification is completed, and agent is performing upgrade
6AGENT_OTA_FINISHEDOTA process completed

31. Add user

Function: Add a user

Request type: POST

url: /user/addUser

Parameters: JSON

This API will parse the payload and only pickup the fields listed below and discard the others which are not mentioned in the following list.

ParametersTypeRequiredComment
tokenStringYesUser token. Both types of tokens are available
paramJSONObjectYes
user_nameStringYesUser name, used to login
passwordStringYesPassword should be between 5-16 characters
re_passwordStringYesEnter the password again
real_nameStringYesReal name
parent_idIntegerNoUser's department id
cellphoneStringYes
emailStringNo
telephoneStringNo
isadminIntegerNo0 -- ordinary admin, 1-- administrator
typeIntegerYesUser type, 0 -- add a user, 1-- add a department

Request parameter example:

{
    "token": "5e2719d6-6556-4fa4-a536-8106a392354e",
    "param": {
        "user_name": "s2",
        "password": "12345678",
        "re_password": "12345678",
        "real_name": "s1",
        "parent_id": "1",
        "cellphone": "123456",
        "email": "[email protected]",
        "telephone": 43566212344,
        "undefined": "435662123dfg",
        "isadmin": "0",
        "type": 1
    }
}

Response JSON:

ParametersTypeComments
statusStringreturn code:
100: successful
103: parameter error
104: invalid token
111: For some other errors, refer to the "msg" value.
116: password mismatch
110: duplicate user
msgStringError message
dataIntegerNewly added user id

32. List all the departments

Function: List all the departments

Request type: GET

url: /user/getTenantUserTree

Parameters:

ParametersTypeRequiredComment
tokenStringYesUser token, got from API /user/getToken (AnylinkCloud UI token)
userTypeIntegerYesThe value is 1. It means list the department.

Response JSON:

ParametersTypeComments
statusStringreturn code:
100: successful
103: parameter error
104: invalid token
111: For some other errors, refer to the "msg" value.
msgStringError message
dataJSONArraycreated_by The user id who created this department
created_on Create time, UNIX time in ms
id The department id
isadmin If this is a user but not department, 0 means ordinary user, 1 means administrator
real_name Department name
remark remark
status 0--disable, 1--enable
type 0-- user, 1--department
updated_by User id who last updated this department
updated_on Last updated time, UNIX time in ms

Response example:

{
    "status": "100",
    "data": [
        {
            "created_by": 1,
            "created_on": 1642651200000,
            "id": 3,
            "isadmin": 0,
            "real_name": "It Department",
            "remark": "",
            "status": 1,
            "type": 1,
            "updated_by": 1,
            "updated_on": 1642651200000
        }
    ]
}