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

# Sepasoft MES for Ignition

> Client-mode REST API connector for Sepasoft MES on an Ignition gateway: gateway health, any Web Services RESTful endpoint or WebDev resource, and MES presets for OEE counts and equipment state, OEE analysis, Track and Trace segments and genealogy, work order quantities and schedules

Technical Preview

## Overview

One client-mode connector, **SepasoftMES**, for Sepasoft MES modules (OEE Downtime, Track and Trace, Settings and Changeover) running on an Inductive Automation Ignition gateway. It moves MES data between your Unified Namespace and the gateway over HTTP.

Sepasoft does not publish a fixed REST API. You author REST endpoints yourself in the Ignition Designer with the Sepasoft **Web Services** module (Web Services, then Providers, then RESTful Endpoints), each one a Python script for `GET`, `POST`, `PUT` or `DELETE`, and the gateway serves them under `/system/ws/rest/<folder>/<resource>`. So the connector has three groups of events:

1. **Gateway health**, no credentials: `/StatusPing` and `/system/gwinfo`.
2. **Generic passthroughs** for any Web Services RESTful endpoint or Ignition WebDev resource you already have.
3. **MES presets** that call a small companion provider folder, `coreflux/v1`. Example scripts for it ship with the connector template (`sepasoft-provider/`), built on documented `system.mes.*` functions.

| Event | Request | Notes |
| - | - | - |
| GatewayStatusPing | `GET /StatusPing` | Returns `{"state":"RUNNING"}` when the gateway is up; no auth |
| GatewayInfo | `GET /system/gwinfo` | Version, platform name and redundancy state as `key=value;` text; no auth |
| WsRestGet | `GET /system/ws/rest/{resource}?{query}` | Any RESTful endpoint `do_GET` |
| WsRestPost | `POST /system/ws/rest/{resource}` | Any RESTful endpoint `do_POST`, JSON body |
| WsRestPut | `PUT /system/ws/rest/{resource}` | Any RESTful endpoint `do_PUT`, JSON body |
| WsRestDelete | `DELETE /system/ws/rest/{resource}?{query}` | Any RESTful endpoint `do_DELETE` |
| WebDevGet | `GET /system/webdev/{project}/{resource}?{query}` | Ignition WebDev resource `doGet` |
| WebDevPost | `POST /system/webdev/{project}/{resource}` | Ignition WebDev resource `doPost` |
| OeeCountInput | `POST /system/ws/rest/coreflux/v1/oee/countinput` | Writes an infeed, outfeed or reject count to the tag your OEE production model reads |
| OeeEquipmentState | `POST /system/ws/rest/coreflux/v1/oee/equipmentstate` | Writes an equipment state code to the OEE state tag |
| OeeAnalysis | `GET /system/ws/rest/coreflux/v1/oee/analysis?{query}` | Runs an MES analysis for `eqPath`, `startDate`, `endDate` |
| TraceMaterialMove | `POST /system/ws/rest/coreflux/v1/trace/materialmove` | Executes a Track and Trace segment with its materials |
| TraceGenealogy | `GET /system/ws/rest/coreflux/v1/trace/genealogy?{query}` | Lot genealogy for `lot` |
| ScheduleRuns | `GET /system/ws/rest/coreflux/v1/schedule/runs?{query}` | Scheduled operations requests for `workOrder` between `begin` and `end` |
| WorkOrderGet | `GET /system/ws/rest/coreflux/v1/workorder/get?{query}` | Work order quantity and scheduled quantity for `name` |

Topics follow `mes/sepasoft/<object>/<verb>`, and each reply arrives on `<topic>/response`.

## Prerequisites

* An Ignition gateway (8.x) with the Sepasoft MES modules you use and the Sepasoft **Web Services** module.
* For the MES presets, the `coreflux/v1` provider folder (see below). The generic events work with any endpoint you already have.
* An Ignition user in the User Source picked on each endpoint, with a role allowed by the endpoint's Required role(s).
* Network reach from the broker to the gateway's HTTPS port (8043 by default) or HTTP port (8088).

## Authentication

Each RESTful endpoint can require **HTTP Basic** authentication against an Ignition User Source, optionally limited to some roles. Missing credentials return `401` with a `WWW-Authenticate` header and wrong credentials return `403`. An HTTP method with no script returns `405`, and a script syntax error returns `500`.

Store the full header value, `Basic <base64 of user:password>`, in a broker secret (suggested `SEPASOFT_BASIC_AUTH`) and map it into the `authorization` payload field with `GET SECRET`. The two gateway health events send no credentials.

## Connector

```lot theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
DEFINE ROUTE SepasoftMES WITH TYPE REST_API
    ADD REST_API_CONFIG
        WITH BASE_ADDRESS "https://YOUR_IGNITION_GATEWAY:8043"
        WITH ENABLE_CLIENT "true"
        WITH USE_SSL "true"
        WITH REQUEST_TIMEOUT '30'
        WITH DEFAULT_CONTENT_TYPE "application/json"
    ADD EVENT GatewayStatusPing
        WITH SOURCE_TOPIC "mes/sepasoft/gateway-status/get"
        WITH DESTINATION_TOPIC "mes/sepasoft/gateway-status/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/StatusPing"
        WITH HEADERS
            ADD "Accept" "application/json"
    ADD EVENT WsRestGet
        WITH SOURCE_TOPIC "mes/sepasoft/ws-rest/get"
        WITH DESTINATION_TOPIC "mes/sepasoft/ws-rest/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/system/ws/rest/{value.json.resource}?{value.json.query}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "{value.json.authorization}"
    ADD EVENT OeeCountInput
        WITH SOURCE_TOPIC "mes/sepasoft/oee-count/create"
        WITH DESTINATION_TOPIC "mes/sepasoft/oee-count/create/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/system/ws/rest/coreflux/v1/oee/countinput"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Authorization" "{value.json.authorization}"
        WITH BODY "{value.json.body}"
```

The full template, `SepasoftMesForIgnitionRestApi.lot`, has all 15 events. Ignition 7.9 mounted providers under `/main/system/ws/rest/...`; on 7.9, change the endpoint prefix.

## Payload fields

| Field | Used by | Example |
| - | - | - |
| `authorization` | every event except the two gateway events | `"Basic Y29yZWZsdXg6Y2hhbmdlLW1l"` (from `GET SECRET`) |
| `resource` | `WsRest*`, `WebDev*` | `"v1/line-status"` (folder and resource name under the mount) |
| `project` | `WebDev*` | `"MESDemo"` |
| `query` | GET and DELETE events | `"eqPath=Enterprise%5CSite%5CLine%201&startDate=2026-10-05T00:00:00&endDate=2026-10-05T08:00:00"`; send `""` when empty |
| `body` | POST and PUT events | JSON object; the provider receives it as `request['body']` |

## Companion provider `coreflux/v1`

In the Designer, create the folders `coreflux` and `v1` under RESTful Endpoints and four endpoints named `oee`, `trace`, `schedule` and `workorder`. Set Data format to JSON, HTTP Authentication to Basic, choose the User Source and roles, tick Redirect to SSL, and paste the matching example script. The part of the URL after the resource name (for example `/countinput`) reaches the script as `request['path']`.

| Script | Sub-paths | Sepasoft and Ignition functions |
| - | - | - |
| `oee.py` | `POST /countinput`, `POST /equipmentstate`, `GET /analysis` | `system.tag.writeBlocking`, `system.mes.analysis.createMESAnalysisSettings`, `system.mes.analysis.executeAnalysis` |
| `trace.py` | `POST /materialmove`, `GET /genealogy` | `system.mes.createSegment`, `setMaterial`, `execute`, `system.mes.trace.getTraceabilityData` |
| `schedule.py` | `GET /runs` | `system.mes.workorder.getMESWorkOrder`, `getOperationsRequests(begin, end)` |
| `workorder.py` | `GET /get` | `system.mes.workorder.getMESWorkOrder`, `updateQuantities`, `getWorkOrderQuantity`, `getScheduledQuantity` |

> [!WARNING]
>
> The scripts are starting points. Test each one on a development gateway with the Designer's Copy RESTful Endpoint URL before you connect the broker. `OeeCountInput`, `OeeEquipmentState` and `TraceMaterialMove` change production records, so restrict who may publish on those topics with broker rules.

## Examples

Check the gateway every minute:

```lot theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
DEFINE ACTION SepasoftGatewayHealth
ON EVERY 1 MINUTE DO
    PUBLISH TOPIC "mes/sepasoft/gateway-status/get" WITH { "query": "" }
```

Forward a line counter to OEE:

```lot theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
DEFINE ACTION SepasoftLineCount
ON TOPIC "porto/line1/infeed/count" DO
    SET "auth" WITH GET SECRET "SEPASOFT_BASIC_AUTH"
    SET "count" WITH PAYLOAD AS INT
    PUBLISH TOPIC "mes/sepasoft/oee-count/create" WITH { "authorization": {auth}, "body": { "tag_path": "[default]Line1/Infeed Count", "value": {count} } }
```

Record a material move in Track and Trace (publish to `mes/sepasoft/trace-material-move/create`):

```json theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
{
  "authorization": "Basic <from GET SECRET>",
  "body": {
    "segment": "Mix Dressing",
    "equipment_path": "Dressings Inc\\California\\Mixing\\Mixer 1",
    "materials": [{ "property": "Vinegar", "lot": "LOT-0042", "quantity": 20 }]
  }
}
```

## Testing

* Gateway health: `GET /StatusPing` and `GET /system/gwinfo` on Sepasoft's public demo gateway (`https://demo.sepasoft.com`) returned `200` with `{"state":"RUNNING"}` and an Ignition 8.1.47 info string. That gateway blocks `/system/ws/*` at its proxy, so it cannot exercise the MES events.
* Every event was rendered from a sample payload and sent to a local mock that follows the documented RESTful endpoint behavior (`401` without credentials, `403` with wrong ones, `405` without a script).
* Not yet run against a gateway with the Web Services module and real credentials.

## Troubleshooting

| Symptom | Cause |
| - | - |
| `401` with `WWW-Authenticate` | `authorization` missing or empty |
| `403` | Wrong user or password, or the user lacks a required role |
| `404` | Wrong folder or resource name, or a 7.9 gateway that needs `/main/system/ws/rest` |
| `405` | The endpoint has no script for that HTTP method |
| `500` | Syntax error in the endpoint script, or the script did not return a dict with integer `code` and dict `content` |

## Related

* [REST API connectors](/latest/lot-language/routes/rest-api-routes)
* [REST API app templates](/latest/lot-language/routes/rest-api-apps/index)
* Sepasoft docs: [RESTful Endpoints](https://docs.sepasoft.com/articles/user-manual/restful-endpoints), [Serving up Analysis Data as a Web Service REST Endpoint](https://docs.sepasoft.com/articles/knowledge-base/serving-up-analysis-data-as-a-web-service-rest-endpoint)


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