Create 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.

    Minimum length is 24, maximum length is 24. 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.

  • 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.

  • projects array[string]

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

  • 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.

  • 400 application/json

    Bad Request.

    Hide response attributes Show response attributes object
    • detail string

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

    • error integer(int32)

      HTTP status code returned with this error.

      External documentation
    • errorCode string

      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.

  • 401 application/json

    Unauthorized.

    Hide response attributes Show response attributes object
    • detail string

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

    • error integer(int32)

      HTTP status code returned with this error.

      External documentation
    • errorCode string

      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
    • detail string

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

    • error integer(int32)

      HTTP status code returned with this error.

      External documentation
    • errorCode string

      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
atlas api invoices createCostExplorerQueryProcess --help
import (
	"os"
	"context"
	"log"
	sdk "go.mongodb.org/atlas-sdk/v20230101001/admin"
)

func main() {
	ctx := context.Background()
	clientID := os.Getenv("MONGODB_ATLAS_CLIENT_ID")
	clientSecret := os.Getenv("MONGODB_ATLAS_CLIENT_SECRET")

	// See https://dochub.mongodb.org/core/atlas-go-sdk-oauth
	client, err := sdk.NewClient(sdk.UseOAuthAuth(clientID, clientSecret))

	if err != nil {
		log.Fatalf("Error: %v", err)
	}

	params = &sdk.CreateCostExplorerQueryProcessApiParams{}
	sdkResp, httpResp, err := client.InvoicesApi.
		CreateCostExplorerQueryProcessWithParams(ctx, params).
		Execute()
}
curl --include --header "Authorization: Bearer ${ACCESS_TOKEN}" \
  --header "Accept: application/vnd.atlas.2023-01-01+json" \
  --header "Content-Type: application/json" \
  -X POST "https://cloud.mongodb.com/api/atlas/v2/orgs/{orgId}/billing/costExplorer/usage" \
  -d '{ <Payload> }'
curl --user "${PUBLIC_KEY}:${PRIVATE_KEY}" \
  --digest --include \
  --header "Accept: application/vnd.atlas.2023-01-01+json" \
  --header "Content-Type: application/json" \
  -X POST "https://cloud.mongodb.com/api/atlas/v2/orgs/{orgId}/billing/costExplorer/usage" \
  -d '{ <Payload> }'
Request examples
{
  "clusters": [
    "5feeac500000000000000000",
    "61cfdfd00000000000000000"
  ],
  "endDate": "2022-02-01",
  "groupBy": "organizations",
  "includePartialMatches": true,
  "organizations": [
    "5feeac500000000000000000",
    "61cfdfd00000000000000000"
  ],
  "projects": [
    "5feeac500000000000000000",
    "61cfdfd00000000000000000"
  ],
  "services": [
    "Data Transfer",
    "Atlas Data Federation"
  ],
  "startDate": "2022-02-01"
}
Response examples (202)
{
  "token": "d9ab638a801efe182f98ae3e18ea4bb47b9fda808a28a8c7de205bb0e94f7d71"
}
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 (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 (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"
}