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

> LoT connector for BarTender Print Portal: authenticate, list libraries and printers, and print BarTender documents with data from MQTT

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

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

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 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 `-addConnector` (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":{"light":"css-variables","dark":"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](https://docs.coreflux.org/latest/connectors/rest-api/overview)
* [REST API Apps catalog](https://docs.coreflux.org/latest/connectors/rest-api-apps)


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