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

> 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"]

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

## Template parameters

| Placeholder | Type | Description | Required |
| - | - | - | - |
| `RouteName` | string | Name of the Bar Tender Print Portal connector | no |
| `BaseUrl` | string | Bar Tender Print Portal base URL without trailing slash (e.g. https\://YOUR\_PRINT\_PORTAL\_HOST) | yes |

`BASE_ADDRESS` default: `https://YOUR_PRINT_PORTAL_HOST`.

## Events

| Event | Method | Endpoint | Request topic | Response topic | Payload fields |
| - | - | - | - | - | - |
| `PortalAuthenticate` | POST | `/BarTender/api/v1/Authenticate` | `mes/bartender-portal/token/create` | `mes/bartender-portal/token/create/response` | `body` |
| `PortalListLibraries` | GET | `/BarTender/api/v1/libraries` | `mes/bartender-portal/library/list` | `mes/bartender-portal/library/list/response` | `token` |
| `PortalGetLibrary` | GET | `/BarTender/api/v1/libraries/{value.json.library_id}` | `mes/bartender-portal/library/get` | `mes/bartender-portal/library/get/response` | `library_id`, `token` |
| `PortalListPrinters` | GET | `/BarTender/api/v1/printers` | `mes/bartender-portal/printer/list` | `mes/bartender-portal/printer/list/response` | `token` |
| `PortalGetPrinter` | GET | `/BarTender/api/v1/printers/{value.json.printer}` | `mes/bartender-portal/printer/get` | `mes/bartender-portal/printer/get/response` | `printer`, `token` |
| `PortalPrint` | POST | `/BarTender/api/v1/print` | `mes/bartender-portal/label/print` | `mes/bartender-portal/label/print/response` | `body`, `token` |

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

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 BarTenderPrintPortal WITH TYPE REST_API
    ADD REST_API_CONFIG
        WITH BASE_ADDRESS "https://YOUR_PRINT_PORTAL_HOST"
        WITH ENABLE_CLIENT "true"
        WITH USE_SSL "true"
        WITH REQUEST_TIMEOUT '45'
        WITH DEFAULT_CONTENT_TYPE "application/json"
    ADD EVENT PortalAuthenticate
        WITH SOURCE_TOPIC "mes/bartender-portal/token/create"
        WITH DESTINATION_TOPIC "mes/bartender-portal/token/create/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/BarTender/api/v1/Authenticate"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
        WITH BODY "{value.json.body}"
    ADD EVENT PortalListLibraries
        WITH SOURCE_TOPIC "mes/bartender-portal/library/list"
        WITH DESTINATION_TOPIC "mes/bartender-portal/library/list/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/BarTender/api/v1/libraries"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Bearer {value.json.token}"
    ADD EVENT PortalGetLibrary
        WITH SOURCE_TOPIC "mes/bartender-portal/library/get"
        WITH DESTINATION_TOPIC "mes/bartender-portal/library/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/BarTender/api/v1/libraries/{value.json.library_id}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Bearer {value.json.token}"
    ADD EVENT PortalListPrinters
        WITH SOURCE_TOPIC "mes/bartender-portal/printer/list"
        WITH DESTINATION_TOPIC "mes/bartender-portal/printer/list/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/BarTender/api/v1/printers"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Bearer {value.json.token}"
    ADD EVENT PortalGetPrinter
        WITH SOURCE_TOPIC "mes/bartender-portal/printer/get"
        WITH DESTINATION_TOPIC "mes/bartender-portal/printer/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/BarTender/api/v1/printers/{value.json.printer}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Bearer {value.json.token}"
    ADD EVENT PortalPrint
        WITH SOURCE_TOPIC "mes/bartender-portal/label/print"
        WITH DESTINATION_TOPIC "mes/bartender-portal/label/print/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/BarTender/api/v1/print"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Authorization" "Bearer {value.json.token}"
        WITH BODY "{value.json.body}"
```

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

## Usage example

Call `PortalAuthenticate` 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-portal/token/create/response' &
mosquitto_pub -t 'mes/bartender-portal/token/create' -m '{"body": {}}'
```

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