---
name: "publishThingModelMessage"
mode: "kit"
versionRequirements:
  - { name: "DeviceKit", version: "2.0.7" }
platform:
  - "iOS"
  - "Android"
async: true
---

## publishThingModelMessage

> [VERSION] DeviceKit >= 2.0.7

> [PLATFORM] iOS, Android

> ⚡ **Supports Promise** — Returns a Promise when success / fail / complete callbacks are omitted.

### Description

Send message via Thing Model

### Parameters

| Property | Type | Required | Default | Since | Description |
| --- | --- | --- | --- | --- | --- |
| `devId` | `string` | Yes | - | `2.0.7` | Device ID |
| `type` | `number` | Yes | - | `2.0.7` | Type 0: property, 1: action, 2: event |
| `payload` | `Record<string, any>` | Yes | - | `2.0.7` | Thing model message payload; the structure varies by type, as follows: Example:   type == property:      payload = {       "color":"green",          "brightness": 50       }   type == action:      payload = {         "actionCode": "testAction",         "inputParams": {           "inputParam1":"value1",           "inputParam2":"value2"         }      } |
| `complete` | `() => void` | No | - | - | Complete callback (executed on success or failure) |
| `success` | `() => void` | No | - | - | Success callback |
| `fail` | `(params: Object) => void` ↓see below | No | - | - | Failure callback |

#### fail callback parameters

| Property | Type | Description |
| --- | --- | --- |
| `errorMsg` | `string` | Error message |
| `errorCode` | `string \| number` | Error code |
| `innerError` | `Object` | Error extension |

##### fail(params).innerError properties

| Property | Type | Description |
| --- | --- | --- |
| `errorCode` | `string \| number` | Extended error code |
| `errorMsg` | `string` | Extended error message |
