---
title: "Patch a global variable"
method: PATCH
path: "/api/v2/synthetics/variables/{variable_id}/jsonpatch"
tags: ["Synthetics"]
---

# Patch a global variable

`PATCH /api/v2/synthetics/variables/{variable_id}/jsonpatch`

## Request

- Base URL: `https://api.datadoghq.com`
- URL: `https://api.datadoghq.com/api/v2/synthetics/variables/{variable_id}/jsonpatch`
- Auth: API key in header `DD-API-KEY` and API key in header `DD-APPLICATION-KEY`

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"}`

## Path parameters

- `variable_id` string, required

## Request body

- GlobalVariableJsonPatchRequest: JSON Patch request for global variable.
  - `data` GlobalVariableJsonPatchRequestData, required: Data object for a JSON Patch request on a Synthetic global variable.
    - `attributes` GlobalVariableJsonPatchRequestDataAttributes: Attributes for a JSON Patch request on a Synthetic global variable.
      - `json_patch` JsonPatchOperation[]: JSON Patch operations following RFC 6902.
        - `op` 'add' | 'remove' | 'replace' | 'move' | 'copy' | 'test', required: The operation to perform.
        - `path` string, required: A JSON Pointer path (e.g., "/name", "/value/secure").
        - `value` unknown
    - `type` 'global_variables_json_patch': Global variable JSON Patch type.

## Response `200`

OK

- GlobalVariableResponse: Global variable response.
  - `data` GlobalVariableData: Synthetics global variable data. Wrapper around the global variable object.
    - `attributes` SyntheticsGlobalVariable: Synthetic global variable.
      - `attributes` SyntheticsGlobalVariableAttributes: Attributes of the global variable.
        - `restricted_roles` string[]: A list of role identifiers that can be pulled from the Roles API, for restricting read and write access. This field is deprecated. Use the restriction policies API to manage permissions.
      - `description` string, required: Description of the global variable.
      - `id` string: Unique identifier of the global variable.
      - `is_fido` boolean: Determines if the global variable is a FIDO variable.
      - `is_totp` boolean: Determines if the global variable is a TOTP/MFA variable.
      - `name` string, required: Name of the global variable. Unique across Synthetic global variables.
      - `parse_test_options` SyntheticsGlobalVariableParseTestOptions: Parser options to use for retrieving a Synthetic global variable from a Synthetic test. Used in conjunction with `parse_test_public_id`.
        - `field` string: When type is `http_header`, name of the header to use to extract the value.
        - `localVariableName` string: When type is `local_variable`, name of the local variable to use to extract the value.
        - `parser` SyntheticsVariableParser: Details of the parser to use for the global variable.
          - `type` 'raw' | 'json_path' | 'regex' | 'x_path', required: Type of parser for a Synthetic global variable from a synthetics test.
          - `value` string: Regex or JSON path used for the parser. Not used with type `raw`.
        - `type` 'http_body' | 'http_header' | 'http_status_code' | 'local_variable', required: Type of value to extract from a test for a Synthetic global variable.
      - `parse_test_public_id` string: A Synthetic test ID to use as a test to generate the variable value.
      - `tags` string[], required: Tags of the global variable.
      - `value` SyntheticsGlobalVariableValue, required: Value of the global variable.
        - `options` SyntheticsGlobalVariableOptions: Options for the Global Variable for MFA.
          - `totp_parameters` SyntheticsGlobalVariableTOTPParameters: Parameters for the TOTP/MFA variable
            - `digits` integer: Number of digits for the OTP code.
            - `refresh_interval` integer: Interval for which to refresh the token (in seconds).
        - `secure` boolean: Determines if the value of the variable is hidden.
        - `value` string: Value of the global variable. When reading a global variable, the value will not be present if the variable is hidden with the `secure` property.
    - `id` string: Global variable identifier.
    - `type` 'global_variables': Global variable type.

## Other responses

- `400`: Bad Request
- `404`: Not Found
- `429`: Too many requests

---

[API](https://skmtc.dev/datadog/apis/datadog-api-v2-collection.md) - [All operations](https://skmtc.dev/datadog/apis/datadog-api-v2-collection/llms.txt) - [OpenAPI document](https://skmtc.dev/datadog/apis/datadog-api-v2-collection/revisions/da68bf029e4c?raw)
