Create or update usage quotas
https://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 thedata[].attributes.handlefield by the Users API. "*", the default quota applied to users without a specific quota."*agents*", the quota shared by all autonomous agents.
- A user's handle, such as
- Validation: A specific handle must identify an existing user in the caller's organization when
include_descendantsis false. Wheninclude_descendantsis 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 thedata[].idfield by the Roles API. - Validation: The role must exist in the caller's organization. Role UUIDs are unique, so
include_descendantshas no effect on arole_uuidscope: 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[].idfield by the Teams API. - Availability: Quotas on
team_idare in private preview. Contact your Datadog account team to request access.
OAuth apps require the billing_edit authorization scope to access this endpoint.
Arguments
Path Parameters
quota_namespace [required]The product-specific namespace whose usage quotas are being managed.
Query Strings
include_descendantsWhether 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.
falsecreate_onlyCreate 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.
falseRequest
Body Data (required)
The usage quotas to create or update.
data [required]A bulk list of usage quota resources to create or update by scope.
attributes [required]Attributes for creating or updating a usage quota by scope. Each item must provide usage_limit, pending_usage_limit, or both. Providing only pending_usage_limit updates an existing organization-wide quota, never creates one, requires enforced to be omitted, and fails if the quota does not exist.
enforcedWhether to actively block usage above usage_limit instead of only tracking or alerting on it. Required when usage_limit is provided and must be omitted when only pending_usage_limit is provided.
pending_usage_limitThe non-negative, whole-number limit to schedule for the organization-wide quota in the usage units defined by the quota namespace. It is not checked against current usage. Each write schedules the value for 00:00 UTC on the first day of the next calendar month and replaces any previously scheduled change; the server computes pending_effective_from. Omit this field to leave any scheduled change unchanged, including when raising usage_limit. Cancel a scheduled change only by deleting the quota's /pending sub-resource.
scopeA namespace-specific key and value identifying what the quota applies to within an organization. See the endpoint description for the supported scope keys, values, and validation rules.
<any-key>usage_limitThe non-negative, whole-number quota limit to set in the usage units defined by the quota namespace. For an organization-wide quota (scope omitted), the limit must be greater than usage already recorded in the current period. When this field is provided, enforced is required.
type [required]The JSON:API resource type for a usage quota.
quotas{
"data": [
{
"attributes": {
"enforced": true,
"pending_usage_limit": 50000,
"scope": {
"<any-key>": "jane@example.com"
},
"usage_limit": 100000
},
"type": "quotas"
}
]
}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.
data [required]The results of writing each usage quota in a bulk create-or-update request, in the same order as the request.
attributes [required]Attributes of a usage quota bulk write result. On success, quota fields are present as applicable, and pending fields are present only when a change is scheduled. On failure, only error is present and the other fields are omitted.
enforcedWhether usage above the limit is actively blocked instead of only tracked or alerted on. Omitted if this item failed to write.
errorAn error message describing why this item failed to write. Omitted if this item was written successfully.
org_public_idThe public ID of the organization that owns the quota. Omitted if this item failed to write.
pending_effective_fromThe future UTC month when the scheduled limit takes effect, formatted as YYYY-MM, starting at 00:00 UTC on its first day. Present only together with pending_usage_limit and omitted when no change is scheduled or this item failed to write.
pending_usage_limitThe usage limit scheduled for the organization-wide quota in the usage units defined by the quota namespace. A value of 0 is valid. At the start of the effective month, this value becomes usage_limit and both pending fields are omitted. Omitted when no change is scheduled or this item failed to write.
scopeA namespace-specific key and value identifying what the quota applies to within an organization. The object contains exactly one entry. A user_handle value of "*" identifies the default quota applied to users without a specific quota. This field is omitted for an organization-wide quota.
<any-key>usage_limitThe quota limit in the usage units defined by the quota namespace. May be fractional for quotas configured before public writes required whole units. Omitted if this item failed to write.
id [required]An opaque usage quota identifier. Clients must pass this value back verbatim in update and delete requests and must not infer any structure from it.
type [required]The JSON:API resource type for a usage quota.
quotas{
"data": [
{
"attributes": {
"enforced": true,
"error": "usage_limit is out of range",
"org_public_id": "abcdef12345",
"pending_effective_from": "2026-11",
"pending_usage_limit": 50000,
"scope": {
"<any-key>": "jane@example.com"
},
"usage_limit": 100000
},
"id": "MTIzNB9haV9jcmVkaXRzH3VzZXJfaGFuZGxlOl9fQUxMX18",
"type": "quotas"
}
]
}Bad Request. Returned when create_only=true is combined with multiple items, pending_usage_limit, or include_descendants=true, or when an item sets pending_usage_limit on a scoped quota, provides enforced without usage_limit, or provides neither limit. A pending-only item for a nonexistent quota reports an error in the item's error field. If only the caller's organization is targeted, this failure returns 400.
API error response.
errors [required]A list of errors.
codeAn application-specific error code.
detailA human-readable explanation specific to this occurrence of the error.
metaNon-standard meta-information about the error
sourceReferences to the source of the error.
headerA string indicating the name of a single request header which caused the error.
parameterA string indicating which URI query parameter caused the error.
pointerA JSON pointer to the value in the request document that caused the error.
statusStatus code of the response.
titleShort human-readable summary of the error.
{
"errors": [
{
"code": "invalid_request",
"detail": "Missing required attribute in body",
"meta": {},
"source": {
"header": "Authorization",
"parameter": "limit",
"pointer": "/data/attributes/title"
},
"status": "400",
"title": "Bad Request"
}
]
}Forbidden
API error response.
errors [required]A list of errors.
codeAn application-specific error code.
detailA human-readable explanation specific to this occurrence of the error.
metaNon-standard meta-information about the error
sourceReferences to the source of the error.
headerA string indicating the name of a single request header which caused the error.
parameterA string indicating which URI query parameter caused the error.
pointerA JSON pointer to the value in the request document that caused the error.
statusStatus code of the response.
titleShort human-readable summary of the error.
{
"errors": [
{
"code": "invalid_request",
"detail": "Missing required attribute in body",
"meta": {},
"source": {
"header": "Authorization",
"parameter": "limit",
"pointer": "/data/attributes/title"
},
"status": "400",
"title": "Bad Request"
}
]
}Conflict. With create_only=true, a quota already exists for this namespace and scope in the caller's organization. The existing quota is unchanged. The error's meta contains error_code set to already_exists and quota_id set to the existing quota's opaque ID. Import the existing quota before managing it with Terraform.
API error response.
errors [required]A list of errors.
codeAn application-specific error code.
detailA human-readable explanation specific to this occurrence of the error.
metaNon-standard meta-information about the error
sourceReferences to the source of the error.
headerA string indicating the name of a single request header which caused the error.
parameterA string indicating which URI query parameter caused the error.
pointerA JSON pointer to the value in the request document that caused the error.
statusStatus code of the response.
titleShort human-readable summary of the error.
{
"errors": [
{
"code": "invalid_request",
"detail": "Missing required attribute in body",
"meta": {},
"source": {
"header": "Authorization",
"parameter": "limit",
"pointer": "/data/attributes/title"
},
"status": "400",
"title": "Bad Request"
}
]
}Too many requests
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Internal Server Error. Every item in the batch failed to write.
API error response.
errors [required]A list of errors.
codeAn application-specific error code.
detailA human-readable explanation specific to this occurrence of the error.
metaNon-standard meta-information about the error
sourceReferences to the source of the error.
headerA string indicating the name of a single request header which caused the error.
parameterA string indicating which URI query parameter caused the error.
pointerA JSON pointer to the value in the request document that caused the error.
statusStatus code of the response.
titleShort human-readable summary of the error.
{
"errors": [
{
"code": "invalid_request",
"detail": "Missing required attribute in body",
"meta": {},
"source": {
"header": "Authorization",
"parameter": "limit",
"pointer": "/data/attributes/title"
},
"status": "400",
"title": "Bad Request"
}
]
}Code Example
## 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// Create or update usage quotas returns "OK. The response includes each item's result; see each item's `error` attribute
// for any that failed to write." response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)
func main() {
body := datadogV2.UsageQuotasCreateRequest{
Data: []datadogV2.UsageQuotaCreateData{
{
Attributes: datadogV2.UsageQuotaCreateAttributes{
Enforced: true,
Scope: map[string]string{
"user_handle": "jane@example.com",
},
UsageLimit: 100000,
},
Type: datadogV2.USAGEQUOTATYPE_QUOTAS,
},
},
}
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
configuration.SetUnstableOperationEnabled("v2.CreateQuotas", true)
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewUsageMeteringApi(apiClient)
resp, r, err := api.CreateQuotas(ctx, "ai_credits", body, *datadogV2.NewCreateQuotasOptionalParameters())
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `UsageMeteringApi.CreateQuotas`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `UsageMeteringApi.CreateQuotas`:\n%s\n", responseContent)
}
Instructions
First install the library and its dependencies and then save the example to main.go and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"// Create or update usage quotas returns "OK. The response includes each item's result; see each
// item's `error` attribute
// for any that failed to write." response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.UsageMeteringApi;
import com.datadog.api.client.v2.model.UsageQuotaCreateAttributes;
import com.datadog.api.client.v2.model.UsageQuotaCreateData;
import com.datadog.api.client.v2.model.UsageQuotaType;
import com.datadog.api.client.v2.model.UsageQuotasBulkResponse;
import com.datadog.api.client.v2.model.UsageQuotasCreateRequest;
import java.util.Collections;
import java.util.Map;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
defaultClient.setUnstableOperationEnabled("v2.createQuotas", true);
UsageMeteringApi apiInstance = new UsageMeteringApi(defaultClient);
UsageQuotasCreateRequest body =
new UsageQuotasCreateRequest()
.data(
Collections.singletonList(
new UsageQuotaCreateData()
.attributes(
new UsageQuotaCreateAttributes()
.enforced(true)
.scope(Map.ofEntries(Map.entry("user_handle", "jane@example.com")))
.usageLimit(100000L))
.type(UsageQuotaType.QUOTAS)));
try {
UsageQuotasBulkResponse result = apiInstance.createQuotas("ai_credits", body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling UsageMeteringApi#createQuotas");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Instructions
First install the library and its dependencies and then save the example to Example.java and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java""""
Create or update usage quotas returns "OK. The response includes each item's result; see each item's `error` attribute
for any that failed to write." response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.usage_metering_api import UsageMeteringApi
from datadog_api_client.v2.model.usage_quota_create_attributes import UsageQuotaCreateAttributes
from datadog_api_client.v2.model.usage_quota_create_data import UsageQuotaCreateData
from datadog_api_client.v2.model.usage_quota_request_scope import UsageQuotaRequestScope
from datadog_api_client.v2.model.usage_quota_type import UsageQuotaType
from datadog_api_client.v2.model.usage_quotas_create_request import UsageQuotasCreateRequest
body = UsageQuotasCreateRequest(
data=[
UsageQuotaCreateData(
attributes=UsageQuotaCreateAttributes(
enforced=True,
scope=UsageQuotaRequestScope(
user_handle="jane@example.com",
),
usage_limit=100000,
),
type=UsageQuotaType.QUOTAS,
),
],
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
configuration.unstable_operations["create_quotas"] = True
with ApiClient(configuration) as api_client:
api_instance = UsageMeteringApi(api_client)
response = api_instance.create_quotas(quota_namespace="ai_credits", body=body)
print(response)
Instructions
First install the library and its dependencies and then save the example to example.py and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"# Create or update usage quotas returns "OK. The response includes each item's result; see each item's `error` attribute
# for any that failed to write." response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
config.unstable_operations["v2.create_quotas".to_sym] = true
end
api_instance = DatadogAPIClient::V2::UsageMeteringAPI.new
body = DatadogAPIClient::V2::UsageQuotasCreateRequest.new({
data: [
DatadogAPIClient::V2::UsageQuotaCreateData.new({
attributes: DatadogAPIClient::V2::UsageQuotaCreateAttributes.new({
enforced: true,
scope: {
user_handle: "jane@example.com",
},
usage_limit: 100000,
}),
type: DatadogAPIClient::V2::UsageQuotaType::QUOTAS,
}),
],
})
p api_instance.create_quotas("ai_credits", body)
Instructions
First install the library and its dependencies and then save the example to example.rb and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" ruby "example.rb"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" ruby "example.rb"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" ruby "example.rb"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" ruby "example.rb"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" ruby "example.rb"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" ruby "example.rb"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" ruby "example.rb"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" ruby "example.rb"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" ruby "example.rb"// Create or update usage quotas returns "OK. The response includes each item's
// result; see each item's `error` attribute for any that failed to write."
// response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_usage_metering::CreateQuotasOptionalParams;
use datadog_api_client::datadogV2::api_usage_metering::UsageMeteringAPI;
use datadog_api_client::datadogV2::model::UsageQuotaCreateAttributes;
use datadog_api_client::datadogV2::model::UsageQuotaCreateData;
use datadog_api_client::datadogV2::model::UsageQuotaType;
use datadog_api_client::datadogV2::model::UsageQuotasCreateRequest;
use std::collections::BTreeMap;
#[tokio::main]
async fn main() {
let body = UsageQuotasCreateRequest::new(vec![UsageQuotaCreateData::new(
UsageQuotaCreateAttributes::new(true, 100000).scope(BTreeMap::from([(
"user_handle".to_string(),
"jane@example.com".to_string(),
)])),
UsageQuotaType::QUOTAS,
)]);
let mut configuration = datadog::Configuration::new();
configuration.set_unstable_operation_enabled("v2.create_quotas", true);
let api = UsageMeteringAPI::with_config(configuration);
let resp = api
.create_quotas(
"ai_credits".to_string(),
body,
CreateQuotasOptionalParams::default(),
)
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
Instructions
First install the library and its dependencies and then save the example to src/main.rs and run following commands:
DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run/**
* Create or update usage quotas returns "OK. The response includes each item's result; see each item's `error` attribute
* for any that failed to write." response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration({
authMethods: {
AuthZ: {
accessToken: process.env.DD_BEARER_TOKEN as string,
},
},
});
configuration.unstableOperations["v2.createQuotas"] = true;
const apiInstance = new v2.UsageMeteringApi(configuration);
const params: v2.UsageMeteringApiCreateQuotasRequest = {
body: {
data: [
{
attributes: {
enforced: true,
scope: {
user_handle: "jane@example.com",
},
usageLimit: 100000,
},
type: "quotas",
},
],
},
quotaNamespace: "ai_credits",
};
apiInstance
.createQuotas(params)
.then((data: v2.UsageQuotasBulkResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
Instructions
First install the library and its dependencies and then save the example to example.ts and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" npx tsx "example.ts"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" npx tsx "example.ts"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" npx tsx "example.ts"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" npx tsx "example.ts"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" npx tsx "example.ts"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" npx tsx "example.ts"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" npx tsx "example.ts"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" npx tsx "example.ts"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" npx tsx "example.ts"