MQL reference navigation

hello

The hello command returns a document describing the role of the DocumentDB server, along with connection limits, supported authentication mechanisms, and the version of the DocumentDB engine you are connected to. It's the recommended way to discover the DocumentDB version from a MongoDB client, since the internal.documentdb_versions field reports the underlying engine version rather than only the emulated MongoDB wire-protocol version.

The versions in internal.documentdb_versions come from the backend DocumentDB PostgreSQL extension, not from the gateway. The array reports two values: the installed SQL extension version (from the pg_extension catalog, in major-minor form such as 0.113-0) followed by the loaded binary version (from documentdb_api.binary_version(), in dotted form such as 0.113.0). In PostgreSQL, the installed extension version is the schema version — it tracks which SQL upgrade scripts have been applied — so the first value reflects the schema currently installed in the database. These two values normally describe the same release and differ only in formatting, but they can diverge during an upgrade — for example, when the shared library has been updated but ALTER EXTENSION documentdb UPDATE hasn't yet been run. A mismatch such as ["0.112-0", "0.113.0"] indicates the SQL schema is behind the loaded binary.

Syntax

The syntax for the hello command is as follows:

db.runCommand({ hello: 1 })

The mongosh helper db.hello() runs the same command:

db.hello()

Return fields

The response includes the following fields. Fields marked as DocumentDB-specific are extensions to the standard MongoDB response.

FieldDescription
isWritablePrimarytrue when the connected node accepts writes.
msgSet to isdbgrid, indicating requests are served through the DocumentDB gateway.
maxBsonObjectSizeMaximum permitted size, in bytes, of a BSON document.
maxMessageSizeBytesMaximum permitted size, in bytes, of a single message.
maxWriteBatchSizeMaximum number of write operations permitted in a single batch.
localTimeThe server's current time, in UTC.
logicalSessionTimeoutMinutesMinutes an idle logical session is retained before timing out.
minWireVersion / maxWireVersionRange of the MongoDB wire protocol versions the server supports.
readOnlytrue when the connection is read-only.
connectionIdIdentifier of the current connection.
saslSupportedMechsAuthentication mechanisms the server supports, for example SCRAM-SHA-256.
internal.documentdb_versions(DocumentDB-specific) Versions reported by the backend DocumentDB PostgreSQL extension: the installed SQL extension version — which in PostgreSQL is the schema version (major-minor, for example 0.113-0) — followed by the loaded binary version (dotted, for example 0.113.0). These normally match and diverge only during an upgrade.
ok1 when the command succeeds.

Examples

Example 1: Inspect the server role and version

Run the hello command to view the full response:

db.runCommand({ hello: 1 })

The server returns a document similar to the following:

{
  "isWritablePrimary": true,
  "msg": "isdbgrid",
  "maxBsonObjectSize": 16777216,
  "maxMessageSizeBytes": 48000000,
  "maxWriteBatchSize": 25000,
  "localTime": 1783006410548,
  "logicalSessionTimeoutMinutes": 30,
  "minWireVersion": 0,
  "maxWireVersion": 21,
  "readOnly": false,
  "connectionId": 382703778,
  "saslSupportedMechs": [
    "SCRAM-SHA-256"
  ],
  "internal": {
    "documentdb_versions": [
      "0.113-0",
      "0.113.0"
    ],
    "kind": ""
  },
  "ok": 1
}

Example 2: Determine the DocumentDB engine version

To read only the DocumentDB engine version, project the internal.documentdb_versions field:

db.runCommand({ hello: 1 }).internal.documentdb_versions

The command returns an array with the installed SQL extension version followed by the loaded binary version:

[ "0.113-0", "0.113.0" ]

The first value is the installed SQL extension version — the schema version, from the pg_extension catalog — and the second is the compiled binary version. They normally describe the same release and differ only in formatting.

Note

The buildInfo command reports the emulated MongoDB wire-protocol version (for example, 7.0.0), not the DocumentDB engine version. Use hello and read internal.documentdb_versions to determine the DocumentDB version.

Related content