Skip to main content

"alterSession"

JSON ADMIN "alterSession" action alters the settings of a session

The "alterSession" action alters the settings of the session identified by the "authToken" property.

  • "alterSession" can modify most session settings but cannot modify the "username" nor the "password" properties used to create the session.

  • The "result" property returned by the server describes the new state of the session that you just changed using the "alterSession" action.

Request examples

Change timeouts

{
  "api": "admin",
  "action": "alterSession",
  "authToken": "replaceWithValidAuthtoken",
  "params": {
    "idleConnectionTimeoutSeconds": 60000,
    "idleCursorTimeoutSeconds": 60000
  }
}
{
  "api": "admin",
  "action": "alterSession",
  "authToken": "replaceWithValidAuthtoken",
  "params": {
    "description": "optional user description of session for troubleshooting",
    "defaultApi": "db",
    "defaultDatabaseName": "ctreeSQL",
    "defaultOwnerName": "admin",
    "defaultBinaryFormat": "hex",
    "defaultDebug": "max",
    "defaultResponseOptions": {
      "dataFormat": "objects",
      "numberFormat": "string",
      "binaryFormat": "hex"
    },
    "idleConnectionTimeoutSeconds": 60000,
    "idleCursorTimeoutSeconds": 60000
  }
}
{
  "authToken": "replaceWithValidAuthtoken",
  "result": {
    "authToken": "replaceWithValidAuthtoken",
    "username": "ADMIN",
    "description": "My test session",
    "defaultDatabaseName": "ctreeSQL",
    "defaultOwnerName": "admin",
    "defaultBinaryFormat": "hex",
    "defaultResponseOptions": {
      "binaryFormat": "hex",
      "dataFormat": "objects",
      "numberFormat": "number"
    },
    "idleConnectionTimeoutSeconds": 60000,
    "idleCursorTimeoutSeconds": 60000,
    "defaultApi": "mq",
    "defaultDebug": "max",
    "sessionStartTimestamp": "2023-04-20T18:08:56",
    "sessionLastAccessedTimestamp": "2023-04-20T18:10:22"
  },
  "requestId": "00000006",
  "errorCode": 0,
  "errorMessage": ""
}
{
  "authToken": "invalidAuthtoken",
  "requestId": "00000011",
  "debugInfo": {
    "request": {
      "authToken": "invalidAuthtoken",
      "api": "admin",
      "action": "alterSession",
      "params": {
        "idleConnectionTimeoutSeconds": 60000,
        "idleCursorTimeoutSeconds": 60000
      },
      "requestId": "00000011"
    }
  },
  "errorCode": 12031,
  "errorMessage": "'authToken' does not match any existing session. Use a valid 'authToken' or use 'createSession' to create a valid 'authToken'."
}

Use the alterSession API action to alter the settings of the session identified by the authToken property

API actionsJSON ADMIN APIadmin session actionalter sessionjsonActionalterSessionaltersSessionalterSessions

The "params" property is an object that contains an action's parameters. Each action defines its own required and optional properties.

Properties summary

Table 1. "params" properties summary

Property

Description

Default

Type

Limits (inclusive)

defaultApi

specifies the default value of the "api" property when "api" is omitted from an action request

FairCom DB defaults to "db"
FairCom Edge defaults "hub"
FairCom MQ defaults "mq"

string enum

"admin"
"hub"
"mq"
"db"

defaultBinaryFormat

specifies the default value for the "binaryFormat" property, which tells the server how to parse binary data from the client when the binary format is not specified in the action request

"base64"

string enum

"base64"
"hex"

defaultDatabaseName

specifies the default value of the "databaseName" property

FairCom DB defaults to "ctreeSQL"
FairCom Edge defaults to "faircom"
FairCom MQ defaults to "faircom"

string

1 to 64 bytes

defaultOwnerName

specifies the initial value of the "defaultOwnerName" property used by JSON APIs and FairCom's web application

"admin"

string

1 to 64 bytes

defaultResponseOptions

specifies a default value for "responseOptions" that is used by default in all other action calls. "includeFields" and "excludeFields" are mutually exclusive and "includePaths" and "excludePaths" are mutually exclusive

{}

object

Zero or more of the following properties:

binaryFormat
"dataFormat"
"numberFormat"
defaultResponseOption
.binaryFormat

specifies how binary values are returned

"base64"

string

"base64"
"hex"
defaultResponseOption
.dataFormat

specifies what format the results will be returned in

"arrays"

string

"default"
"arrays"
"objects"
defaultResponseOption
.numberFormat

specifies how numbers are formatted in the JSON response message

"number"

string

"number"
string

description

describes an object for later identification

""

string

0 to 65,500 bytes

idleConnectionTimeoutSeconds

specifies the number of seconds that a session with no activity will stay open

3600

integer

0 to 2147483647

idleCursorTimeoutSeconds

specifies the number of seconds to keep a cursor open

600

integer

0 to 2147483647

permanentSession

persists a session. Its authToken never expires because the server permanently associates it with the session's username and settings

false

Boolean

true
false


The "binaryFormat" property designates how binary values are formatted in the JSON request and JSON response message. The default value is "base64".

Note

Typically, response options apply only to the server’s response, but the "binaryFormat" property applies to both the request and the response.

  • The "binaryFormat" property may occur inside "params""responseOptions", "defaultResponseOptions" , and "result".

  • When "binaryFormat" occurs in "params" it specifies how the sender represents binary values.

    For example, when  "binaryFormat" is set to "hex", the FairCom server expects the binary values of fields and keys to be represented in strings with hexadecimal format.

  • When "binaryFormat" occurs in "responseOptions" or "defaultResponseOptions" it specifies how the FairCom server should represent binary values in responses.

    For example, when "binaryFormat" is set to "hex", the FairCom server represents binary values in strings with hexadecimal format.

  • When "binaryFormat" occurs in "result" it signifies how binary values are represented.

    For example, when "binaryFormat" is set to "base64", the FairCom server represents binary values in the response in base64 format.

  • The following are the possible values for each format.

    • "base64"

      When the server reads and writes from a binary field, it represents the binary value as a base64 string.

      • Base64 is harder for people to read and convert to binary.

      • Base64 creates the smallest payload for the most efficient data transmission in JSON.

      • "base64" strings contain the characters 0 - 9 , A - Z, a - z, +, /, and =.

    • "hex"

      When the server reads and writes from a binary field, it represents the binary value as a hexadecimal string.

      • Hexadecimal is easier for people to read and convert to binary.

      • Hexadecimal creates a 30% larger payload than "base64", which makes it less efficient for data transmission.

      • Hexadecimal strings contain the characters 0 - 9 and A - F.

    • "byteArray"

      When the server reads and writes from a binary field, it represents the binary value as an array of bytes.

      • An array of bytes is easiest for a program to manipulate.

      • An array of bytes creates a larger payload than "base64" and "hex", which makes it less efficient for data transmission.

      • An array of bytes returns a JSON array containing one integer number between 0 and 255 for each byte in the binary value:

        • "aBinaryField": [ 255, 0, 255 ]

Examples

Create a "binary_test" table

This example creates a table containing one binary field named "bin" with a fixed length of 5 bytes.

{
  "api": "db",
  "action": "createTable",
  "params": {
    "tableName": "binary_test",
    "fields": [
      {
        "name": "bin",
        "type": "binary",
        "length": 5
      }
    ]
  },
  "authToken": "replaceWithValidAuthtoken"
}
Insert a record into the "binary_test" table using an array of bytes format

This example inserts a record with the ASCII characters "123" in the "bin" field. The value of "bin" is represented as an array of bytes.

{
  "api": "db",
  "action": "insertRecords",
  "params": {
    "tableName": "binary_test",
    "dataFormat": "objects",
    "binaryFormat": "byteArray",
    "sourceData": [
      {
        "bin": [49,50,51]
      }
    ]
  },
  "authToken": "replaceWithValidAuthtoken"
}
Insert a record into the "binary_test" table using hexadecimal format

This example inserts a record with the ASCII characters "123" in the "bin" field. The value of "bin" is represented as a string in hexadecimal format.

{
  "api": "db",
  "action": "insertRecords",
  "params": {
    "tableName": "binary_test",
    "dataFormat": "objects",
    "binaryFormat": "hex",
    "sourceData": [
      {
        "bin": "313233"
      }
    ]
  },
  "authToken": "replaceWithValidAuthtoken"
}
Insert a record into the "binary_test" table using base64 format

This example inserts a record with the ASCII characters "123" in the "bin" field. The value of "bin" is represented as a string in base64 format.

{
  "api": "db",
  "action": "insertRecords",
  "params": {
    "tableName": "binary_test",
    "dataFormat": "objects",
    "binaryFormat": "base64",
    "sourceData": [
      {
        "bin": "MTIz"
      }
    ]
  },
  "authToken": "replaceWithValidAuthtoken"
}
Retrieve a record with "binaryFormat" as an array of bytes

This example requests the first record in the "binary_test" table with the value of "bin" represented as an array of bytes.

{
  "api": "db",
  "action": "getRecordsByTable",
  "params": {
    "tableName": "binary_test",
    "maxRecords": 1
  },
  "responseOptions": {
    "binaryFormat": "byteArray",
    "dataFormat": "objects",
    "numberFormat": "number"
  },
  "authToken": "replaceWithValidAuthtoken"
}
Response

Note

Our examples insert only 3 bytes into "bin" . Because the "bin" field has a fixed-length if 5 bytes, the server pads unused bytes with 0x00 and stores the result. When a record is retrieved, the server returns all 5 bytes.

{
  "authToken": "authtokenFromServer",
  "result": {
    "dataFormat": "objects",
    "binaryFormat": "byteArray",
    "fields": [
      { "name": "id",       "type": "bigint", "length": null, "scale": null, "autoTimestamp": "none", "defaultValue": null, "nullable": false, "primaryKey": 1 },
      { "name": "changeId", "type": "bigint", "length": null, "scale": null, "autoTimestamp": "none", "defaultValue": null, "nullable": true,  "primaryKey": 0 },
      { "name": "bin",      "type": "binary", "length": 5,    "scale": null, "autoTimestamp": "none", "defaultValue": null, "nullable": true,  "primaryKey": 0 }
    ],
    "data": [
      {
        "bin": [49,50,51,0,0],
        "changeId": 50217,
        "id": 1
      }
    ],
    "moreRecords": true,
    "requestedRecordCount": 1,
    "returnedRecordCount": 1,
    "totalRecordCount": 3
  },
  "errorCode": 0,
  "errorMessage": ""
}

Retrieve a record with "binaryFormat" as hexadecimal

This example requests the first record in the "binary_test" table with the value of "bin" represented as a hexadecimal string.

{
  "api": "db",
  "action": "getRecordsByTable",
  "params": {
    "tableName": "binary_test",
    "maxRecords": 1
  },
  "responseOptions": {
    "binaryFormat": "hex",
    "dataFormat": "objects",
    "numberFormat": "number"
  },
  "authToken": "replaceWithValidAuthtoken"
}
Response
{
  "authToken": "authtokenFromServer",
  "result": {
    "dataFormat": "objects",
    "binaryFormat": "byteArray",
    "fields": [
      { "name": "id",       "type": "bigint", "length": null, "scale": null, "autoTimestamp": "none", "defaultValue": null, "nullable": false, "primaryKey": 1 },
      { "name": "changeId", "type": "bigint", "length": null, "scale": null, "autoTimestamp": "none", "defaultValue": null, "nullable": true,  "primaryKey": 0 },
      { "name": "bin",      "type": "binary", "length": 5,    "scale": null, "autoTimestamp": "none", "defaultValue": null, "nullable": true,  "primaryKey": 0 }
    ],
    "data": [
      {
        "bin": "3132330000",
        "changeId": 50217,
        "id": 1
      }
    ],
    "moreRecords": true,
    "requestedRecordCount": 1,
    "returnedRecordCount": 1,
    "totalRecordCount": 3
  },
  "errorCode": 0,
  "errorMessage": ""
}


Retrieve a record with "binaryFormat" as base64

This example requests the first record in the "binary_test" table with the value of "bin" represented as a base64 string.

{
  "api": "db",
  "action": "getRecordsByTable",
  "params": {
    "tableName": "binary_test",
    "maxRecords": 1
  },
  "responseOptions": {
    "binaryFormat": "base64",
    "dataFormat": "objects",
    "numberFormat": "number"
  },
  "authToken": "replaceWithValidAuthtoken"
}
Response
{
  "authToken": "authtokenFromServer",
  "result": {
    "dataFormat": "objects",
    "binaryFormat": "byteArray",
    "fields": [
      { "name": "id",       "type": "bigint", "length": null, "scale": null, "autoTimestamp": "none", "defaultValue": null, "nullable": false, "primaryKey": 1 },
      { "name": "changeId", "type": "bigint", "length": null, "scale": null, "autoTimestamp": "none", "defaultValue": null, "nullable": true,  "primaryKey": 0 },
      { "name": "bin",      "type": "binary", "length": 5,    "scale": null, "autoTimestamp": "none", "defaultValue": null, "nullable": true,  "primaryKey": 0 }
    ],
    "data": [
      {
        "bin": "MTIzAAA=",
        "changeId": 50217,
        "id": 1
      }
    ],
    "moreRecords": true,
    "requestedRecordCount": 1,
    "returnedRecordCount": 1,
    "totalRecordCount": 3
  },
  "errorCode": 0,
  "errorMessage": ""
}


The "defaultOwnerName" property is an optional string that is supplied at "createSession". It is used by the "ownerName" property which specifies the owner account name. It defaults to the "username". When "ownerName" is omitted, the server sets "ownerName" to the value of "defaultOwnerName". However, if "defaultOwnerName" is set to the empty string, then the "ownerName" is set to the empty string.

  • See Object owner in the JSON DB Concepts section for an explanation of how to use the "defaultOwnerName" property to specify the owner of objects created in the session

  • When "ownerName" is omitted the server uses the "defaultOwnerName" property value set during login.

  • In "createSession" and "alterSession" when "defaultOwnerName" is omitted or set to null:

    • In the JSON DB API, the server sets "defaultOwnerName" to the "username" of the logged-in user. Thus, by default, the logged-in account owns the objects it creates.

    • In the JSON Hub API and JSON MQ API, the server sets "defaultOwnerName" to "admin" allowing the server to own the objects it creates.

  • Actions that create objects, such as "createTable" and "createIntegrationTable", can omit the "ownerName" property making the server set "ownerName" to the value of "defaultOwnerName".

  • When an action that creates an object sets the "ownerName" property to a valid account name, the specified account owns the created object and an account that owns an object has full management rights over the object. You can use object ownership as a simple way to control access to objects.

  • When "ownerName" is set to the empty string, then no account owns the object. Unowned objects can be managed by administrator accounts and by accounts assigned to roles that grant access rights to the object making it useful when you want to prevent an account from owning an object and inheriting full management rights to that object.

The "defaultResponseOptions" property is a "responseOptions" object. It defines a default value for "responseOptions" that is used by default in all other action calls. It defaults to an empty object.

  • 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 and omitting the error object 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 "errorCode", "errorMessage", and "errorData" properties are always present whether there is an error or not.

Example

"defaultResponseOptions": {
      "dataFormat": "objects",
      "numberFormat": "string",
      "binaryFormat": "hex"
    }

The "dataFormat" property is an optional, case-insensitive string enum that defines the format of the response in the "data" property. The default format is an array of arrays. The alternative is an array of objects. The default for "dataFormat" can be changed during a "createSession" action by assigning a different value to the "dataFormat" property in "defaultResponseOptions".

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.

  • "dataFormat" in the request inside "responseOptions" determines how the "data" property in the response is formatted.

    Possible values include:

    • "arrays"

      This is the default and causes the server to return results as an array of arrays, which is the most efficient.

    • "objects"

      This returns results as an array of objects. This is less efficient but is simpler to generate, read, and troubleshoot.

  • "dataFormat" in the request in the "params" object notifies the server how the "sourceData" property is formatted in the request. This version is rarely used because of the default "autoDetect" behavior.

    Possible values include:

    • "arrays"

      This causes the server to return results as an array of arrays, which is the most efficient.

    • "objects"

      This returns results as an array of objects. This is less efficient but is simpler to generate, read, and troubleshoot.

    • "autoDetect"

      This is the default and causes the server to automatically detect the format of the data in the "sourceData" property.

  • "dataFormat" in the response shows the client how the server formatted the "data" property.

    Possible values include:

    • "arrays"

      This is the default and causes the server to return results as an array of arrays, which is the most efficient.

    • "objects"

      This returns results as an array of objects. This is less efficient but is simpler to generate, read, and troubleshoot.

The "idleConnectionTimeoutSeconds" property is an optional integer from 0 to 2,147,483,647. It is the number of seconds that a session with no activity will stay open.

  • Each time a session executes an operation, the session timer restarts.

  • A value of 0 keeps a session open indefinitely.

The "idleCursorTimeoutSeconds" property is an optional integer from 0 to 2,147,483,647. It is the number of seconds to keep a cursor open.

  • Each time a cursor retrieves records, the cursor timer restarts.

  • A value of -1 keeps a cursor open indefinitely.

  • A value of 0 immediately closes a cursor after the current operation.

The "permanentSession" property is an optional Boolean that indicates if a session will expire. If "permanentSession" is set to true, the session will never expire and is always valid even if the server is restarted.

Its authToken never expires because the server permanently associates it with the session's settings and username. A permanent authToken works like an API Key and authenticates an application without the need for a username/password or a client certificate. Applications do not need to call the "createSession" action to get an authToken. Instead, multiple applications can use the same permanent authToken to authorize each JSON action.

Essential information

  • When true, the server returns a permanent authToken that represents the account that logged into "createSession" and the default session settings. You can use "alterSession" to modify the default session settings of a permanent session.

  • The default value is false.

    • The FairCom server securely stores each generated session ID in the encrypted faircom.fcs file.

  • Developers can use a permanent authToken to connect to a FairCom product without having to call createSession to get a temporary authToken.

  • Multiple app servers can use the same permanent authToken to share the same session.

  • Whether or not application share the same session, an application must create and use a transaction to protect the visibility and integrity of multiple operations from other applications.

  • Warning

    A permanent authToken is not as secure as a temporary one.

  • Important

    Before an application is released into production, it should be enhanced with additional code to use a temporary authToken.

  • Warning

    If an application changes the session defaults of a shared session, such as database and owner, it impacts the default behavior of all applications using the permanent session. To prevent this, an application must not rely on session defaults.

  • Warning

    When app servers use the same permanent authToken, you cannot use the authToken to determine which app server executes an action. This makes troubleshooting more difficult.

The "result" property is a required object set by the server that contains the result of an action.

Essential information:

Properties summary

This table contains only the properties that differ from those in the request.

Table 2. "result" properties summary

Property

Description

Type

Limits (inclusive)

authToken

signifies that the client is authenticated and authorized

string

0 to 225 bytes

defaultDebug

specifies the default value of the "debug" property for all requests in a session

string enum

One of the following:

"none"
"max"

defaultResponseOptions

specifies a default value for "responseOptions" that is used by default in all other action calls. "includeFields" and "excludeFields" are mutually exclusive and "includePaths" and "excludePaths" are mutually exclusive

object

One of the following:

"includeFields"
"excludeFields"
"includePaths"
"excludePaths"
"omit"
"numberFormat"
"dataFormat"

Note

"includeFields" and "excludeFields" are mutually exclusive

"includePaths" and "excludePaths" are mutually exclusive

errorCode

indicates an error when set to a non-zero integer or success when 0

integer

-2147483648 to 2147483647

username

specifies the account name of a user or application

string

1 to 64 bytes



The "authToken" property signifies that the client is authenticated and authorized. It is required.

  • It is supplied by the server in response to the connect action.

  • Clients must include it in all subsequent requests to validate that the client is authenticated and authorized. If the client does not supply the correct values, the server returns an unauthorized error.

"defaultDebug" is an optional string enum that defined the default value of the "debug" property for all requests in a session. It defaults to "max".

Important

This is different than the "debug" property in that the "debug" property can be universally used in any action while the "defaultDebug" property is only set in the "createSession" action and sets the "debug" property for any action run using the session being created.

  • Possible values include:

    • "none"

    • "max"

  • If "defaultDebug" is omitted or set to null, it defaults to "max".

    This causes the server to include the "debugInfo" property in the response.

    This setting is typically used in development environments and for temporarily troubleshooting issues in production environments.

  • For maximum performance set set "defaultDebug" to "none" .

    This causes the server to omit the "debugInfo" property in the response.

    This setting is typically used in production and staging environments where it is desirable to have maximum performance and minimal network traffic.

The "defaultResponseOptions" property is a "responseOptions" object. It defines a default value for "responseOptions" that is used by default in all other action calls. It defaults to an empty object.

  • 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 and omitting the error object 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 "errorCode", "errorMessage", and "errorData" properties are always present whether there is an error or not.

Example

"defaultResponseOptions": {
      "dataFormat": "objects",
      "numberFormat": "string",
      "binaryFormat": "hex"
    }

The "dataFormat" property is an optional, case-insensitive string enum that defines the format of the response in the "data" property. The default format is an array of arrays. The alternative is an array of objects. The default for "dataFormat" can be changed during a "createSession" action by assigning a different value to the "dataFormat" property in "defaultResponseOptions".

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.

  • "dataFormat" in the request inside "responseOptions" determines how the "data" property in the response is formatted.

    Possible values include:

    • "arrays"

      This is the default and causes the server to return results as an array of arrays, which is the most efficient.

    • "objects"

      This returns results as an array of objects. This is less efficient but is simpler to generate, read, and troubleshoot.

  • "dataFormat" in the request in the "params" object notifies the server how the "sourceData" property is formatted in the request. This version is rarely used because of the default "autoDetect" behavior.

    Possible values include:

    • "arrays"

      This causes the server to return results as an array of arrays, which is the most efficient.

    • "objects"

      This returns results as an array of objects. This is less efficient but is simpler to generate, read, and troubleshoot.

    • "autoDetect"

      This is the default and causes the server to automatically detect the format of the data in the "sourceData" property.

  • "dataFormat" in the response shows the client how the server formatted the "data" property.

    Possible values include:

    • "arrays"

      This is the default and causes the server to return results as an array of arrays, which is the most efficient.

    • "objects"

      This returns results as an array of objects. This is less efficient but is simpler to generate, read, and troubleshoot.

The "idleConnectionTimeoutSeconds" property is an optional integer from 0 to 2,147,483,647. It is the number of seconds that a session with no activity will stay open.

  • Each time a session executes an operation, the session timer restarts.

  • A value of 0 keeps a session open indefinitely.

The "idleCursorTimeoutSeconds" property is an optional integer from 0 to 2,147,483,647. It is the number of seconds to keep a cursor open.

  • Each time a cursor retrieves records, the cursor timer restarts.

  • A value of -1 keeps a cursor open indefinitely.

  • A value of 0 immediately closes a cursor after the current operation.

The "username" property is a required string from 1 to 64 bytes. It is the account name of a user or application.

  • It is required by the "createSession" action for authentication.

  • All API actions are performed in the context of the account identified by "username". For example, all tables created by an account are owned by the account. All queries use tables owned by the account.

  • In JSON DB API and JSON Hub API, use the "ownerName" property to cause an action to use a different account name than the value of "username". This allows an account to use tables created by another account and to create tables that are owned by another account.

  • Unlike other property names, such as "databaseName", "username" is all lowercase.

  • A zero-length username is invalid.