---
name: "startAddUnlockMethod"
mode: "api"
versionRequirements:
  - { name: "@ray-js/lock-sdk", version: "1.0.0" }
title: "startAddUnlockMethod - 开始添加开锁方式。"
summary: "开始添加开锁方式。此方法用于开始添加指纹、人脸、卡片等需要录入的开锁方式。"
---

## startAddUnlockMethod

> [VERSION] @ray-js/lock-sdk >= 1.0.0

### 描述

开始添加开锁方式

### 参数

| 参数 | 类型 | 必填 | 描述 |
| --- | --- | --- | --- |
| `type` | `"finger" \| "face" \| "password" \| "card" \| "fingerVein" \| "hand" \| "eye"` | 是 | 开锁方式类型 |
| `userId` | `string` | 是 | 用户 id |
| `timeout` | `number` | 否 | 超时时间（毫秒） |

### 返回值

类型: `Promise<StartAddUnlockMethodResult>`

无（流程结束后 resolve）

##### StartAddUnlockMethodResult

| 属性 | 类型 | 描述 |
| --- | --- | --- |
| `total` | `number` | 总步骤数 |

### 错误码

| 错误码 | 错误信息 |
| --- | --- |
| `1014` | 不支持该开锁方式类型 |
| `1001` | 设备不在线 |
| `1002` | 操作超时 |
| `1015` | ~1025 设备上报添加失败（status 0~10） |
| `1026` | 设备上报添加失败（status 0xfe） |
| `1027` | 设备上报未知阶段 |

### 示例代码

#### 示例

```ts
import { startAddUnlockMethod } from '@ray-js/lock-sdk';
await startAddUnlockMethod({ type: 'fingerprint', userId: 'user_001' });
```
