APIs Related to Constructor Authorization

Last Updated on : 2025-05-30 01:56:03download

API List

Request method API description
POST /v1.0/osaas/contractor/authorization API for Authorizing a Constructor.
GET /v1.0/osaas/contractor/authorizations API for Querying the Constructor Authorization List.
DELETE /v1.0/osaas/contractor/authorizations/{authorization_id} URL for Unauthorizing a Constructor.
GET /v1.0/osaas/contractors API for Obtaining the Constructor List.

API for Authorizing a Constructor

API Description

You can use this API to authorize the main account of a constructor that has been registered with and passed the enterprise authentication on the construction platform.

API Address

POST /v1.0/osaas/contractor/authorization

Request Parameters

Parameter Type Position Description Mandatory
country_code String BODY Country code. 86: China Yes
username String BODY Main account of a constructor, which is a mobile number or an email address. Yes

Response Parameters

Parameter Type Description
code Integer Response code.Null indicates success.
success Boolean Request result.
true: success
false: failure
msg String Exception message.It is null when the request result is success.
t Long Response time, which is a 13-digit timestamp.
result String Unique ID of an authorization.

Request Example

POST /v1.0/osaas/contractor/authorization
{ "countryCode": "86", "username": "test@tuya.com" }

Success Response Example

{ "success": true, "t": 1566053034624, "result": "116082396505314xxxxx" }

Failure Response Example

{ "code": 500, "msg": "system error,please contact the admin", "success": false, "t": 1561378856383 }

API for Querying the Constructor Authorization List

API Description

You can use this API to query the list of authorized constructors.

API Address

GET /v1.0/osaas/contractor/authorizations

Request Parameters

Parameter Type Position Description Mandatory
page_no Integer URL Page number. The default value is 1. No
page_size Integer URL Number of records on a page, which is greater than 0 and less than 100. If this parameter is not set, the number is 20 by default. No

Response Parameters

Parameter Type Description
code Integer Response code.Null indicates success.
success Boolean Request result.
true: success
false: failure
msg String Exception message.It is null when the request result is success.
t Long Response time, which is a 13-digit timestamp.
result Object Result object.

Parameters in result

Parameter Type Description
total Integer Total number of records.
page_no Integer Page number.
page_size Integer Number of records on a page.
authorizations Arrays Set of authorized constructors.

Parameters in authorizations

Parameter Type Description
authorization_id String Unique ID of an authorization.
username String Main account of a constructor.
enterprise_name String Enterprise name of a constructor.
cooperation_time Long Cooperation time, which is a 13-digit timestamp. The default value is 0. A value is assigned after the constructor confirms the authorization.

Request Example

GET {url}/v1.0/osaas/contractor/authorizations?page_no=1&page_size=10

Success Response Example

{ "result": { "total": 1, "page_no": 1, "page_size": 10, "authorizations":[ { "authorization_id": "1160823965053******", "username": "test@tuya.com", "enterprise_name": "Enterprise name of a constructor", "cooperation_time": 1559707046000 } ] }, "success": true, "t": 1561381210234 }

Failure Response Example

{ "code": 500, "msg": "system error,please contact the admin", "success": false, "t": 1561378856383 }

URL for Unauthorizing a Constructor

API Description

You can use this API to unauthorize a constructor.

API Address

DELETE /v1.0/osaas/contractor/authorizations/{authorization_id}

Request Parameters

Parameter Type Position Description Mandatory
authorization_id String URI Unique ID of an authorization. Yes

Response Parameters

Parameter Type Description
code Integer Response code.Null indicates success.
success Boolean Request result.
true: success
false: failure
msg String Exception message.It is null when the request result is success.
t Long Response time, which is a 13-digit timestamp.
result Boolean Operation result.

Request Example

DELETE {url}/v1.0/osaas/contractor/authorizations/{authorization_id}

Success Response Example

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

Failure Response Example

{ "code": 500, "msg": "system error,please contact the admin", "success": false, "t": 1561378856383 }

API for Obtaining the Constructor List

API Description

You can use this API to obtain the list of authorized constructors.

API Address

GET /v1.0/osaas/contractors

Response Parameters

Parameter Type Description
code Integer Response code.Null indicates success.
success Boolean Request result.
true: success
false: failure
msg String Exception message.It is null when the request result is success.
t Long Response time, which is a 13-digit timestamp.
result Arrays Set of authorized constructors.

Parameters in result

Parameter Type Description
contractor_uid String Unique ID of a constructor.
contractor_name String Constructor name.

Success Response Example

{ "result": [ { "contractor_uid": "bayxxxxxxxxxxxxxfcDz", "contractor_name": "XXX 服务商" } ], "success": true, "t": 1561381210234 }

Failure Response Example

{ "code": 500, "msg": "system error,please contact the admin", "success": false, "t": 1561378856383 }

Error Code

The following are common business exceptions for this interface. For more exception errors, see Global Error Codes.

error code explain
500 system error