---
name: "createTempLimit"
mode: "api"
versionRequirements:
  - { name: "@ray-js/lock-sdk", version: "1.0.0" }
title: "createTempLimit - Create temporary time-limited password."
summary: "Create temporary time-limited password."
---

## createTempLimit

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

### Description

Create a time-limited temporary password

### Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | `string` | Yes | Password name, length must not exceed 20 |
| `effectiveTime` | `number` | Yes | Password effective start time (seconds) |
| `invalidTime` | `number` | Yes | Password effective end time (seconds) |

### Return Value

Type: `Promise<TempPasswordResult>`

Time-limited temporary password creation result

##### TempPasswordResult

| Property | Type | Description |
| --- | --- | --- |
| `type` | `"once" \| "limit" \| "custom" \| "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 (exceeds 20 characters) |
| `1010` | Start time is later than expiry time |
| `1038` | Cloud: Duplicate password name (OFFLINE_PWD_NAME_REPEAT) |
| `1067` | Cloud: Offline passwords for the period exhausted (OFFLINE_PWD_EXAUST_IN_PERIOD) |

### Referenced Types

##### `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,
];
```

##### `type` BitStatus

Bit switch: 0 off, 1 on / Single-bit flag

```typescript
export type BitStatus = 0 | 1;
```


### Examples

#### Example

```ts
import { createTempLimit } from '@ray-js/lock-sdk';
const result = await createTempLimit({ count: 5 });
```
