# Response (/docs/settings/mqtt/topics/response)



<Callout title="Tip" type="info">
  Webview Kiosk also utilises the request-response pattern for manual query
  of device information states.<br />
  This pattern is explained in:

  * [EMQX — MQTT 5: Request–Response](https://www.emqx.com/en/blog/mqtt5-request-response)
  * [HiveMQ — MQTT 5 Essentials Part 9: Request–Response Pattern](https://www.hivemq.com/blog/mqtt5-essentials-part9-request-response-pattern/)
</Callout>

## 1. Settings [#1-settings]

### 1.1. Topic Name [#11-topic-name]

All [global variables](/docs/settings/mqtt/#3-global-variables) are supported,
in addition to `RESPONSE_TYPE`. For example,

```js
wk/${USERNAME}/${APP_INSTANCE_ID}/response/${RESPONSE_TYPE}
```

If a `responseTopic` is specified in the request, either in the
payload or using MQTT V5's metadata
([3.1.3.2.7. Response Topic](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901066)),
the reply will be published to that `responseTopic` instead.

**Default:**

```js
wk/response/${RESPONSE_TYPE}
```

### 1.2. Quality of Service (QoS) [#12-quality-of-service-qos]

Quality of Service (QoS) ensures different message delivery guarantees
in case of connection failures.

**Default:** At Most Once (0)

### 1.3. Retain [#13-retain]

Keep response topic messages retained for new subscribers.

**Default:** false

## 2. Payloads [#2-payloads]

All published events will contain the
[shared payload properties](/docs/settings/mqtt/topics#2-shared-payload-properties)
mentioned previously, as well as the following:

| Property           | Type                     | Description                                                                                                                                                                                                                                                |
| ------------------ | ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `responseType`     | string                   | The type of response matching the request type, e.g. `get_status`.                                                                                                                                                                                         |
| `requestMessageId` | string &#x2A;(nullable)* | if a `messageId` was provided in the request, it will be re-used here.                                                                                                                                                                                     |
| `correlationData`  | string &#x2A;(nullable)* | if provided in the request, either in the payload or using MQTT V5's metadata ([3.1.3.2.7. Correlation Data](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901067)), it will be present here in addition to the message's metadata. |

### 2.1. Get Status [#21-get-status]

This response is published when a `get_status` request is received.

Example Payload:

```json
{
  "responseType": "get_status",
  "messageId": "e3d50b37-febf-4289-86ff-bf2f5506fafc",
  "username": "medium-phone-api-35",
  "appInstanceId": "42188f0c-6784-4a52-95b6-8569f0f4d2f1",
  "requestMessageId": null,
  "correlationData": null,
  "data": {
    "currentUrl": "https://webviewkiosk.nktnet.uk",
    "isLocked": false,
    "lockStateType": "NONE",
    "lastInteractionTime": 1764695317211,
    "batteryPercentage": 62,
    "appBrightnessPercentage": -1,
    "systemBrightness": 255,
    "isDeviceInteractive": true
  }
}
```

### 2.2. Get Settings [#22-get-settings]

This response is published when a `get_settings` request is received.

The returned settings will depend on what was included in the request payload.

Example Payload:

```jsonc
{
  "responseType": "get_settings",
  "messageId": "887eb103-43c8-4306-b9cc-97f1e8499fe1",
  "username": "medium-phone-api-35",
  "appInstanceId": "42188f0c-6784-4a52-95b6-8569f0f4d2f1",
  "requestMessageId": null,
  "correlationData": null,
  "data": {
    "settings": {
      // Response settings depends on the request payload
      "appearance.theme": "SYSTEM",
      "device.rotation": "AUTO"
    }
  }
}
```

### 2.3. Get System Info [#23-get-system-info]

This response is published when a `get_system_info` request is received.

```json
{
  "responseType": "get_system_info",
  "messageId": "154ec3ff-ff5a-49e6-9fa0-f6311e6893b8",
  "username": "medium-phone-api-35",
  "appInstanceId": "42188f0c-6784-4a52-95b6-8569f0f4d2f1",
  "requestMessageId": null,
  "correlationData": null,
  "data": {
    "app": {
      "name": "Webview Kiosk",
      "packageName": "uk.nktnet.webviewkiosk",
      "versionName": "0.25.0.12-mqtt-beta",
      "versionCode": 98,
      "minSdk": 21,
      "targetSdk": 36,
      "isDebug": true,
      "installer": null,
      "isDeviceOwner": false,
      "isLockTaskPermitted": true,
      "dhizukuPermissionGranted": true,
      "instanceId": "42188f0c-6784-4a52-95b6-8569f0f4d2f1",
      "sourceCodeUrl": "https://github.com/nktnet1/webview-kiosk"
    },
    "device": {
      "releaseVersion": "15",
      "sdkVersion": 35,
      "incrementalVersion": "12592187",
      "webViewVersion": "141.0.7390.122",
      "screenWidth": 1080,
      "screenHeight": 2400,
      "screenDensity": 2.625,
      "isManagedProfile": false,
      "timeZone": "Australia/Sydney",
      "locale": "en_US",
      "totalMemory": 2070986752,
      "totalStorage": 6228115456,
      "manufacturer": "Google",
      "model": "sdk_gphone64_arm64",
      "brand": "google",
      "device": "emu64a",
      "product": "sdk_gphone64_arm64",
      "hardware": "ranchu",
      "board": "goldfish_arm64",
      "bootloader": "unknown",
      "securityPatch": "2024-09-05",
      "supportedAbis": [
        "arm64-v8a"
      ],
      "supported32BitAbis": [],
      "supported64BitAbis": [
        "arm64-v8a"
      ],
      "buildFingerprint": "google/sdk_gphone64_arm64/emu64a:15/AE3A.240806.036/12592187:user/release-keys"
    }
  }
}
```

### 2.4. Get Launchable Packages [#24-get-launchable-packages]

This response is published when a `get_launchable_packages` request is received.

Example Payload:

```json
{
  "responseType": "get_launchable_packages",
  "messageId": "69569438-c6c7-488f-bce4-f9b348e3baad",
  "username": "medium-phone-api-35",
  "appInstanceId": "42188f0c-6784-4a52-95b6-8569f0f4d2f1",
  "requestMessageId": null,
  "correlationData": null,
  "data": {
    "packages": [
      "com.afwsamples.testdpc",
      "com.android.vending",
      "com.bintianqi.owndroid",
      "com.google.android.calendar",
      "com.google.android.deskclock",
      "com.looker.droidify"
      "com.rosan.dhizuku",
      "com.termux",
      "moe.shizuku.privileged.api"
      "uk.nktnet.webviewkiosk"
    ]
  }
}
```

### 2.5. Get Lock Task Packages [#25-get-lock-task-packages]

This response is published when a `get_lock_task_packages` request is received.

Example Payload:

```json
{
  "responseType": "get_lock_task_packages",
  "messageId": "aa92ece1-4daf-4a44-83ad-cbfc5317f8c0",
  "username": "medium-phone-api-35",
  "appInstanceId": "42188f0c-6784-4a52-95b6-8569f0f4d2f1",
  "requestMessageId": null,
  "correlationData": null,
  "data": {
    "packages": [
      "com.google.android.calendar",
      "com.google.android.deskclock",
      "uk.nktnet.webviewkiosk"
    ]
  }
}
```

### 2.6. Error [#26-error]

This response is published whenever an error occurs with processing a request.

For example, the `requestType` could be invalid.

Example Payload:

```json
{
  "responseType": "error",
  "messageId": "058a8f44-d34a-43b6-a7e7-8f5537cea62f",
  "username": "medium-phone-api-35",
  "appInstanceId": "42188f0c-6784-4a52-95b6-8569f0f4d2f1",
  "requestMessageId": null,
  "correlationData": null,
  "payloadStr": "{\n  \"requestType\": \"invalid\"\n}",
  "errorMessage": "Unexpected JSON token at offset 0: Serializer for subclass 'invalid' is not found in the polymorphic scope of 'MqttRequestMessage' at path: $\nCheck if class with serial name 'invalid' exists and serializer is registered in a corresponding SerializersModule.\nTo be registered automatically, class 'invalid' has to be '@Serializable', and the base class 'MqttRequestMessage' has to be sealed and '@Serializable'.\nJSON input: {\n  \"requestType\": \"invalid\"\n}"
}
```
