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

# Bar Tender Actions

> LoT connector for the on-premises BarTender Actions API: submit print scripts with MQTT data, follow script status and read script variables

Technical Preview

## Overview

Client-mode REST API connectors for BarTender label printing: print BarTender documents with data from MQTT through the BarTender 2022+ Actions API (on-premises or BarTender Cloud) or Print Portal, follow the print script status and variables, and list printers and Print Portal libraries.

This is one of the templates in the BarTender (Seagull Scientific) label printing REST API app (`bartender-label-printing`). Deploy it alongside the other connectors of that app when they depend on each other (for example a token connector plus an API connector).

## Auth

* **BarTenderActions**: Windows authentication (Negotiate) on the REST service; not sent by the connector (reverse proxy needed, unverified)
* **BarTenderCloud**: Authorization: Bearer \{value.json.access\_token}
* **BarTenderPrintPortal**: POST /BarTender/api/v1/Authenticate \{userName,password} -> token; Authorization: Bearer \{value.json.token}
* **secret**: \["BARTENDER\_PORTAL\_USERNAME", "BARTENDER\_PORTAL\_PASSWORD"]

## Template parameters

| Placeholder | Type | Description | Required |
| - | - | - | - |
| `RouteName` | string | Name of the Bar Tender Actions connector | no |
| `BaseUrl` | string | Bar Tender Actions base URL without trailing slash (e.g. http\://YOUR\_BARTENDER\_HOST:5159) | yes |

`BASE_ADDRESS` default: `http://YOUR_BARTENDER_HOST:5159`.

## Events

| Event | Method | Endpoint | Request topic | Response topic | Payload fields |
| - | - | - | - | - | - |
| `SubmitScript` | POST | `/api/actions?{value.json.query}` | `mes/bartender/script/submit` | `mes/bartender/script/submit/response` | `body`, `query` |
| `ListScripts` | GET | `/api/actions?{value.json.query}` | `mes/bartender/script/list` | `mes/bartender/script/list/response` | `query` |
| `GetScriptStatus` | GET | `/api/actions/{value.json.script_id}?{value.json.query}` | `mes/bartender/script/get` | `mes/bartender/script/get/response` | `query`, `script_id` |
| `UpdateScript` | PATCH | `/api/actions/{value.json.script_id}` | `mes/bartender/script/update` | `mes/bartender/script/update/response` | `body`, `script_id` |
| `ListScriptVariables` | GET | `/api/actions/{value.json.script_id}/variables` | `mes/bartender/script-variable/list` | `mes/bartender/script-variable/list/response` | `script_id` |
| `GetScriptVariable` | GET | `/api/actions/{value.json.script_id}/variables/{value.json.variable}` | `mes/bartender/script-variable/get` | `mes/bartender/script-variable/get/response` | `script_id`, `variable` |

## Deploy

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

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

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

```lot theme={"theme":{"light":"css-variables","dark":"css-variables"},"languages":{"custom":["/languages/lot.json"]}}
DEFINE CONNECTOR BarTenderActions WITH TYPE REST_API
    ADD REST_API_CONFIG
        WITH BASE_ADDRESS "http://YOUR_BARTENDER_HOST:5159"
        WITH ENABLE_CLIENT "true"
        WITH USE_SSL "false"
        WITH REQUEST_TIMEOUT '45'
        WITH DEFAULT_CONTENT_TYPE "application/json"
    ADD EVENT SubmitScript
        WITH SOURCE_TOPIC "mes/bartender/script/submit"
        WITH DESTINATION_TOPIC "mes/bartender/script/submit/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/api/actions?{value.json.query}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
        WITH BODY "{value.json.body}"
    ADD EVENT ListScripts
        WITH SOURCE_TOPIC "mes/bartender/script/list"
        WITH DESTINATION_TOPIC "mes/bartender/script/list/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/api/actions?{value.json.query}"
        WITH HEADERS
            ADD "Accept" "application/json"
    ADD EVENT GetScriptStatus
        WITH SOURCE_TOPIC "mes/bartender/script/get"
        WITH DESTINATION_TOPIC "mes/bartender/script/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/api/actions/{value.json.script_id}?{value.json.query}"
        WITH HEADERS
            ADD "Accept" "application/json"
    ADD EVENT UpdateScript
        WITH SOURCE_TOPIC "mes/bartender/script/update"
        WITH DESTINATION_TOPIC "mes/bartender/script/update/response"
        WITH METHOD "PATCH"
        WITH ENDPOINT "/api/actions/{value.json.script_id}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
        WITH BODY "{value.json.body}"
    ADD EVENT ListScriptVariables
        WITH SOURCE_TOPIC "mes/bartender/script-variable/list"
        WITH DESTINATION_TOPIC "mes/bartender/script-variable/list/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/api/actions/{value.json.script_id}/variables"
        WITH HEADERS
            ADD "Accept" "application/json"
    ADD EVENT GetScriptVariable
        WITH SOURCE_TOPIC "mes/bartender/script-variable/get"
        WITH DESTINATION_TOPIC "mes/bartender/script-variable/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/api/actions/{value.json.script_id}/variables/{value.json.variable}"
        WITH HEADERS
            ADD "Accept" "application/json"
```

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

## Usage example

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

```bash theme={"theme":{"light":"css-variables","dark":"css-variables"},"languages":{"custom":["/languages/lot.json"]}}
mosquitto_sub -t 'mes/bartender/script/submit/response' &
mosquitto_pub -t 'mes/bartender/script/submit' -m '{"body": {}, "query": "<query>"}'
```

## Related

* [REST API Connectors](https://docs.coreflux.org/v2.22/lot-language/routes/rest-api-routes.md)
* [REST API Apps catalog](https://docs.coreflux.org/v2.22/lot-language/routes/rest-api-apps.md)


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