Create One Cost Explorer Query Process

POST /api/atlas/v2/orgs/{orgId}/billing/costExplorer/usage

Creates a query process within the Cost Explorer for the given parameters. A token is returned that can be used to poll the status of the query and eventually retrieve the results.

Path parameters

  • orgId string Required

    Unique 24-hexadecimal digit string that identifies the organization that contains your projects. Use the /orgs endpoint to retrieve all organizations to which the authenticated user has access.

    Format should match the following pattern: ^([a-f0-9]{24})$.

Query parameters

  • envelope boolean

    Flag that indicates whether Application wraps the response in an envelope JSON object. Some API clients cannot access the HTTP response headers or status code. To remediate this, set envelope=true in the query. Endpoints that return a list of results use the results object as an envelope. Application adds the status parameter to the response body.

    Default value is false.

application/vnd.atlas.2023-01-01+json

Body Required

Filter parameters for the Cost Explorer query.

  • clusters array[string]

    The list of projects to be included in the Cost Explorer Query.

    Format of each should match the following pattern: ^([a-f0-9]{24})$.

  • endDate string(date) Required

    The exclusive ending date for the Cost Explorer query. The date must be the start of a month.

  • groupBy string

    The dimension to group the returned usage results by. At least one filter value needs to be provided for a dimension to be used.

    Values are organizations, projects, clusters, or services.

  • includePartialMatches boolean

    Flag to control whether usage that matches the filter criteria, but does not have values for all filter criteria is included in response. Default is false, which excludes the partially matching data.

  • organizations array[string]

    The list of organizations to be included in the Cost Explorer Query.

    Format of each should match the following pattern: ^([a-f0-9]{24})$.

  • projects array[string]

    The list of projects to be included in the Cost Explorer Query.

    Format of each should match the following pattern: ^([a-f0-9]{24})$.

  • services array[string]

    The list of projects to be included in the Cost Explorer Query.

    Values are Atlas, Clusters, Storage, Serverless Instances, Backup, Data Transfer, BI Connector, Premium Features, Atlas Data Federation, Atlas Stream Processing, App Services, Charts, Cloud Manager, Cloud Manager Standard/Premium, Legacy Backup, Flex Consulting, Support, or Credits.

  • startDate string(date) Required

    The inclusive starting date for the Cost Explorer query. The date must be the start of a month.

Responses

  • 202 application/vnd.atlas.2023-01-01+json

    Accepted

    Hide response attribute Show response attribute object
    • token string

      The token used to identify the created Cost Explorer query.

      Minimum length is 64, maximum length is 64.

  • 401 application/json

    Unauthorized.

    Hide response attributes Show response attributes object
    • badRequestDetail object

      Bad request detail.

      Hide badRequestDetail attribute Show badRequestDetail attribute object
      • fields array[object]

        Describes all violations in a client request.

        Hide fields attributes Show fields attributes object
        • description string Required

          A description of why the request element is bad.

        • field string Required

          A path that leads to a field in the request body.

    • detail string

      Describes the specific conditions or reasons that cause each type of error.

    • error integer(int32) Required

      HTTP status code returned with this error.

      External documentation
    • errorCode string Required

      Application error code returned with this error.

    • parameters array[object]

      Parameters used to give more information about the error.

    • reason string

      Application error message returned with this error.

  • 403 application/json

    Forbidden.

    Hide response attributes Show response attributes object
    • badRequestDetail object

      Bad request detail.

      Hide badRequestDetail attribute Show badRequestDetail attribute object
      • fields array[object]

        Describes all violations in a client request.

        Hide fields attributes Show fields attributes object
        • description string Required

          A description of why the request element is bad.

        • field string Required

          A path that leads to a field in the request body.

    • detail string

      Describes the specific conditions or reasons that cause each type of error.

    • error integer(int32) Required

      HTTP status code returned with this error.

      External documentation
    • errorCode string Required

      Application error code returned with this error.

    • parameters array[object]

      Parameters used to give more information about the error.

    • reason string

      Application error message returned with this error.

  • 404 application/json

    Not Found.

    Hide response attributes Show response attributes object
    • badRequestDetail object

      Bad request detail.

      Hide badRequestDetail attribute Show badRequestDetail attribute object
      • fields array[object]

        Describes all violations in a client request.

        Hide fields attributes Show fields attributes object
        • description string Required

          A description of why the request element is bad.

        • field string Required

          A path that leads to a field in the request body.

    • detail string

      Describes the specific conditions or reasons that cause each type of error.

    • error integer(int32) Required

      HTTP status code returned with this error.

      External documentation
    • errorCode string Required

      Application error code returned with this error.

    • parameters array[object]

      Parameters used to give more information about the error.

    • reason string

      Application error message returned with this error.

  • 400 application/json

    Bad Request.

    Hide response attributes Show response attributes object
    • badRequestDetail object

      Bad request detail.

      Hide badRequestDetail attribute Show badRequestDetail attribute object
      • fields array[object]

        Describes all violations in a client request.

        Hide fields attributes Show fields attributes object
        • description string Required

          A description of why the request element is bad.

        • field string Required

          A path that leads to a field in the request body.

    • detail string

      Describes the specific conditions or reasons that cause each type of error.

    • error integer(int32) Required

      HTTP status code returned with this error.

      External documentation
    • errorCode string Required

      Application error code returned with this error.

    • parameters array[object]

      Parameters used to give more information about the error.

    • reason string

      Application error message returned with this error.

  • 500 application/json

    Internal Server Error.

    Hide response attributes Show response attributes object
    • badRequestDetail object

      Bad request detail.

      Hide badRequestDetail attribute Show badRequestDetail attribute object
      • fields array[object]

        Describes all violations in a client request.

        Hide fields attributes Show fields attributes object
        • description string Required

          A description of why the request element is bad.

        • field string Required

          A path that leads to a field in the request body.

    • detail string

      Describes the specific conditions or reasons that cause each type of error.

    • error integer(int32) Required

      HTTP status code returned with this error.

      External documentation
    • errorCode string Required

      Application error code returned with this error.

    • parameters array[object]

      Parameters used to give more information about the error.

    • reason string

      Application error message returned with this error.

POST /api/atlas/v2/orgs/{orgId}/billing/costExplorer/usage
curl \
 --request POST 'https://cloud.mongodb.com/api/atlas/v2/orgs/4888442a3354817a7320eb61/billing/costExplorer/usage' \
 --header "Authorization: Bearer $ACCESS_TOKEN" \
 --header "Content-Type: application/vnd.atlas.2023-01-01+json"
Request examples
{
  "clusters": [
    "32b6e34b3d91647abb20e7b8"
  ],
  "endDate": "2025-05-04",
  "groupBy": "organizations",
  "includePartialMatches": true,
  "organizations": [
    "32b6e34b3d91647abb20e7b8"
  ],
  "projects": [
    "32b6e34b3d91647abb20e7b8"
  ],
  "services": [
    "Atlas"
  ],
  "startDate": "2025-05-04"
}
Response examples (202)
{
  "token": "d9ab638a801efe182f98ae3e18ea4bb47b9fda808a28a8c7de205bb0e94f7d71"
}
Response examples (401)
{
  "error": 401,
  "detail": "(This is just an example, the exception may not be related to this endpoint)",
  "reason": "Unauthorized",
  "errorCode": "NOT_ORG_GROUP_CREATOR"
}
Response examples (403)
{
  "error": 403,
  "detail": "(This is just an example, the exception may not be related to this endpoint)",
  "reason": "Forbidden",
  "errorCode": "CANNOT_CHANGE_GROUP_NAME"
}
Response examples (404)
{
  "error": 404,
  "detail": "(This is just an example, the exception may not be related to this endpoint) Cannot find resource AWS",
  "reason": "Not Found",
  "errorCode": "RESOURCE_NOT_FOUND"
}
Response examples (400)
{
  "error": 400,
  "detail": "(This is just an example, the exception may not be related to this endpoint) No provider AWS exists.",
  "reason": "Bad Request",
  "errorCode": "VALIDATION_ERROR"
}
Response examples (500)
{
  "error": 500,
  "detail": "(This is just an example, the exception may not be related to this endpoint)",
  "reason": "Internal Server Error",
  "errorCode": "UNEXPECTED_ERROR"
}