---
name: "bindPanelAgentWithRole"
mode: "api"
versionRequirements:
  - { name: "@tuya-miniapp/cloud-api", version: "1.0.6" }
---

## bindPanelAgentWithRole

> [VERSION] @tuya-miniapp/cloud-api >= 1.0.6

> 💡 This API relies on cloud capabilities; authorize it under Development Settings - Cloud Capabilities in the [Mini App Developer Platform](https://platform.tuya.com/miniapp/).

### Description

Bind a role.

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `params` | `BindPanelAgentWithRoleParams` | Yes | Request body |

### Return Value

Type: `Promise<boolean>`

BindPanelAgentWithRoleResult (see type definitions and minituya response parameters for field meanings)

### Referenced Types

##### `interface` BindPanelAgentWithRoleParams

| Property | Type | Description |
| --- | --- | --- |
| `devId` | `string` | Device ID |
| `bindRoleType` | `0 \| 1 \| 2` | 0 - custom agent role, 1 - agent role template, 2 - default role in a single-role scenario |
| `roleId` | `string` | Role ID (its meaning depends on bindRoleType) |


### Examples

#### Request example

```typescript
import { bindPanelAgentWithRole } from '@tuya-miniapp/cloud-api';

const params = {
  devId: 'your_device_id',
  bindRoleType: 0,
  roleId: 'role_custom_12345',
};

bindPanelAgentWithRole(params)
  .then(result => {
    console.log('Binding result:', result);
  })
  .catch(error => {
    console.error('Failed to bind role:', error);
  });
```

#### Response example

```json
true
```
