User service

Updated at:

This service provides a set of user-related API operations. Cloud applications can use these operations to detach users, retrieve lists of devices attached to users, and more.

Perform a paged query for a user list

Description

pathVersionDescriptioncloudToken required
/cloud/account/queryIdentityByPage1.0.4Performs a paged query for the user list under a tenant.Yes

Request parameters

ParameterTypeRequiredDescription
offsetIntegerNoThe query offset.
countIntegerNoThe number of entries to return on each page.

Response parameters

NameTypeDescription
identityIdStringThe identity ID of the account.
loginIdStringLogin ID
loginSourceStringThe source of the account.
gmtCreateLongCreation Time
gmtModifiedLongLast Modified
loginNameStringThe logon name.
phoneStringThe phone number.
emailStringThe email address.
nickNameStringThe nickname.
avatarUrlStringProfile picture
genderStringThe gender.
lastLoginTimeDateThe time of the last logon.
onlineStatusIntegerThe logon status of the account.
  • 1: Online
  • 0: Offline

Examples

  • Request example
    {
         "id":"bb179e80-39fd-xxxx-xxxx-48ca87a3f5c5",
          "request": {
            "cloudToken": "109049c8xxxxxxxxf62e29a3ba",
            "apiVer": "1.0.4"
          },
          "params": {
            "offset":0, "count":1
          },
          "version": "1.0"
    }
  • Successful response example
    {
        "code": 200,
        "data": [
            {
                "gmtModified": 1508314232000,
                "loginId": "4398047084811",
                "gmtCreate": 1508314232000,
                "identityId": "506bop1ef3axxxxxxxx7ae175ac94618",
                "loginSource": "openAccount",
                "loginName":"test",
                "phone":"1381111****",
                "email":"test@aliyun.com",
                "nickName":"test"
            }
        ],
        "id":"bb179e80-39fd-xxxx-xxxx-48ca87a3f5c5"
    }

Query account information using a third-party external ID

Description

pathVersionDescriptioncloudToken required
/cloud/account/getByOpenId1.0.4Queries account information using a third-party external ID.Yes

Request parameters

ParameterTypeRequiredDescription
openIdStringYesThe external ID of your own account.
openIdAppKeyStringYesThe appKey of the application.

Response parameters

NameTypeDescription
identityIdStringThe identity ID of the account.
loginIdStringThe openAccountId of the account.
loginSourceStringThe source of the account.
gmtCreateLongCreated At
gmtModifiedLongLast Modified
loginNameStringThe logon name.
phoneStringThe phone number.
emailStringmailbox
nickNameStringNickname
tenantIdStringThe tenant ID.
genderStringThe gender.
lastLoginTimeLongThe time of the last logon.
avatarUrlStringProfile picture
onlineStatusIntegerThe logon status of the account.
  • 1: Online
  • 0: Offline

Examples

  • Request example
    {
         "id":"bb179e80-39fd-xxxx-xxxx-48ca87a3f5c5",
          "request": {
            "cloudToken": "109049c8xxxxxxxx6f62e29a3ba",
            "apiVer": "1.0.4"
          },
          "params": {
            "openId":"4398050099996", "openIdAppKey":"appkey1"
          },
          "version": "1.0"
    }
  • Successful response example
    {
        "code": 200,
        "data": 
            {
                "gmtModified":1515590332000,
                "loginId":"4398050099996",
                "gmtCreate":1513181985000,
                "lastLoginTime":1515590332000,
                "phone":"1390000****",
                "identityId":"5091op618xxxxxxxxe93ba653a5928119",
                "loginName":"1390000****",
                "tenantId":"45CFEA7xxxxxxxx05D59452B1437",
                "loginSource":"openAccount"
                "email":"test@aliyun.com",
                "nickName":"test"
            }
    ,
        "message":"success"
    }

Get a list of devices attached to a user, including device details

Description

pathVersionDescriptioncloudToken requiredNotes
/cloud/device/queryByUser1.0.6Gets a list of devices attached to a user, including device details.YesQueries the list of devices attached to a user. Set different offsets to query any part of the records. A query for the total number of records is not supported.

Request parameters

ParameterTypeRequiredDescription
openIdStringNoThe external ID of the third-party user. You must specify either openId or identityId.
openIdAppKeyStringNoThe appKey issued by the platform to the third-party application.
identityIdStringNoThe identity ID of the user. You must specify either openId or identityId.
limitintNoThis parameter was added in version 1.0.5. It specifies the maximum number of entries to return. The value of limit cannot exceed 100.
offsetintNoThis parameter was added in version 1.0.5. It specifies the offset.

Response parameters

ParameterTypeDescription
identityIdStringThe identity ID of the user.
iotIdStringThe iotId of the device.
productKeyStringThe ProductKey of the device.
deviceNameStringThe DeviceName of the device.
productNameStringThe product name of the device.
categoryImageStringThe product image of the device.
productModelStringThe product model of the device.
nickNameStringThe nickname that the user gives to the device.
netTypeStringThe network connection type of the device:
  • LoRa: NET_LORA
  • GPRS: NET_CELLULAR
  • Wi-Fi: NET_WIFI
  • Zigbee: NET_ZIGBEE
  • Bluetooth: NET_BT
  • Ethernet: NET_ETHERNET
  • Other: NET_OTHER
thingTypeStringThe type of the Thing:
  • VIRTUAL (virtual device)
  • VIRTUAL_SHADOW (virtual shadow device)
  • WEB
  • APP
  • DEVICE (regular device)
statusByteThe status of the device. 0: Inactive, 1: Online, 3: Offline, 8: Disabled.
Note This field is not supported in versions earlier than 1.0.6.
ownedintThe sharing flag.
  • 0: Regular user (sharer)
  • 1: Administrator (owner)

Examples

  • Request examples
    • Passing openId and openIdAppKey
      {
         "id":"55428a70-a740-4xxxx-xxxx-89f727744740",
          "request": {
            "cloudToken": "109049cxxxxxxxx6f62e29a3ba",
            "apiVer": "1.0.6"
          },
          "params": {
            "openId":"10000000001",
            "openIdAppKey":"xxx",
            "limit":50,
            "offset":100
          },
          "version": "1.0"
      }
    • Passing identityId
      {
         "id":"55428a70-a740-xxxx-xxxx-89f727744740",
          "request": {
            "cloudToken": "109049c8xxxxxxxx6f62e29a3ba",
            "apiVer": "1.0.6"
          },
          "params": {
            "identityId": "506bop1efxxxxxxxx57ae175ac94618",
            "limit":50,
            "offset":100
          },
          "version": "1.0"
      }
  • Successful response example
    {
      "code": 200,
      "data": {
          "code": 200,
          "data": [{
              "iotId": "VPuHLddp6fixxxxxxxx10dbd910",
              "identityId": "50ceop3441838xxxxxxxx455be61f0356",
              "netType": "NET_WIFI",
              "thingType": "DEVICE",
              "productKey": "a1FNS8TYhpQ",
              "deviceName": "VD_sdDaqyTXeQ",
              "productName": "Fan3-Copy"
          }],
          "message": "success"
      },
      "id": "55428a70-a740-xxxx-xxxx-89f727744740"
    }

Detach a user from a device

Description

pathVersionDescriptioncloudToken required
/cloud/user/device/unbind1.0.4Detaches a user from a device.Yes

Request parameters

ParameterTypeRequiredDescription
openIdStringNoThe external ID of the third-party user. You must specify either openId or identityId.
openIdAppKeyStringNoThe appKey issued by the Open Platform. This parameter is required if you use openId.
identityIdStringNoThe identity ID of the user. You must specify either openId or identityId.
iotIdStringYesiotId

Response parameters

None.

Examples

  • Request examples
    • Pass openId and openIdAppKey
      {
         "id":"3389580f-c698-xxxx-xxxx-b576c6d6c874",
          "request": {
            "cloudToken": "109049c80xxxxxxxx6f62e29a3ba",
            "apiVer": "1.0.4"
          },
          "params": {
            "openId":"10000000001",
            "openIdAppKey":"xxx"
            "iotId":"VPuHLddpxxxxxxxx0010dbd910"
          },
          "version": "1.0"
      }     
    • Pass identityId
      {
         "id":"3389580f-c698-xxxx-xxxx-b576c6d6c874",
          "request": {
            "cloudToken": "109049c8xxxxxxxxf62e29a3ba",
            "apiVer": "1.0.4"
          },
          "params": {
            "identityId": "506bop1ef3a1xxxxxxxx7ae175ac94618"
            "iotId":"VPuHLddp6xxxxxxxx010dbd910"
          },
          "version": "1.0"
      } 
  • Successful response example
    {
      "code": 200,
      "data": "",
      "id": "3389580f-c698-xxxx-xxxx-b576c6d6c874"
    }

Forcefully detach all users from a device

Description

pathVersionDescriptioncloudToken required
/living/cloud/user/binding/device/unbind1.0.0Detaches all attachments from the specified device.Yes

Request parameters

ParameterTypeRequiredDescription
iotIdStringNoThe unique ID of the device. This parameter is required if productKey and deviceName are empty.
productKeyStringNoThe ProductKey of the device. This parameter is required if iotId is empty.
deviceNameStringNoThe DeviceName of the device. This parameter is required if iotId is empty.

Response parameters

This operation does not return any business-related parameters.

Examples

  • Request example
    {
         "id":"3389580f-c698-4a83-9eee-b576c6d6c874",
          "request": {
            "cloudToken": "109049c80bxxxxx06b15f6f62e29a3ba",
            "apiVer": "1.0.0"
          },
          "params": {
            "iotId":"Aawfy6tNxxxxxKOJ9Ffg000101"
          },
          "version": "1.0"
    }
  • Successful response example
    {
        "code": 200,
        "data": "",
        "id": "3389580f-c698-4a83-9eee-b576c6d6c874"
    }

Get a third-party OpenID using an identity ID

Description

PathVersionDescriptioncloudToken required
/cloud/account/openId/getByIdentityId1.0.4Gets a third-party OAuth OpenID using an identity ID.Yes
Note Use this API operation only if you use a third-party account system.

Request parameters

ParameterTypeRequiredDescription
identityIdStringYesThe identity ID.
openIdAppKeyStringYesThe appKey issued by the Open Platform.

Response parameters

ParameterTypeRequiredDescription
dataStringYesThe identity ID of the account.

Examples

  • Request example
    {
        "id":"bb179e80-39fd-xxxx-xxxx-48ca87a3f5c5",
        "request":{
            "apiVer":"1.0.4"
        },
        "params":{
            "identityId":"506bop1ef3xxxxxxxxf57ae175ac94618",
            "openIdAppKey":"12345678"
        },
        "version":"1.0"
    }
  • Successful response example
    {
        "code": 200,
        "data": "506bop1ef3a1cexxxxxxxx175ac94618",
    "id":"bb179e80-39fd-xxxx-xxxx-48ca87a3f5c5"
    }

Find all users attached to a device

Description

pathVersionDescriptioncloudToken required
/living/user/device/binding/query1.0.0Queries for accounts attached to a device based on the device iotId.Yes

Request parameters

ParameterTypeRequiredDescription
iotIdStringYesThe device ID.
pageNoIntegerYesThe page number. Starts from 1.
pageSizeIntegerYesThe number of entries per page.

Response parameters

ParameterSub-parameterSecond-level sub-parameterTypeDescription
dataJSONThe list of attached users.
totalIntegerThe total number of records.
accountDevListJSONArrayThe list of attachments.
deviceNameStringThe DeviceName of the device.
identityIdStringThe user account ID.
iotIdStringThe iotId of the device.
nickNameStringThe nickname that the user sets for the device. Can be empty.
ownedInteger
  • 0: Sharer
  • 1: Owner
productKeyDateThe ProductKey of the device.
productNameStringThe product name of the device.

Examples

  • Request example
    {
         "id":"bb179e80-39fd-xxxx-xxxx-48ca87a3f5c5",
          "request": {
            "cloudToken": "109049c80bxxxxxxxx62e29a3ba",
            "apiVer": "1.0.0"
          },
          "params": {
            "iotId":"VPuHLddpxxxxxxxx0010dbd910",
            "pageNo": 1,
            "pageSize": 50
          },
          "version": "1.0"
    }
  • Successful response example
    {
        "code": 200,
        "data": 
    {
        "accountDevList":[
            {
                "deviceName":"00158D00xxxxB3",
                "identityId":"50caop1fxxxxxxxxe55dae27b479165",
                "iotId":"OK61KXgxxxxxxxxtTk000100",
                "nickName":"Infrared Aisle 2",
                "owned":1,
                "productKey":"a1xxxxyZ",
                "productName":"Infrared Detector",
            }
        ],
        "total":1
    },
        "id":"bb179e80-39fd-xxxx-xxxx-48ca87a3f5c5"
    }

Query account details using an identity ID

Description

pathVersionDescriptioncloudToken required
/cloud/account/getByIdentityId1.0.4Queries the details of an account using its IdentityId. You can get the IdentityId from the /cloud/account/queryIdentityByPage operation. Fields with no value are not returned.Yes

Request parameters

ParameterTypeRequiredDescription
identityIdStringYesIdentity IDs

Response parameters

NameTypeDescription
identityIdStringThe identity ID of the account.
loginIdStringThe logon ID.
loginSourceStringThe source of the account.
gmtCreateLongCreation Time
gmtModifiedLongModification Time
loginNameStringThe logon name.
phoneStringThe phone number.
emailStringMailbox
nickNameStringNickname
avatarUrlStringThe profile picture.
genderStringThe gender.
lastLoginTimeDateThe time of the last logon.
onlineStatusIntegerThe logon status of the account.
  • 1: Online
  • 0: Offline

Examples

  • Request example
    {
         "id":"bb179e80-39fd-xxxx-xxxx-48ca87a3f5c5",
          "request": {
            "cloudToken": "109049c8xxxxxxxxf6f62e29a3ba",
            "apiVer": "1.0.4"
          },
          "params": {
            "identityId":"506bop1ef3xxxxxxxx57ae175ac94618"
          },
          "version": "1.0"
    }
  • Successful response example
    {
        "code": 200,
        "data": 
            {
                "gmtModified":1515590332000,
                "loginId":"4398050099996",
                "gmtCreate":1513181985000,
                "lastLoginTime":1515590332000,
                "phone":"1390000****",
                "identityId":"5091op61850061xxxxxxxxba653a5928119",
                "loginName":"1390000****",
                "tenantId":"45CFEA75xxxxxxxxD59452B1437",
                "loginSource":"openAccount"
                "email":"test@aliyun.com",
                "nickName":"test"
            },
        "message":"success"
    }

Update a user nickname from your own account system on the platform

Description

pathVersionDescriptioncloudToken required
/user/account/info/update1.0.0-Yes

Request parameters

ParameterTypeRequiredDescription
openIdAppKeyStringYesThe OpenId AppKey issued by the platform.
openIdStringNoThe openId of your own account system.
identityIdStringNo (You must specify at least one of openId or identityId)The user account ID.
nickNameStringYesThe user account nickname.

Response parameters

None.

Examples

  • Request example
    {
         "id":"bb179e80-39fd-xxxx-xxxx-48ca87a3f5c5",
          "request": {
            "cloudToken": "109049c8xxxxxxxxf6f62e29a3ba",
            "apiVer": "1.0.4"
          },
          "params": {
            "identityId":"506bop1ef3a1xxxxxxxxf57ae175ac94618",
            "nickName":"Feiyan User 001"
          },
          "version": "1.0"
    }
  • Successful response example
    {
        "code": 200,
        "data": {},
        "id":"bb179e80-39fd-xxxx-xxxx-48ca87a3f5c5"
    }