---
title: Update a DEM journey variant
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: Docs > API Reference > DEM
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# Update a DEM journey variant{% #update-a-dem-journey-variant %}
Copy pageCopied
{% tab title="v2" %}

| Datadog site      | API endpoint                                                                |
| ----------------- | --------------------------------------------------------------------------- |
| ap1.datadoghq.com | PUT https://api.ap1.datadoghq.com/api/v2/dem/journeys/variants/{variant_id} |
| ap2.datadoghq.com | PUT https://api.ap2.datadoghq.com/api/v2/dem/journeys/variants/{variant_id} |
| app.datadoghq.eu  | PUT https://api.datadoghq.eu/api/v2/dem/journeys/variants/{variant_id}      |
| app.ddog-gov.com  | PUT https://api.ddog-gov.com/api/v2/dem/journeys/variants/{variant_id}      |
| us2.ddog-gov.com  | PUT https://api.us2.ddog-gov.com/api/v2/dem/journeys/variants/{variant_id}  |
| uk1.datadoghq.com | PUT https://api.uk1.datadoghq.com/api/v2/dem/journeys/variants/{variant_id} |
| app.datadoghq.com | PUT https://api.datadoghq.com/api/v2/dem/journeys/variants/{variant_id}     |
| us3.datadoghq.com | PUT https://api.us3.datadoghq.com/api/v2/dem/journeys/variants/{variant_id} |
| us5.datadoghq.com | PUT https://api.us5.datadoghq.com/api/v2/dem/journeys/variants/{variant_id} |

### Overview

Update an existing variant of a DEM journey. This endpoint requires the `synthetics_write` permission.

### Arguments

#### Path Parameters

| Name                         | Type   | Description                                     |
| ---------------------------- | ------ | ----------------------------------------------- |
| variant_id [*required*] | string | The unique identifier of the variant to update. |

### Request

#### Body Data (required)



{% tab title="Model" %}

| Parent field | Field                        | Type     | Description                                                                   |
| ------------ | ---------------------------- | -------- | ----------------------------------------------------------------------------- |
|              | data [*required*]       | object   | Data object for a DEM journey variant request.                                |
| data         | attributes [*required*] | object   | Attributes of a DEM journey variant.                                          |
| attributes   | filter                       | string   | An optional RUM query filter to scope this variant.                           |
| attributes   | name [*required*]       | string   | The name of the variant.                                                      |
| attributes   | rum_steps [*required*]  | [object] | List of RUM journey steps.                                                    |
| rum_steps    | nodes [*required*]      | [object] | List of RUM nodes within a journey step.                                      |
| nodes        | app_id                       | string   | The application ID associated with this node.                                 |
| nodes        | id                           | string   | The ID of the RUM node element.                                               |
| nodes        | query [*required*]      | string   | The RUM query for matching this node.                                         |
| rum_steps    | type [*required*]       | enum     | The type of a RUM journey step. Allowed enum values: `start,stop,step`        |
| data         | type [*required*]       | enum     | The type identifier for DEM journey variants. Allowed enum values: `variants` |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "filter": "device.type:mobile",
      "name": "Mobile checkout",
      "rum_steps": [
        {
          "nodes": [
            {
              "app_id": "app-xyz789",
              "id": "element-id-123",
              "query": "action.name:'checkout'"
            }
          ],
          "type": "start"
        }
      ]
    },
    "type": "variants"
  }
}
```

{% /tab %}

### Response

{% tab title="200" %}
OK
{% tab title="Model" %}
Response containing a DEM journey variant.

| Parent field | Field                        | Type     | Description                                                                   |
| ------------ | ---------------------------- | -------- | ----------------------------------------------------------------------------- |
|              | data [*required*]       | object   | Data object returned for a DEM journey variant.                               |
| data         | attributes [*required*] | object   | Attributes of a DEM journey variant.                                          |
| attributes   | filter                       | string   | An optional RUM query filter to scope this variant.                           |
| attributes   | name [*required*]       | string   | The name of the variant.                                                      |
| attributes   | rum_steps [*required*]  | [object] | List of RUM journey steps.                                                    |
| rum_steps    | nodes [*required*]      | [object] | List of RUM nodes within a journey step.                                      |
| nodes        | app_id                       | string   | The application ID associated with this node.                                 |
| nodes        | id                           | string   | The ID of the RUM node element.                                               |
| nodes        | query [*required*]      | string   | The RUM query for matching this node.                                         |
| rum_steps    | type [*required*]       | enum     | The type of a RUM journey step. Allowed enum values: `start,stop,step`        |
| data         | id [*required*]         | string   | The unique identifier of the variant.                                         |
| data         | type [*required*]       | enum     | The type identifier for DEM journey variants. Allowed enum values: `variants` |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "filter": "device.type:mobile",
      "name": "Mobile checkout",
      "rum_steps": [
        {
          "nodes": [
            {
              "app_id": "app-xyz789",
              "id": "element-id-123",
              "query": "action.name:'checkout'"
            }
          ],
          "type": "start"
        }
      ]
    },
    "id": "variant-001",
    "type": "variants"
  }
}
```

{% /tab %}

{% /tab %}

{% tab title="400" %}
Bad Request
{% tab title="Model" %}
API error response.

| Parent field | Field                    | Type     | Description                                                                     |
| ------------ | ------------------------ | -------- | ------------------------------------------------------------------------------- |
|              | errors [*required*] | [object] | A list of errors.                                                               |
| errors       | detail                   | string   | A human-readable explanation specific to this occurrence of the error.          |
| errors       | meta                     | object   | Non-standard meta-information about the error                                   |
| errors       | source                   | object   | References to the source of the error.                                          |
| source       | header                   | string   | A string indicating the name of a single request header which caused the error. |
| source       | parameter                | string   | A string indicating which URI query parameter caused the error.                 |
| source       | pointer                  | string   | A JSON pointer to the value in the request document that caused the error.      |
| errors       | status                   | string   | Status code of the response.                                                    |
| errors       | title                    | string   | Short human-readable summary of the error.                                      |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    {
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "Bad Request"
    }
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="404" %}
Not Found
{% tab title="Model" %}
API error response.

| Parent field | Field                    | Type     | Description                                                                     |
| ------------ | ------------------------ | -------- | ------------------------------------------------------------------------------- |
|              | errors [*required*] | [object] | A list of errors.                                                               |
| errors       | detail                   | string   | A human-readable explanation specific to this occurrence of the error.          |
| errors       | meta                     | object   | Non-standard meta-information about the error                                   |
| errors       | source                   | object   | References to the source of the error.                                          |
| source       | header                   | string   | A string indicating the name of a single request header which caused the error. |
| source       | parameter                | string   | A string indicating which URI query parameter caused the error.                 |
| source       | pointer                  | string   | A JSON pointer to the value in the request document that caused the error.      |
| errors       | status                   | string   | Status code of the response.                                                    |
| errors       | title                    | string   | Short human-readable summary of the error.                                      |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    {
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "Bad Request"
    }
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too many requests
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

### Code Example

##### 
                  \## default
# 
 \# Path parameters export variant_id="variant-001" \# Use a Personal Access Token or Service Access Token export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"  \# Curl command curl -X PUT "https://api.datadoghq.com/api/v2/dem/journeys/variants/${variant_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "filter": "device.type:mobile",
      "name": "Mobile checkout",
      "rum_steps": [
        {
          "nodes": [
            {
              "query": "action.name:'checkout'"
            }
          ],
          "type": "start"
        },
        {
          "nodes": [
            {
              "query": "action.name:'confirmation'"
            }
          ],
          "type": "stop"
        }
      ]
    },
    "type": "variants"
  }
}
EOF 
                
##### 

```python
"""
Update a DEM journey variant returns "OK" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.dem_api import DEMApi
from datadog_api_client.v2.model.dem_rum_node import DemRumNode
from datadog_api_client.v2.model.dem_rum_step import DemRumStep
from datadog_api_client.v2.model.dem_rum_step_type import DemRumStepType
from datadog_api_client.v2.model.dem_variant_attributes import DemVariantAttributes
from datadog_api_client.v2.model.dem_variant_request import DemVariantRequest
from datadog_api_client.v2.model.dem_variant_request_data import DemVariantRequestData
from datadog_api_client.v2.model.dem_variant_type import DemVariantType

body = DemVariantRequest(
    data=DemVariantRequestData(
        attributes=DemVariantAttributes(
            filter="device.type:mobile",
            name="Mobile checkout",
            rum_steps=[
                DemRumStep(
                    nodes=[
                        DemRumNode(
                            query="action.name:'checkout'",
                        ),
                    ],
                    type=DemRumStepType.START,
                ),
                DemRumStep(
                    nodes=[
                        DemRumNode(
                            query="action.name:'confirmation'",
                        ),
                    ],
                    type=DemRumStepType.STOP,
                ),
            ],
        ),
        type=DemVariantType.VARIANTS,
    ),
)

configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
    api_instance = DEMApi(api_client)
    response = api_instance.update_journey_variant(variant_id="variant_id", body=body)

    print(response)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python) 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"
##### 

```ruby
# Update a DEM journey variant returns "OK" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
  config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::DEMAPI.new

body = DatadogAPIClient::V2::DemVariantRequest.new({
  data: DatadogAPIClient::V2::DemVariantRequestData.new({
    attributes: DatadogAPIClient::V2::DemVariantAttributes.new({
      filter: "device.type:mobile",
      name: "Mobile checkout",
      rum_steps: [
        DatadogAPIClient::V2::DemRumStep.new({
          nodes: [
            DatadogAPIClient::V2::DemRumNode.new({
              query: "action.name:'checkout'",
            }),
          ],
          type: DatadogAPIClient::V2::DemRumStepType::START,
        }),
        DatadogAPIClient::V2::DemRumStep.new({
          nodes: [
            DatadogAPIClient::V2::DemRumNode.new({
              query: "action.name:'confirmation'",
            }),
          ],
          type: DatadogAPIClient::V2::DemRumStepType::STOP,
        }),
      ],
    }),
    type: DatadogAPIClient::V2::DemVariantType::VARIANTS,
  }),
})
p api_instance.update_journey_variant("variant_id", body)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby) 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>" rb "example.rb"
##### 

```go
// Update a DEM journey variant returns "OK" 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.DemVariantRequest{
		Data: datadogV2.DemVariantRequestData{
			Attributes: datadogV2.DemVariantAttributes{
				Filter: datadog.PtrString("device.type:mobile"),
				Name:   "Mobile checkout",
				RumSteps: []datadogV2.DemRumStep{
					{
						Nodes: []datadogV2.DemRumNode{
							{
								Query: "action.name:'checkout'",
							},
						},
						Type: datadogV2.DEMRUMSTEPTYPE_START,
					},
					{
						Nodes: []datadogV2.DemRumNode{
							{
								Query: "action.name:'confirmation'",
							},
						},
						Type: datadogV2.DEMRUMSTEPTYPE_STOP,
					},
				},
			},
			Type: datadogV2.DEMVARIANTTYPE_VARIANTS,
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewDEMApi(apiClient)
	resp, r, err := api.UpdateJourneyVariant(ctx, "variant_id", body)

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `DEMApi.UpdateJourneyVariant`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `DEMApi.UpdateJourneyVariant`:\n%s\n", responseContent)
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=go) 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"
##### 

```java
// Update a DEM journey variant returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.DemApi;
import com.datadog.api.client.v2.model.DemRumNode;
import com.datadog.api.client.v2.model.DemRumStep;
import com.datadog.api.client.v2.model.DemRumStepType;
import com.datadog.api.client.v2.model.DemVariantAttributes;
import com.datadog.api.client.v2.model.DemVariantRequest;
import com.datadog.api.client.v2.model.DemVariantRequestData;
import com.datadog.api.client.v2.model.DemVariantResponse;
import com.datadog.api.client.v2.model.DemVariantType;
import java.util.Arrays;
import java.util.Collections;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
    DemApi apiInstance = new DemApi(defaultClient);

    DemVariantRequest body =
        new DemVariantRequest()
            .data(
                new DemVariantRequestData()
                    .attributes(
                        new DemVariantAttributes()
                            .filter("device.type:mobile")
                            .name("Mobile checkout")
                            .rumSteps(
                                Arrays.asList(
                                    new DemRumStep()
                                        .nodes(
                                            Collections.singletonList(
                                                new DemRumNode().query("action.name:'checkout'")))
                                        .type(DemRumStepType.START),
                                    new DemRumStep()
                                        .nodes(
                                            Collections.singletonList(
                                                new DemRumNode()
                                                    .query("action.name:'confirmation'")))
                                        .type(DemRumStepType.STOP))))
                    .type(DemVariantType.VARIANTS));

    try {
      DemVariantResponse result = apiInstance.updateJourneyVariant("variant-001", body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling DemApi#updateJourneyVariant");
      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](https://docs.datadoghq.com/api/latest.md?code-lang=java) 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"
##### 

```rust
// Update a DEM journey variant returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_dem::DEMAPI;
use datadog_api_client::datadogV2::model::DemRumNode;
use datadog_api_client::datadogV2::model::DemRumStep;
use datadog_api_client::datadogV2::model::DemRumStepType;
use datadog_api_client::datadogV2::model::DemVariantAttributes;
use datadog_api_client::datadogV2::model::DemVariantRequest;
use datadog_api_client::datadogV2::model::DemVariantRequestData;
use datadog_api_client::datadogV2::model::DemVariantType;

#[tokio::main]
async fn main() {
    let body = DemVariantRequest::new(DemVariantRequestData::new(
        DemVariantAttributes::new(
            "Mobile checkout".to_string(),
            vec![
                DemRumStep::new(
                    vec![DemRumNode::new("action.name:'checkout'".to_string())],
                    DemRumStepType::START,
                ),
                DemRumStep::new(
                    vec![DemRumNode::new("action.name:'confirmation'".to_string())],
                    DemRumStepType::STOP,
                ),
            ],
        )
        .filter("device.type:mobile".to_string()),
        DemVariantType::VARIANTS,
    ));
    let configuration = datadog::Configuration::new();
    let api = DEMAPI::with_config(configuration);
    let resp = api
        .update_journey_variant("variant_id".to_string(), body)
        .await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=rust) and then save the example to `src/main.rs` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo run
##### 

```typescript
/**
 * Update a DEM journey variant returns "OK" response
 */

import { client, v2 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration({
  authMethods: {
    AuthZ: {
      accessToken: process.env.DD_BEARER_TOKEN as string,
    },
  },
});
const apiInstance = new v2.DEMApi(configuration);

const params: v2.DEMApiUpdateJourneyVariantRequest = {
  body: {
    data: {
      attributes: {
        filter: "device.type:mobile",
        name: "Mobile checkout",
        rumSteps: [
          {
            nodes: [
              {
                query: "action.name:'checkout'",
              },
            ],
            type: "start",
          },
          {
            nodes: [
              {
                query: "action.name:'confirmation'",
              },
            ],
            type: "stop",
          },
        ],
      },
      type: "variants",
    },
  },
  variantId: "variant_id",
};

apiInstance
  .updateJourneyVariant(params)
  .then((data: v2.DemVariantResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=typescript) 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>" tsc "example.ts"
{% /tab %}
