> Documentation index for AI agents: https://docs.pagerduty.com/llms.txt

# Update a Cache Variable for a Service Event Orchestration

`PUT https://api.pagerduty.com/event_orchestrations/services/{service_id}/cache_variables/{cache_variable_id}`

Update a Cache Variable for a Service Event Orchestration.

Cache Variables allow you to store event data on an Event Orchestration, which can then be used in Event Orchestration rules as part of conditions or actions.

For more information see the [API Concepts Document](https://docs.pagerduty.com/developer/api-concepts#event-orchestrations)

Scoped OAuth requires: `services.write`

## Authorization

- **api_key** (apiKey) — `Authorization` header. The API Key with format `Token token=<API_KEY>`

## Path parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `service_id` | string | yes | The service ID. |
| `cache_variable_id` | string | yes | The ID of a Cache Variable. |

## Header parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `Accept` | string | yes | The `Accept` header is used as a versioning header. Default: `application/vnd.pagerduty+json;version=2`. |

## Request body (`application/json`)

| Field | Type | Required | Description |
|---|---|---|---|
| `cache_variable` | one of: object \| object \| object | yes |  |
| `cache_variable.id` | string |  | (Recent Value) Read-only. |
| `cache_variable.name` | string | yes | (Recent Value) The name of the Cache Variable. |
| `cache_variable.disabled` | boolean |  | (Recent Value) Indicates whether the Cache Variable is disabled and would therefore not be evaluated. |
| `cache_variable.created_at` | string (date-time) |  | (Recent Value) The date/time the object was created. Read-only. |
| `cache_variable.created_by` | object |  | (Recent Value) Reference to the user that created the object. Read-only. |
| `cache_variable.created_by.id` | string |  | Read-only. |
| `cache_variable.created_by.type` | string |  | A string that determines the schema of the object. This must be the standard name for the entity, suffixed by `_reference` if the object is a reference. Read-only. |
| `cache_variable.created_by.self` | string (url) |  | The API show URL at which the object is accessible. Read-only. |
| `cache_variable.updated_at` | string (date-time) |  | (Recent Value) The date/time the object was last updated. Read-only. |
| `cache_variable.updated_by` | object |  | (Recent Value) Reference to the user that last updated the object. Read-only. |
| `cache_variable.updated_by.id` | string |  | Read-only. |
| `cache_variable.updated_by.type` | string |  | A string that determines the schema of the object. This must be the standard name for the entity, suffixed by `_reference` if the object is a reference. Read-only. |
| `cache_variable.updated_by.self` | string (url) |  | The API show URL at which the object is accessible. Read-only. |
| `cache_variable.configuration` | object | yes | (Recent Value) |
| `cache_variable.configuration.type` | string |  | Cache Variable will be set to the most recent value seen, based on the source event field and the extraction regex specified. One of: `recent_value`. |
| `cache_variable.configuration.source` | string |  | The path to the event field where the regex will be applied to extract a value. |
| `cache_variable.configuration.regex` | string |  | A RE2 regular expression. If it contains one or more capture groups, their values will be extracted and appended together. If it contains no capture groups, the whole match is used. |
| `cache_variable.conditions` | array of object |  | (Recent Value) Each of these conditions is evaluated to check if an event matches this rule. The rule is considered a match if **any** of these conditions match. |
| `cache_variable.conditions[].expression` | string |  | A PCL condition string. Note: The `trigger_count` and `resetting_trigger_count` operators are unsupported for Cache Variables. |
| `cache_variable.id` | string |  | (Trigger Event Count) Read-only. |
| `cache_variable.name` | string | yes | (Trigger Event Count) The name of the Cache Variable. |
| `cache_variable.disabled` | boolean |  | (Trigger Event Count) Indicates whether the Cache Variable is disabled and would therefore not be evaluated. |
| `cache_variable.created_at` | string (date-time) |  | (Trigger Event Count) The date/time the object was created. Read-only. |
| `cache_variable.created_by` | object |  | (Trigger Event Count) Reference to the user that created the object. Read-only. |
| `cache_variable.created_by.id` | string |  | Read-only. |
| `cache_variable.created_by.type` | string |  | A string that determines the schema of the object. This must be the standard name for the entity, suffixed by `_reference` if the object is a reference. Read-only. |
| `cache_variable.created_by.self` | string (url) |  | The API show URL at which the object is accessible. Read-only. |
| `cache_variable.updated_at` | string (date-time) |  | (Trigger Event Count) The date/time the object was last updated. Read-only. |
| `cache_variable.updated_by` | object |  | (Trigger Event Count) Reference to the user that last updated the object. Read-only. |
| `cache_variable.updated_by.id` | string |  | Read-only. |
| `cache_variable.updated_by.type` | string |  | A string that determines the schema of the object. This must be the standard name for the entity, suffixed by `_reference` if the object is a reference. Read-only. |
| `cache_variable.updated_by.self` | string (url) |  | The API show URL at which the object is accessible. Read-only. |
| `cache_variable.configuration` | object | yes | (Trigger Event Count) |
| `cache_variable.configuration.type` | string |  | Cache Variable will be set to the number of trigger events that have been seen within the TTL range. One of: `trigger_event_count`. |
| `cache_variable.configuration.ttl_seconds` | integer |  | The time to live (in seconds) for how long to count trigger events before resetting back to 0. |
| `cache_variable.conditions` | array of object |  | (Trigger Event Count) Each of these conditions is evaluated to check if an event matches this rule. The rule is considered a match if **any** of these conditions match. |
| `cache_variable.conditions[].expression` | string |  | A PCL condition string. Note: The `trigger_count` and `resetting_trigger_count` operators are unsupported for Cache Variables. |
| `cache_variable.id` | string |  | (External Data) Read-only. |
| `cache_variable.name` | string | yes | (External Data) The name of the Cache Variable. |
| `cache_variable.disabled` | boolean |  | (External Data) Indicates whether the Cache Variable is disabled and would therefore not be evaluated. |
| `cache_variable.created_at` | string (date-time) |  | (External Data) The date/time the object was created. Read-only. |
| `cache_variable.created_by` | object |  | (External Data) Reference to the user that created the object. Read-only. |
| `cache_variable.created_by.id` | string |  | Read-only. |
| `cache_variable.created_by.type` | string |  | A string that determines the schema of the object. This must be the standard name for the entity, suffixed by `_reference` if the object is a reference. Read-only. |
| `cache_variable.created_by.self` | string (url) |  | The API show URL at which the object is accessible. Read-only. |
| `cache_variable.updated_at` | string (date-time) |  | (External Data) The date/time the object was last updated. Read-only. |
| `cache_variable.updated_by` | object |  | (External Data) Reference to the user that last updated the object. Read-only. |
| `cache_variable.updated_by.id` | string |  | Read-only. |
| `cache_variable.updated_by.type` | string |  | A string that determines the schema of the object. This must be the standard name for the entity, suffixed by `_reference` if the object is a reference. Read-only. |
| `cache_variable.updated_by.self` | string (url) |  | The API show URL at which the object is accessible. Read-only. |
| `cache_variable.configuration` | object | yes | (External Data) |
| `cache_variable.configuration.type` | string |  | The Cache Variable value will be set via a PUT API request to a dedicated endpoint that is made available after the creation of the cache variable. One of: `external_data`. |
| `cache_variable.configuration.data_type` | string |  | The type of data that will eventually be set for this cache variable via an API request. One of: `string`, `number`, `boolean`. |
| `cache_variable.configuration.ttl_seconds` | integer |  | The time to live (in seconds) for how long data sent to endpoint is persisted. After the TTL passes the data is deleted. |
| `cache_variable.data_endpoint` | string (uri) |  | (External Data) The endpoint that can be used to manage the data for an `external_data` type cache variable. Read-only. |

Example: Request Example: Update conditions (trigger_event_count, recent_value)

```json
{
  "cache_variable": {
    "name": "example_1",
    "conditions": [
      {
        "expression": "event.summary matches 'exception'"
      },
      {
        "expression": "event.summary matches 'error'"
      }
    ]
  }
}
```

Example: Request Example: Update configuration

```json
{
  "cache_variable": {
    "name": "example_1",
    "configuration": {
      "type": "trigger_event_count",
      "ttl_seconds": 2
    }
  }
}
```

Example: Request Example: Update disabled state

```json
{
  "cache_variable": {
    "name": "example_1",
    "disabled": true
  }
}
```

## Response 200

The updated Cache Variable for this Event Orchestration.

### `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `cache_variable` | one of: object \| object \| object |  |  |
| `cache_variable.id` | string |  | (Recent Value) Read-only. |
| `cache_variable.name` | string | yes | (Recent Value) The name of the Cache Variable. |
| `cache_variable.disabled` | boolean |  | (Recent Value) Indicates whether the Cache Variable is disabled and would therefore not be evaluated. |
| `cache_variable.created_at` | string (date-time) |  | (Recent Value) The date/time the object was created. Read-only. |
| `cache_variable.created_by` | object |  | (Recent Value) Reference to the user that created the object. Read-only. |
| `cache_variable.created_by.id` | string |  | Read-only. |
| `cache_variable.created_by.type` | string |  | A string that determines the schema of the object. This must be the standard name for the entity, suffixed by `_reference` if the object is a reference. Read-only. |
| `cache_variable.created_by.self` | string (url) |  | The API show URL at which the object is accessible. Read-only. |
| `cache_variable.updated_at` | string (date-time) |  | (Recent Value) The date/time the object was last updated. Read-only. |
| `cache_variable.updated_by` | object |  | (Recent Value) Reference to the user that last updated the object. Read-only. |
| `cache_variable.updated_by.id` | string |  | Read-only. |
| `cache_variable.updated_by.type` | string |  | A string that determines the schema of the object. This must be the standard name for the entity, suffixed by `_reference` if the object is a reference. Read-only. |
| `cache_variable.updated_by.self` | string (url) |  | The API show URL at which the object is accessible. Read-only. |
| `cache_variable.configuration` | object | yes | (Recent Value) |
| `cache_variable.configuration.type` | string |  | Cache Variable will be set to the most recent value seen, based on the source event field and the extraction regex specified. One of: `recent_value`. |
| `cache_variable.configuration.source` | string |  | The path to the event field where the regex will be applied to extract a value. |
| `cache_variable.configuration.regex` | string |  | A RE2 regular expression. If it contains one or more capture groups, their values will be extracted and appended together. If it contains no capture groups, the whole match is used. |
| `cache_variable.conditions` | array of object |  | (Recent Value) Each of these conditions is evaluated to check if an event matches this rule. The rule is considered a match if **any** of these conditions match. |
| `cache_variable.conditions[].expression` | string |  | A PCL condition string. Note: The `trigger_count` and `resetting_trigger_count` operators are unsupported for Cache Variables. |
| `cache_variable.id` | string |  | (Trigger Event Count) Read-only. |
| `cache_variable.name` | string | yes | (Trigger Event Count) The name of the Cache Variable. |
| `cache_variable.disabled` | boolean |  | (Trigger Event Count) Indicates whether the Cache Variable is disabled and would therefore not be evaluated. |
| `cache_variable.created_at` | string (date-time) |  | (Trigger Event Count) The date/time the object was created. Read-only. |
| `cache_variable.created_by` | object |  | (Trigger Event Count) Reference to the user that created the object. Read-only. |
| `cache_variable.created_by.id` | string |  | Read-only. |
| `cache_variable.created_by.type` | string |  | A string that determines the schema of the object. This must be the standard name for the entity, suffixed by `_reference` if the object is a reference. Read-only. |
| `cache_variable.created_by.self` | string (url) |  | The API show URL at which the object is accessible. Read-only. |
| `cache_variable.updated_at` | string (date-time) |  | (Trigger Event Count) The date/time the object was last updated. Read-only. |
| `cache_variable.updated_by` | object |  | (Trigger Event Count) Reference to the user that last updated the object. Read-only. |
| `cache_variable.updated_by.id` | string |  | Read-only. |
| `cache_variable.updated_by.type` | string |  | A string that determines the schema of the object. This must be the standard name for the entity, suffixed by `_reference` if the object is a reference. Read-only. |
| `cache_variable.updated_by.self` | string (url) |  | The API show URL at which the object is accessible. Read-only. |
| `cache_variable.configuration` | object | yes | (Trigger Event Count) |
| `cache_variable.configuration.type` | string |  | Cache Variable will be set to the number of trigger events that have been seen within the TTL range. One of: `trigger_event_count`. |
| `cache_variable.configuration.ttl_seconds` | integer |  | The time to live (in seconds) for how long to count trigger events before resetting back to 0. |
| `cache_variable.conditions` | array of object |  | (Trigger Event Count) Each of these conditions is evaluated to check if an event matches this rule. The rule is considered a match if **any** of these conditions match. |
| `cache_variable.conditions[].expression` | string |  | A PCL condition string. Note: The `trigger_count` and `resetting_trigger_count` operators are unsupported for Cache Variables. |
| `cache_variable.id` | string |  | (External Data) Read-only. |
| `cache_variable.name` | string | yes | (External Data) The name of the Cache Variable. |
| `cache_variable.disabled` | boolean |  | (External Data) Indicates whether the Cache Variable is disabled and would therefore not be evaluated. |
| `cache_variable.created_at` | string (date-time) |  | (External Data) The date/time the object was created. Read-only. |
| `cache_variable.created_by` | object |  | (External Data) Reference to the user that created the object. Read-only. |
| `cache_variable.created_by.id` | string |  | Read-only. |
| `cache_variable.created_by.type` | string |  | A string that determines the schema of the object. This must be the standard name for the entity, suffixed by `_reference` if the object is a reference. Read-only. |
| `cache_variable.created_by.self` | string (url) |  | The API show URL at which the object is accessible. Read-only. |
| `cache_variable.updated_at` | string (date-time) |  | (External Data) The date/time the object was last updated. Read-only. |
| `cache_variable.updated_by` | object |  | (External Data) Reference to the user that last updated the object. Read-only. |
| `cache_variable.updated_by.id` | string |  | Read-only. |
| `cache_variable.updated_by.type` | string |  | A string that determines the schema of the object. This must be the standard name for the entity, suffixed by `_reference` if the object is a reference. Read-only. |
| `cache_variable.updated_by.self` | string (url) |  | The API show URL at which the object is accessible. Read-only. |
| `cache_variable.configuration` | object | yes | (External Data) |
| `cache_variable.configuration.type` | string |  | The Cache Variable value will be set via a PUT API request to a dedicated endpoint that is made available after the creation of the cache variable. One of: `external_data`. |
| `cache_variable.configuration.data_type` | string |  | The type of data that will eventually be set for this cache variable via an API request. One of: `string`, `number`, `boolean`. |
| `cache_variable.configuration.ttl_seconds` | integer |  | The time to live (in seconds) for how long data sent to endpoint is persisted. After the TTL passes the data is deleted. |
| `cache_variable.data_endpoint` | string (uri) |  | (External Data) The endpoint that can be used to manage the data for an `external_data` type cache variable. Read-only. |

Example: Response Example: Recent value cache variable

```json
{
  "cache_variable": [
    {
      "id": "66bb56c3-2a17-44f3-9193-06b166d759ad",
      "name": "example_1",
      "conditions": [
        {
          "expression": "event.summary matches 'exception'"
        },
        {
          "expression": "event.summary matches 'error'"
        }
      ],
      "configuration": {
        "type": "recent_value",
        "source": "event.summary",
        "regex": ".*"
      },
      "created_at": "2021-11-18T16:42:01Z",
      "created_by": {
        "id": "P8B9WR8",
        "self": "https://api.pagerduty.com/users/P8B9WR8",
        "type": "user_reference"
      },
      "updated_at": "2021-11-18T16:42:01Z",
      "updated_by": {
        "id": "P8B9WR8",
        "self": "https://api.pagerduty.com/users/P8B9WR8",
        "type": "user_reference"
      }
    }
  ]
}
```

Example: Response Example: Trigger event count cache variable

```json
{
  "cache_variable": [
    {
      "id": "66bb56c3-2a17-44f3-9193-06b166d759ad",
      "name": "example_1",
      "conditions": [
        {
          "expression": "not event.custom_details.errors exists"
        }
      ],
      "configuration": {
        "type": "trigger_event_count",
        "ttl_seconds": 2
      },
      "created_at": "2021-11-18T16:42:01Z",
      "created_by": {
        "id": "P8B9WR8",
        "self": "https://api.pagerduty.com/users/P8B9WR8",
        "type": "user_reference"
      },
      "updated_at": "2021-11-18T16:42:01Z",
      "updated_by": {
        "id": "P8B9WR8",
        "self": "https://api.pagerduty.com/users/P8B9WR8",
        "type": "user_reference"
      }
    }
  ]
}
```

Example: Response Example: Disabled cache variable

```json
{
  "cache_variable": [
    {
      "id": "66bb56c3-2a17-44f3-9193-06b166d759ad",
      "name": "example_1",
      "conditions": [
        {
          "expression": "not event.custom_details.errors exists"
        }
      ],
      "configuration": {
        "type": "recent_value",
        "source": "event.summary",
        "regex": ".*"
      },
      "disabled": true,
      "created_at": "2021-11-18T16:42:01Z",
      "created_by": {
        "id": "P8B9WR8",
        "self": "https://api.pagerduty.com/users/P8B9WR8",
        "type": "user_reference"
      },
      "updated_at": "2021-11-18T16:42:01Z",
      "updated_by": {
        "id": "P8B9WR8",
        "self": "https://api.pagerduty.com/users/P8B9WR8",
        "type": "user_reference"
      }
    }
  ]
}
```

## Response 400

Caller provided invalid arguments. Please review the response for error details. Retrying with the same arguments will *not* work.

### `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | object |  |  |
| `error.code` | integer |  | Read-only. |
| `error.message` | string |  | Error message string. Read-only. |
| `error.errors` | array of string |  | Read-only. |

## Response 401

Caller did not supply credentials or did not provide the correct credentials.
If you are using an API key, it may be invalid or your Authorization header may be malformed.

### `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | object |  |  |
| `error.code` | integer |  | Read-only. |
| `error.message` | string |  | Error message string. Read-only. |
| `error.errors` | array of string |  | Read-only. |

## Response 403

Caller is not authorized to view the requested resource.
While your authentication is valid, the authenticated user or token does not have permission to perform this action.

### `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | object |  |  |
| `error.code` | integer |  | Read-only. |
| `error.message` | string |  | Error message string. Read-only. |
| `error.errors` | array of string |  | Read-only. |

## Response 404

The requested resource was not found.

### `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | object |  |  |
| `error.code` | integer |  | Read-only. |
| `error.message` | string |  | Error message string. Read-only. |
| `error.errors` | array of string |  | Read-only. |

## Response 405

The request was received and recognized by the server, but its HTTP method was rejected for the requested resource.

### `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | object |  |  |
| `error.code` | integer |  | Read-only. |
| `error.message` | string |  | Error message string. Read-only. |
| `error.errors` | array of string |  | Read-only. |

## Developer Agreement

Your access to and use of the PagerDuty Developer Services is governed by the [PagerDuty Developer Agreement](https://docs.pagerduty.com/developer/pagerduty-developer-agreement).
