Skip to main content

Overview

The MongoDB API allows you to create, manage, deploy, and monitor MongoDB database instances. MongoDB databases run as Docker containers with support for replica sets, automated backups, and external port configuration.

Create MongoDB Database

curl -X POST https://your-dokploy-instance.com/api/mongo.create \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "production-mongo",
    "appName": "prod-mongo",
    "databaseUser": "admin",
    "databasePassword": "securePassword123!",
    "dockerImage": "mongo:15",
    "environmentId": "env_123456",
    "replicaSets": false,
    "description": "Production MongoDB database"
  }'
{
  "mongoId": "mongo_abc123",
  "name": "production-mongo",
  "appName": "prod-mongo",
  "databaseUser": "admin",
  "dockerImage": "mongo:15",
  "replicaSets": false,
  "applicationStatus": "idle",
  "createdAt": "2024-02-28T12:00:00Z"
}

Request Body

name
string
required
Display name for the MongoDB database (minimum 1 character)
appName
string
required
Unique application name used for Docker container naming (minimum 1 character)
databaseUser
string
required
Username for database authentication (minimum 1 character)
databasePassword
string
required
Password for database authentication. Must match pattern: ^[a-zA-Z0-9@#%^&*()_+\-=[\]{}|;:,.<>?~]*$`
environmentId
string
required
ID of the environment where the database will be deployed
dockerImage
string
default:"mongo:15"
Docker image to use for MongoDB (e.g., mongo:15, mongo:7, mongo:6)
replicaSets
boolean
default:false
Enable MongoDB replica sets for high availability
description
string
Optional description for the database instance
serverId
string
ID of the server where the database should be deployed (required in cloud environments)

Get MongoDB Database

Retrieve details about a specific MongoDB database instance.
curl -X GET "https://your-dokploy-instance.com/api/mongo.one?mongoId=mongo_abc123" \
  -H "Authorization: Bearer YOUR_API_TOKEN"

Query Parameters

mongoId
string
required
Unique identifier of the MongoDB database

Deploy MongoDB Database

Deploy or redeploy a MongoDB database container.
curl -X POST https://your-dokploy-instance.com/api/mongo.deploy \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "mongoId": "mongo_abc123"
  }'

Request Body

mongoId
string
required
ID of the MongoDB database to deploy

Start MongoDB Database

Start a stopped MongoDB database container.
curl -X POST https://your-dokploy-instance.com/api/mongo.start \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "mongoId": "mongo_abc123"
  }'

Stop MongoDB Database

Stop a running MongoDB database container.
curl -X POST https://your-dokploy-instance.com/api/mongo.stop \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "mongoId": "mongo_abc123"
  }'

Reload MongoDB Database

Reload (restart) a MongoDB database container.
curl -X POST https://your-dokploy-instance.com/api/mongo.reload \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "mongoId": "mongo_abc123",
    "appName": "prod-mongo"
  }'

Request Body

mongoId
string
required
ID of the MongoDB database to reload
appName
string
required
Application name of the MongoDB database (minimum 1 character)

Update MongoDB Database

Update MongoDB database configuration, including credentials, resources, and Docker image.
curl -X POST https://your-dokploy-instance.com/api/mongo.update \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "mongoId": "mongo_abc123",
    "name": "production-mongo-updated",
    "databasePassword": "newSecurePassword456!",
    "replicaSets": true,
    "memoryLimit": "2g",
    "cpuLimit": "1.5"
  }'

Request Body

mongoId
string
required
ID of the MongoDB database to update (minimum 1 character)
name
string
Updated display name (minimum 1 character)
appName
string
Updated application name (minimum 1 character)
databaseUser
string
Updated database username (minimum 1 character)
databasePassword
string
Updated database password
dockerImage
string
default:"mongo:15"
Updated Docker image version
replicaSets
boolean
Enable or disable MongoDB replica sets
memoryReservation
string
Memory reservation (e.g., “512m”, “1g”)
memoryLimit
string
Memory limit (e.g., “1g”, “2g”)
cpuReservation
string
CPU reservation (e.g., “0.5”, “1.0”)
cpuLimit
string
CPU limit (e.g., “1.0”, “2.0”)
command
string
Custom command to run in the container
args
array
Command line arguments for the MongoDB server
externalPort
number
External port to expose MongoDB

Save Environment Variables

Update environment variables for the MongoDB database container.
curl -X POST https://your-dokploy-instance.com/api/mongo.saveEnvironment \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "mongoId": "mongo_abc123",
    "env": "MONGO_INITDB_DATABASE=myapp\nMONGO_MAX_CONNECTIONS=500"
  }'

Request Body

mongoId
string
required
ID of the MongoDB database
env
string
Environment variables in KEY=VALUE format, separated by newlines

Save External Port

Configure external port mapping for the MongoDB database.
curl -X POST https://your-dokploy-instance.com/api/mongo.saveExternalPort \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "mongoId": "mongo_abc123",
    "externalPort": 27017
  }'

Request Body

mongoId
string
required
ID of the MongoDB database
externalPort
number
required
Port number to expose MongoDB externally. Set to null to remove external port mapping.

Change Status

Manually update the application status of a MongoDB database.
curl -X POST https://your-dokploy-instance.com/api/mongo.changeStatus \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "mongoId": "mongo_abc123",
    "applicationStatus": "done"
  }'

Request Body

mongoId
string
required
ID of the MongoDB database
applicationStatus
string
required
New status. Options: idle, running, done, error

Move MongoDB Database

Move a MongoDB database to a different environment.
curl -X POST https://your-dokploy-instance.com/api/mongo.move \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "mongoId": "mongo_abc123",
    "targetEnvironmentId": "env_789xyz"
  }'

Request Body

mongoId
string
required
ID of the MongoDB database to move
targetEnvironmentId
string
required
ID of the destination environment

Rebuild MongoDB Database

Rebuild the MongoDB database container from scratch.
curl -X POST https://your-dokploy-instance.com/api/mongo.rebuild \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "mongoId": "mongo_abc123"
  }'

Request Body

mongoId
string
required
ID of the MongoDB database to rebuild

Remove MongoDB Database

Delete a MongoDB database and all associated resources, including backups and scheduled jobs.
This action is irreversible. All database data and backups will be permanently deleted.
curl -X POST https://your-dokploy-instance.com/api/mongo.remove \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "mongoId": "mongo_abc123"
  }'

Request Body

mongoId
string
required
ID of the MongoDB database to remove

Backup Operations

For backup and restore operations, see the Backup API documentation.
  • Create automated backups: backup.create
  • Manual backup: backup.manualBackupMongo
  • Restore from backup: backup.restoreBackupWithLogs