For AI agents: A markdown version of this page is available at https://dnd37xeb23o8n.cloudfront.net/stefon.simmons/docs-astro-web-10435/es/api/latest/synthetics/patch-a-global-variable.md. A documentation index is available at /llms.txt.
Language
Datadog site

Patch a global variable

PATCHhttps://api.datadoghq.com/api/v2/synthetics/variables/{variable_id}/jsonpatchhttps://api.us3.datadoghq.com/api/v2/synthetics/variables/{variable_id}/jsonpatchhttps://api.us5.datadoghq.com/api/v2/synthetics/variables/{variable_id}/jsonpatchhttps://api.datadoghq.eu/api/v2/synthetics/variables/{variable_id}/jsonpatchhttps://api.ap1.datadoghq.com/api/v2/synthetics/variables/{variable_id}/jsonpatchhttps://api.ap2.datadoghq.com/api/v2/synthetics/variables/{variable_id}/jsonpatchhttps://api.uk1.datadoghq.com/api/v2/synthetics/variables/{variable_id}/jsonpatchhttps://api.ddog-gov.com/api/v2/synthetics/variables/{variable_id}/jsonpatchhttps://api.us2.ddog-gov.com/api/v2/synthetics/variables/{variable_id}/jsonpatch

Descripción general

Patch a global variable using JSON Patch (RFC 6902). This endpoint allows partial updates to a global variable by specifying only the fields to modify.

Common operations include:

  • Replace field values: {"op": "replace", "path": "/name", "value": "new_name"}
  • Update nested values: {"op": "replace", "path": "/value/value", "value": "new_value"}
  • Add/update tags: {"op": "add", "path": "/tags/-", "value": "new_tag"}
  • Remove fields: {"op": "remove", "path": "/description"}

This endpoint requires the synthetics_global_variable_write permission.

Argumentos

Parámetros de ruta

Nombre
Type
Descripción
variable_id [required]
string

The ID of the global variable.

Solicitud

Body Data (required)

JSON Patch document with operations to apply.

Campo
Type
Descripción
data [required]
object

Data object for a JSON Patch request on a Synthetic global variable.

Respuesta

OK

Global variable response.

Campo
Type
Descripción
data
object

Synthetics global variable data. Wrapper around the global variable object.

Ejemplo de código

# Path parameters
export variable_id="CHANGE_ME"

# 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 PATCH "https://api.${DD_SITE}/api/v2/synthetics/variables/${variable_id}/jsonpatch" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "json_patch": [
        {
          "op": "add",
          "path": "/name"
        }
      ]
    },
    "type": "global_variables_json_patch"
  }
}
EOF
# Path parameters
export variable_id="CHANGE_ME"

# 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 PATCH "https://api.${DD_SITE}/api/v2/synthetics/variables/${variable_id}/jsonpatch" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "json_patch": [
        {
          "op": "add",
          "path": "/name"
        }
      ]
    },
    "type": "global_variables_json_patch"
  }
}
EOF
# Path parameters
export variable_id="CHANGE_ME"

# 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 PATCH "https://api.${DD_SITE}/api/v2/synthetics/variables/${variable_id}/jsonpatch" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "json_patch": [
        {
          "op": "add",
          "path": "/name"
        }
      ]
    },
    "type": "global_variables_json_patch"
  }
}
EOF
# Path parameters
export variable_id="CHANGE_ME"

# 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 PATCH "https://api.${DD_SITE}/api/v2/synthetics/variables/${variable_id}/jsonpatch" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "json_patch": [
        {
          "op": "add",
          "path": "/name"
        }
      ]
    },
    "type": "global_variables_json_patch"
  }
}
EOF
# Path parameters
export variable_id="CHANGE_ME"

# 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 PATCH "https://api.${DD_SITE}/api/v2/synthetics/variables/${variable_id}/jsonpatch" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "json_patch": [
        {
          "op": "add",
          "path": "/name"
        }
      ]
    },
    "type": "global_variables_json_patch"
  }
}
EOF
# Path parameters
export variable_id="CHANGE_ME"

# 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 PATCH "https://api.${DD_SITE}/api/v2/synthetics/variables/${variable_id}/jsonpatch" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "json_patch": [
        {
          "op": "add",
          "path": "/name"
        }
      ]
    },
    "type": "global_variables_json_patch"
  }
}
EOF
# Path parameters
export variable_id="CHANGE_ME"

# 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 PATCH "https://api.${DD_SITE}/api/v2/synthetics/variables/${variable_id}/jsonpatch" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "json_patch": [
        {
          "op": "add",
          "path": "/name"
        }
      ]
    },
    "type": "global_variables_json_patch"
  }
}
EOF
# Path parameters
export variable_id="CHANGE_ME"

# 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 PATCH "https://api.${DD_SITE}/api/v2/synthetics/variables/${variable_id}/jsonpatch" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "json_patch": [
        {
          "op": "add",
          "path": "/name"
        }
      ]
    },
    "type": "global_variables_json_patch"
  }
}
EOF
# Path parameters
export variable_id="CHANGE_ME"

# 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 PATCH "https://api.${DD_SITE}/api/v2/synthetics/variables/${variable_id}/jsonpatch" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "json_patch": [
        {
          "op": "add",
          "path": "/name"
        }
      ]
    },
    "type": "global_variables_json_patch"
  }
}
EOF