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

# Fracttal One Api

> Client-mode REST API connector for Fracttal One CMMS: create work requests from alarms, turn them into pending tasks and work orders, update work order status and notes or cancel them, read and update assets, create meters and push meter readings, with OAuth 2.0 client credentials

Technical Preview

## Overview

Client-mode REST API connector for Fracttal One CMMS: create work requests from alarms, turn them into pending tasks and work orders, update work order status and notes or cancel them, read and update assets, create meters and push meter readings, with OAuth 2.0 client credentials.

This is one of the templates in the Fracttal One REST API app (`fracttal-one`). Deploy it alongside the other connectors of that app when they depend on each other (for example a token connector plus an API connector).

> [!NOTE]
>
> Not yet verified against the live vendor API: No Fracttal One account or OAuth consumer on the factory box (no FRACTTAL\_\* variables); only static, mock, negative-control and fake-credential public probes ran.

## Auth

OAuth 2.0 client credentials (queue hint 'API key + secret' refers to the older Hawk scheme, which needs a per-request MAC and is not used). GetToken / RefreshToken: Basic base64(key:secret) + form body to [https://one.fracttal.com/oauth/token](https://one.fracttal.com/oauth/token); tokens last 7200 s. API events: Authorization: Bearer \<access\_token> from payload. Every event also sends User-Agent: Coreflux-Broker.

Auth headers used by the template: `Authorization: Bearer {value.json.access_token}`.

## Template parameters

| Placeholder | Type | Description | Required |
| - | - | - | - |
| `RouteName` | string | Name of the Fracttal One Api connector | no |
| `BaseUrl` | string | Fracttal One Api base URL without trailing slash (e.g. [https://app.fracttal.com](https://app.fracttal.com)) | yes |

`BASE_ADDRESS` default: `https://app.fracttal.com`.

## Events

| Event | Method | Endpoint | Request topic | Response topic | Payload fields |
| - | - | - | - | - | - |
| `ListAssets` | GET | `/api/items/?{value.json.query}` | `cmms/fracttal/asset/list` | `cmms/fracttal/asset/list/response` | `access_token`, `query` |
| `GetAsset` | GET | `/api/items/{value.json.code}` | `cmms/fracttal/asset/get` | `cmms/fracttal/asset/get/response` | `access_token`, `code` |
| `UpdateAsset` | PUT | `/api/items/{value.json.code}` | `cmms/fracttal/asset/update` | `cmms/fracttal/asset/update/response` | `access_token`, `body`, `code` |
| `ListMeters` | GET | `/api/meters_list/?{value.json.query}` | `cmms/fracttal/meter/list` | `cmms/fracttal/meter/list/response` | `access_token`, `query` |
| `ListMeterReadings` | GET | `/api/meters_reading_list/?{value.json.query}` | `cmms/fracttal/meter-reading/list` | `cmms/fracttal/meter-reading/list/response` | `access_token`, `query` |
| `CreateMeter` | POST | `/api/meters` | `cmms/fracttal/meter/create` | `cmms/fracttal/meter/create/response` | `access_token`, `body` |
| `AddMeterReading` | PUT | `/api/meter_reading/{value.json.code}` | `cmms/fracttal/meter-reading/create` | `cmms/fracttal/meter-reading/create/response` | `access_token`, `body`, `code` |
| `ListWorkRequests` | GET | `/api/work_requests?{value.json.query}` | `cmms/fracttal/work-request/list` | `cmms/fracttal/work-request/list/response` | `access_token`, `query` |
| `GetWorkRequest` | GET | `/api/work_requests/{value.json.code}` | `cmms/fracttal/work-request/get` | `cmms/fracttal/work-request/get/response` | `access_token`, `code` |
| `ListWorkRequestStatusChanges` | GET | `/api/work_requests_status/?{value.json.query}` | `cmms/fracttal/work-request-status/list` | `cmms/fracttal/work-request-status/list/response` | `access_token`, `query` |
| `CreateWorkRequest` | POST | `/api/work_requests` | `cmms/fracttal/work-request/create` | `cmms/fracttal/work-request/create/response` | `access_token`, `body` |
| `UpdateWorkRequestData` | PUT | `/api/work_requests_data/{value.json.code}` | `cmms/fracttal/work-request/update` | `cmms/fracttal/work-request/update/response` | `access_token`, `body`, `code` |
| `CreateTaskFromWorkRequest` | POST | `/api/tasks_from_work_request/` | `cmms/fracttal/work-request/to-task` | `cmms/fracttal/work-request/to-task/response` | `access_token`, `body` |
| `CreateUnscheduledTask` | POST | `/api/tasks_nonscheduled` | `cmms/fracttal/task/create-unscheduled` | `cmms/fracttal/task/create-unscheduled/response` | `access_token`, `body` |
| `ListWorkOrders` | GET | `/api/work_orders?{value.json.query}` | `cmms/fracttal/work-order/list` | `cmms/fracttal/work-order/list/response` | `access_token`, `query` |
| `GetWorkOrder` | GET | `/api/work_orders/{value.json.folio}` | `cmms/fracttal/work-order/get` | `cmms/fracttal/work-order/get/response` | `access_token`, `folio` |
| `CreateWorkOrder` | POST | `/api/work_orders` | `cmms/fracttal/work-order/create` | `cmms/fracttal/work-order/create/response` | `access_token`, `body` |
| `UpdateWorkOrderStatus` | PUT | `/api/work_order_change_status/{value.json.folio}` | `cmms/fracttal/work-order/status` | `cmms/fracttal/work-order/status/response` | `access_token`, `body`, `folio` |
| `UpdateWorkOrderNote` | PUT | `/api/work_orders/{value.json.folio}` | `cmms/fracttal/work-order/note` | `cmms/fracttal/work-order/note/response` | `access_token`, `body`, `folio` |
| `CancelWorkOrder` | PUT | `/api/work_order_cancel?folio={value.json.folio}` | `cmms/fracttal/work-order/cancel` | `cmms/fracttal/work-order/cancel/response` | `access_token`, `body`, `folio` |

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

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 FracttalOneApi WITH TYPE REST_API
    ADD REST_API_CONFIG
        WITH BASE_ADDRESS "https://app.fracttal.com"
        WITH ENABLE_CLIENT "true"
        WITH USE_SSL "true"
        WITH REQUEST_TIMEOUT '30'
        WITH DEFAULT_CONTENT_TYPE "application/json"
    ADD EVENT ListAssets
        WITH SOURCE_TOPIC "cmms/fracttal/asset/list"
        WITH DESTINATION_TOPIC "cmms/fracttal/asset/list/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/api/items/?{value.json.query}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker"
            ADD "Authorization" "Bearer {value.json.access_token}"
    ADD EVENT GetAsset
        WITH SOURCE_TOPIC "cmms/fracttal/asset/get"
        WITH DESTINATION_TOPIC "cmms/fracttal/asset/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/api/items/{value.json.code}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker"
            ADD "Authorization" "Bearer {value.json.access_token}"
    ADD EVENT UpdateAsset
        WITH SOURCE_TOPIC "cmms/fracttal/asset/update"
        WITH DESTINATION_TOPIC "cmms/fracttal/asset/update/response"
        WITH METHOD "PUT"
        WITH ENDPOINT "/api/items/{value.json.code}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker"
            ADD "Authorization" "Bearer {value.json.access_token}"
            ADD "Content-Type" "application/json"
        WITH BODY "{value.json.body}"
    ADD EVENT ListMeters
        WITH SOURCE_TOPIC "cmms/fracttal/meter/list"
        WITH DESTINATION_TOPIC "cmms/fracttal/meter/list/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/api/meters_list/?{value.json.query}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker"
            ADD "Authorization" "Bearer {value.json.access_token}"
    ADD EVENT ListMeterReadings
        WITH SOURCE_TOPIC "cmms/fracttal/meter-reading/list"
        WITH DESTINATION_TOPIC "cmms/fracttal/meter-reading/list/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/api/meters_reading_list/?{value.json.query}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker"
            ADD "Authorization" "Bearer {value.json.access_token}"
    ADD EVENT CreateMeter
        WITH SOURCE_TOPIC "cmms/fracttal/meter/create"
        WITH DESTINATION_TOPIC "cmms/fracttal/meter/create/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/api/meters"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker"
            ADD "Authorization" "Bearer {value.json.access_token}"
            ADD "Content-Type" "application/json"
        WITH BODY "{value.json.body}"
    ADD EVENT AddMeterReading
        WITH SOURCE_TOPIC "cmms/fracttal/meter-reading/create"
        WITH DESTINATION_TOPIC "cmms/fracttal/meter-reading/create/response"
        WITH METHOD "PUT"
        WITH ENDPOINT "/api/meter_reading/{value.json.code}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker"
            ADD "Authorization" "Bearer {value.json.access_token}"
            ADD "Content-Type" "application/json"
        WITH BODY "{value.json.body}"
    ADD EVENT ListWorkRequests
        WITH SOURCE_TOPIC "cmms/fracttal/work-request/list"
        WITH DESTINATION_TOPIC "cmms/fracttal/work-request/list/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/api/work_requests?{value.json.query}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker"
            ADD "Authorization" "Bearer {value.json.access_token}"
    ADD EVENT GetWorkRequest
        WITH SOURCE_TOPIC "cmms/fracttal/work-request/get"
        WITH DESTINATION_TOPIC "cmms/fracttal/work-request/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/api/work_requests/{value.json.code}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker"
            ADD "Authorization" "Bearer {value.json.access_token}"
    ADD EVENT ListWorkRequestStatusChanges
        WITH SOURCE_TOPIC "cmms/fracttal/work-request-status/list"
        WITH DESTINATION_TOPIC "cmms/fracttal/work-request-status/list/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/api/work_requests_status/?{value.json.query}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker"
            ADD "Authorization" "Bearer {value.json.access_token}"
    ADD EVENT CreateWorkRequest
        WITH SOURCE_TOPIC "cmms/fracttal/work-request/create"
        WITH DESTINATION_TOPIC "cmms/fracttal/work-request/create/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/api/work_requests"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker"
            ADD "Authorization" "Bearer {value.json.access_token}"
            ADD "Content-Type" "application/json"
        WITH BODY "{value.json.body}"
    ADD EVENT UpdateWorkRequestData
        WITH SOURCE_TOPIC "cmms/fracttal/work-request/update"
        WITH DESTINATION_TOPIC "cmms/fracttal/work-request/update/response"
        WITH METHOD "PUT"
        WITH ENDPOINT "/api/work_requests_data/{value.json.code}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker"
            ADD "Authorization" "Bearer {value.json.access_token}"
            ADD "Content-Type" "application/json"
        WITH BODY "{value.json.body}"
    ADD EVENT CreateTaskFromWorkRequest
        WITH SOURCE_TOPIC "cmms/fracttal/work-request/to-task"
        WITH DESTINATION_TOPIC "cmms/fracttal/work-request/to-task/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/api/tasks_from_work_request/"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker"
            ADD "Authorization" "Bearer {value.json.access_token}"
            ADD "Content-Type" "application/json"
        WITH BODY "{value.json.body}"
    ADD EVENT CreateUnscheduledTask
        WITH SOURCE_TOPIC "cmms/fracttal/task/create-unscheduled"
        WITH DESTINATION_TOPIC "cmms/fracttal/task/create-unscheduled/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/api/tasks_nonscheduled"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker"
            ADD "Authorization" "Bearer {value.json.access_token}"
            ADD "Content-Type" "application/json"
        WITH BODY "{value.json.body}"
    ADD EVENT ListWorkOrders
        WITH SOURCE_TOPIC "cmms/fracttal/work-order/list"
        WITH DESTINATION_TOPIC "cmms/fracttal/work-order/list/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/api/work_orders?{value.json.query}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker"
            ADD "Authorization" "Bearer {value.json.access_token}"
    ADD EVENT GetWorkOrder
        WITH SOURCE_TOPIC "cmms/fracttal/work-order/get"
        WITH DESTINATION_TOPIC "cmms/fracttal/work-order/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/api/work_orders/{value.json.folio}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker"
            ADD "Authorization" "Bearer {value.json.access_token}"
    ADD EVENT CreateWorkOrder
        WITH SOURCE_TOPIC "cmms/fracttal/work-order/create"
        WITH DESTINATION_TOPIC "cmms/fracttal/work-order/create/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/api/work_orders"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker"
            ADD "Authorization" "Bearer {value.json.access_token}"
            ADD "Content-Type" "application/json"
        WITH BODY "{value.json.body}"
    ADD EVENT UpdateWorkOrderStatus
        WITH SOURCE_TOPIC "cmms/fracttal/work-order/status"
        WITH DESTINATION_TOPIC "cmms/fracttal/work-order/status/response"
        WITH METHOD "PUT"
        WITH ENDPOINT "/api/work_order_change_status/{value.json.folio}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker"
            ADD "Authorization" "Bearer {value.json.access_token}"
            ADD "Content-Type" "application/json"
        WITH BODY "{value.json.body}"
    ADD EVENT UpdateWorkOrderNote
        WITH SOURCE_TOPIC "cmms/fracttal/work-order/note"
        WITH DESTINATION_TOPIC "cmms/fracttal/work-order/note/response"
        WITH METHOD "PUT"
        WITH ENDPOINT "/api/work_orders/{value.json.folio}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker"
            ADD "Authorization" "Bearer {value.json.access_token}"
            ADD "Content-Type" "application/json"
        WITH BODY "{value.json.body}"
    ADD EVENT CancelWorkOrder
        WITH SOURCE_TOPIC "cmms/fracttal/work-order/cancel"
        WITH DESTINATION_TOPIC "cmms/fracttal/work-order/cancel/response"
        WITH METHOD "PUT"
        WITH ENDPOINT "/api/work_order_cancel?folio={value.json.folio}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker"
            ADD "Authorization" "Bearer {value.json.access_token}"
            ADD "Content-Type" "application/json"
        WITH BODY "{value.json.body}"
```

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

## Usage example

Call `ListAssets` 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 'cmms/fracttal/asset/list/response' &
mosquitto_pub -t 'cmms/fracttal/asset/list' -m '{"access_token": "<access_token>", "query": "<query>"}'
```

## Related

* [REST API Connectors](/latest/lot-language/routes/rest-api-routes)
* [REST API Apps catalog](/latest/lot-language/routes/rest-api-apps)


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