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

> 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

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

> [!NOTE]
>
> Not yet verified against the live vendor API: No BarTender host, BarTender Cloud token or Print Portal URL/user on the factory box (no BARTENDER\_ variables in env). Static 176/176 against the cached Actions API v1 OpenAPI spec and documented Print Portal / Cloud Printers paths, local mock 20/20 (+4/4 controls), BarTender Cloud unauthenticated probes 9/9 (8 real paths 401, bogus path 404). Unblock: BARTENDER\_BASE\_URL (+BARTENDER\_TEST\_BTW) for a 2022+ REST service the broker can authenticate to, or BARTENDER\_CLOUD\_TOKEN, or BARTENDER\_PORTAL\_BASE + BARTENDER\_PORTAL\_USERNAME/PASSWORD; then python3 smoke\_bartender.py and a broker MQTT round-trip printing to PDF.

## 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":"css-variables","languages":{"custom":["/languages/lot.json"]}}
mosquitto_pub -t '$SYS/Coreflux/Command' -m "-routeCode BAR_TENDER_ACTIONS"
```

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 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 `-addRoute` (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":"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](/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.