> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreflux.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Ubidots

> Client-mode REST API connector for a curated Ubidots v1.6 slice: post device values and read a variable

Technical Preview

# Ubidots

Client-mode REST API connector for a curated Ubidots v1.6 slice: post device values and read a variable.

* Hub category: **Cloud IoT**.
* Base: `https://industrial.api.ubidots.com`

## Template reference

Generated from the shipped broker template `ubidots` (`-routeCode UBIDOTS`). It lists every event the template defines.

### Auth

Auth headers used by the template: `X-Auth-Token: Bearer {value.json.api_token}`.

### Template parameters

| Placeholder | Type | Description | Required |
| - | - | - | - |
| `RouteName` | string | Name of the Ubidots connector | no |
| `BaseUrl` | string | Ubidots base URL without trailing slash (e.g. [https://industrial.api.ubidots.com](https://industrial.api.ubidots.com)) | yes |

`BASE_ADDRESS` default: `https://industrial.api.ubidots.com`.

### Events

| Event | Method | Endpoint | Request topic | Response topic | Payload fields |
| - | - | - | - | - | - |
| `Postvalues` | POST | `/api/v1.6/devices/{value.json.device}` | `iot/ubidots/devices/post` | `iot/ubidots/devices/post/response` | `api_token`, `body`, `device` |
| `Getvalues` | GET | `/api/v1.6/devices/{value.json.device}/{value.json.variable}/values` | `iot/ubidots/variables/values` | `iot/ubidots/variables/values/response` | `api_token`, `device`, `variable` |

### Deploy

Get the template card (JSON with `template` and `metadata`) from the broker, then deploy the connector:

```bash theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
mosquitto_pub -t '$SYS/Coreflux/Command' -m "-routeCode UBIDOTS"
```

The deployable connector from the REST API app, with `BASE_ADDRESS` already filled in:

```lot theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
DEFINE ROUTE UbidotsRestApi WITH TYPE REST_API
    ADD REST_API_CONFIG
        WITH BASE_ADDRESS "https://industrial.api.ubidots.com"
        WITH ENABLE_CLIENT "true"
        WITH USE_SSL "true"
        WITH REQUEST_TIMEOUT '60'
        WITH DEFAULT_CONTENT_TYPE "application/json"
    ADD EVENT Postvalues
        WITH SOURCE_TOPIC "iot/ubidots/devices/post"
        WITH DESTINATION_TOPIC "iot/ubidots/devices/post/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/api/v1.6/devices/{value.json.device}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "X-Auth-Token" "Bearer {value.json.api_token}"
        WITH BODY "{value.json.body}"
    ADD EVENT Getvalues
        WITH SOURCE_TOPIC "iot/ubidots/variables/values"
        WITH DESTINATION_TOPIC "iot/ubidots/variables/values/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/api/v1.6/devices/{value.json.device}/{value.json.variable}/values"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "X-Auth-Token" "Bearer {value.json.api_token}"
```

Deploy it with `-addRoute` (do not include `ADD METADATA`).

### Usage example

Call `Postvalues` by publishing a JSON payload to its request topic, and read the reply on the response topic:

```bash theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
mosquitto_sub -t 'iot/ubidots/devices/post/response' &
mosquitto_pub -t 'iot/ubidots/devices/post' -m '{"api_token": "<api_token>", "body": {}, "device": "<device>"}'
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.