---
name: "createTempCustom"
mode: "api"
versionRequirements:
  - { name: "@ray-js/lock-sdk", version: "1.0.0" }
title: "createTempCustom - Create custom temporary password, supports setting password content, name and validity configuration."
summary: "Create custom temporary password, supports setting password content, name and validity configuration."
---

## createTempCustom

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

### Description

Create a custom temporary password.

### Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `password` | `string` | Yes | Password content, must be numeric |
| `name` | `string` | No | Password name, length cannot exceed 20 |
| `effective` | `EffectiveConfig` | Yes | Password validity configuration |

### Return Value

Type: `Promise<TempPasswordResult>`

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 |
| --- | --- |
| `1052` | The previous operation on the same device has not completed |
| `1030` | Invalid password format |
| `1031` | Password name is too long (exceeds 20 characters) |
| `1032` | Missing effective time configuration |
| `1033` | Missing effective date |
| `1034` | Missing expiration date |
| `1010` | Effective time is later than expiration time |
| `1035` | weeks not provided in weekly repeat mode |
| `1043` | The cloud did not return a sequence number (near-field channel) |
| `1001` | Device is offline (near-field channel) |
| `1002` | Operation timed out (near-field channel) |
| `1041` | Device reported creation failure: duplicate password (near-field channel) |
| `1042` | Device reported creation failure (near-field channel) |
| `1037` | Cloud: Password already exists (USER_PWD_ALREADY_EXIST) |
| `1038` | Cloud: Duplicate password name (LOCK_PWD_NAME_REPEAT) |
| `1039` | Cloud: Invalid time parameters (START_END_DATE_NOT_RIGHT) |

### Referenced Types

##### `type` BitStatus

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

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

##### `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

#### Example

```ts
import { createTempCustom } from '@ray-js/lock-sdk';
await createTempCustom({ password: '123456', effectiveTime: 1700000000, invalidTime: 1700086400 });
```
