Download OpenAPI specification:Download
A fully-managed API to read, write, and aggregate data in MongoDB Atlas. The Data API is powered by serverless Atlas Functions and secured with user authentication and role-based permissions. To learn more about the Data API, see Atlas Data API.
Before you can use the Data API, you must enable and configure it in an Atlas App Services App. The configuration controls how the App's users authenticate, authorize requests, and interact with the API.
To learn how to start using the Data API in your App, see Set up the Data API.
Your Data API configuration in App Services controls how users authenticate their API requests. In most cases, you will use Application authentication, which lets users log in with one of the App's authentication providers. Users can either provide their login credentials directly in every request or provide a reusable access token for an authenticated session.
To learn more, see Authenticate Data API Requests.
Find a single document that matches a query.
dataSource required | string The name of a linked MongoDB Atlas data source. This is
commonly |
database required | string The name of a database in the specified data source. |
collection required | string The name of a collection in the specified database. |
filter required | object A MongoDB query filter that matches documents. For a list of all query operators that the Data API supports, see Query Operators. |
object A MongoDB projection for matched documents returned by the operation. |
{- "dataSource": "mongodb-atlas",
- "database": "todo",
- "collection": "tasks",
- "filter": {
- "text": "Do the dishes"
}, - "projection": {
- "status": 1,
- "text": 1
}
}
{- "document": {
- "_id": "6193504e1be4ab27791c8133",
- "status": "open",
- "text": "Do the dishes"
}
}
Find multiple documents that match a query.
dataSource required | string The name of a linked MongoDB Atlas data source. This is
commonly |
database required | string The name of a database in the specified data source. |
collection required | string The name of a collection in the specified database. |
filter required | object A MongoDB query filter that matches documents. For a list of all query operators that the Data API supports, see Query Operators. |
object A MongoDB projection for matched documents returned by the operation. | |
sort | object A MongoDB sort expression that indicates sorted field names and directions. |
limit | number The maximum number of matching documents to include the in the response. |
skip | number The number of matching documents to omit from the response. |
{- "dataSource": "mongodb-atlas",
- "database": "todo",
- "collection": "tasks",
- "filter": {
- "status": "complete"
}, - "projection": {
- "text": 1,
- "completedAt": 1
}, - "sort": {
- "completedAt": 1
}, - "limit": 10
}
{- "documents": [
- {
- "_id": "6193504e1be4ab27791c8133",
- "text": "Do the dishes",
- "completedAt": "2022-05-16T20:22:01.104Z"
}, - {
- "_id": "6194604e1d38dc33792d8257",
- "text": "Feed the dog",
- "completedAt": "2022-05-17T05:12:42.828Z"
}
]
}
Insert a single document into a collection.
dataSource required | string The name of a linked MongoDB Atlas data source. This is
commonly |
database required | string The name of a database in the specified data source. |
collection required | string The name of a collection in the specified database. |
document required | object A document to insert into the collection. |
{- "dataSource": "mongodb-atlas",
- "database": "todo",
- "collection": "tasks",
- "document": {
- "status": "open${{ env.BUNDLED_SPEC_FILEPATH }}",
- "text": "Do the dishes"
}
}
{- "insertedId": "6193504e1be4ab27791c8133"
}
Insert multiple documents into a collection.
dataSource required | string The name of a linked MongoDB Atlas data source. This is
commonly |
database required | string The name of a database in the specified data source. |
collection required | string The name of a collection in the specified database. |
documents required | Array of objects A list of documents to insert into the collection. |
{- "dataSource": "mongodb-atlas",
- "database": "todo",
- "collection": "tasks",
- "documents": [
- {
- "status": "open",
- "text": "Mop the floor"
}, - {
- "status": "open",
- "text": "Clean the windows"
}
]
}
{- "insertedIds": [
- "61935189ec53247016a623c9",
- "61935189ec53247016a623ca"
]
}
Update a single document in a collection.
dataSource required | string The name of a linked MongoDB Atlas data source. This is
commonly |
database required | string The name of a database in the specified data source. |
collection required | string The name of a collection in the specified database. |
filter required | object A MongoDB query filter that matches documents. For a list of all query operators that the Data API supports, see Query Operators. |
update required | object A MongoDB update expression to apply to matching documents. For a list of all update operators that the Data API supports, see Update Operators. |
upsert | boolean Default: false When |
{- "dataSource": "mongodb-atlas",
- "database": "todo",
- "collection": "tasks",
- "filter": {
- "_id": {
- "$oid": "642f1bb5cee4111898828bf6"
}
}, - "update": {
- "$set": {
- "status": "complete"
}
}, - "upsert": false
}
{- "matchedCount": 1,
- "modifiedCount": 1
}
Update multiple documents in a collection.
dataSource required | string The name of a linked MongoDB Atlas data source. This is
commonly |
database required | string The name of a database in the specified data source. |
collection required | string The name of a collection in the specified database. |
filter required | object A MongoDB query filter that matches documents. For a list of all query operators that the Data API supports, see Query Operators. |
update required | object A MongoDB update expression to apply to matching documents. For a list of all update operators that the Data API supports, see Update Operators. |
upsert | boolean Default: false When |
{- "dataSource": "mongodb-atlas",
- "database": "todo",
- "collection": "tasks",
- "filter": {
- "status": "open"
}, - "update": {
- "$set": {
- "status": "complete"
}
}
}
{- "matchedCount": 12,
- "modifiedCount": 12
}
Delete a single document that matches a query.
dataSource required | string The name of a linked MongoDB Atlas data source. This is
commonly |
database required | string The name of a database in the specified data source. |
collection required | string The name of a collection in the specified database. |
filter | object A MongoDB query filter that matches documents. For a list of all query operators that the Data API supports, see Query Operators. |
{- "dataSource": "mongodb-atlas",
- "database": "todo",
- "collection": "tasks",
- "filter": {
- "text": "Do the dishes"
}
}
{- "deletedCount": 1
}
Delete multiple documents that match a query.
dataSource required | string The name of a linked MongoDB Atlas data source. This is
commonly |
database required | string The name of a database in the specified data source. |
collection required | string The name of a collection in the specified database. |
filter | object A MongoDB query filter that matches documents. For a list of all query operators that the Data API supports, see Query Operators. |
{- "dataSource": "mongodb-atlas",
- "database": "todo",
- "collection": "tasks",
- "filter": {
- "status": "complete"
}
}
{- "deletedCount": 12
}
Run an aggregation pipeline.
dataSource required | string The name of a linked MongoDB Atlas data source. This is
commonly |
database required | string The name of a database in the specified data source. |
collection required | string The name of a collection in the specified database. |
pipeline required | Array of objects An array of aggregation stages. |
[- {
- "$groupBy": {
- "_id": "$status",
- "count": {
- "$sum": 1
}, - "tasks": {
- "$push": "$text"
}
}
}, - {
- "$sort": {
- "count": 1
}
}
]
[- {
- "$groupBy": {
- "_id": "$status",
- "count": {
- "$sum": 1
}, - "tasks": {
- "$push": "$text"
}
}
}, - {
- "$sort": {
- "count": 1
}
}
]