The "createMqApiSession" action creates a new MQ API session, which is a different type of connection than MQTT. An MQ API session uses the HTTP protocol, and an MQTT session uses the MQTT wire protocol. Thus, only an MQTT client using the MQTT protocol can create an MQTT session, and only software using the "createMqApiSession" action can create an MQ API session.
You can use an MQ API session to publish a message to any MQTT topic, retrieve a message from any MQTT topic, and list, describe, configure, or delete any MQTT or MQ API session. This is because an MQ API session has the same properties and capabilities as an MQTT session. Thus, from either type of session, you can publish to, subscribe to, and retrieve messages from the same topics. Lastly, you can use the following MQ API actions with any MQTT or MQ API session: "alterMqSession", "listMqSessions", "describeMqSessions", "deleteMqSession", "subscribeToMq", "getMessagesFromMqTopic", and "publishMessagesToMq".
The value of the "clientName" property uniquely identifies the session. It is comparable to the Client ID property in MQTT. Because the client name is the unique identifier of a messaging session, an MQ API session cannot use the same client name as an MQTT session and vice-versa.
The "createMqApiSession" action returns an error if "clientName" refers to any existing session. This behavior differs from MQTT, which disconnects an existing MQTT session when a new MQTT client uses the same Client ID. In addition, MQTT clients receive an error if they attempt to connect to a session created by the "createMqApiSession" action, and vice-versa.
You can create a permanent or temporary MQ API session. Once you create a permanent session, it persists until you run the "deleteMqSession" action. If you create a temporary MQ API session, the server automatically deletes it when the session times out because of a lack of session activity. Once you create a permanent MQ API session, it never expires, and you can use its "clientName" in any MQ API action.
Note
- Only the
"createMqApiSession"action can create an MQ API session. This is why the phrase"MqApi"is in the action's name. In contrast, clients using the MQTT protocol can create an MQTT session but not an MQ API session.- There are two MQ API actions with
"MqApi"in their names:"createMqApiSession"and"getMessagesFromMqApiSession". The"getMessagesFromMqApiSession"action has"MqApi"in its name because it only works with sessions created by the"createMqApiSession"action. The remaining MQ API actions work with both the MQ API and MQTT. For example, you can use"alterMqSession"to alter an MQ API session and an MQTT session.
Request examples
Minimal
{
"action": "createMqApiSession",
"params": {},
"authToken": "replaceWithAuthTokenFromCreateSession"
}Maximal
{
"api": "mq",
"action": "createMqApiSession",
"params":
{
"clientName": "a unique MQ API client identifier or empty string",
"cleanSession": true,
"temporarySession": false,
"sessionStatus": "normal | hidden | banned | inactive",
"mqttProtocol": "5.0 | 3.1.1",
"keepAliveSeconds": 60,
"userProperties": [
{
"key": "some key",
"value": "some value"
}
],
"mqttPayloadType": "utf8",
"sessionExpiryInterval": 4294967296,
"receiveMaximum": 1024,
"maximumPacketSize": 1024,
"topicAliasMaximum": 0,
"requestProblemInformation": true,
"requestResponseInformation": false,
"willTopic": "some/Topic/Name/",
"willQoS": 2,
"willPayload": "This message is sent when client disconnects.",
"willRetain": true,
"willContentType": "IanaMediaType or a CustomType",
"willCorrelationData": "any JSON value up to 65500 bytes",
"willPayloadFormatIndicator": "none | utf8",
"willExpirySeconds": 60,
"willDelaySeconds": 60,
"willResponseTopic": "topic/name/for/subscriber/to/respond/to",
"willUserProperties": [
{
"key": "some key",
"value": "some value"
}
],
"label": {
"group": "group name",
"name": "label name"
},
"minHealthySendRatePerMinute": 10,
"maxHealthySendRatePerMinute": 1000,
"maxHealthyBacklogRatePerMinute": 10,
"minHealthySubscribedTopicFiltersCount": 10,
"maxHealthySubscribedTopicFiltersCount": 1000,
"metadata": {}
},
"debug": "max",
"requestId": "optionalUniqueRequestIdFromTheClient",
"authToken": "replaceWithAuthTokenFromCreateSession"
}
Response example
Maximal
{
"authToken": "GcKIH09dV3rcatEkEQStNN8nmP2Qqh7LSuXIGfV8N7ILy20NDezxm1S9nVXdp1Sf",
"result": {
"clientName": "client1",
"cleanSession": true,
"temporarySession": false,
"sessionStatus": "normal",
"username": "ADMIN",
"ipaddress": "127.0.0.1",
"port": 64283,
"mqttProtocol": "3.1.1",
"keepAliveSeconds": 0,
"connectionStatus": "connected",
"connectionDateTime": "2025-09-17T16:24:41",
"defaultBinaryFormat": "hex",
"defaultVariantFormat": "json",
"defaultResponseOptions": {
"binaryFormat": "hex",
"variantFormat": "json",
"dataFormat": "objects",
"numberFormat": "number"
},
"sessionType": "mqApi",
"willTopic": "some/Topic/Name/",
"willQoS": 2,
"willPayload": "This message is sent when client disconnects.",
"willRetain": true,
"metadata": {},
"sessionPresent": false
},
"requestId": "00000003",
}
Properties
Request properties ("params")
| Property | Description | Default | Type | Limits (inclusive) |
|---|---|---|---|---|
cleanSession |
The The |
Optional with default of false
|
Boolean |
|
clientName |
The "clientName" property specifies the unique name that identifies the client to the FairCom MQ engine. |
Optional with default of ""
|
string | 0 to 65,550 bytes |
keepAliveSeconds |
The |
Optional with default of 0
|
integer | No limit |
label |
The A label is a tag that you can add to some objects, such as an MQTT topic or session. You can use list actions such as The |
Optional with default of null
|
object | "label": {
"group": "group name",
"name": "label name"
} |
|
label .group |
The The When you assign a group name to a label, the server automatically checks if the group name exists in the list of groups that the
|
Optional with default of ""
|
string | 1 to 64 bytes of UTF-8 encoded characters |
|
label .name |
The The The
|
Required - No default value | string | 1 to 64 bytes |
maxHealthyBacklogRatePerMinute |
The A connected session is healthy when its message backlog rate does not exceed the maximum. The |
Optional with default of 0
|
integer | Any positive integer |
maxHealthySendRatePerMinute |
The A connected session is healthy when its message send rate does not exceed the maximum. The |
Optional with default of 0
|
integer | Any positive integer |
maxHealthySubscribedTopicFiltersCount |
The A connected session is healthy when it has subscribed to at most the maximum number of topic filters. The A topic filter may include MQTT wildcard characters, which allows one topic filter to subscribe to many topics. The |
Optional with default of 0
|
integer | Any positive integer |
maximumPacketSize |
The |
Optional with default of 1024
|
integer | |
metadata |
The "metadata" property contains user-defined properties that add keywords and tags about the code package. The server indexes this field with a full-text index so you can search for any word or phrase to find code packages. |
Optional with default of {}
|
object | 0 or more key/value pairs |
minHealthySendRatePerMinute |
The A connected session is healthy when its message send rate exceeds the minimum. The |
Optional with default of 0
|
integer | Any positive number |
minHealthySubscribedTopicFiltersCount |
The A connected session is healthy when it has subscribed to at least the minimum number of topic filters. The A topic filter may include MQTT wildcard characters, which allows one topic filter to subscribe to many topics. The |
Optional with default of 0
|
integer | Any positive number |
mqttPayloadType |
The |
Optional with default of "binary"
|
string enum |
|
mqttProtocol |
The "mqttProtocol" property specifies the version of MQTT protocol to use in your session. |
Optional with default of 5.0
|
string enum |
|
receiveMaximum |
The |
Optional with default of 1024
|
integer |
1 to 65535
|
requestProblemInformation |
The |
Optional with default of true
|
Boolean |
|
requestResponseInformation |
The |
Optional with default of false
|
Boolean |
|
sessionExpiryInterval |
The The
The
|
If "temporarySession" is true, "sessionExpiryInterval" defaults to 0 to ensure the temporary session expires when the JSON session does. If "temporarySession" is false, it defaults to 4294967296 because a permanent session never expires. |
integer |
0 to 4294967296
|
sessionStatus |
The
|
Optional with default of "normal"
|
string enum |
|
temporarySession |
The When Use the |
Optional with default of false
|
Boolean |
|
topicAliasMaximum |
The |
Optional with default of 0
|
integer |
0 to 65535
|
userProperties |
The "userProperties": [
{
"key": "some key",
"value": "some value"
}
] |
Optional with default of null
|
array | 0 or more key/value pairs |
|
userProperties .key |
The "key" property is part of an optional key-value object that is defined in an array in the "userProperties" property. It is a user-defined string value. |
Optional with default of
Required in the Key-Value API |
string | 1 to 128 bytes |
|
userProperties .value |
The
In Key-Value actions, the required |
Required - No default value | string |
|
willContentType |
The |
Optional with default of ""
|
string |
IanaMediaType CustomType |
willCorrelationData |
The |
Optional with default of ""
|
JSON | 0 to 65,500 bytes |
willDelaySeconds |
The |
Optional with default of 60
|
integer | |
willExpirySeconds |
The |
Optional with default of 60
|
integer | |
willPayload |
The |
Required - No default value | JSON | |
willPayloadFormatIndicator |
The |
Optional with default of "none"
|
ENUM |
|
willQoS |
The property |
Optional with default of 2
|
integer | |
willResponseTopic |
The |
Optional with default of ""
|
string | |
willRetain |
The |
Optional with default of false
|
Boolean |
|
willTopic |
The |
Optional with default of ""
|
UTF-8 string | |
willUserProperties |
The |
Optional with default of []
|
array |
|
|
willUserProperties .key |
The "key" property is part of an optional key-value object that is defined in an array in the "userProperties" property. It is a user-defined string value. |
Optional with default of
Required in the Key-Value API |
string | 1 to 128 bytes |
|
willUserProperties .value |
The
In Key-Value actions, the required |
Required - No default value | string |
|
Response properties ("result")
| Property | Description | Type | Limits (inclusive) |
|---|---|---|---|
cleanSession |
The The |
Boolean |
|
clientName |
The "Clientname" property uniquely identifies an MQ session. |
string | |
connectionDateTime |
The "connectionDateTime" property indicates when the connection was made. |
timestamp | An ISO 8601 timestamp |
connectionStatus |
The "connectionStatus" property specifies if and how a client is connected to an MQ session. |
string enum |
"disconnected""connected""connectedTemporarily"
|
defaultBinaryFormat |
Defines the default value of "binaryFormat". |
string | One of the following: "base64", "hex", or "byteArray". |
defaultResponseOptions |
The JSON NAV allows you to choose how your program detects errors. By default, all error properties are included in each response – unless you override this behavior as shown in the example. The example omits the error object in all responses which makes it easier for statically typed languages, such as C, C++, Java, C#, and VB, because they prefer properties to always be present. To help these languages, the Example "defaultResponseOptions": {
"binaryFormat": "hex",
"dataFormat": "objects",
"numberFormat": "number",
"variantFormat": "json"
} |
object |
|
|
defaultResponseOptions .binaryFormat |
The "binaryFormat" property designates the format of binary values embedded in JSON strings. For more details, see "binaryFormat". |
string | One of the following: "base64", "hex", or "byteArray". |
|
defaultResponseOptions .dataFormat |
The There are three different (but similar) versions of the "dataFormat" property:
Two of those versions occur in a request, and another occurs in a response. They all indicate how data is formatted.
|
string |
|
|
defaultResponseOptions .numberFormat |
The |
string |
|
|
defaultResponseOptions .variantFormat |
The "variantFormat" property tells the server how to interpret the variant data included in a JSON Action request. For more details, see "variantFormat". |
string |
|
defaultVariantFormat |
The |
string |
|
ipaddress |
The "ipAddress" property specifies the PLC/Equipment IPV4 Address. |
string | A valid IP address |
keepAliveSeconds |
The |
integer | No limit |
metadata |
The |
JSON | 0 to 65,500 bytes |
mqttProtocol |
The "mqttProtocol" property specifies the version of MQTT protocol to use in your session. |
string enum |
|
port |
The |
integer | an integer port number |
sessionPresent |
Boolean that specifies whether the broker will use a previously stored session state, including the client's previous descriptions. |
Boolean |
|
sessionStatus |
The
|
string enum |
|
sessionType |
"sessionType" specifies which type of session the requested client is currently running. |
string |
|
temporarySession |
The When Use the |
Boolean |
|
username |
The It is required by the All API actions are performed in the context of the account identified by In JSON DB API and JSON Hub API, use the Unlike other property names, such as A zero-length username is invalid.
In Key-Value actions, the
|
string
|
1 to 64 bytes |
willPayload |
The |
JSON | |
willQoS |
The property |
integer | |
willRetain |
When |
Boolean |
|
willTopic |
The "willTopic" property contains the topic that the FairCom server will use to publish the will message. If you set it to an empty string, "", null, or omit it, the FairCom server will not add the will message to the connection. |
UTF-8 string |