Sync Users

Last Updated on : 2023-06-15 04:53:12

This API operation is used to sync user accounts. To suit your own business scenarios, you can create accounts and modify account information based on the sync parameters.

Note: - Once an account is created, you cannot modify the country code, username, and username type. Confirm the data when you create an account. - If you pass in the same username under the same application, the last password, nickname, or time zone ID of this user will be updated according to the specific sync parameters.

API address

POST: /v1.0/apps/{schema}/user

Request parameter

Parameter nameTypeINRequiredDescription
schemaStringuritrueThe channel identifier of the specified app.

Description of body

Parameter nameTypeINRequiredDescription
country_codeStringbodytrueThe code of the specified country or region.
usernameStringbodytrueThe username.
passwordStringbodytrueThe user's password. The original password encrypted with MD5 Hash is recommended.
username_typeIntegerbodytrueThe type of username. Valid values:
  • 1: mobile phone number.
  • 2: email address.
  • 3: others. Default value is 3.
nick_nameStringbodyfalseThe nickname.
time_zone_idStringbodyfalseThe ID of the specified time zone.

Return parameter

Parameter nameTypeDescription
resultJSONObjectThe returned result of synchronizing a user.

Description of result

Parameter nameTypeDescription
uidStringTuya user ID.

Request example

POST: /v1.0/apps/testApp/user
{
  "country_code": "86",
  "username": "182*****678",
  "password": "c7fb2740c5f******4ed765a479fa",
  "username_type": 1,
  "time_zone_id": "Asia/Shanghai"
}

Return example

{
    "result": {
        "uid": "ay1534*****4744oIAa"
    },
    "success": true
}

Error code

For more information, see error code.