For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/api/latest/usage-metering/create-or-update-usage-quotas.md. A documentation index is available at /llms.txt.
Language
Datadog site

Create or update usage quotas

WARNINGNote: This endpoint is in Preview and is subject to change. If you have any feedback, contact Datadog support.
POSThttps://api.datadoghq.com/api/v2/usage/quotas/{quota_namespace}https://api.us3.datadoghq.com/api/v2/usage/quotas/{quota_namespace}https://api.us5.datadoghq.com/api/v2/usage/quotas/{quota_namespace}https://api.datadoghq.eu/api/v2/usage/quotas/{quota_namespace}https://api.ap1.datadoghq.com/api/v2/usage/quotas/{quota_namespace}https://api.ap2.datadoghq.com/api/v2/usage/quotas/{quota_namespace}https://api.uk1.datadoghq.com/api/v2/usage/quotas/{quota_namespace}https://api.ddog-gov.com/api/v2/usage/quotas/{quota_namespace}https://api.us2.ddog-gov.com/api/v2/usage/quotas/{quota_namespace}

Overview

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.

This endpoint requires the billing_edit permission.

OAuth apps require the billing_edit authorization scope to access this endpoint.

Arguments

Path Parameters

Name
Type
Description
quota_namespace [required]
string

The product-specific namespace whose usage quotas are being managed.

Query Strings

Name
Type
Description
include_descendants
boolean

Whether to write every item in the request to the caller's organization and all of its descendant organizations, instead of only the caller's organization. Only descendants in the same data center are supported. For a user-handle scope, the quota is applied only to the caller's organization and to descendant organizations where that user handle exists; the item fails only if the handle exists in none of them.

Default: false
create_only
boolean

Create one quota without updating an existing quota. Requires exactly one item that specifies usage_limit and enforced, omits pending_usage_limit, and sets include_descendants=false. The quota belongs to the caller's organization. An existing quota returns 409 without being modified.

Default: false

Request

Body Data (required)

The usage quotas to create or update.

Field
Type
Description
data [required]
[object]

A bulk list of usage quota resources to create or update by scope.

Response

OK. The response includes each item's result; see each item's error attribute for any that failed to write.

Response containing the result of a bulk usage quota create-or-update request. Returned with a 200 status regardless of whether individual items succeeded or failed; check each item's error attribute to determine its outcome.

Field
Type
Description
data [required]
[object]

The results of writing each usage quota in a bulk create-or-update request, in the same order as the request.

Code Example

Create or update usage quotas
## Create or update quotas for the caller's organization.

# Path parameters
export quota_namespace="ai_credits"

# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/usage/quotas/${quota_namespace}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": [
    {
      "attributes": {
        "enforced": true,
        "scope": {
          "user_handle": "jane@example.com"
        },
        "usage_limit": 100000
      },
      "type": "quotas"
    },
    {
      "attributes": {
        "enforced": false,
        "scope": {
          "user_handle": "*"
        },
        "usage_limit": 250000
      },
      "type": "quotas"
    }
  ]
}
EOF

## Set a limit and schedule a reduction

# Path parameters
export quota_namespace="ai_credits"

# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/usage/quotas/${quota_namespace}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": [
    {
      "attributes": {
        "enforced": true,
        "pending_usage_limit": 100000,
        "usage_limit": 600000
      },
      "type": "quotas"
    }
  ]
}
EOF
## Create or update quotas for the caller's organization.

# Path parameters
export quota_namespace="ai_credits"

# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/usage/quotas/${quota_namespace}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": [
    {
      "attributes": {
        "enforced": true,
        "scope": {
          "user_handle": "jane@example.com"
        },
        "usage_limit": 100000
      },
      "type": "quotas"
    },
    {
      "attributes": {
        "enforced": false,
        "scope": {
          "user_handle": "*"
        },
        "usage_limit": 250000
      },
      "type": "quotas"
    }
  ]
}
EOF

## Set a limit and schedule a reduction

# Path parameters
export quota_namespace="ai_credits"

# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/usage/quotas/${quota_namespace}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": [
    {
      "attributes": {
        "enforced": true,
        "pending_usage_limit": 100000,
        "usage_limit": 600000
      },
      "type": "quotas"
    }
  ]
}
EOF
## Create or update quotas for the caller's organization.

# Path parameters
export quota_namespace="ai_credits"

# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/usage/quotas/${quota_namespace}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": [
    {
      "attributes": {
        "enforced": true,
        "scope": {
          "user_handle": "jane@example.com"
        },
        "usage_limit": 100000
      },
      "type": "quotas"
    },
    {
      "attributes": {
        "enforced": false,
        "scope": {
          "user_handle": "*"
        },
        "usage_limit": 250000
      },
      "type": "quotas"
    }
  ]
}
EOF

## Set a limit and schedule a reduction

# Path parameters
export quota_namespace="ai_credits"

# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/usage/quotas/${quota_namespace}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": [
    {
      "attributes": {
        "enforced": true,
        "pending_usage_limit": 100000,
        "usage_limit": 600000
      },
      "type": "quotas"
    }
  ]
}
EOF
## Create or update quotas for the caller's organization.

# Path parameters
export quota_namespace="ai_credits"

# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/usage/quotas/${quota_namespace}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": [
    {
      "attributes": {
        "enforced": true,
        "scope": {
          "user_handle": "jane@example.com"
        },
        "usage_limit": 100000
      },
      "type": "quotas"
    },
    {
      "attributes": {
        "enforced": false,
        "scope": {
          "user_handle": "*"
        },
        "usage_limit": 250000
      },
      "type": "quotas"
    }
  ]
}
EOF

## Set a limit and schedule a reduction

# Path parameters
export quota_namespace="ai_credits"

# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/usage/quotas/${quota_namespace}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": [
    {
      "attributes": {
        "enforced": true,
        "pending_usage_limit": 100000,
        "usage_limit": 600000
      },
      "type": "quotas"
    }
  ]
}
EOF
## Create or update quotas for the caller's organization.

# Path parameters
export quota_namespace="ai_credits"

# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/usage/quotas/${quota_namespace}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": [
    {
      "attributes": {
        "enforced": true,
        "scope": {
          "user_handle": "jane@example.com"
        },
        "usage_limit": 100000
      },
      "type": "quotas"
    },
    {
      "attributes": {
        "enforced": false,
        "scope": {
          "user_handle": "*"
        },
        "usage_limit": 250000
      },
      "type": "quotas"
    }
  ]
}
EOF

## Set a limit and schedule a reduction

# Path parameters
export quota_namespace="ai_credits"

# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/usage/quotas/${quota_namespace}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": [
    {
      "attributes": {
        "enforced": true,
        "pending_usage_limit": 100000,
        "usage_limit": 600000
      },
      "type": "quotas"
    }
  ]
}
EOF
## Create or update quotas for the caller's organization.

# Path parameters
export quota_namespace="ai_credits"

# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/usage/quotas/${quota_namespace}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": [
    {
      "attributes": {
        "enforced": true,
        "scope": {
          "user_handle": "jane@example.com"
        },
        "usage_limit": 100000
      },
      "type": "quotas"
    },
    {
      "attributes": {
        "enforced": false,
        "scope": {
          "user_handle": "*"
        },
        "usage_limit": 250000
      },
      "type": "quotas"
    }
  ]
}
EOF

## Set a limit and schedule a reduction

# Path parameters
export quota_namespace="ai_credits"

# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/usage/quotas/${quota_namespace}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": [
    {
      "attributes": {
        "enforced": true,
        "pending_usage_limit": 100000,
        "usage_limit": 600000
      },
      "type": "quotas"
    }
  ]
}
EOF
## Create or update quotas for the caller's organization.

# Path parameters
export quota_namespace="ai_credits"

# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/usage/quotas/${quota_namespace}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": [
    {
      "attributes": {
        "enforced": true,
        "scope": {
          "user_handle": "jane@example.com"
        },
        "usage_limit": 100000
      },
      "type": "quotas"
    },
    {
      "attributes": {
        "enforced": false,
        "scope": {
          "user_handle": "*"
        },
        "usage_limit": 250000
      },
      "type": "quotas"
    }
  ]
}
EOF

## Set a limit and schedule a reduction

# Path parameters
export quota_namespace="ai_credits"

# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/usage/quotas/${quota_namespace}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": [
    {
      "attributes": {
        "enforced": true,
        "pending_usage_limit": 100000,
        "usage_limit": 600000
      },
      "type": "quotas"
    }
  ]
}
EOF
## Create or update quotas for the caller's organization.

# Path parameters
export quota_namespace="ai_credits"

# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/usage/quotas/${quota_namespace}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": [
    {
      "attributes": {
        "enforced": true,
        "scope": {
          "user_handle": "jane@example.com"
        },
        "usage_limit": 100000
      },
      "type": "quotas"
    },
    {
      "attributes": {
        "enforced": false,
        "scope": {
          "user_handle": "*"
        },
        "usage_limit": 250000
      },
      "type": "quotas"
    }
  ]
}
EOF

## Set a limit and schedule a reduction

# Path parameters
export quota_namespace="ai_credits"

# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/usage/quotas/${quota_namespace}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": [
    {
      "attributes": {
        "enforced": true,
        "pending_usage_limit": 100000,
        "usage_limit": 600000
      },
      "type": "quotas"
    }
  ]
}
EOF
## Create or update quotas for the caller's organization.

# Path parameters
export quota_namespace="ai_credits"

# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/usage/quotas/${quota_namespace}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": [
    {
      "attributes": {
        "enforced": true,
        "scope": {
          "user_handle": "jane@example.com"
        },
        "usage_limit": 100000
      },
      "type": "quotas"
    },
    {
      "attributes": {
        "enforced": false,
        "scope": {
          "user_handle": "*"
        },
        "usage_limit": 250000
      },
      "type": "quotas"
    }
  ]
}
EOF

## Set a limit and schedule a reduction

# Path parameters
export quota_namespace="ai_credits"

# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/usage/quotas/${quota_namespace}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": [
    {
      "attributes": {
        "enforced": true,
        "pending_usage_limit": 100000,
        "usage_limit": 600000
      },
      "type": "quotas"
    }
  ]
}
EOF