Docs Menu
Docs Home
/ /
Atlas App Services

Wire Protocol

On this page

  • Overview
  • Compatible Clients
  • Connection Strings
  • Credentials
  • Region
  • Parameters
  • Enable Wire Protocol Connections
  • Navigate to the Data Source Configuration Screen
  • Enable Connection Strings for the Cluster
  • Select the Authentication Method
  • Pull the Latest Version of Your App
  • Enable Wire Protocol for the Cluster
  • Deploy the Updated Data Source Configuration
  • Connect Over the Wire Protocol
  • Connect to App Services with a Connection String
  • Read and Modify Data
  • Call a Function
  • Call a Service Action [DEPRECATED]
  • Get the Logged In User's Data

Atlas App Services natively implements a subset of the MongoDB wire protocol, which allows you to connect to an App through one of its linked MongoDB Atlas data sources using standard MongoDB drivers and tools. Clients use a specialized App Services connection string to connect and send requests. App Services supports most client features over the wire protocol, including role-based data access rules, functions, and service actions.

This is a good choice for languages that do not currently have a Realm SDK. The examples here are for Python, C++11, and the Mongo Shell. Any MongoDB driver that supports the appName connection string parameter can use the wire protocol to connect to App Services.


You can use the following tools and drivers to communicate with App Services using a connection string:

  • Version 4.0+ of the mongo shell.

  • Any MongoDB driver that supports the appName connection string parameter. All official MongoDB drivers support this parameter in their current releases.


Connections to App Services over the wire protocol have access to the full functionality of the MongoDB Service. However, App Services does not support all operations and features available in standard tools and clients. For details, see MongoDB Service Limitations.

To connect to App Services over the wire protocol, you must construct a MongoDB connection string that includes credentials for an application user and an application-specific appName query parameter.


URL Encoding

You must URL encode connection strings before you can use them to connect to App Services. Connection strings in the App Services UI are properly encoded by default.

App Services connection strings have the following form:


All operations that you issue over the wire protocol run in the context of a specific application user that you specify in the connection string. The user must be registered with one of the following authentication providers:

The contents of connection string credentials depend on the authentication provider with which the user registered:

The connection string must specify the deployment region and cloud provider in which the App is hosted.

Global Apps use the global region:


Local Apps specify the cloud provider and region name using <region>.<cloud> format. For example, an app deployed to aws-us-east-1 would use the following connection string:


App Services requires specific connection string options that identify the application you want to connect to and the authentication provider associated with the credentials that you provide.

App Services connection strings have the following query parameters:

This parameter should always be set to PLAIN.
This parameter should always be set to $external.

Uniquely identifies the application, MongoDB service, and authentication provider to which you want to connect.

The appName parameter has the following form:

<app id>:<service>:<provider>
<app id>
The App ID of the App.
The name of the MongoDB Service that you want to connect to. This value will always be mongodb-atlas.

The authentication provider for which you provided credentials.

Valid values:

  • local-userpass

  • api-key

  • custom-token

You must enable wire protocol connections for a linked clusters before you can connect to an App Services App with a connection string.

To connect to App Services over the wire protocol, pass a URL-encoded App Services connection string when you create a client, just as you would with a regular connection string.

While connected to App Services over the wire protocol you can use standard MongoDB CRUD operations. App Services applies role-based data access rules to all queries in the context of the authenticated user specified in the connection string credentials.

You can call functions using the callFunction database command.

Calls the specified function and returns any result.
callFunction: <function name>,
arguments: [<arg1>, <arg2>, ...]

You can call service actions using the callServiceFunction database command.

Calls the specified service action and returns any result.
callServiceFunction: <function name>,
service: <service name>,
arguments: [<arg1>, <arg2>, ...]

You can get the user object for the authenticated user using the userProfile database command.

Returns the user object for the authenticated user.
userProfile: 1
← Read Preference