---
name: "createTempClear"
mode: "api"
versionRequirements:
  - { name: "@ray-js/lock-sdk", version: "1.0.0" }
title: "createTempClear - Generate clear password."
summary: "Generate clear password. Can support clearing all or a specific time-limited password."
---

## createTempClear

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

### Description

Create an offline password clear code

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `params` | `CreateClearParams` | Yes | Clear parameters |

### Return Value

Type: `Promise<TempPasswordResult>`

Offline clear code creation result

##### TempPasswordResult

| Property | Type | Description |
| --- | --- | --- |
| `type` | `"custom" \| "once" \| "limit" \| "clear" \| "clearOne" \| "dynamic"` | Password type, or dynamic (dynamic code) |
| `name` | `string` | Display name |
| `password` | `string` | Password plaintext or display string |
| `unlockBindingId` | `string` | Cloud binding relationship ID |
| `effectiveConfig` | `EffectiveConfig` | Effective time configuration |

### Error Codes

| Error Code | Error Message |
| --- | --- |
| `1031` | Password name too long (over 20 characters) |
| `1044` | unlockBindingId not specified when not clearing all |
| `1038` | Cloud: duplicate password name (OFFLINE_PWD_NAME_REPEAT) |
| `1067` | Cloud: offline passwords exhausted for the period (OFFLINE_PWD_EXAUST_IN_PERIOD) |
| `1040` | Cloud: record not found (RECORD_NOT_EXIST) |

### Referenced Types

##### `interface` CreateClearParams

| Property | Type | Description |
| --- | --- | --- |
| `name` | `string` | Name |
| `unlockBindingId` | `string` | Single password binding ID (required when clearAll is false) |
| `clearAll` | `boolean` | Whether to clear all time-limited passwords |

##### `interface` EffectiveConfig

| Property | Type | Description |
| --- | --- | --- |
| `effectiveDate` | `number` | Effective date (seconds-level timestamp) |
| `expiredDate` | `number` | Expiration date (seconds-level timestamp) |
| `repeat` | `"none" \| "week"` | Repeat policy: none or weekly |
| `weeks` | `Week` | Weekly repeat bitmap |
| `effectiveTime` | `number` | Daily start time (minutes) |
| `expiredTime` | `number` | Daily end time (minutes) |

##### `type` Week

Weekly repeat bitmap: indices 0–6 correspond to Sun–Sat; 0 inactive, 1 active

```typescript
export type Week = [
  BitStatus,
  BitStatus,
  BitStatus,
  BitStatus,
  BitStatus,
  BitStatus,
  BitStatus,
];
```


### Examples

```ts
import { createTempClear } from '@ray-js/lock-sdk';
const result = await createTempClear({ type: 'all' });
```
