Keys / MongoDB Atlas
MONGODB_URI
The connection string your app connects to a MongoDB Atlas cluster with. It holds a database user's name and password.
- Starts with
mongodb+srv://- Expires
- never, unless you make a temporary user (up to 1 week)
- API
- create, update and delete database users, with the Atlas Admin API
Get it
Create one on cloud.mongodb.com. The steps aren't recorded yet.
Set it
MONGODB_URI=mongodb+srv://...
MongoDB's drivers don't read it on their own; MongoDB's examples read MONGODB_URI and pass it to the client. Or keep it out of .env with keypin: keypin run -- npm run dev
Replace it
- On the Database & Network Access page, add a database user with the same roles and cluster access as the old one.
- Build the new connection string with that user and deploy it everywhere that reads
MONGODB_URI. - Check that nothing still connects as the old user, then delete it.
Set rotate_every on the key in keypin.toml and a rotated date on its vault item, and keypin status shows when it's due.