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

## addCommandToCache

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

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

### Description

Add a command (a JSON string of DP key-value pairs) to the cloud cache so it can be delivered to the specified device later. Supports Wi-Fi and ZigBee devices.

### Parameters

`Params`

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

### Return Value

Type: `Promise<boolean>`

Operation result; true indicates success. In the documentation, the return parameter is labeled result (boolean).

### Referenced Types

##### `interface` AddCommandToCacheParams

| Property | Type | Description |
| --- | --- | --- |
| `devId` | `string` | Device ID |
| `dps` | `string` | JSON string of DP key-value pairs |
| `time` | `number` | Timestamp when the command is sent, in milliseconds |


### Examples

#### Request example

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

const result = await addCommandToCache({
  devId: 'your_device_id',
  dps: JSON.stringify({
    switch_1: true,
  }),
  time: Date.now(),
});
```

#### Response example

```json
true
```
