Hierarchy

  • UsageMeteringApi

Constructors

Properties

configuration: Configuration
requestFactory: UsageMeteringApiRequestFactory
responseProcessor: UsageMeteringApiResponseProcessor

Methods

  • Creates or updates one or more usage quotas by scope. If a quota already exists for a supplied scope, it is updated. Otherwise, a quota is created only when usage_limit and enforced are provided. Set create_only=true to atomically create exactly one quota in the caller's organization and reject an existing quota with 409 instead of updating it. This mode does not support pending limits or descendant writes. Repeated create-only requests do not replay the original response. If a response is lost, a retry can return 409 even if the first request succeeded; reconcile the outcome before retrying or importing the quota. For the organization-wide quota, pending_usage_limit schedules a limit for the next usage period and can accompany an immediate limit or update an existing quota by itself. Scheduled changes follow include_descendants like the other fields. Requires the billing_edit permission.

    Quota namespaces and scope keys

    The quota_namespace path parameter selects the product whose usage quotas are managed. Each namespace supports its own scope keys, described below. Omit scope for the organization-wide quota.

    ai_credits scope keys

    Each item's scope contains exactly one of the following keys.

    user_handle

    • Value: One of the following:
      • A user's handle, such as jane@example.com. User handles are returned in the data[].attributes.handle field by the Users API.
      • "*", the default quota applied to users without a specific quota.
      • "*agents*", the quota shared by all autonomous agents.
    • Validation: A specific handle must identify an existing user in the caller's organization when include_descendants is false. When include_descendants is true, the handle must exist in the caller's organization or in at least one targeted descendant organization. The quota is then applied only to the organizations where the handle exists, and the item fails only if the handle exists in none of them.

    role_uuid

    • Value: The UUID of a role, for example 12345678-1234-1234-1234-123456789012. "*" is not accepted because there is no default role quota. Role UUIDs are returned in the data[].id field by the Roles API.
    • Validation: The role must exist in the caller's organization. Role UUIDs are unique, so include_descendants has no effect on a role_uuid scope: the role is validated against the caller's organization only.

    team_id (private preview)

    • Value: The ID of a team. Team IDs are returned in the data[].id field by the Teams API.
    • Availability: Quotas on team_id are in private preview. Contact your Datadog account team to request access.

    Parameters

    Returns Promise<UsageQuotasBulkResponse>

  • Get resource-level usage for a billing dimension and month, using the same data as the resource breakdown in Plan & Usage. Supports all host and non-host resource types available in that breakdown. Availability depends on the billing dimension and the organization's usage data.

    Results are scoped to the authenticated organization. Set filter[include_descendants] to true to also return usage from its descendant organizations in all regions.

    Set filter[view] to billable to return resources that contribute to billable usage. For dimensions billed at the 99th percentile, this view returns resources at the selected billing hour. For sum-based dimensions, it returns monthly resource usage. Set filter[view] to all to return the full monthly resource breakdown. Requests for unsupported billing dimensions, or dimensions configured with an unsupported billing aggregation method, return a 400 Bad Request error.

    To get the next page of results, pass the meta.pagination.next_record_id value from the previous response as page[next_record_id], and keep all filters unchanged. A null cursor indicates the last page. Paginated responses contain at most page[limit] resource records, including queries across descendant organizations.

    Exception: for any billing dimension billed at the 99th percentile, filter[view]=billable returns the complete resource breakdown in one response, including requested descendants. Eligibility depends on the organization's billing configuration for the requested dimension and month, not on the product name. For these queries, page[limit] and page[next_record_id] are ignored, and meta.pagination.next_record_id is null. Sum-based usage and filter[view]=all remain paginated.

    Parameters

    Returns Promise<MonthlyResourcesResponse>

  • List the field names returned by GET /api/v1/usage/summary at each of its three response levels. Each list contains every key the data endpoint emits—both typed fields declared in the OpenAPI spec and untyped keys exposed through additionalProperties (the latter used for billing dimensions and usage types added after the v1 schema freeze).

    This endpoint is only accessible for parent-level organizations.

    Go example:

    fields, _, err := api.GetUsageSummaryAvailableFields(ctx)
    attr := fields.Data.GetAttributes()

    // resp is the *UsageSummaryResponse returned by api.GetUsageSummary(ctx, ...)
    // Layer 1: UsageSummaryResponse
    for _, key := range attr.GetResponseFields() {
    if val, ok := resp.AdditionalProperties[key]; ok {
    fmt.Println(key, val.(json.Number))
    }
    }
    // Layer 2: UsageSummaryDate (per month)
    for _, date := range resp.GetUsage() {
    for _, key := range attr.GetDateFields() {
    if val, ok := date.AdditionalProperties[key]; ok {
    fmt.Println(key, val.(json.Number))
    }
    }
    // Layer 3: UsageSummaryDateOrg (per org per month)
    for _, org := range date.GetOrgs() {
    for _, key := range attr.GetDateOrgFields() {
    if val, ok := org.AdditionalProperties[key]; ok {
    fmt.Println(key, val.(json.Number))
    }
    }
    }
    }

    Parameters

    Returns Promise<UsageSummaryAvailableFieldsResponse>

Generated using TypeDoc