> ## Documentation Index
> Fetch the complete documentation index at: https://docs.thanx.com/llms.txt
> Use this file to discover all available pages before exploring further.

# MongoDB

> Configuring your MongoDB destination.

## Prerequisites

* [ ] If your MongoDB deployment requires IP whitelisting, have the data-syncing service's static IP available to complete Step 3.

## Step 1: Locate your connection information

1. If you are running self-managed MongoDB, connect as an admin user and run the following command to find your replica set's host identifiers.

```
db.adminCommand( { replSetGetStatus : 1 } ).members
```

2. If you are using MongoDB Atlas, open your cluster in the Atlas dashboard, click **Connect**, then **Drivers**, and copy the host identifier from the `mongodb+srv` connection string (in the form `some-cluster.some-characters.mongodb.net`).

## Step 2: Create a writer user

Create a database user to perform the writing of the source data.

* If you are running self-managed MongoDB, connect as an admin user and run:

```
db.createUser({user: "<username>", pwd: "<password>", roles: [{role: "readWrite", db: "<database>"}]})
```

* If you are using MongoDB Atlas, go to **Security** > **Database Access** > **Add New Database User**, choose **Password** authentication, and grant the `readWrite` role scoped to your target database.

## Step 3: Allow network access

* If you are running self-managed MongoDB, configure your firewall to whitelist the data-syncing service's static IP.
* If you are using MongoDB Atlas, add the static IP under **Security** > **Network Access** > **Add IP Address**, either through the UI or with the Atlas CLI:

```
atlas accessLists create "<static_ip_address>/32" --comment "data-syncing service static IP"
```

<Note>
  **Network allowlisting**

  Cloud-hosted (US): `35.192.85.117/32`

  Cloud-hosted (EU): `104.199.49.149/32`

  If private-cloud or self-hosted, contact your Thanx representative for the static egress IP.
</Note>

## Step 4: Add your destination

Securely share your **host identifier**, **database name**, your chosen **collection prefix**, **username**, and **password** with us to complete the connection. A port is not required for MongoDB Atlas connections.

## Permissions checklist

* Network or firewall rules allow inbound connections from the data-syncing service's static egress IP.
* The database user has the `readWrite` role scoped to the target database.
* If using MongoDB Atlas, the static IP has been added via the UI or the Atlas CLI (`atlas accessLists create`).

## FAQ

<AccordionGroup>
  <Accordion title="How is the MongoDB connection secured?">
    The connection uses a dedicated MongoDB user with the `readWrite` role scoped to the target database. Network access can be restricted to the static egress IP.
  </Accordion>
</AccordionGroup>
