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

# Aveva Mes Api

> Client-mode REST API connector for AVEVA MES (formerly Wonderware MES): read the job queue, work orders, OEE and utilization, and post production counts, consumption, downtime events and job state changes from MQTT through the MES Web API V3

Technical Preview

## Overview

Client-mode REST API connector for AVEVA MES (formerly Wonderware MES): read the job queue, work orders, OEE and utilization, and post production counts, consumption, downtime events and job state changes from MQTT through the MES Web API V3.

This is one of the templates in the AVEVA MES (formerly Wonderware MES) REST API app (`aveva-mes`). 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 AVEVA MES server or AIM client on the factory box (no AVEVA\_MES\_\* variables) and AVEVA offers no public MES sandbox; the ready gate needs an authenticated live GET + POST (or broker MQTT round-trip). Mock-server checks do not clear the gate.

## Auth

MES security mode OS User or OS Group + AVEVA Identity Manager. Register a service client with RegisterAIMServiceClient.ps1 (InstallFiles/CD-MES/AIMRegistration), POST https\://\<AIM host>/identitymanager/connect/token grant\_type=client\_credentials (form) -> access\_token (24 h default), then Authorization: Bearer \<token> from the MQTT payload field authorization. Service-to-service calls run as the MES Default Background User (system attribute 199).

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

## Template parameters

| Placeholder | Type | Description | Required |
| - | - | - | - |
| `RouteName` | string | Name of the Aveva Mes Api connector | no |
| `BaseUrl` | string | Aveva Mes Api base URL without trailing slash (e.g. https\://YOUR\_MES\_SERVER) | yes |

`BASE_ADDRESS` default: `https://YOUR_MES_SERVER`.

## Events

| Event | Method | Endpoint | Request topic | Response topic | Payload fields |
| - | - | - | - | - | - |
| `GetOpenApiSpec` | GET | `/mesmw/swagger/docs/v3` | `mes/aveva-mes/openapi/get` | `mes/aveva-mes/openapi/get/response` | `authorization` |
| `ListEntities` | GET | `/mesmw/api/v3/Entity?{value.json.query}` | `mes/aveva-mes/entity/list` | `mes/aveva-mes/entity/list/response` | `authorization`, `query` |
| `GetEntity` | GET | `/mesmw/api/v3/Entity/key?entId={value.json.ent_id}` | `mes/aveva-mes/entity/get` | `mes/aveva-mes/entity/get/response` | `authorization`, `ent_id` |
| `FindEntityId` | GET | `/mesmw/api/v3/Entity/name?entName={value.json.ent_name}&siteName={value.json.site_name}` | `mes/aveva-mes/entity-id/get` | `mes/aveva-mes/entity-id/get/response` | `authorization`, `ent_name`, `site_name` |
| `ListLines` | GET | `/mesmw/api/v3/line` | `mes/aveva-mes/line/list` | `mes/aveva-mes/line/list/response` | `authorization` |
| `ListLineEntities` | GET | `/mesmw/api/v3/LineEntity?{value.json.query}` | `mes/aveva-mes/line-entity/list` | `mes/aveva-mes/line-entity/list/response` | `authorization`, `query` |
| `GetJobQueue` | GET | `/mesmw/api/v3/JobQueue?{value.json.query}` | `mes/aveva-mes/job-queue/get` | `mes/aveva-mes/job-queue/get/response` | `authorization`, `query` |
| `ListWorkOrders` | GET | `/mesmw/api/v3/WO/filter?{value.json.query}` | `mes/aveva-mes/work-order/list` | `mes/aveva-mes/work-order/list/response` | `authorization`, `query` |
| `GetWorkOrder` | GET | `/mesmw/api/v3/WO/key?woId={value.json.wo_id}` | `mes/aveva-mes/work-order/get` | `mes/aveva-mes/work-order/get/response` | `authorization`, `wo_id` |
| `ListWorkOrderJobs` | GET | `/mesmw/api/v3/Jobs?woId={value.json.wo_id}` | `mes/aveva-mes/work-order-jobs/list` | `mes/aveva-mes/work-order-jobs/list/response` | `authorization`, `wo_id` |
| `GetJob` | GET | `/mesmw/api/v3/Jobs/key?woId={value.json.wo_id}&operId={value.json.oper_id}&seqNo={value.json.seq_no}` | `mes/aveva-mes/job/get` | `mes/aveva-mes/job/get/response` | `authorization`, `oper_id`, `seq_no`, `wo_id` |
| `GetJobExec` | GET | `/mesmw/api/v3/JobExec/key?{value.json.query}` | `mes/aveva-mes/job-exec/get` | `mes/aveva-mes/job-exec/get/response` | `authorization`, `query` |
| `GetOeeExec` | GET | `/mesmw/api/v3/OeeExec/key?entId={value.json.ent_id}` | `mes/aveva-mes/oee-exec/get` | `mes/aveva-mes/oee-exec/get/response` | `authorization`, `ent_id` |
| `GetEntityCountsAndDuration` | GET | `/mesmw/api/v3/countsAndDuration/entity?{value.json.query}` | `mes/aveva-mes/counts-duration-entity/get` | `mes/aveva-mes/counts-duration-entity/get/response` | `authorization`, `query` |
| `GetLineCountsAndDuration` | GET | `/mesmw/api/v3/countsAndDuration/line?{value.json.query}` | `mes/aveva-mes/counts-duration-line/get` | `mes/aveva-mes/counts-duration-line/get/response` | `authorization`, `query` |
| `ListUtilStates` | GET | `/mesmw/api/v3/UtilState` | `mes/aveva-mes/util-state/list` | `mes/aveva-mes/util-state/list/response` | `authorization` |
| `ListUtilReasons` | GET | `/mesmw/api/v3/utilreason/flat` | `mes/aveva-mes/util-reason/list` | `mes/aveva-mes/util-reason/list/response` | `authorization` |
| `GetAllowableReasons` | GET | `/mesmw/api/v3/Util/AllowableReasons?entID={value.json.ent_id}` | `mes/aveva-mes/allowable-reason/list` | `mes/aveva-mes/allowable-reason/list/response` | `authorization`, `ent_id` |
| `ListProduction` | GET | `/mesmw/api/v3/Production/filter?{value.json.query}` | `mes/aveva-mes/production/list` | `mes/aveva-mes/production/list/response` | `authorization`, `query` |
| `ListConsumption` | GET | `/mesmw/api/v3/Consumption/filter?{value.json.query}` | `mes/aveva-mes/consumption/list` | `mes/aveva-mes/consumption/list/response` | `authorization`, `query` |
| `ListItems` | GET | `/mesmw/api/v3/Item/filter?{value.json.query}` | `mes/aveva-mes/item/list` | `mes/aveva-mes/item/list/response` | `authorization`, `query` |
| `ListInventory` | GET | `/mesmw/api/v3/ItemInventory/filter?{value.json.query}` | `mes/aveva-mes/inventory/list` | `mes/aveva-mes/inventory/list/response` | `authorization`, `query` |
| `ListLots` | GET | `/mesmw/api/v3/Lot/filter?{value.json.query}` | `mes/aveva-mes/lot/list` | `mes/aveva-mes/lot/list/response` | `authorization`, `query` |
| `ListSamples` | GET | `/mesmw/api/v3/Sample/filter?{value.json.query}` | `mes/aveva-mes/sample/list` | `mes/aveva-mes/sample/list/response` | `authorization`, `query` |
| `AddProductionByJob` | POST | `/mesmw/api/v3/Production/ByJob` | `mes/aveva-mes/production/post` | `mes/aveva-mes/production/post/response` | `authorization`, `body` |
| `AddProductionPostExec` | POST | `/mesmw/api/v3/Production/PostExec` | `mes/aveva-mes/production-post-exec/post` | `mes/aveva-mes/production-post-exec/post/response` | `authorization`, `body` |
| `AddConsumptionByJob` | POST | `/mesmw/api/v3/Consumption/ByJob` | `mes/aveva-mes/consumption/post` | `mes/aveva-mes/consumption/post/response` | `authorization`, `body` |
| `AddUtilizationEvent` | POST | `/mesmw/api/v3/UtilHistory/AddEvent` | `mes/aveva-mes/util-event/post` | `mes/aveva-mes/util-event/post/response` | `authorization`, `body` |
| `AddCurrentUtilizationEvent` | POST | `/mesmw/api/v3/UtilHistory` | `mes/aveva-mes/util-history/post` | `mes/aveva-mes/util-history/post/response` | `authorization`, `body` |
| `StartJob` | PUT | `/mesmw/api/v3/Jobs/Start` | `mes/aveva-mes/job/start` | `mes/aveva-mes/job/start/response` | `authorization`, `body` |
| `PauseJob` | PUT | `/mesmw/api/v3/Jobs/Pause` | `mes/aveva-mes/job/pause` | `mes/aveva-mes/job/pause/response` | `authorization`, `body` |
| `EndJob` | PUT | `/mesmw/api/v3/Jobs/End` | `mes/aveva-mes/job/end` | `mes/aveva-mes/job/end/response` | `authorization`, `body` |
| `ChangeJobStates` | PUT | `/mesmw/api/v3/Jobs/ChangeJobStates` | `mes/aveva-mes/job-states/put` | `mes/aveva-mes/job-states/put/response` | `authorization`, `body` |
| `ReleaseWorkOrder` | PUT | `/mesmw/api/v3/WO/Release` | `mes/aveva-mes/work-order/release` | `mes/aveva-mes/work-order/release/response` | `authorization`, `body` |
| `RecordSampleData` | PUT | `/mesmw/api/v3/Sample/RecordData` | `mes/aveva-mes/sample-data/put` | `mes/aveva-mes/sample-data/put/response` | `authorization`, `body` |
| `MiddlewareAccessXml` | POST | `/mesmw/api/v3/MiddlewareAccess/xml` | `mes/aveva-mes/middleware-xml/post` | `mes/aveva-mes/middleware-xml/post/response` | `authorization`, `body` |

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

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 AvevaMesApi WITH TYPE REST_API
    ADD REST_API_CONFIG
        WITH BASE_ADDRESS "https://YOUR_MES_SERVER"
        WITH ENABLE_CLIENT "true"
        WITH USE_SSL "true"
        WITH REQUEST_TIMEOUT '60'
        WITH DEFAULT_CONTENT_TYPE "application/json"
    ADD EVENT GetOpenApiSpec
        WITH SOURCE_TOPIC "mes/aveva-mes/openapi/get"
        WITH DESTINATION_TOPIC "mes/aveva-mes/openapi/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/mesmw/swagger/docs/v3"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "{value.json.authorization}"
    ADD EVENT ListEntities
        WITH SOURCE_TOPIC "mes/aveva-mes/entity/list"
        WITH DESTINATION_TOPIC "mes/aveva-mes/entity/list/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/mesmw/api/v3/Entity?{value.json.query}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "{value.json.authorization}"
    ADD EVENT GetEntity
        WITH SOURCE_TOPIC "mes/aveva-mes/entity/get"
        WITH DESTINATION_TOPIC "mes/aveva-mes/entity/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/mesmw/api/v3/Entity/key?entId={value.json.ent_id}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "{value.json.authorization}"
    ADD EVENT FindEntityId
        WITH SOURCE_TOPIC "mes/aveva-mes/entity-id/get"
        WITH DESTINATION_TOPIC "mes/aveva-mes/entity-id/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/mesmw/api/v3/Entity/name?entName={value.json.ent_name}&siteName={value.json.site_name}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "{value.json.authorization}"
    ADD EVENT ListLines
        WITH SOURCE_TOPIC "mes/aveva-mes/line/list"
        WITH DESTINATION_TOPIC "mes/aveva-mes/line/list/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/mesmw/api/v3/line"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "{value.json.authorization}"
    ADD EVENT ListLineEntities
        WITH SOURCE_TOPIC "mes/aveva-mes/line-entity/list"
        WITH DESTINATION_TOPIC "mes/aveva-mes/line-entity/list/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/mesmw/api/v3/LineEntity?{value.json.query}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "{value.json.authorization}"
    ADD EVENT GetJobQueue
        WITH SOURCE_TOPIC "mes/aveva-mes/job-queue/get"
        WITH DESTINATION_TOPIC "mes/aveva-mes/job-queue/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/mesmw/api/v3/JobQueue?{value.json.query}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "{value.json.authorization}"
    ADD EVENT ListWorkOrders
        WITH SOURCE_TOPIC "mes/aveva-mes/work-order/list"
        WITH DESTINATION_TOPIC "mes/aveva-mes/work-order/list/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/mesmw/api/v3/WO/filter?{value.json.query}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "{value.json.authorization}"
    ADD EVENT GetWorkOrder
        WITH SOURCE_TOPIC "mes/aveva-mes/work-order/get"
        WITH DESTINATION_TOPIC "mes/aveva-mes/work-order/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/mesmw/api/v3/WO/key?woId={value.json.wo_id}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "{value.json.authorization}"
    ADD EVENT ListWorkOrderJobs
        WITH SOURCE_TOPIC "mes/aveva-mes/work-order-jobs/list"
        WITH DESTINATION_TOPIC "mes/aveva-mes/work-order-jobs/list/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/mesmw/api/v3/Jobs?woId={value.json.wo_id}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "{value.json.authorization}"
    ADD EVENT GetJob
        WITH SOURCE_TOPIC "mes/aveva-mes/job/get"
        WITH DESTINATION_TOPIC "mes/aveva-mes/job/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/mesmw/api/v3/Jobs/key?woId={value.json.wo_id}&operId={value.json.oper_id}&seqNo={value.json.seq_no}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "{value.json.authorization}"
    ADD EVENT GetJobExec
        WITH SOURCE_TOPIC "mes/aveva-mes/job-exec/get"
        WITH DESTINATION_TOPIC "mes/aveva-mes/job-exec/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/mesmw/api/v3/JobExec/key?{value.json.query}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "{value.json.authorization}"
    ADD EVENT GetOeeExec
        WITH SOURCE_TOPIC "mes/aveva-mes/oee-exec/get"
        WITH DESTINATION_TOPIC "mes/aveva-mes/oee-exec/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/mesmw/api/v3/OeeExec/key?entId={value.json.ent_id}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "{value.json.authorization}"
    ADD EVENT GetEntityCountsAndDuration
        WITH SOURCE_TOPIC "mes/aveva-mes/counts-duration-entity/get"
        WITH DESTINATION_TOPIC "mes/aveva-mes/counts-duration-entity/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/mesmw/api/v3/countsAndDuration/entity?{value.json.query}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "{value.json.authorization}"
    ADD EVENT GetLineCountsAndDuration
        WITH SOURCE_TOPIC "mes/aveva-mes/counts-duration-line/get"
        WITH DESTINATION_TOPIC "mes/aveva-mes/counts-duration-line/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/mesmw/api/v3/countsAndDuration/line?{value.json.query}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "{value.json.authorization}"
    ADD EVENT ListUtilStates
        WITH SOURCE_TOPIC "mes/aveva-mes/util-state/list"
        WITH DESTINATION_TOPIC "mes/aveva-mes/util-state/list/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/mesmw/api/v3/UtilState"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "{value.json.authorization}"
    ADD EVENT ListUtilReasons
        WITH SOURCE_TOPIC "mes/aveva-mes/util-reason/list"
        WITH DESTINATION_TOPIC "mes/aveva-mes/util-reason/list/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/mesmw/api/v3/utilreason/flat"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "{value.json.authorization}"
    ADD EVENT GetAllowableReasons
        WITH SOURCE_TOPIC "mes/aveva-mes/allowable-reason/list"
        WITH DESTINATION_TOPIC "mes/aveva-mes/allowable-reason/list/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/mesmw/api/v3/Util/AllowableReasons?entID={value.json.ent_id}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "{value.json.authorization}"
    ADD EVENT ListProduction
        WITH SOURCE_TOPIC "mes/aveva-mes/production/list"
        WITH DESTINATION_TOPIC "mes/aveva-mes/production/list/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/mesmw/api/v3/Production/filter?{value.json.query}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "{value.json.authorization}"
    ADD EVENT ListConsumption
        WITH SOURCE_TOPIC "mes/aveva-mes/consumption/list"
        WITH DESTINATION_TOPIC "mes/aveva-mes/consumption/list/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/mesmw/api/v3/Consumption/filter?{value.json.query}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "{value.json.authorization}"
    ADD EVENT ListItems
        WITH SOURCE_TOPIC "mes/aveva-mes/item/list"
        WITH DESTINATION_TOPIC "mes/aveva-mes/item/list/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/mesmw/api/v3/Item/filter?{value.json.query}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "{value.json.authorization}"
    ADD EVENT ListInventory
        WITH SOURCE_TOPIC "mes/aveva-mes/inventory/list"
        WITH DESTINATION_TOPIC "mes/aveva-mes/inventory/list/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/mesmw/api/v3/ItemInventory/filter?{value.json.query}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "{value.json.authorization}"
    ADD EVENT ListLots
        WITH SOURCE_TOPIC "mes/aveva-mes/lot/list"
        WITH DESTINATION_TOPIC "mes/aveva-mes/lot/list/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/mesmw/api/v3/Lot/filter?{value.json.query}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "{value.json.authorization}"
    ADD EVENT ListSamples
        WITH SOURCE_TOPIC "mes/aveva-mes/sample/list"
        WITH DESTINATION_TOPIC "mes/aveva-mes/sample/list/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/mesmw/api/v3/Sample/filter?{value.json.query}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "{value.json.authorization}"
    ADD EVENT AddProductionByJob
        WITH SOURCE_TOPIC "mes/aveva-mes/production/post"
        WITH DESTINATION_TOPIC "mes/aveva-mes/production/post/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/mesmw/api/v3/Production/ByJob"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Authorization" "{value.json.authorization}"
        WITH BODY "{value.json.body}"
    ADD EVENT AddProductionPostExec
        WITH SOURCE_TOPIC "mes/aveva-mes/production-post-exec/post"
        WITH DESTINATION_TOPIC "mes/aveva-mes/production-post-exec/post/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/mesmw/api/v3/Production/PostExec"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Authorization" "{value.json.authorization}"
        WITH BODY "{value.json.body}"
    ADD EVENT AddConsumptionByJob
        WITH SOURCE_TOPIC "mes/aveva-mes/consumption/post"
        WITH DESTINATION_TOPIC "mes/aveva-mes/consumption/post/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/mesmw/api/v3/Consumption/ByJob"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Authorization" "{value.json.authorization}"
        WITH BODY "{value.json.body}"
    ADD EVENT AddUtilizationEvent
        WITH SOURCE_TOPIC "mes/aveva-mes/util-event/post"
        WITH DESTINATION_TOPIC "mes/aveva-mes/util-event/post/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/mesmw/api/v3/UtilHistory/AddEvent"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Authorization" "{value.json.authorization}"
        WITH BODY "{value.json.body}"
    ADD EVENT AddCurrentUtilizationEvent
        WITH SOURCE_TOPIC "mes/aveva-mes/util-history/post"
        WITH DESTINATION_TOPIC "mes/aveva-mes/util-history/post/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/mesmw/api/v3/UtilHistory"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Authorization" "{value.json.authorization}"
        WITH BODY "{value.json.body}"
    ADD EVENT StartJob
        WITH SOURCE_TOPIC "mes/aveva-mes/job/start"
        WITH DESTINATION_TOPIC "mes/aveva-mes/job/start/response"
        WITH METHOD "PUT"
        WITH ENDPOINT "/mesmw/api/v3/Jobs/Start"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Authorization" "{value.json.authorization}"
        WITH BODY "{value.json.body}"
    ADD EVENT PauseJob
        WITH SOURCE_TOPIC "mes/aveva-mes/job/pause"
        WITH DESTINATION_TOPIC "mes/aveva-mes/job/pause/response"
        WITH METHOD "PUT"
        WITH ENDPOINT "/mesmw/api/v3/Jobs/Pause"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Authorization" "{value.json.authorization}"
        WITH BODY "{value.json.body}"
    ADD EVENT EndJob
        WITH SOURCE_TOPIC "mes/aveva-mes/job/end"
        WITH DESTINATION_TOPIC "mes/aveva-mes/job/end/response"
        WITH METHOD "PUT"
        WITH ENDPOINT "/mesmw/api/v3/Jobs/End"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Authorization" "{value.json.authorization}"
        WITH BODY "{value.json.body}"
    ADD EVENT ChangeJobStates
        WITH SOURCE_TOPIC "mes/aveva-mes/job-states/put"
        WITH DESTINATION_TOPIC "mes/aveva-mes/job-states/put/response"
        WITH METHOD "PUT"
        WITH ENDPOINT "/mesmw/api/v3/Jobs/ChangeJobStates"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Authorization" "{value.json.authorization}"
        WITH BODY "{value.json.body}"
    ADD EVENT ReleaseWorkOrder
        WITH SOURCE_TOPIC "mes/aveva-mes/work-order/release"
        WITH DESTINATION_TOPIC "mes/aveva-mes/work-order/release/response"
        WITH METHOD "PUT"
        WITH ENDPOINT "/mesmw/api/v3/WO/Release"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Authorization" "{value.json.authorization}"
        WITH BODY "{value.json.body}"
    ADD EVENT RecordSampleData
        WITH SOURCE_TOPIC "mes/aveva-mes/sample-data/put"
        WITH DESTINATION_TOPIC "mes/aveva-mes/sample-data/put/response"
        WITH METHOD "PUT"
        WITH ENDPOINT "/mesmw/api/v3/Sample/RecordData"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Authorization" "{value.json.authorization}"
        WITH BODY "{value.json.body}"
    ADD EVENT MiddlewareAccessXml
        WITH SOURCE_TOPIC "mes/aveva-mes/middleware-xml/post"
        WITH DESTINATION_TOPIC "mes/aveva-mes/middleware-xml/post/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/mesmw/api/v3/MiddlewareAccess/xml"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Authorization" "{value.json.authorization}"
        WITH BODY "{value.json.body}"
```

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

## Usage example

Call `GetOpenApiSpec` 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 'mes/aveva-mes/openapi/get/response' &
mosquitto_pub -t 'mes/aveva-mes/openapi/get' -m '{"authorization": "<authorization>"}'
```

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