Home Sharing

Last Updated on : 2024-06-05 03:15:11download

Add sharing invitation

API description

Generate a ticket for inviting a user to join a home.

API endpoint

action: sharing.homeTicket

Request parameter

Parameter name Type Description Required
home_id Long The home ID. Yes
sharer String The account of the user who initiates the sharing invitation. Yes
receiver String The account of the user who receives the sharing invitation. If this parameter is not set, the home is shared with QR code. No
app_schema String The schema of the Tuya-enabled app. Set the value to cloud. Yes

Response parameter

Parameter name Type Description
code Integer The response code. For more information, see the error code section.
success Boolean Indicates whether the operation is successful.
- true: succeeded
- false: failed
msg String The error message that is returned if the API call fails. This parameter value is empty if the API call succeeds.
result Object The returned result.

Description of result

Parameter name Type Description
sharing_id String The ID of the sharing invitation.
sharing_ticket String The one-time ticket for sharing.
expire_time Long The time when the ticket expires. Unit: seconds.

Sample request

{
	"action": "sharing.homeTicket",
	"params": {
		"home_id": 10001,
    "sharer": "ay15309353754999xY2T",
    "app_schema": "xxxxxx"
	}
}

Sample response

{
    "result": {
      "sharing_id": 5003,
      "sharing_ticket": "3ce76bc4f8ef36f5a709043b49175ad8",
      "expire_time": 300
    },
    "t":1540799929837,
    "success": true
}

Error codes

The following table lists the error codes that might be returned when you make the API request. For more error codes, see Global Error Codes.

Error code Description
500 A system error has occurred while processing your request.
1106 Invalid permission.

Verify home sharing ticket

API description

Check whether the temporary ticket for home sharing is valid.

API endpoint

action: sharing.homeTicketVerification

Request parameter

Parameter name Type Description Required
sharing_ticket String The ticket for sharing a home. Yes

Response parameter

Parameter name Type Description
code Integer The response code. For more information, see the error code section.
success Boolean Indicates whether the operation is successful.
- true: succeeded
- false: failed
msg String The error message that is returned if the API call fails. This parameter value is empty if the API call succeeds.
result Object The returned result.

Description of result

Parameter name Type Description
sharing_id String The ID of the sharing invitation.
sharing_ticket String The one-time ticket for sharing.
expire_time Long The time when the ticket expires. Unit: seconds.

Sample request

{
	"action": "sharing.homeTicketVerification",
	"params": {
    "sharing_ticket": "3ce76bc4f8ef36f5a709043b49175ad8"
	}
}

Sample response

{
    "result": {
      "sharing_id": 5003,
      "sharing_ticket": "3ce76bc4f8ef36f5a709043b49175ad8",
      "expire_time": 300
    },
    "t":1540799929837,
    "success": true
}

Error codes

The following table lists the error codes that might be returned when you make the API request. For more error codes, see Global Error Codes.

Error code Description
500 A system error has occurred while processing your request.
1106 Invalid permission.
2703 The ticket for home sharing has expired.

Accept sharing invitation

API description

Accept the invitation to join a home.

API endpoint

action: sharing.homeConfirm

Request parameters

Parameter name Type Description Required
sharing_id Long The ID of the sharing invitation. Yes
sharing_ticket String The ticket for sharing a home. Yes
receiver String The account of the user who receives the invitation. Yes
app_schema String The schema of the Tuya-enabled app. Set the value to cloud. Yes

Response parameter

Parameter name Type Description
code Integer The response code. For more information, see the error code section.
success Boolean Indicates whether the operation is successful.
- true: succeeded
- false: failed
msg String The error message that is returned if the API call fails. This parameter value is empty if the API call succeeds.
result Boolean The returned result.

Sample request

{
	"action": "sharing.homeConfirm",
	"params": {
		"sharing_id": 5003,
    "sharing_ticket": "3ce76bc4f8ef36f5a709043b49175ad8",
    "receiver": "ay15309353754xxxxxx",
    "app_schema": "xxxxxxx"
	}
}

Sample response

{
    "success":true,
    "t":1540799929837,
    "result":true
}

Error codes

The following table lists the error codes that might be returned when you make the API request. For more error codes, see Global Error Codes.

Error code Description
500 A system error has occurred while processing your request.
1106 Insufficient permissions.
2703 The ticket for home sharing has expired.

Cancel sharing invitation

API description

Cancel a home sharing invitation.

API endpoint

action: sharing.homeCancel

Request parameters

Parameter name Type Description Required
sharing_id Long The ID of the sharing invitation. Yes

Response parameter

Parameter name Type Description
code Integer The response code. For more information, see the error code section.
success Boolean Indicates whether the operation is successful.
- true: succeeded
- false: failed
msg String The error message that is returned if the API call fails. This parameter value is empty if the API call succeeds.
result Boolean The returned result.

Sample request

{
	"action": "sharing.homeCancel",
	"params": {
		"sharing_id": 5003
	}
}

Sample response

{
    "success":true,
    "t":1540799929837,
    "result":true
}

Error codes

The following table lists the error codes that might be returned when you make the API request. For more error codes, see Global Error Codes.

Error code Description
500 A system error has occurred while processing your request.
1106 Insufficient permissions.