Sync User Account

Last Updated on : 2024-09-10 09:53:02

This API operation is used to sync a user account. When you need to bind your internal user account with Tuya's user platform, you can choose to synchronize your user account. When you synchronize your account for the first time, Tuya will create a user account based on your parameters and return the user ID of the Tuya platform. The next time you synchronize with the same parameters, a new user account will not be created, but the platform user ID created for the first time will be returned.

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 account will be updated according to the specific sync parameters.

API address

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

Request parameter

Parameter nameTypeINRequiredDescription
schemaStringuritrueThe schema of the specified app.

Description of body

Parameter nameTypeINRequiredDescription
country_codeStringbodytrueThe country code.
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. The 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 account.

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.