Variables


Overview

Template variables allow you to insert dynamic values from your mobile test results and configuration into notification messages. These variables are accessed using the synthetics.attributes prefix.

Use the filter above to view variables by category.

This section covers two categories of variables:

  • Test execution variables: Shortcuts for commonly used values such as failure messages, step counts, duration, and tags.
  • Execution results: The full result object with status, timestamps, failure codes, and step counts.

Test execution variables

Path: synthetics (various shortcuts)

Use these variables to access common test execution data such as failure messages, step counts, duration, and tags.

{{synthetics.failed_step.failure.message}}
The error message (for example, Element's content should match the given regex).
{{synthetics.failed_step.url}}
The URL of the failed step (for example, https://www.datadoghq.com/blog/).
{{synthetics.attributes.result.response.statusCode}}
The HTTP status code (for example, 403).
Note: Review the conditional alerting page for an example of how to use this variable in a notification.
{{synthetics.result.step_count}}
Number of steps (for example, 4).
{{synthetics.result.duration}}
Duration of the test run (in milliseconds) (for example, 9096).
{{tags}}
Lists all the tags added to the synthetics test.
To access individual tag values, use {{tags.<tag-key>}}. For example, if your test is tagged with env:prod, use {{tags.env}} to return the tag value prod.

Execution results

Path: synthetics.attributes

Use these variables to access test execution results, status, duration, and step counts.

{{synthetics.attributes.result}}
The result object contains information about the executed test run
{{synthetics.attributes.result.id}}
Unique result ID
{{synthetics.attributes.result.status}}
Test execution status (for example, passed or failed)
{{synthetics.attributes.result.duration}}
Test duration in milliseconds
{{synthetics.attributes.result.testStartedAt}}, {{synthetics.attributes.result.testFinishedAt}}, {{synthetics.attributes.result.testTriggeredAt}}
Epoch timestamps in milliseconds
{{synthetics.attributes.result.failure}}
The failure object contains information about why the test failed
{{synthetics.attributes.result.failure.message}}
The failure message
{{synthetics.attributes.result.failure.code}}
The failure code

For a complete list of API test error codes, see API Testing Errors. Review the conditional alerting page for an example of how to use the synthetics.attributes.result.failure variable in a notification.

{{synthetics.attributes.count}}
The count object contains step statistics about the test
{{synthetics.attributes.count.steps.total}}
The total number of steps
{{synthetics.attributes.count.steps.completed}}
The number of steps that were run
{{synthetics.attributes.count.errors}}
The total number of errors that occurred while running the test. For multistep and mobile tests, this is the number of failed steps. For browser tests, this is the sum of all browser errors.
{{synthetics.attributes.count.hops}}
The number of traceroute hops for TCP and ICMP tests

Test metadata

Path: synthetics.attributes

Use these variables to access test configuration and execution location information.

{{synthetics.attributes.test}}
The test object contains information about the test like its name, type, subtype, and id
{{synthetics.attributes.test.name}}
The name of the test
{{synthetics.attributes.test.type}}
Test type (for example, api)
{{synthetics.attributes.test.subType}}
Subtype for API tests (for example, http, dns, and multi)
{{synthetics.attributes.test.id}}
The test's public ID (for example, abc-def-ghi)
{{synthetics.attributes.location}}
The location object contains information about the location of where the test is run from
{{synthetics.attributes.location.id}}
Location ID (for example, aws:eu-central-1)
{{synthetics.attributes.location.name}}
Name of the location (for example, Frankfurt (AWS))
{{synthetics.attributes.location.privateLocation}}
true for Private Locations

Path: synthetics.attributes.device

{{synthetics.attributes.device}}
The device object contains information about the device on which the test is run on
{{synthetics.attributes.device.id}}
Device identifier
{{synthetics.attributes.device.name}}
Human-readable device name
{{synthetics.attributes.device.type}}
Device type classification
{{synthetics.attributes.device.width}}, {{synthetics.attributes.device.height}}
Screen resolution dimensions

Mobile-specific:

{{synthetics.attributes.device.platform.name}}, {{synthetics.attributes.device.platform.version}}
Platform information (for example, android, ios)

This section covers step-level variables organized by category:

Failed step information

Path: synthetics.failed_step

Use these variables to access information about the step that caused a test failure.

{{synthetics.failed_step}}
The failed_step object provides a shortcut to the step that caused the test to fail, eliminating the need to reference {{synthetics.attributes.result.steps.<step-index>}} directly.
{{synthetics.failed_step.description}}
Shortcut for {{synthetics.attributes.result.steps.<step-index>.description}}

Review the conditional alerting page for an example of how to use the synthetics.failed_step.description shortcut variable in a notification.

Step execution details

Path: synthetics.attributes.variables.extracted

These are step execution metadata and results containing detailed information about how each step ran, including response data, timing metrics, and protocol-specific details. These values are only available when the step completes successfully.

synthetics.attributes.variables.extracted.steps.allowFailure
Whether the step is allowed to fail without failing the entire test
synthetics.attributes.variables.extracted.steps.duration
Step execution duration in milliseconds
synthetics.attributes.variables.extracted.steps.failure
Failure information object containing .code and .message
synthetics.attributes.variables.extracted.steps.id
Unique step identifier
synthetics.attributes.variables.extracted.steps.isCritical
Whether the step is critical to the test
synthetics.attributes.variables.extracted.steps.status
Step execution status
synthetics.attributes.variables.extracted.steps.type
Type of step being executed

Mobile-specific:

synthetics.attributes.variables.extracted.application.versionId
Mobile application version identifier
synthetics.attributes.variables.extracted.apiTest
API test data (for API test steps within mobile tests)
synthetics.attributes.variables.extracted.description
Step description
synthetics.attributes.variables.extracted.warnings
List of warnings, each containing .message (the warning message) and .type (the warning type)

Path: synthetics.attributes.result.steps.<step-index>.extractedValue

These are the actual variable values that a step captured during test execution. For example, if you have a mobile test step that extracts a value into a variable, this is where you access that extracted value.

For information on how to access the <step-index>, see the step summary section.

synthetics.attributes.result.steps.<step-index>.extractedValue.name
Variable name
synthetics.attributes.result.steps.<step-index>.extractedValue.secure
Whether the variable value is obfuscated
synthetics.attributes.result.steps.<step-index>.extractedValue.value
Variable value (if step was successful)
synthetics.attributes.variables.extracted.steps.subTest.id
Subtest identifier
synthetics.attributes.variables.extracted.steps.subStep.parentStep.id
Parent step identifier
synthetics.attributes.variables.extracted.steps.subStep.parentTest.id
Parent test identifier
synthetics.attributes.variables.extracted.steps.subStep.level
Nesting level (1 for subtests, 2 for subtests of subtests)

Local & Global Variables

Use these variables to access locally configured variables and globally defined variables in your notifications.

Path: synthetics.attributes.result.variables.config

These are local variables configured for API tests or defined outside individual steps in step-based tests. This also includes variables created by JavaScript code execution.

{{synthetics.attributes.result.variables.config.name}}
Variable name
{{synthetics.attributes.result.variables.config.type}}
Variable type
{{synthetics.attributes.result.variables.config.secure}}
Whether the variable value is obfuscated
{{synthetics.attributes.result.variables.config.value}}
Variable value (non-obfuscated only)

Path: synthetics.attributes.result.variables.extracted

These are extracted variables whose value updates a global variable value.

Available only for successful test results and recovery notifications.

{{synthetics.attributes.result.variables.extracted.id}}
Global variable ID
{{synthetics.attributes.result.variables.extracted.name}}
Variable name
{{synthetics.attributes.result.variables.extracted.secure}}
Whether the variable value is obfuscated
{{synthetics.attributes.result.variables.extracted.val}}
Variable value (note: uses .val, not .value)

Step summary

Path: synthetics.attributes.result.steps

Access step data by index, name, or ID to reference specific steps in your notification messages. Use these reference methods when working with step-related variables throughout this documentation.

Each step exposes the following properties: .id, .status, .type, .duration, .description, .failure.message, .code, and .url.

You can reference steps in three ways:

Use positive numbers to count from the beginning, or negative numbers to count from the end:

synthetics.attributes.result.steps.0
First step
synthetics.attributes.result.steps.1
Second step
synthetics.attributes.result.steps.-1
Last step
synthetics.attributes.result.steps.-2
Second to last step

Example: {{synthetics.attributes.result.steps.-1.status}} returns the status of the last step.

Use the step name in brackets:

synthetics.attributes.result.steps[Click button]
References the step named "Click button"

Example: {{synthetics.attributes.result.steps[Click button].status}} returns the status of the step named "Click button".

Use the step's unique identifier:

synthetics.attributes.result.steps.abc-def-ghi
References the step with ID "abc-def-ghi"

Example: {{synthetics.attributes.result.steps.abc-def-ghi.status}} returns the status of the step with step ID "abc-def-ghi".

Review the conditional alerting page for an example of how to use the synthetics.attributes.result.step variable in a Slack notification based on a failed step.

Accessing step properties

Combine any reference method with a property:

  • {{synthetics.attributes.result.steps.-1.status}} - Status of the last step
  • {{synthetics.attributes.result.steps[Click button].status}} - Status of the step named "Click button"
  • {{synthetics.attributes.result.steps.abc-def-ghi.status}} - Status of the step with step ID "abc-def-ghi"

Further reading