Synthetics

Synthetics

Datadog Synthetics uses simulated user requests and browser rendering to help you ensure uptime, identify regional issues, and track your application performance. Datadog Synthetics tests come in two different flavors, API tests and browser tests. You can use Datadog’s API to manage both test types programmatically.

For more information about Synthetics, see the Synthetics overview.

POST https://api.datadoghq.eu/api/v1/synthetics/tests/apihttps://api.ddog-gov.com/api/v1/synthetics/tests/apihttps://api.datadoghq.com/api/v1/synthetics/tests/apihttps://api.us3.datadoghq.com/api/v1/synthetics/tests/apihttps://api.us5.datadoghq.com/api/v1/synthetics/tests/api

Overview

Create a Synthetic API test.

Request

Body Data (required)

Details of the test to create.

Expand All

Field

Type

Description

config

object

Configuration object for a Synthetic API test.

assertions

[object <oneOf>]

Array of assertions used for the test.

Option 1

object

An assertion which uses a simple target.

operator [required]

enum

Assertion operator to apply. Allowed enum values: contains,doesNotContain,is,isNot,lessThan,lessThanOrEqual,moreThan,moreThanOrEqual,matches,doesNotMatch,validates,isInMoreThan,isInLessThan

property

string

The associated assertion property.

target

Value used by the operator.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion,latency,packetLossPercentage,packetsReceived,networkHop

Option 2

object

An assertion for the validatesJSONPath operator.

operator [required]

enum

Assertion operator to apply. Allowed enum values: validatesJSONPath

property

string

The associated assertion property.

target

object

Composed target for validatesJSONPath operator.

jsonPath

string

The JSON path to assert.

operator

string

The specific operator to use on the path.

targetValue

The path target value to compare to.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion,latency,packetLossPercentage,packetsReceived,networkHop

configVariables

[object]

Array of variables used for the test.

example

string

Example for the variable.

id

string

ID of the variable for global variables.

name [required]

string

Name of the variable.

pattern

string

Pattern of the variable.

type [required]

enum

Type of the configuration variable. Allowed enum values: global,text

request

object

Object describing the Synthetic test request.

allow_insecure

boolean

Allows loading insecure content for an HTTP request in a multistep test step.

basicAuth

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authentication.

username [required]

string

Username to use for the basic authentication.

body

string

Body to include in the test.

certificate

object

Client certificate to use when performing the test request.

cert

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

key

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

dnsServer

string

DNS server to use for DNS tests.

dnsServerPort

int32

DNS server port to use for DNS tests.

follow_redirects

boolean

Specifies whether or not the request follows redirects.

headers

object

Headers to include when performing the test.

<any-key>

string

A single Header.

host

string

Host name to perform the test with.

method

enum

The HTTP method. Allowed enum values: GET,POST,PATCH,PUT,DELETE,HEAD,OPTIONS

noSavingResponseBody

boolean

Determines whether or not to save the response body.

numberOfPackets

int32

Number of pings to use per test.

port

int64

Port to use when performing the test.

query

object

Query to use for the test.

servername

string

For SSL tests, it specifies on which server you want to initiate the TLS handshake, allowing the server to present one of multiple possible certificates on the same IP address and TCP port number.

shouldTrackHops

boolean

Turns on a traceroute probe to discover all gateways along the path to the host destination.

timeout

double

Timeout in seconds for the test.

url

string

URL to perform the test with.

steps

[object]

When the test subtype is multi, the steps of the test.

allowFailure

boolean

Determines whether or not to continue with test if this step fails.

assertions

[object <oneOf>]

Array of assertions used for the test.

Option 1

object

An assertion which uses a simple target.

operator [required]

enum

Assertion operator to apply. Allowed enum values: contains,doesNotContain,is,isNot,lessThan,lessThanOrEqual,moreThan,moreThanOrEqual,matches,doesNotMatch,validates,isInMoreThan,isInLessThan

property

string

The associated assertion property.

target

Value used by the operator.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion,latency,packetLossPercentage,packetsReceived,networkHop

Option 2

object

An assertion for the validatesJSONPath operator.

operator [required]

enum

Assertion operator to apply. Allowed enum values: validatesJSONPath

property

string

The associated assertion property.

target

object

Composed target for validatesJSONPath operator.

jsonPath

string

The JSON path to assert.

operator

string

The specific operator to use on the path.

targetValue

The path target value to compare to.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion,latency,packetLossPercentage,packetsReceived,networkHop

extractedValues

[object]

Array of values to parse and save as variables from the response.

field

string

When type is http_header, name of the header to use to extract the value.

name

string

Name of the variable to extract.

parser

object

Details of the parser to use for the global variable.

type [required]

enum

Type of parser for a Synthetics global variable from a synthetics test. Allowed enum values: raw,json_path,regex,x_path

value

string

Regex or JSON path used for the parser. Not used with type raw.

type

enum

Property of the Synthetics Test Response to use for a Synthetics global variable. Allowed enum values: http_body,http_header

isCritical

boolean

Determines whether or not to consider the entire test as failed if this step fails. Can be used only if allowFailure is true.

name

string

The name of the step.

request

object

Object describing the Synthetic test request.

allow_insecure

boolean

Allows loading insecure content for an HTTP request in a multistep test step.

basicAuth

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authentication.

username [required]

string

Username to use for the basic authentication.

body

string

Body to include in the test.

certificate

object

Client certificate to use when performing the test request.

cert

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

key

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

dnsServer

string

DNS server to use for DNS tests.

dnsServerPort

int32

DNS server port to use for DNS tests.

follow_redirects

boolean

Specifies whether or not the request follows redirects.

headers

object

Headers to include when performing the test.

<any-key>

string

A single Header.

host

string

Host name to perform the test with.

method

enum

The HTTP method. Allowed enum values: GET,POST,PATCH,PUT,DELETE,HEAD,OPTIONS

noSavingResponseBody

boolean

Determines whether or not to save the response body.

numberOfPackets

int32

Number of pings to use per test.

port

int64

Port to use when performing the test.

query

object

Query to use for the test.

servername

string

For SSL tests, it specifies on which server you want to initiate the TLS handshake, allowing the server to present one of multiple possible certificates on the same IP address and TCP port number.

shouldTrackHops

boolean

Turns on a traceroute probe to discover all gateways along the path to the host destination.

timeout

double

Timeout in seconds for the test.

url

string

URL to perform the test with.

subtype

enum

The subtype of the Synthetic multistep API test step, currently only supporting http. Allowed enum values: http

locations

[string]

Array of locations used to run the test.

message

string

Notification message associated with the test.

monitor_id

int64

The associated monitor ID.

name

string

Name of the test.

options

object

Object describing the extra options for a Synthetic test.

accept_self_signed

boolean

For SSL test, whether or not the test should allow self signed certificates.

allow_insecure

boolean

Allows loading insecure content for an HTTP request.

device_ids

[string]

For browser test, array with the different device IDs used to run the test.

disableCors

boolean

Whether or not to disable CORS mechanism.

follow_redirects

boolean

For API HTTP test, whether or not the test should follow redirects.

min_failure_duration

int64

Minimum amount of time in failure required to trigger an alert.

min_location_failed

int64

Minimum number of locations in failure required to trigger an alert.

monitor_name

string

The monitor name is used for the alert title as well as for all monitor dashboard widgets and SLOs.

monitor_options

object

Object containing the options for a Synthetic test as a monitor (for example, renotification).

renotify_interval

int64

Time interval before renotifying if the test is still failing (in minutes).

monitor_priority

int32

Integer from 1 (high) to 5 (low) indicating alert severity.

noScreenshot

boolean

Prevents saving screenshots of the steps.

retry

object

Object describing the retry strategy to apply to a Synthetic test.

count

int64

Number of times a test needs to be retried before marking a location as failed. Defaults to 0.

interval

double

Time interval between retries (in milliseconds). Defaults to 300ms.

tick_every

int64

The frequency at which to run the Synthetic test (in seconds).

public_id

string

The public ID for the test.

status

enum

Define whether you want to start (live) or pause (paused) a Synthetic test. Allowed enum values: live,paused

subtype

enum

The subtype of the Synthetic API test, http, ssl, tcp, dns, icmp or multi. Allowed enum values: http,ssl,tcp,dns,multi,icmp

tags

[string]

Array of tags attached to the test.

type

enum

Type of the Synthetic test, api. Allowed enum values: api

{
  "config": {
    "assertions": [
      []
    ],
    "configVariables": [
      {
        "example": "string",
        "id": "string",
        "name": "VARIABLE_NAME",
        "pattern": "string",
        "type": "text"
      }
    ],
    "request": {
      "allow_insecure": false,
      "basicAuth": {
        "password": "",
        "username": ""
      },
      "body": "string",
      "certificate": {
        "cert": {
          "content": "string",
          "filename": "string",
          "updatedAt": "string"
        },
        "key": {
          "content": "string",
          "filename": "string",
          "updatedAt": "string"
        }
      },
      "dnsServer": "string",
      "dnsServerPort": "integer",
      "follow_redirects": false,
      "headers": {
        "<any-key>": "string"
      },
      "host": "string",
      "method": "GET",
      "noSavingResponseBody": false,
      "numberOfPackets": "integer",
      "port": "integer",
      "query": {},
      "servername": "string",
      "shouldTrackHops": false,
      "timeout": "number",
      "url": "https://example.com"
    },
    "steps": [
      {
        "allowFailure": false,
        "assertions": [
          {
            "operator": "contains",
            "property": "string",
            "target": "undefined",
            "type": "statusCode"
          }
        ],
        "extractedValues": [
          {
            "field": "content-type",
            "name": "string",
            "parser": {
              "type": "raw",
              "value": "string"
            },
            "type": "http_body"
          }
        ],
        "isCritical": false,
        "name": "string",
        "request": {
          "allow_insecure": false,
          "basicAuth": {
            "password": "",
            "username": ""
          },
          "body": "string",
          "certificate": {
            "cert": {
              "content": "string",
              "filename": "string",
              "updatedAt": "string"
            },
            "key": {
              "content": "string",
              "filename": "string",
              "updatedAt": "string"
            }
          },
          "dnsServer": "string",
          "dnsServerPort": "integer",
          "follow_redirects": false,
          "headers": {
            "<any-key>": "string"
          },
          "host": "string",
          "method": "GET",
          "noSavingResponseBody": false,
          "numberOfPackets": "integer",
          "port": "integer",
          "query": {},
          "servername": "string",
          "shouldTrackHops": false,
          "timeout": "number",
          "url": "https://example.com"
        },
        "subtype": "string"
      }
    ]
  },
  "locations": [
    "aws:eu-west-3"
  ],
  "message": "Notification message",
  "name": "Test name",
  "options": {
    "accept_self_signed": false,
    "allow_insecure": false,
    "device_ids": [
      "laptop_large"
    ],
    "disableCors": false,
    "follow_redirects": false,
    "min_failure_duration": "integer",
    "min_location_failed": "integer",
    "monitor_name": "string",
    "monitor_options": {
      "renotify_interval": "integer"
    },
    "monitor_priority": "integer",
    "noScreenshot": false,
    "retry": {
      "count": "integer",
      "interval": "number"
    },
    "tick_every": "integer"
  },
  "status": "live",
  "subtype": "http",
  "tags": [
    "env:production"
  ],
  "type": "api"
}

Response

OK - Returns the created test details.

Object containing details about a Synthetic API test.

Expand All

Field

Type

Description

config

object

Configuration object for a Synthetic API test.

assertions

[object <oneOf>]

Array of assertions used for the test.

Option 1

object

An assertion which uses a simple target.

operator [required]

enum

Assertion operator to apply. Allowed enum values: contains,doesNotContain,is,isNot,lessThan,lessThanOrEqual,moreThan,moreThanOrEqual,matches,doesNotMatch,validates,isInMoreThan,isInLessThan

property

string

The associated assertion property.

target

Value used by the operator.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion,latency,packetLossPercentage,packetsReceived,networkHop

Option 2

object

An assertion for the validatesJSONPath operator.

operator [required]

enum

Assertion operator to apply. Allowed enum values: validatesJSONPath

property

string

The associated assertion property.

target

object

Composed target for validatesJSONPath operator.

jsonPath

string

The JSON path to assert.

operator

string

The specific operator to use on the path.

targetValue

The path target value to compare to.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion,latency,packetLossPercentage,packetsReceived,networkHop

configVariables

[object]

Array of variables used for the test.

example

string

Example for the variable.

id

string

ID of the variable for global variables.

name [required]

string

Name of the variable.

pattern

string

Pattern of the variable.

type [required]

enum

Type of the configuration variable. Allowed enum values: global,text

request

object

Object describing the Synthetic test request.

allow_insecure

boolean

Allows loading insecure content for an HTTP request in a multistep test step.

basicAuth

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authentication.

username [required]

string

Username to use for the basic authentication.

body

string

Body to include in the test.

certificate

object

Client certificate to use when performing the test request.

cert

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

key

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

dnsServer

string

DNS server to use for DNS tests.

dnsServerPort

int32

DNS server port to use for DNS tests.

follow_redirects

boolean

Specifies whether or not the request follows redirects.

headers

object

Headers to include when performing the test.

<any-key>

string

A single Header.

host

string

Host name to perform the test with.

method

enum

The HTTP method. Allowed enum values: GET,POST,PATCH,PUT,DELETE,HEAD,OPTIONS

noSavingResponseBody

boolean

Determines whether or not to save the response body.

numberOfPackets

int32

Number of pings to use per test.

port

int64

Port to use when performing the test.

query

object

Query to use for the test.

servername

string

For SSL tests, it specifies on which server you want to initiate the TLS handshake, allowing the server to present one of multiple possible certificates on the same IP address and TCP port number.

shouldTrackHops

boolean

Turns on a traceroute probe to discover all gateways along the path to the host destination.

timeout

double

Timeout in seconds for the test.

url

string

URL to perform the test with.

steps

[object]

When the test subtype is multi, the steps of the test.

allowFailure

boolean

Determines whether or not to continue with test if this step fails.

assertions

[object <oneOf>]

Array of assertions used for the test.

Option 1

object

An assertion which uses a simple target.

operator [required]

enum

Assertion operator to apply. Allowed enum values: contains,doesNotContain,is,isNot,lessThan,lessThanOrEqual,moreThan,moreThanOrEqual,matches,doesNotMatch,validates,isInMoreThan,isInLessThan

property

string

The associated assertion property.

target

Value used by the operator.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion,latency,packetLossPercentage,packetsReceived,networkHop

Option 2

object

An assertion for the validatesJSONPath operator.

operator [required]

enum

Assertion operator to apply. Allowed enum values: validatesJSONPath

property

string

The associated assertion property.

target

object

Composed target for validatesJSONPath operator.

jsonPath

string

The JSON path to assert.

operator

string

The specific operator to use on the path.

targetValue

The path target value to compare to.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion,latency,packetLossPercentage,packetsReceived,networkHop

extractedValues

[object]

Array of values to parse and save as variables from the response.

field

string

When type is http_header, name of the header to use to extract the value.

name

string

Name of the variable to extract.

parser

object

Details of the parser to use for the global variable.

type [required]

enum

Type of parser for a Synthetics global variable from a synthetics test. Allowed enum values: raw,json_path,regex,x_path

value

string

Regex or JSON path used for the parser. Not used with type raw.

type

enum

Property of the Synthetics Test Response to use for a Synthetics global variable. Allowed enum values: http_body,http_header

isCritical

boolean

Determines whether or not to consider the entire test as failed if this step fails. Can be used only if allowFailure is true.

name

string

The name of the step.

request

object

Object describing the Synthetic test request.

allow_insecure

boolean

Allows loading insecure content for an HTTP request in a multistep test step.

basicAuth

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authentication.

username [required]

string

Username to use for the basic authentication.

body

string

Body to include in the test.

certificate

object

Client certificate to use when performing the test request.

cert

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

key

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

dnsServer

string

DNS server to use for DNS tests.

dnsServerPort

int32

DNS server port to use for DNS tests.

follow_redirects

boolean

Specifies whether or not the request follows redirects.

headers

object

Headers to include when performing the test.

<any-key>

string

A single Header.

host

string

Host name to perform the test with.

method

enum

The HTTP method. Allowed enum values: GET,POST,PATCH,PUT,DELETE,HEAD,OPTIONS

noSavingResponseBody

boolean

Determines whether or not to save the response body.

numberOfPackets

int32

Number of pings to use per test.

port

int64

Port to use when performing the test.

query

object

Query to use for the test.

servername

string

For SSL tests, it specifies on which server you want to initiate the TLS handshake, allowing the server to present one of multiple possible certificates on the same IP address and TCP port number.

shouldTrackHops

boolean

Turns on a traceroute probe to discover all gateways along the path to the host destination.

timeout

double

Timeout in seconds for the test.

url

string

URL to perform the test with.

subtype

enum

The subtype of the Synthetic multistep API test step, currently only supporting http. Allowed enum values: http

locations

[string]

Array of locations used to run the test.

message

string

Notification message associated with the test.

monitor_id

int64

The associated monitor ID.

name

string

Name of the test.

options

object

Object describing the extra options for a Synthetic test.

accept_self_signed

boolean

For SSL test, whether or not the test should allow self signed certificates.

allow_insecure

boolean

Allows loading insecure content for an HTTP request.

device_ids

[string]

For browser test, array with the different device IDs used to run the test.

disableCors

boolean

Whether or not to disable CORS mechanism.

follow_redirects

boolean

For API HTTP test, whether or not the test should follow redirects.

min_failure_duration

int64

Minimum amount of time in failure required to trigger an alert.

min_location_failed

int64

Minimum number of locations in failure required to trigger an alert.

monitor_name

string

The monitor name is used for the alert title as well as for all monitor dashboard widgets and SLOs.

monitor_options

object

Object containing the options for a Synthetic test as a monitor (for example, renotification).

renotify_interval

int64

Time interval before renotifying if the test is still failing (in minutes).

monitor_priority

int32

Integer from 1 (high) to 5 (low) indicating alert severity.

noScreenshot

boolean

Prevents saving screenshots of the steps.

retry

object

Object describing the retry strategy to apply to a Synthetic test.

count

int64

Number of times a test needs to be retried before marking a location as failed. Defaults to 0.

interval

double

Time interval between retries (in milliseconds). Defaults to 300ms.

tick_every

int64

The frequency at which to run the Synthetic test (in seconds).

public_id

string

The public ID for the test.

status

enum

Define whether you want to start (live) or pause (paused) a Synthetic test. Allowed enum values: live,paused

subtype

enum

The subtype of the Synthetic API test, http, ssl, tcp, dns, icmp or multi. Allowed enum values: http,ssl,tcp,dns,multi,icmp

tags

[string]

Array of tags attached to the test.

type

enum

Type of the Synthetic test, api. Allowed enum values: api

{
  "config": {
    "assertions": [
      []
    ],
    "configVariables": [
      {
        "example": "string",
        "id": "string",
        "name": "VARIABLE_NAME",
        "pattern": "string",
        "type": "text"
      }
    ],
    "request": {
      "allow_insecure": false,
      "basicAuth": {
        "password": "",
        "username": ""
      },
      "body": "string",
      "certificate": {
        "cert": {
          "content": "string",
          "filename": "string",
          "updatedAt": "string"
        },
        "key": {
          "content": "string",
          "filename": "string",
          "updatedAt": "string"
        }
      },
      "dnsServer": "string",
      "dnsServerPort": "integer",
      "follow_redirects": false,
      "headers": {
        "<any-key>": "string"
      },
      "host": "string",
      "method": "GET",
      "noSavingResponseBody": false,
      "numberOfPackets": "integer",
      "port": "integer",
      "query": {},
      "servername": "string",
      "shouldTrackHops": false,
      "timeout": "number",
      "url": "https://example.com"
    },
    "steps": [
      {
        "allowFailure": false,
        "assertions": [
          {
            "operator": "contains",
            "property": "string",
            "target": "undefined",
            "type": "statusCode"
          }
        ],
        "extractedValues": [
          {
            "field": "content-type",
            "name": "string",
            "parser": {
              "type": "raw",
              "value": "string"
            },
            "type": "http_body"
          }
        ],
        "isCritical": false,
        "name": "string",
        "request": {
          "allow_insecure": false,
          "basicAuth": {
            "password": "",
            "username": ""
          },
          "body": "string",
          "certificate": {
            "cert": {
              "content": "string",
              "filename": "string",
              "updatedAt": "string"
            },
            "key": {
              "content": "string",
              "filename": "string",
              "updatedAt": "string"
            }
          },
          "dnsServer": "string",
          "dnsServerPort": "integer",
          "follow_redirects": false,
          "headers": {
            "<any-key>": "string"
          },
          "host": "string",
          "method": "GET",
          "noSavingResponseBody": false,
          "numberOfPackets": "integer",
          "port": "integer",
          "query": {},
          "servername": "string",
          "shouldTrackHops": false,
          "timeout": "number",
          "url": "https://example.com"
        },
        "subtype": "string"
      }
    ]
  },
  "locations": [
    "aws:eu-west-3"
  ],
  "message": "Notification message",
  "monitor_id": 12345678,
  "name": "Test name",
  "options": {
    "accept_self_signed": false,
    "allow_insecure": false,
    "device_ids": [
      "laptop_large"
    ],
    "disableCors": false,
    "follow_redirects": false,
    "min_failure_duration": "integer",
    "min_location_failed": "integer",
    "monitor_name": "string",
    "monitor_options": {
      "renotify_interval": "integer"
    },
    "monitor_priority": "integer",
    "noScreenshot": false,
    "retry": {
      "count": "integer",
      "interval": "number"
    },
    "tick_every": "integer"
  },
  "public_id": "123-abc-456",
  "status": "live",
  "subtype": "http",
  "tags": [
    "env:production"
  ],
  "type": "api"
}

- JSON format is wrong - Creation failed

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Test quota is reached

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Forbidden

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Code Example


# Curl command
curl -X POST "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/synthetics/tests/api" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
  "config": {
    "configVariables": [
      {
        "name": "VARIABLE_NAME",
        "type": "text"
      }
    ],
    "request": {
      "basicAuth": {
        "password": "",
        "username": ""
      }
    },
    "steps": [
      {
        "extractedValues": [
          {
            "parser": {
              "type": "raw"
            }
          }
        ],
        "request": {
          "basicAuth": {
            "password": "",
            "username": ""
          }
        }
      }
    ]
  }
}
EOF
package main

import (
    "context"
    "encoding/json"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := datadog.NewDefaultContext(context.Background())

    body := *datadog.NewSyntheticsAPITest() // SyntheticsAPITest | Details of the test to create.

    configuration := datadog.NewConfiguration()

    apiClient := datadog.NewAPIClient(configuration)
    resp, r, err := apiClient.SyntheticsApi.CreateSyntheticsAPITest(ctx, body)
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.CreateSyntheticsAPITest`: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `CreateSyntheticsAPITest`: SyntheticsAPITest
    responseContent, _ := json.MarshalIndent(resp, "", "  ")
    fmt.Fprintf(os.Stdout, "Response from SyntheticsApi.CreateSyntheticsAPITest:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
import os
from dateutil.parser import parse as dateutil_parser
from datadog_api_client.v1 import ApiClient, ApiException, Configuration
from datadog_api_client.v1.api import synthetics_api
from datadog_api_client.v1.models import *
from pprint import pprint
# See configuration.py for a list of all supported configuration parameters.
configuration = Configuration()

# Enter a context with an instance of the API client
with ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = synthetics_api.SyntheticsApi(api_client)
    body = SyntheticsAPITest(
        config=SyntheticsAPITestConfig(
            assertions=[
                SyntheticsAssertion(),
            ],
            config_variables=[
                SyntheticsConfigVariable(
                    example="example_example",
                    id="id_example",
                    name="VARIABLE_NAME",
                    pattern="pattern_example",
                    type=SyntheticsConfigVariableType("text"),
                ),
            ],
            request=SyntheticsTestRequest(
                allow_insecure=True,
                basic_auth=SyntheticsBasicAuth(
                    password="",
                    username="",
                ),
                body="body_example",
                certificate=SyntheticsTestRequestCertificate(
                    cert=SyntheticsTestRequestCertificateItem(
                        content="content_example",
                        filename="filename_example",
                        updated_at="updated_at_example",
                    ),
                    key=SyntheticsTestRequestCertificateItem(
                        content="content_example",
                        filename="filename_example",
                        updated_at="updated_at_example",
                    ),
                ),
                dns_server="dns_server_example",
                dns_server_port=1,
                follow_redirects=True,
                headers=SyntheticsTestHeaders(
                    key="key_example",
                ),
                host="host_example",
                method=HTTPMethod("GET"),
                no_saving_response_body=True,
                number_of_packets=0,
                port=1,
                query={},
                servername="servername_example",
                should_track_hops=True,
                timeout=3.14,
                url="https://example.com",
            ),
            steps=[
                SyntheticsAPIStep(
                    allow_failure=True,
                    assertions=[
                        SyntheticsAssertion(),
                    ],
                    extracted_values=[
                        SyntheticsParsingOptions(
                            field="content-type",
                            name="name_example",
                            parser=SyntheticsVariableParser(
                                type=SyntheticsGlobalVariableParserType("raw"),
                                value="value_example",
                            ),
                            type=SyntheticsGlobalVariableParseTestOptionsType("http_body"),
                        ),
                    ],
                    is_critical=True,
                    name="name_example",
                    request=SyntheticsTestRequest(
                        allow_insecure=True,
                        basic_auth=SyntheticsBasicAuth(
                            password="",
                            username="",
                        ),
                        body="body_example",
                        certificate=SyntheticsTestRequestCertificate(
                            cert=SyntheticsTestRequestCertificateItem(
                                content="content_example",
                                filename="filename_example",
                                updated_at="updated_at_example",
                            ),
                            key=SyntheticsTestRequestCertificateItem(
                                content="content_example",
                                filename="filename_example",
                                updated_at="updated_at_example",
                            ),
                        ),
                        dns_server="dns_server_example",
                        dns_server_port=1,
                        follow_redirects=True,
                        headers=SyntheticsTestHeaders(
                            key="key_example",
                        ),
                        host="host_example",
                        method=HTTPMethod("GET"),
                        no_saving_response_body=True,
                        number_of_packets=0,
                        port=1,
                        query={},
                        servername="servername_example",
                        should_track_hops=True,
                        timeout=3.14,
                        url="https://example.com",
                    ),
                    subtype=SyntheticsAPIStepSubtype("http"),
                ),
            ],
        ),
        locations=["aws:eu-west-3"],
        message="Notification message",
        name="Test name",
        options=SyntheticsTestOptions(
            accept_self_signed=True,
            allow_insecure=True,
            device_ids=[
                SyntheticsDeviceID("laptop_large"),
            ],
            disable_cors=True,
            follow_redirects=True,
            min_failure_duration=1,
            min_location_failed=1,
            monitor_name="monitor_name_example",
            monitor_options=SyntheticsTestOptionsMonitorOptions(
                renotify_interval=0,
            ),
            monitor_priority=1,
            no_screenshot=True,
            retry=SyntheticsTestOptionsRetry(
                count=1,
                interval=3.14,
            ),
            tick_every=30,
        ),
        status=SyntheticsTestPauseStatus("live"),
        subtype=SyntheticsTestDetailsSubType("http"),
        tags=["env:production"],
        type=SyntheticsAPITestType("api"),
    )  # SyntheticsAPITest | Details of the test to create.

    # example passing only required values which don't have defaults set
    try:
        # Create an API test
        api_response = api_instance.create_synthetics_api_test(body)
        pprint(api_response)
    except ApiException as e:
        print("Exception when calling SyntheticsApi->create_synthetics_api_test: %s\n" % e)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
require 'datadog_api_client'
api_instance = DatadogAPIClient::V1::SyntheticsAPI.new
body = DatadogAPIClient::V1::SyntheticsAPITest.new # SyntheticsAPITest | Details of the test to create.

begin
  # Create an API test
  result = api_instance.create_synthetics_api_test(body)
  p result
rescue DatadogAPIClient::V1::APIError => e
  puts "Error when calling SyntheticsAPI->create_synthetics_api_test: #{e}"
end

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
import { v1 } from "@datadog/datadog-api-client";
import * as fs from "fs";

const configuration = v1.createConfiguration();
const apiInstance = new v1.SyntheticsApi(configuration);

let params: v1.SyntheticsApiCreateSyntheticsAPITestRequest = {
  // SyntheticsAPITest | Details of the test to create.
  body: {
    config: {
      assertions: [
        {
          operator: "contains",
          property: "property_example",
          target: null,
          type: "statusCode",
        },
      ],
      configVariables: [
        {
          example: "example_example",
          id: "id_example",
          name: "VARIABLE_NAME",
          pattern: "pattern_example",
          type: "text",
        },
      ],
      request: {
        allowInsecure: true,
        basicAuth: {
          password: "",
          username: "",
        },
        body: "body_example",
        certificate: {
          cert: {
            content: "content_example",
            filename: "filename_example",
            updatedAt: "updatedAt_example",
          },
          key: {
            content: "content_example",
            filename: "filename_example",
            updatedAt: "updatedAt_example",
          },
        },
        dnsServer: "dnsServer_example",
        dnsServerPort: 1,
        followRedirects: true,
        headers: {
          key: "key_example",
        },
        host: "host_example",
        method: "GET",
        noSavingResponseBody: true,
        numberOfPackets: 0,
        port: 1,
        query: {},
        servername: "servername_example",
        shouldTrackHops: true,
        timeout: 3.14,
        url: "https://example.com",
      },
      steps: [
        {
          allowFailure: true,
          assertions: [],
          extractedValues: [
            {
              field: "content-type",
              name: "name_example",
              parser: {
                type: "raw",
                value: "value_example",
              },
              type: "http_body",
            },
          ],
          isCritical: true,
          name: "name_example",
          request: {
            allowInsecure: true,
            basicAuth: {
              password: "",
              username: "",
            },
            body: "body_example",
            certificate: {
              cert: {
                content: "content_example",
                filename: "filename_example",
                updatedAt: "updatedAt_example",
              },
              key: {
                content: "content_example",
                filename: "filename_example",
                updatedAt: "updatedAt_example",
              },
            },
            dnsServer: "dnsServer_example",
            dnsServerPort: 1,
            followRedirects: true,
            headers: {
              key: "key_example",
            },
            host: "host_example",
            method: "GET",
            noSavingResponseBody: true,
            numberOfPackets: 0,
            port: 1,
            query: {},
            servername: "servername_example",
            shouldTrackHops: true,
            timeout: 3.14,
            url: "https://example.com",
          },
          subtype: "http",
        },
      ],
    },
    locations: ["aws:eu-west-3"],
    message: "Notification message",
    name: "Test name",
    options: {
      acceptSelfSigned: true,
      allowInsecure: true,
      deviceIds: ["laptop_large"],
      disableCors: true,
      followRedirects: true,
      minFailureDuration: 1,
      minLocationFailed: 1,
      monitorName: "monitorName_example",
      monitorOptions: {
        renotifyInterval: 0,
      },
      monitorPriority: 1,
      noScreenshot: true,
      retry: {
        count: 1,
        interval: 3.14,
      },
      tickEvery: 30,
    },
    status: "live",
    subtype: "http",
    tags: ["env:production"],
    type: "api",
  },
};

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

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"
import java.util.*;
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.SyntheticsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();

        SyntheticsApi apiInstance = new SyntheticsApi(defaultClient);
        SyntheticsAPITest body = new SyntheticsAPITest(); // SyntheticsAPITest | Details of the test to create.
        try {
            SyntheticsAPITest result = apiInstance.createSyntheticsAPITest(body);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling SyntheticsApi#createSyntheticsAPITest");
            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 and then save the example to Example.java and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"

POST https://api.datadoghq.eu/api/v1/synthetics/tests/browserhttps://api.ddog-gov.com/api/v1/synthetics/tests/browserhttps://api.datadoghq.com/api/v1/synthetics/tests/browserhttps://api.us3.datadoghq.com/api/v1/synthetics/tests/browserhttps://api.us5.datadoghq.com/api/v1/synthetics/tests/browser

Overview

Create a Synthetic browser test.

Request

Body Data (required)

Details of the test to create.

Expand All

Field

Type

Description

config

object

Configuration object for a Synthetic browser test.

assertions [required]

[object <oneOf>]

Array of assertions used for the test.

Option 1

object

An assertion which uses a simple target.

operator [required]

enum

Assertion operator to apply. Allowed enum values: contains,doesNotContain,is,isNot,lessThan,lessThanOrEqual,moreThan,moreThanOrEqual,matches,doesNotMatch,validates,isInMoreThan,isInLessThan

property

string

The associated assertion property.

target

Value used by the operator.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion,latency,packetLossPercentage,packetsReceived,networkHop

Option 2

object

An assertion for the validatesJSONPath operator.

operator [required]

enum

Assertion operator to apply. Allowed enum values: validatesJSONPath

property

string

The associated assertion property.

target

object

Composed target for validatesJSONPath operator.

jsonPath

string

The JSON path to assert.

operator

string

The specific operator to use on the path.

targetValue

The path target value to compare to.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion,latency,packetLossPercentage,packetsReceived,networkHop

configVariables

[object]

Array of variables used for the test.

example

string

Example for the variable.

id

string

ID of the variable for global variables.

name [required]

string

Name of the variable.

pattern

string

Pattern of the variable.

type [required]

enum

Type of the configuration variable. Allowed enum values: global,text

request [required]

object

Object describing the Synthetic test request.

allow_insecure

boolean

Allows loading insecure content for an HTTP request in a multistep test step.

basicAuth

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authentication.

username [required]

string

Username to use for the basic authentication.

body

string

Body to include in the test.

certificate

object

Client certificate to use when performing the test request.

cert

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

key

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

dnsServer

string

DNS server to use for DNS tests.

dnsServerPort

int32

DNS server port to use for DNS tests.

follow_redirects

boolean

Specifies whether or not the request follows redirects.

headers

object

Headers to include when performing the test.

<any-key>

string

A single Header.

host

string

Host name to perform the test with.

method

enum

The HTTP method. Allowed enum values: GET,POST,PATCH,PUT,DELETE,HEAD,OPTIONS

noSavingResponseBody

boolean

Determines whether or not to save the response body.

numberOfPackets

int32

Number of pings to use per test.

port

int64

Port to use when performing the test.

query

object

Query to use for the test.

servername

string

For SSL tests, it specifies on which server you want to initiate the TLS handshake, allowing the server to present one of multiple possible certificates on the same IP address and TCP port number.

shouldTrackHops

boolean

Turns on a traceroute probe to discover all gateways along the path to the host destination.

timeout

double

Timeout in seconds for the test.

url

string

URL to perform the test with.

setCookie

string

Cookies to be used for the request, using the Set-Cookie syntax.

variables

[object]

Array of variables used for the test steps.

example

string

Example for the variable.

id

string

ID for the variable.

name [required]

string

Name of the variable.

pattern

string

Pattern of the variable.

type [required]

enum

Type of browser test variable. Allowed enum values: element,email,global,javascript,text

locations

[string]

Array of locations used to run the test.

message [required]

string

Notification message associated with the test. Message can either be text or an empty string.

monitor_id

int64

The associated monitor ID.

name

string

Name of the test.

options

object

Object describing the extra options for a Synthetic test.

accept_self_signed

boolean

For SSL test, whether or not the test should allow self signed certificates.

allow_insecure

boolean

Allows loading insecure content for an HTTP request.

device_ids

[string]

For browser test, array with the different device IDs used to run the test.

disableCors

boolean

Whether or not to disable CORS mechanism.

follow_redirects

boolean

For API HTTP test, whether or not the test should follow redirects.

min_failure_duration

int64

Minimum amount of time in failure required to trigger an alert.

min_location_failed

int64

Minimum number of locations in failure required to trigger an alert.

monitor_name

string

The monitor name is used for the alert title as well as for all monitor dashboard widgets and SLOs.

monitor_options

object

Object containing the options for a Synthetic test as a monitor (for example, renotification).

renotify_interval

int64

Time interval before renotifying if the test is still failing (in minutes).

monitor_priority

int32

Integer from 1 (high) to 5 (low) indicating alert severity.

noScreenshot

boolean

Prevents saving screenshots of the steps.

retry

object

Object describing the retry strategy to apply to a Synthetic test.

count

int64

Number of times a test needs to be retried before marking a location as failed. Defaults to 0.

interval

double

Time interval between retries (in milliseconds). Defaults to 300ms.

tick_every

int64

The frequency at which to run the Synthetic test (in seconds).

public_id

string

The public ID of the test.

status

enum

Define whether you want to start (live) or pause (paused) a Synthetic test. Allowed enum values: live,paused

steps

[object]

The steps of the test.

allowFailure

boolean

A boolean set to allow this step to fail.

name

string

The name of the step.

params

object

The parameters of the step.

timeout

int64

The time before declaring a step failed.

type

enum

Step type used in your Synthetic test. Allowed enum values: assertCurrentUrl,assertElementAttribute,assertElementContent,assertElementPresent,assertEmail,assertFileDownload,assertFromJavascript,assertPageContains,assertPageLacks,click,extractFromJavascript,extractVariable,goToEmailLink,goToUrl,goToUrlAndMeasureTti,hover,playSubTest,pressKey,refresh,runApiTest,scroll,selectOption,typeText,uploadFiles,wait

tags

[string]

Array of tags attached to the test.

type

enum

Type of the Synthetic test, browser. Allowed enum values: browser

{
  "config": {
    "assertions": [
      {
        "operator": "contains",
        "property": "string",
        "target": "undefined",
        "type": "statusCode"
      }
    ],
    "configVariables": [
      {
        "example": "string",
        "id": "string",
        "name": "VARIABLE_NAME",
        "pattern": "string",
        "type": "text"
      }
    ],
    "request": {
      "allow_insecure": false,
      "basicAuth": {
        "password": "",
        "username": ""
      },
      "body": "string",
      "certificate": {
        "cert": {
          "content": "string",
          "filename": "string",
          "updatedAt": "string"
        },
        "key": {
          "content": "string",
          "filename": "string",
          "updatedAt": "string"
        }
      },
      "dnsServer": "string",
      "dnsServerPort": "integer",
      "follow_redirects": false,
      "headers": {
        "<any-key>": "string"
      },
      "host": "string",
      "method": "GET",
      "noSavingResponseBody": false,
      "numberOfPackets": "integer",
      "port": "integer",
      "query": {},
      "servername": "string",
      "shouldTrackHops": false,
      "timeout": "number",
      "url": "https://example.com"
    },
    "setCookie": "string",
    "variables": [
      {
        "example": "string",
        "id": "string",
        "name": "VARIABLE_NAME",
        "pattern": "string",
        "type": "text"
      }
    ]
  },
  "locations": [],
  "message": "",
  "name": "string",
  "options": {
    "accept_self_signed": false,
    "allow_insecure": false,
    "device_ids": [
      "laptop_large"
    ],
    "disableCors": false,
    "follow_redirects": false,
    "min_failure_duration": "integer",
    "min_location_failed": "integer",
    "monitor_name": "string",
    "monitor_options": {
      "renotify_interval": "integer"
    },
    "monitor_priority": "integer",
    "noScreenshot": false,
    "retry": {
      "count": "integer",
      "interval": "number"
    },
    "tick_every": "integer"
  },
  "status": "live",
  "steps": [
    {
      "allowFailure": false,
      "name": "string",
      "params": {},
      "timeout": "integer",
      "type": "assertElementContent"
    }
  ],
  "tags": [],
  "type": "browser"
}

Response

OK - Returns the created test details.

Object containing details about a Synthetic browser test.

Expand All

Field

Type

Description

config

object

Configuration object for a Synthetic browser test.

assertions [required]

[object <oneOf>]

Array of assertions used for the test.

Option 1

object

An assertion which uses a simple target.

operator [required]

enum

Assertion operator to apply. Allowed enum values: contains,doesNotContain,is,isNot,lessThan,lessThanOrEqual,moreThan,moreThanOrEqual,matches,doesNotMatch,validates,isInMoreThan,isInLessThan

property

string

The associated assertion property.

target

Value used by the operator.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion,latency,packetLossPercentage,packetsReceived,networkHop

Option 2

object

An assertion for the validatesJSONPath operator.

operator [required]

enum

Assertion operator to apply. Allowed enum values: validatesJSONPath

property

string

The associated assertion property.

target

object

Composed target for validatesJSONPath operator.

jsonPath

string

The JSON path to assert.

operator

string

The specific operator to use on the path.

targetValue

The path target value to compare to.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion,latency,packetLossPercentage,packetsReceived,networkHop

configVariables

[object]

Array of variables used for the test.

example

string

Example for the variable.

id

string

ID of the variable for global variables.

name [required]

string

Name of the variable.

pattern

string

Pattern of the variable.

type [required]

enum

Type of the configuration variable. Allowed enum values: global,text

request [required]

object

Object describing the Synthetic test request.

allow_insecure

boolean

Allows loading insecure content for an HTTP request in a multistep test step.

basicAuth

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authentication.

username [required]

string

Username to use for the basic authentication.

body

string

Body to include in the test.

certificate

object

Client certificate to use when performing the test request.

cert

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

key

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

dnsServer

string

DNS server to use for DNS tests.

dnsServerPort

int32

DNS server port to use for DNS tests.

follow_redirects

boolean

Specifies whether or not the request follows redirects.

headers

object

Headers to include when performing the test.

<any-key>

string

A single Header.

host

string

Host name to perform the test with.

method

enum

The HTTP method. Allowed enum values: GET,POST,PATCH,PUT,DELETE,HEAD,OPTIONS

noSavingResponseBody

boolean

Determines whether or not to save the response body.

numberOfPackets

int32

Number of pings to use per test.

port

int64

Port to use when performing the test.

query

object

Query to use for the test.

servername

string

For SSL tests, it specifies on which server you want to initiate the TLS handshake, allowing the server to present one of multiple possible certificates on the same IP address and TCP port number.

shouldTrackHops

boolean

Turns on a traceroute probe to discover all gateways along the path to the host destination.

timeout

double

Timeout in seconds for the test.

url

string

URL to perform the test with.

setCookie

string

Cookies to be used for the request, using the Set-Cookie syntax.

variables

[object]

Array of variables used for the test steps.

example

string

Example for the variable.

id

string

ID for the variable.

name [required]

string

Name of the variable.

pattern

string

Pattern of the variable.

type [required]

enum

Type of browser test variable. Allowed enum values: element,email,global,javascript,text

locations

[string]

Array of locations used to run the test.

message [required]

string

Notification message associated with the test. Message can either be text or an empty string.

monitor_id

int64

The associated monitor ID.

name

string

Name of the test.

options

object

Object describing the extra options for a Synthetic test.

accept_self_signed

boolean

For SSL test, whether or not the test should allow self signed certificates.

allow_insecure

boolean

Allows loading insecure content for an HTTP request.

device_ids

[string]

For browser test, array with the different device IDs used to run the test.

disableCors

boolean

Whether or not to disable CORS mechanism.

follow_redirects

boolean

For API HTTP test, whether or not the test should follow redirects.

min_failure_duration

int64

Minimum amount of time in failure required to trigger an alert.

min_location_failed

int64

Minimum number of locations in failure required to trigger an alert.

monitor_name

string

The monitor name is used for the alert title as well as for all monitor dashboard widgets and SLOs.

monitor_options

object

Object containing the options for a Synthetic test as a monitor (for example, renotification).

renotify_interval

int64

Time interval before renotifying if the test is still failing (in minutes).

monitor_priority

int32

Integer from 1 (high) to 5 (low) indicating alert severity.

noScreenshot

boolean

Prevents saving screenshots of the steps.

retry

object

Object describing the retry strategy to apply to a Synthetic test.

count

int64

Number of times a test needs to be retried before marking a location as failed. Defaults to 0.

interval

double

Time interval between retries (in milliseconds). Defaults to 300ms.

tick_every

int64

The frequency at which to run the Synthetic test (in seconds).

public_id

string

The public ID of the test.

status

enum

Define whether you want to start (live) or pause (paused) a Synthetic test. Allowed enum values: live,paused

steps

[object]

The steps of the test.

allowFailure

boolean

A boolean set to allow this step to fail.

name

string

The name of the step.

params

object

The parameters of the step.

timeout

int64

The time before declaring a step failed.

type

enum

Step type used in your Synthetic test. Allowed enum values: assertCurrentUrl,assertElementAttribute,assertElementContent,assertElementPresent,assertEmail,assertFileDownload,assertFromJavascript,assertPageContains,assertPageLacks,click,extractFromJavascript,extractVariable,goToEmailLink,goToUrl,goToUrlAndMeasureTti,hover,playSubTest,pressKey,refresh,runApiTest,scroll,selectOption,typeText,uploadFiles,wait

tags

[string]

Array of tags attached to the test.

type

enum

Type of the Synthetic test, browser. Allowed enum values: browser

{
  "config": {
    "assertions": [
      {
        "operator": "contains",
        "property": "string",
        "target": "undefined",
        "type": "statusCode"
      }
    ],
    "configVariables": [
      {
        "example": "string",
        "id": "string",
        "name": "VARIABLE_NAME",
        "pattern": "string",
        "type": "text"
      }
    ],
    "request": {
      "allow_insecure": false,
      "basicAuth": {
        "password": "",
        "username": ""
      },
      "body": "string",
      "certificate": {
        "cert": {
          "content": "string",
          "filename": "string",
          "updatedAt": "string"
        },
        "key": {
          "content": "string",
          "filename": "string",
          "updatedAt": "string"
        }
      },
      "dnsServer": "string",
      "dnsServerPort": "integer",
      "follow_redirects": false,
      "headers": {
        "<any-key>": "string"
      },
      "host": "string",
      "method": "GET",
      "noSavingResponseBody": false,
      "numberOfPackets": "integer",
      "port": "integer",
      "query": {},
      "servername": "string",
      "shouldTrackHops": false,
      "timeout": "number",
      "url": "https://example.com"
    },
    "setCookie": "string",
    "variables": [
      {
        "example": "string",
        "id": "string",
        "name": "VARIABLE_NAME",
        "pattern": "string",
        "type": "text"
      }
    ]
  },
  "locations": [],
  "message": "",
  "monitor_id": "integer",
  "name": "string",
  "options": {
    "accept_self_signed": false,
    "allow_insecure": false,
    "device_ids": [
      "laptop_large"
    ],
    "disableCors": false,
    "follow_redirects": false,
    "min_failure_duration": "integer",
    "min_location_failed": "integer",
    "monitor_name": "string",
    "monitor_options": {
      "renotify_interval": "integer"
    },
    "monitor_priority": "integer",
    "noScreenshot": false,
    "retry": {
      "count": "integer",
      "interval": "number"
    },
    "tick_every": "integer"
  },
  "public_id": "string",
  "status": "live",
  "steps": [
    {
      "allowFailure": false,
      "name": "string",
      "params": {},
      "timeout": "integer",
      "type": "assertElementContent"
    }
  ],
  "tags": [],
  "type": "browser"
}

- JSON format is wrong - Creation failed

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Test quota is reached

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Forbidden

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Code Example


# Curl command
curl -X POST "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/synthetics/tests/browser" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
  "config": {
    "assertions": [
      {}
    ],
    "configVariables": [
      {
        "name": "VARIABLE_NAME",
        "type": "text"
      }
    ],
    "request": {
      "basicAuth": {
        "password": "",
        "username": ""
      }
    },
    "variables": [
      {
        "name": "VARIABLE_NAME",
        "type": "text"
      }
    ]
  },
  "message": ""
}
EOF
package main

import (
    "context"
    "encoding/json"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := datadog.NewDefaultContext(context.Background())

    body := *datadog.NewSyntheticsBrowserTest("Message_example") // SyntheticsBrowserTest | Details of the test to create.

    configuration := datadog.NewConfiguration()

    apiClient := datadog.NewAPIClient(configuration)
    resp, r, err := apiClient.SyntheticsApi.CreateSyntheticsBrowserTest(ctx, body)
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.CreateSyntheticsBrowserTest`: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `CreateSyntheticsBrowserTest`: SyntheticsBrowserTest
    responseContent, _ := json.MarshalIndent(resp, "", "  ")
    fmt.Fprintf(os.Stdout, "Response from SyntheticsApi.CreateSyntheticsBrowserTest:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
import os
from dateutil.parser import parse as dateutil_parser
from datadog_api_client.v1 import ApiClient, ApiException, Configuration
from datadog_api_client.v1.api import synthetics_api
from datadog_api_client.v1.models import *
from pprint import pprint
# See configuration.py for a list of all supported configuration parameters.
configuration = Configuration()

# Enter a context with an instance of the API client
with ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = synthetics_api.SyntheticsApi(api_client)
    body = SyntheticsBrowserTest(
        config=SyntheticsBrowserTestConfig(
            assertions=[
                SyntheticsAssertion(),
            ],
            config_variables=[
                SyntheticsConfigVariable(
                    example="example_example",
                    id="id_example",
                    name="VARIABLE_NAME",
                    pattern="pattern_example",
                    type=SyntheticsConfigVariableType("text"),
                ),
            ],
            request=SyntheticsTestRequest(
                allow_insecure=True,
                basic_auth=SyntheticsBasicAuth(
                    password="",
                    username="",
                ),
                body="body_example",
                certificate=SyntheticsTestRequestCertificate(
                    cert=SyntheticsTestRequestCertificateItem(
                        content="content_example",
                        filename="filename_example",
                        updated_at="updated_at_example",
                    ),
                    key=SyntheticsTestRequestCertificateItem(
                        content="content_example",
                        filename="filename_example",
                        updated_at="updated_at_example",
                    ),
                ),
                dns_server="dns_server_example",
                dns_server_port=1,
                follow_redirects=True,
                headers=SyntheticsTestHeaders(
                    key="key_example",
                ),
                host="host_example",
                method=HTTPMethod("GET"),
                no_saving_response_body=True,
                number_of_packets=0,
                port=1,
                query={},
                servername="servername_example",
                should_track_hops=True,
                timeout=3.14,
                url="https://example.com",
            ),
            set_cookie="set_cookie_example",
            variables=[
                SyntheticsBrowserVariable(
                    example="example_example",
                    id="id_example",
                    name="VARIABLE_NAME",
                    pattern="pattern_example",
                    type=SyntheticsBrowserVariableType("text"),
                ),
            ],
        ),
        locations=[
            "locations_example",
        ],
        message="",
        name="name_example",
        options=SyntheticsTestOptions(
            accept_self_signed=True,
            allow_insecure=True,
            device_ids=[
                SyntheticsDeviceID("laptop_large"),
            ],
            disable_cors=True,
            follow_redirects=True,
            min_failure_duration=1,
            min_location_failed=1,
            monitor_name="monitor_name_example",
            monitor_options=SyntheticsTestOptionsMonitorOptions(
                renotify_interval=0,
            ),
            monitor_priority=1,
            no_screenshot=True,
            retry=SyntheticsTestOptionsRetry(
                count=1,
                interval=3.14,
            ),
            tick_every=30,
        ),
        status=SyntheticsTestPauseStatus("live"),
        steps=[
            SyntheticsStep(
                allow_failure=True,
                name="name_example",
                params={},
                timeout=1,
                type=SyntheticsStepType("assertElementContent"),
            ),
        ],
        tags=[
            "tags_example",
        ],
        type=SyntheticsBrowserTestType("browser"),
    )  # SyntheticsBrowserTest | Details of the test to create.

    # example passing only required values which don't have defaults set
    try:
        # Create a browser test
        api_response = api_instance.create_synthetics_browser_test(body)
        pprint(api_response)
    except ApiException as e:
        print("Exception when calling SyntheticsApi->create_synthetics_browser_test: %s\n" % e)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
require 'datadog_api_client'
api_instance = DatadogAPIClient::V1::SyntheticsAPI.new
body = DatadogAPIClient::V1::SyntheticsBrowserTest.new({message: 'message_example'}) # SyntheticsBrowserTest | Details of the test to create.

begin
  # Create a browser test
  result = api_instance.create_synthetics_browser_test(body)
  p result
rescue DatadogAPIClient::V1::APIError => e
  puts "Error when calling SyntheticsAPI->create_synthetics_browser_test: #{e}"
end

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
import { v1 } from "@datadog/datadog-api-client";
import * as fs from "fs";

const configuration = v1.createConfiguration();
const apiInstance = new v1.SyntheticsApi(configuration);

let params: v1.SyntheticsApiCreateSyntheticsBrowserTestRequest = {
  // SyntheticsBrowserTest | Details of the test to create.
  body: {
    config: {
      assertions: [],
      configVariables: [
        {
          example: "example_example",
          id: "id_example",
          name: "VARIABLE_NAME",
          pattern: "pattern_example",
          type: "text",
        },
      ],
      request: {
        allowInsecure: true,
        basicAuth: {
          password: "",
          username: "",
        },
        body: "body_example",
        certificate: {
          cert: {
            content: "content_example",
            filename: "filename_example",
            updatedAt: "updatedAt_example",
          },
          key: {
            content: "content_example",
            filename: "filename_example",
            updatedAt: "updatedAt_example",
          },
        },
        dnsServer: "dnsServer_example",
        dnsServerPort: 1,
        followRedirects: true,
        headers: {
          key: "key_example",
        },
        host: "host_example",
        method: "GET",
        noSavingResponseBody: true,
        numberOfPackets: 0,
        port: 1,
        query: {},
        servername: "servername_example",
        shouldTrackHops: true,
        timeout: 3.14,
        url: "https://example.com",
      },
      setCookie: "setCookie_example",
      variables: [
        {
          example: "example_example",
          id: "id_example",
          name: "VARIABLE_NAME",
          pattern: "pattern_example",
          type: "text",
        },
      ],
    },
    locations: ["locations_example"],
    message: "",
    name: "name_example",
    options: {
      acceptSelfSigned: true,
      allowInsecure: true,
      deviceIds: ["laptop_large"],
      disableCors: true,
      followRedirects: true,
      minFailureDuration: 1,
      minLocationFailed: 1,
      monitorName: "monitorName_example",
      monitorOptions: {
        renotifyInterval: 0,
      },
      monitorPriority: 1,
      noScreenshot: true,
      retry: {
        count: 1,
        interval: 3.14,
      },
      tickEvery: 30,
    },
    status: "live",
    steps: [
      {
        allowFailure: true,
        name: "name_example",
        params: {},
        timeout: 1,
        type: "assertElementContent",
      },
    ],
    tags: ["tags_example"],
    type: "browser",
  },
};

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

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"
import java.util.*;
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.SyntheticsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();

        SyntheticsApi apiInstance = new SyntheticsApi(defaultClient);
        SyntheticsBrowserTest body = new SyntheticsBrowserTest(); // SyntheticsBrowserTest | Details of the test to create.
        try {
            SyntheticsBrowserTest result = apiInstance.createSyntheticsBrowserTest(body);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling SyntheticsApi#createSyntheticsBrowserTest");
            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 and then save the example to Example.java and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"

PUT https://api.datadoghq.eu/api/v1/synthetics/tests/api/{public_id}https://api.ddog-gov.com/api/v1/synthetics/tests/api/{public_id}https://api.datadoghq.com/api/v1/synthetics/tests/api/{public_id}https://api.us3.datadoghq.com/api/v1/synthetics/tests/api/{public_id}https://api.us5.datadoghq.com/api/v1/synthetics/tests/api/{public_id}

Overview

Edit the configuration of a Synthetic API test.

Arguments

Path Parameters

Name

Type

Description

public_id [required]

string

The public ID of the test to get details from.

Request

Body Data (required)

New test details to be saved.

Expand All

Field

Type

Description

config

object

Configuration object for a Synthetic API test.

assertions

[object <oneOf>]

Array of assertions used for the test.

Option 1

object

An assertion which uses a simple target.

operator [required]

enum

Assertion operator to apply. Allowed enum values: contains,doesNotContain,is,isNot,lessThan,lessThanOrEqual,moreThan,moreThanOrEqual,matches,doesNotMatch,validates,isInMoreThan,isInLessThan

property

string

The associated assertion property.

target

Value used by the operator.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion,latency,packetLossPercentage,packetsReceived,networkHop

Option 2

object

An assertion for the validatesJSONPath operator.

operator [required]

enum

Assertion operator to apply. Allowed enum values: validatesJSONPath

property

string

The associated assertion property.

target

object

Composed target for validatesJSONPath operator.

jsonPath

string

The JSON path to assert.

operator

string

The specific operator to use on the path.

targetValue

The path target value to compare to.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion,latency,packetLossPercentage,packetsReceived,networkHop

configVariables

[object]

Array of variables used for the test.

example

string

Example for the variable.

id

string

ID of the variable for global variables.

name [required]

string

Name of the variable.

pattern

string

Pattern of the variable.

type [required]

enum

Type of the configuration variable. Allowed enum values: global,text

request

object

Object describing the Synthetic test request.

allow_insecure

boolean

Allows loading insecure content for an HTTP request in a multistep test step.

basicAuth

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authentication.

username [required]

string

Username to use for the basic authentication.

body

string

Body to include in the test.

certificate

object

Client certificate to use when performing the test request.

cert

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

key

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

dnsServer

string

DNS server to use for DNS tests.

dnsServerPort

int32

DNS server port to use for DNS tests.

follow_redirects

boolean

Specifies whether or not the request follows redirects.

headers

object

Headers to include when performing the test.

<any-key>

string

A single Header.

host

string

Host name to perform the test with.

method

enum

The HTTP method. Allowed enum values: GET,POST,PATCH,PUT,DELETE,HEAD,OPTIONS

noSavingResponseBody

boolean

Determines whether or not to save the response body.

numberOfPackets

int32

Number of pings to use per test.

port

int64

Port to use when performing the test.

query

object

Query to use for the test.

servername

string

For SSL tests, it specifies on which server you want to initiate the TLS handshake, allowing the server to present one of multiple possible certificates on the same IP address and TCP port number.

shouldTrackHops

boolean

Turns on a traceroute probe to discover all gateways along the path to the host destination.

timeout

double

Timeout in seconds for the test.

url

string

URL to perform the test with.

steps

[object]

When the test subtype is multi, the steps of the test.

allowFailure

boolean

Determines whether or not to continue with test if this step fails.

assertions

[object <oneOf>]

Array of assertions used for the test.

Option 1

object

An assertion which uses a simple target.

operator [required]

enum

Assertion operator to apply. Allowed enum values: contains,doesNotContain,is,isNot,lessThan,lessThanOrEqual,moreThan,moreThanOrEqual,matches,doesNotMatch,validates,isInMoreThan,isInLessThan

property

string

The associated assertion property.

target

Value used by the operator.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion,latency,packetLossPercentage,packetsReceived,networkHop

Option 2

object

An assertion for the validatesJSONPath operator.

operator [required]

enum

Assertion operator to apply. Allowed enum values: validatesJSONPath

property

string

The associated assertion property.

target

object

Composed target for validatesJSONPath operator.

jsonPath

string

The JSON path to assert.

operator

string

The specific operator to use on the path.

targetValue

The path target value to compare to.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion,latency,packetLossPercentage,packetsReceived,networkHop

extractedValues

[object]

Array of values to parse and save as variables from the response.

field

string

When type is http_header, name of the header to use to extract the value.

name

string

Name of the variable to extract.

parser

object

Details of the parser to use for the global variable.

type [required]

enum

Type of parser for a Synthetics global variable from a synthetics test. Allowed enum values: raw,json_path,regex,x_path

value

string

Regex or JSON path used for the parser. Not used with type raw.

type

enum

Property of the Synthetics Test Response to use for a Synthetics global variable. Allowed enum values: http_body,http_header

isCritical

boolean

Determines whether or not to consider the entire test as failed if this step fails. Can be used only if allowFailure is true.

name

string

The name of the step.

request

object

Object describing the Synthetic test request.

allow_insecure

boolean

Allows loading insecure content for an HTTP request in a multistep test step.

basicAuth

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authentication.

username [required]

string

Username to use for the basic authentication.

body

string

Body to include in the test.

certificate

object

Client certificate to use when performing the test request.

cert

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

key

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

dnsServer

string

DNS server to use for DNS tests.

dnsServerPort

int32

DNS server port to use for DNS tests.

follow_redirects

boolean

Specifies whether or not the request follows redirects.

headers

object

Headers to include when performing the test.

<any-key>

string

A single Header.

host

string

Host name to perform the test with.

method

enum

The HTTP method. Allowed enum values: GET,POST,PATCH,PUT,DELETE,HEAD,OPTIONS

noSavingResponseBody

boolean

Determines whether or not to save the response body.

numberOfPackets

int32

Number of pings to use per test.

port

int64

Port to use when performing the test.

query

object

Query to use for the test.

servername

string

For SSL tests, it specifies on which server you want to initiate the TLS handshake, allowing the server to present one of multiple possible certificates on the same IP address and TCP port number.

shouldTrackHops

boolean

Turns on a traceroute probe to discover all gateways along the path to the host destination.

timeout

double

Timeout in seconds for the test.

url

string

URL to perform the test with.

subtype

enum

The subtype of the Synthetic multistep API test step, currently only supporting http. Allowed enum values: http

locations

[string]

Array of locations used to run the test.

message

string

Notification message associated with the test.

monitor_id

int64

The associated monitor ID.

name

string

Name of the test.

options

object

Object describing the extra options for a Synthetic test.

accept_self_signed

boolean

For SSL test, whether or not the test should allow self signed certificates.

allow_insecure

boolean

Allows loading insecure content for an HTTP request.

device_ids

[string]

For browser test, array with the different device IDs used to run the test.

disableCors

boolean

Whether or not to disable CORS mechanism.

follow_redirects

boolean

For API HTTP test, whether or not the test should follow redirects.

min_failure_duration

int64

Minimum amount of time in failure required to trigger an alert.

min_location_failed

int64

Minimum number of locations in failure required to trigger an alert.

monitor_name

string

The monitor name is used for the alert title as well as for all monitor dashboard widgets and SLOs.

monitor_options

object

Object containing the options for a Synthetic test as a monitor (for example, renotification).

renotify_interval

int64

Time interval before renotifying if the test is still failing (in minutes).

monitor_priority

int32

Integer from 1 (high) to 5 (low) indicating alert severity.

noScreenshot

boolean

Prevents saving screenshots of the steps.

retry

object

Object describing the retry strategy to apply to a Synthetic test.

count

int64

Number of times a test needs to be retried before marking a location as failed. Defaults to 0.

interval

double

Time interval between retries (in milliseconds). Defaults to 300ms.

tick_every

int64

The frequency at which to run the Synthetic test (in seconds).

public_id

string

The public ID for the test.

status

enum

Define whether you want to start (live) or pause (paused) a Synthetic test. Allowed enum values: live,paused

subtype

enum

The subtype of the Synthetic API test, http, ssl, tcp, dns, icmp or multi. Allowed enum values: http,ssl,tcp,dns,multi,icmp

tags

[string]

Array of tags attached to the test.

type

enum

Type of the Synthetic test, api. Allowed enum values: api

{
  "config": {
    "assertions": [
      []
    ],
    "configVariables": [
      {
        "example": "string",
        "id": "string",
        "name": "VARIABLE_NAME",
        "pattern": "string",
        "type": "text"
      }
    ],
    "request": {
      "allow_insecure": false,
      "basicAuth": {
        "password": "",
        "username": ""
      },
      "body": "string",
      "certificate": {
        "cert": {
          "content": "string",
          "filename": "string",
          "updatedAt": "string"
        },
        "key": {
          "content": "string",
          "filename": "string",
          "updatedAt": "string"
        }
      },
      "dnsServer": "string",
      "dnsServerPort": "integer",
      "follow_redirects": false,
      "headers": {
        "<any-key>": "string"
      },
      "host": "string",
      "method": "GET",
      "noSavingResponseBody": false,
      "numberOfPackets": "integer",
      "port": "integer",
      "query": {},
      "servername": "string",
      "shouldTrackHops": false,
      "timeout": "number",
      "url": "https://example.com"
    },
    "steps": [
      {
        "allowFailure": false,
        "assertions": [
          {
            "operator": "contains",
            "property": "string",
            "target": "undefined",
            "type": "statusCode"
          }
        ],
        "extractedValues": [
          {
            "field": "content-type",
            "name": "string",
            "parser": {
              "type": "raw",
              "value": "string"
            },
            "type": "http_body"
          }
        ],
        "isCritical": false,
        "name": "string",
        "request": {
          "allow_insecure": false,
          "basicAuth": {
            "password": "",
            "username": ""
          },
          "body": "string",
          "certificate": {
            "cert": {
              "content": "string",
              "filename": "string",
              "updatedAt": "string"
            },
            "key": {
              "content": "string",
              "filename": "string",
              "updatedAt": "string"
            }
          },
          "dnsServer": "string",
          "dnsServerPort": "integer",
          "follow_redirects": false,
          "headers": {
            "<any-key>": "string"
          },
          "host": "string",
          "method": "GET",
          "noSavingResponseBody": false,
          "numberOfPackets": "integer",
          "port": "integer",
          "query": {},
          "servername": "string",
          "shouldTrackHops": false,
          "timeout": "number",
          "url": "https://example.com"
        },
        "subtype": "string"
      }
    ]
  },
  "locations": [
    "aws:eu-west-3"
  ],
  "message": "Notification message",
  "name": "Test name",
  "options": {
    "accept_self_signed": false,
    "allow_insecure": false,
    "device_ids": [
      "laptop_large"
    ],
    "disableCors": false,
    "follow_redirects": false,
    "min_failure_duration": "integer",
    "min_location_failed": "integer",
    "monitor_name": "string",
    "monitor_options": {
      "renotify_interval": "integer"
    },
    "monitor_priority": "integer",
    "noScreenshot": false,
    "retry": {
      "count": "integer",
      "interval": "number"
    },
    "tick_every": "integer"
  },
  "status": "live",
  "subtype": "http",
  "tags": [
    "env:production"
  ],
  "type": "api"
}

Response

OK

Object containing details about a Synthetic API test.

Expand All

Field

Type

Description

config

object

Configuration object for a Synthetic API test.

assertions

[object <oneOf>]

Array of assertions used for the test.

Option 1

object

An assertion which uses a simple target.

operator [required]

enum

Assertion operator to apply. Allowed enum values: contains,doesNotContain,is,isNot,lessThan,lessThanOrEqual,moreThan,moreThanOrEqual,matches,doesNotMatch,validates,isInMoreThan,isInLessThan

property

string

The associated assertion property.

target

Value used by the operator.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion,latency,packetLossPercentage,packetsReceived,networkHop

Option 2

object

An assertion for the validatesJSONPath operator.

operator [required]

enum

Assertion operator to apply. Allowed enum values: validatesJSONPath

property

string

The associated assertion property.

target

object

Composed target for validatesJSONPath operator.

jsonPath

string

The JSON path to assert.

operator

string

The specific operator to use on the path.

targetValue

The path target value to compare to.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion,latency,packetLossPercentage,packetsReceived,networkHop

configVariables

[object]

Array of variables used for the test.

example

string

Example for the variable.

id

string

ID of the variable for global variables.

name [required]

string

Name of the variable.

pattern

string

Pattern of the variable.

type [required]

enum

Type of the configuration variable. Allowed enum values: global,text

request

object

Object describing the Synthetic test request.

allow_insecure

boolean

Allows loading insecure content for an HTTP request in a multistep test step.

basicAuth

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authentication.

username [required]

string

Username to use for the basic authentication.

body

string

Body to include in the test.

certificate

object

Client certificate to use when performing the test request.

cert

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

key

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

dnsServer

string

DNS server to use for DNS tests.

dnsServerPort

int32

DNS server port to use for DNS tests.

follow_redirects

boolean

Specifies whether or not the request follows redirects.

headers

object

Headers to include when performing the test.

<any-key>

string

A single Header.

host

string

Host name to perform the test with.

method

enum

The HTTP method. Allowed enum values: GET,POST,PATCH,PUT,DELETE,HEAD,OPTIONS

noSavingResponseBody

boolean

Determines whether or not to save the response body.

numberOfPackets

int32

Number of pings to use per test.

port

int64

Port to use when performing the test.

query

object

Query to use for the test.

servername

string

For SSL tests, it specifies on which server you want to initiate the TLS handshake, allowing the server to present one of multiple possible certificates on the same IP address and TCP port number.

shouldTrackHops

boolean

Turns on a traceroute probe to discover all gateways along the path to the host destination.

timeout

double

Timeout in seconds for the test.

url

string

URL to perform the test with.

steps

[object]

When the test subtype is multi, the steps of the test.

allowFailure

boolean

Determines whether or not to continue with test if this step fails.

assertions

[object <oneOf>]

Array of assertions used for the test.

Option 1

object

An assertion which uses a simple target.

operator [required]

enum

Assertion operator to apply. Allowed enum values: contains,doesNotContain,is,isNot,lessThan,lessThanOrEqual,moreThan,moreThanOrEqual,matches,doesNotMatch,validates,isInMoreThan,isInLessThan

property

string

The associated assertion property.

target

Value used by the operator.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion,latency,packetLossPercentage,packetsReceived,networkHop

Option 2

object

An assertion for the validatesJSONPath operator.

operator [required]

enum

Assertion operator to apply. Allowed enum values: validatesJSONPath

property

string

The associated assertion property.

target

object

Composed target for validatesJSONPath operator.

jsonPath

string

The JSON path to assert.

operator

string

The specific operator to use on the path.

targetValue

The path target value to compare to.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion,latency,packetLossPercentage,packetsReceived,networkHop

extractedValues

[object]

Array of values to parse and save as variables from the response.

field

string

When type is http_header, name of the header to use to extract the value.

name

string

Name of the variable to extract.

parser

object

Details of the parser to use for the global variable.

type [required]

enum

Type of parser for a Synthetics global variable from a synthetics test. Allowed enum values: raw,json_path,regex,x_path

value

string

Regex or JSON path used for the parser. Not used with type raw.

type

enum

Property of the Synthetics Test Response to use for a Synthetics global variable. Allowed enum values: http_body,http_header

isCritical

boolean

Determines whether or not to consider the entire test as failed if this step fails. Can be used only if allowFailure is true.

name

string

The name of the step.

request

object

Object describing the Synthetic test request.

allow_insecure

boolean

Allows loading insecure content for an HTTP request in a multistep test step.

basicAuth

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authentication.

username [required]

string

Username to use for the basic authentication.

body

string

Body to include in the test.

certificate

object

Client certificate to use when performing the test request.

cert

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

key

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

dnsServer

string

DNS server to use for DNS tests.

dnsServerPort

int32

DNS server port to use for DNS tests.

follow_redirects

boolean

Specifies whether or not the request follows redirects.

headers

object

Headers to include when performing the test.

<any-key>

string

A single Header.

host

string

Host name to perform the test with.

method

enum

The HTTP method. Allowed enum values: GET,POST,PATCH,PUT,DELETE,HEAD,OPTIONS

noSavingResponseBody

boolean

Determines whether or not to save the response body.

numberOfPackets

int32

Number of pings to use per test.

port

int64

Port to use when performing the test.

query

object

Query to use for the test.

servername

string

For SSL tests, it specifies on which server you want to initiate the TLS handshake, allowing the server to present one of multiple possible certificates on the same IP address and TCP port number.

shouldTrackHops

boolean

Turns on a traceroute probe to discover all gateways along the path to the host destination.

timeout

double

Timeout in seconds for the test.

url

string

URL to perform the test with.

subtype

enum

The subtype of the Synthetic multistep API test step, currently only supporting http. Allowed enum values: http

locations

[string]

Array of locations used to run the test.

message

string

Notification message associated with the test.

monitor_id

int64

The associated monitor ID.

name

string

Name of the test.

options

object

Object describing the extra options for a Synthetic test.

accept_self_signed

boolean

For SSL test, whether or not the test should allow self signed certificates.

allow_insecure

boolean

Allows loading insecure content for an HTTP request.

device_ids

[string]

For browser test, array with the different device IDs used to run the test.

disableCors

boolean

Whether or not to disable CORS mechanism.

follow_redirects

boolean

For API HTTP test, whether or not the test should follow redirects.

min_failure_duration

int64

Minimum amount of time in failure required to trigger an alert.

min_location_failed

int64

Minimum number of locations in failure required to trigger an alert.

monitor_name

string

The monitor name is used for the alert title as well as for all monitor dashboard widgets and SLOs.

monitor_options

object

Object containing the options for a Synthetic test as a monitor (for example, renotification).

renotify_interval

int64

Time interval before renotifying if the test is still failing (in minutes).

monitor_priority

int32

Integer from 1 (high) to 5 (low) indicating alert severity.

noScreenshot

boolean

Prevents saving screenshots of the steps.

retry

object

Object describing the retry strategy to apply to a Synthetic test.

count

int64

Number of times a test needs to be retried before marking a location as failed. Defaults to 0.

interval

double

Time interval between retries (in milliseconds). Defaults to 300ms.

tick_every

int64

The frequency at which to run the Synthetic test (in seconds).

public_id

string

The public ID for the test.

status

enum

Define whether you want to start (live) or pause (paused) a Synthetic test. Allowed enum values: live,paused

subtype

enum

The subtype of the Synthetic API test, http, ssl, tcp, dns, icmp or multi. Allowed enum values: http,ssl,tcp,dns,multi,icmp

tags

[string]

Array of tags attached to the test.

type

enum

Type of the Synthetic test, api. Allowed enum values: api

{
  "config": {
    "assertions": [
      []
    ],
    "configVariables": [
      {
        "example": "string",
        "id": "string",
        "name": "VARIABLE_NAME",
        "pattern": "string",
        "type": "text"
      }
    ],
    "request": {
      "allow_insecure": false,
      "basicAuth": {
        "password": "",
        "username": ""
      },
      "body": "string",
      "certificate": {
        "cert": {
          "content": "string",
          "filename": "string",
          "updatedAt": "string"
        },
        "key": {
          "content": "string",
          "filename": "string",
          "updatedAt": "string"
        }
      },
      "dnsServer": "string",
      "dnsServerPort": "integer",
      "follow_redirects": false,
      "headers": {
        "<any-key>": "string"
      },
      "host": "string",
      "method": "GET",
      "noSavingResponseBody": false,
      "numberOfPackets": "integer",
      "port": "integer",
      "query": {},
      "servername": "string",
      "shouldTrackHops": false,
      "timeout": "number",
      "url": "https://example.com"
    },
    "steps": [
      {
        "allowFailure": false,
        "assertions": [
          {
            "operator": "contains",
            "property": "string",
            "target": "undefined",
            "type": "statusCode"
          }
        ],
        "extractedValues": [
          {
            "field": "content-type",
            "name": "string",
            "parser": {
              "type": "raw",
              "value": "string"
            },
            "type": "http_body"
          }
        ],
        "isCritical": false,
        "name": "string",
        "request": {
          "allow_insecure": false,
          "basicAuth": {
            "password": "",
            "username": ""
          },
          "body": "string",
          "certificate": {
            "cert": {
              "content": "string",
              "filename": "string",
              "updatedAt": "string"
            },
            "key": {
              "content": "string",
              "filename": "string",
              "updatedAt": "string"
            }
          },
          "dnsServer": "string",
          "dnsServerPort": "integer",
          "follow_redirects": false,
          "headers": {
            "<any-key>": "string"
          },
          "host": "string",
          "method": "GET",
          "noSavingResponseBody": false,
          "numberOfPackets": "integer",
          "port": "integer",
          "query": {},
          "servername": "string",
          "shouldTrackHops": false,
          "timeout": "number",
          "url": "https://example.com"
        },
        "subtype": "string"
      }
    ]
  },
  "locations": [
    "aws:eu-west-3"
  ],
  "message": "Notification message",
  "monitor_id": 12345678,
  "name": "Test name",
  "options": {
    "accept_self_signed": false,
    "allow_insecure": false,
    "device_ids": [
      "laptop_large"
    ],
    "disableCors": false,
    "follow_redirects": false,
    "min_failure_duration": "integer",
    "min_location_failed": "integer",
    "monitor_name": "string",
    "monitor_options": {
      "renotify_interval": "integer"
    },
    "monitor_priority": "integer",
    "noScreenshot": false,
    "retry": {
      "count": "integer",
      "interval": "number"
    },
    "tick_every": "integer"
  },
  "public_id": "123-abc-456",
  "status": "live",
  "subtype": "http",
  "tags": [
    "env:production"
  ],
  "type": "api"
}

- JSON format is wrong - Updating sub-type is forbidden

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Forbidden

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

- Synthetic Monitoring is not activated for the user - Test is not owned by the user - Test can't be found

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Code Example


# Path parameters
export public_id="CHANGE_ME"
# Curl command curl -X PUT "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/synthetics/tests/api/${public_id}" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \ -d @- << EOF { "config": { "configVariables": [ { "name": "VARIABLE_NAME", "type": "text" } ], "request": { "basicAuth": { "password": "", "username": "" } }, "steps": [ { "extractedValues": [ { "parser": { "type": "raw" } } ], "request": { "basicAuth": { "password": "", "username": "" } } } ] } } EOF
package main

import (
    "context"
    "encoding/json"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := datadog.NewDefaultContext(context.Background())

    publicId := "publicId_example" // string | The public ID of the test to get details from.
    body := *datadog.NewSyntheticsAPITest() // SyntheticsAPITest | New test details to be saved.

    configuration := datadog.NewConfiguration()

    apiClient := datadog.NewAPIClient(configuration)
    resp, r, err := apiClient.SyntheticsApi.UpdateAPITest(ctx, publicId, body)
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.UpdateAPITest`: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `UpdateAPITest`: SyntheticsAPITest
    responseContent, _ := json.MarshalIndent(resp, "", "  ")
    fmt.Fprintf(os.Stdout, "Response from SyntheticsApi.UpdateAPITest:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
import os
from dateutil.parser import parse as dateutil_parser
from datadog_api_client.v1 import ApiClient, ApiException, Configuration
from datadog_api_client.v1.api import synthetics_api
from datadog_api_client.v1.models import *
from pprint import pprint
# See configuration.py for a list of all supported configuration parameters.
configuration = Configuration()

# Enter a context with an instance of the API client
with ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = synthetics_api.SyntheticsApi(api_client)
    public_id = "public_id_example"  # str | The public ID of the test to get details from.
    body = SyntheticsAPITest(
        config=SyntheticsAPITestConfig(
            assertions=[
                SyntheticsAssertion(),
            ],
            config_variables=[
                SyntheticsConfigVariable(
                    example="example_example",
                    id="id_example",
                    name="VARIABLE_NAME",
                    pattern="pattern_example",
                    type=SyntheticsConfigVariableType("text"),
                ),
            ],
            request=SyntheticsTestRequest(
                allow_insecure=True,
                basic_auth=SyntheticsBasicAuth(
                    password="",
                    username="",
                ),
                body="body_example",
                certificate=SyntheticsTestRequestCertificate(
                    cert=SyntheticsTestRequestCertificateItem(
                        content="content_example",
                        filename="filename_example",
                        updated_at="updated_at_example",
                    ),
                    key=SyntheticsTestRequestCertificateItem(
                        content="content_example",
                        filename="filename_example",
                        updated_at="updated_at_example",
                    ),
                ),
                dns_server="dns_server_example",
                dns_server_port=1,
                follow_redirects=True,
                headers=SyntheticsTestHeaders(
                    key="key_example",
                ),
                host="host_example",
                method=HTTPMethod("GET"),
                no_saving_response_body=True,
                number_of_packets=0,
                port=1,
                query={},
                servername="servername_example",
                should_track_hops=True,
                timeout=3.14,
                url="https://example.com",
            ),
            steps=[
                SyntheticsAPIStep(
                    allow_failure=True,
                    assertions=[
                        SyntheticsAssertion(),
                    ],
                    extracted_values=[
                        SyntheticsParsingOptions(
                            field="content-type",
                            name="name_example",
                            parser=SyntheticsVariableParser(
                                type=SyntheticsGlobalVariableParserType("raw"),
                                value="value_example",
                            ),
                            type=SyntheticsGlobalVariableParseTestOptionsType("http_body"),
                        ),
                    ],
                    is_critical=True,
                    name="name_example",
                    request=SyntheticsTestRequest(
                        allow_insecure=True,
                        basic_auth=SyntheticsBasicAuth(
                            password="",
                            username="",
                        ),
                        body="body_example",
                        certificate=SyntheticsTestRequestCertificate(
                            cert=SyntheticsTestRequestCertificateItem(
                                content="content_example",
                                filename="filename_example",
                                updated_at="updated_at_example",
                            ),
                            key=SyntheticsTestRequestCertificateItem(
                                content="content_example",
                                filename="filename_example",
                                updated_at="updated_at_example",
                            ),
                        ),
                        dns_server="dns_server_example",
                        dns_server_port=1,
                        follow_redirects=True,
                        headers=SyntheticsTestHeaders(
                            key="key_example",
                        ),
                        host="host_example",
                        method=HTTPMethod("GET"),
                        no_saving_response_body=True,
                        number_of_packets=0,
                        port=1,
                        query={},
                        servername="servername_example",
                        should_track_hops=True,
                        timeout=3.14,
                        url="https://example.com",
                    ),
                    subtype=SyntheticsAPIStepSubtype("http"),
                ),
            ],
        ),
        locations=["aws:eu-west-3"],
        message="Notification message",
        name="Test name",
        options=SyntheticsTestOptions(
            accept_self_signed=True,
            allow_insecure=True,
            device_ids=[
                SyntheticsDeviceID("laptop_large"),
            ],
            disable_cors=True,
            follow_redirects=True,
            min_failure_duration=1,
            min_location_failed=1,
            monitor_name="monitor_name_example",
            monitor_options=SyntheticsTestOptionsMonitorOptions(
                renotify_interval=0,
            ),
            monitor_priority=1,
            no_screenshot=True,
            retry=SyntheticsTestOptionsRetry(
                count=1,
                interval=3.14,
            ),
            tick_every=30,
        ),
        status=SyntheticsTestPauseStatus("live"),
        subtype=SyntheticsTestDetailsSubType("http"),
        tags=["env:production"],
        type=SyntheticsAPITestType("api"),
    )  # SyntheticsAPITest | New test details to be saved.

    # example passing only required values which don't have defaults set
    try:
        # Edit an API test
        api_response = api_instance.update_api_test(public_id, body)
        pprint(api_response)
    except ApiException as e:
        print("Exception when calling SyntheticsApi->update_api_test: %s\n" % e)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
require 'datadog_api_client'
api_instance = DatadogAPIClient::V1::SyntheticsAPI.new
public_id = 'public_id_example' # String | The public ID of the test to get details from.
body = DatadogAPIClient::V1::SyntheticsAPITest.new # SyntheticsAPITest | New test details to be saved.

begin
  # Edit an API test
  result = api_instance.update_api_test(public_id, body)
  p result
rescue DatadogAPIClient::V1::APIError => e
  puts "Error when calling SyntheticsAPI->update_api_test: #{e}"
end

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
import { v1 } from "@datadog/datadog-api-client";
import * as fs from "fs";

const configuration = v1.createConfiguration();
const apiInstance = new v1.SyntheticsApi(configuration);

let params: v1.SyntheticsApiUpdateAPITestRequest = {
  // string | The public ID of the test to get details from.
  publicId: "public_id_example",
  // SyntheticsAPITest | New test details to be saved.
  body: {
    config: {
      assertions: [
        {
          operator: "contains",
          property: "property_example",
          target: null,
          type: "statusCode",
        },
      ],
      configVariables: [
        {
          example: "example_example",
          id: "id_example",
          name: "VARIABLE_NAME",
          pattern: "pattern_example",
          type: "text",
        },
      ],
      request: {
        allowInsecure: true,
        basicAuth: {
          password: "",
          username: "",
        },
        body: "body_example",
        certificate: {
          cert: {
            content: "content_example",
            filename: "filename_example",
            updatedAt: "updatedAt_example",
          },
          key: {
            content: "content_example",
            filename: "filename_example",
            updatedAt: "updatedAt_example",
          },
        },
        dnsServer: "dnsServer_example",
        dnsServerPort: 1,
        followRedirects: true,
        headers: {
          key: "key_example",
        },
        host: "host_example",
        method: "GET",
        noSavingResponseBody: true,
        numberOfPackets: 0,
        port: 1,
        query: {},
        servername: "servername_example",
        shouldTrackHops: true,
        timeout: 3.14,
        url: "https://example.com",
      },
      steps: [
        {
          allowFailure: true,
          assertions: [],
          extractedValues: [
            {
              field: "content-type",
              name: "name_example",
              parser: {
                type: "raw",
                value: "value_example",
              },
              type: "http_body",
            },
          ],
          isCritical: true,
          name: "name_example",
          request: {
            allowInsecure: true,
            basicAuth: {
              password: "",
              username: "",
            },
            body: "body_example",
            certificate: {
              cert: {
                content: "content_example",
                filename: "filename_example",
                updatedAt: "updatedAt_example",
              },
              key: {
                content: "content_example",
                filename: "filename_example",
                updatedAt: "updatedAt_example",
              },
            },
            dnsServer: "dnsServer_example",
            dnsServerPort: 1,
            followRedirects: true,
            headers: {
              key: "key_example",
            },
            host: "host_example",
            method: "GET",
            noSavingResponseBody: true,
            numberOfPackets: 0,
            port: 1,
            query: {},
            servername: "servername_example",
            shouldTrackHops: true,
            timeout: 3.14,
            url: "https://example.com",
          },
          subtype: "http",
        },
      ],
    },
    locations: ["aws:eu-west-3"],
    message: "Notification message",
    name: "Test name",
    options: {
      acceptSelfSigned: true,
      allowInsecure: true,
      deviceIds: ["laptop_large"],
      disableCors: true,
      followRedirects: true,
      minFailureDuration: 1,
      minLocationFailed: 1,
      monitorName: "monitorName_example",
      monitorOptions: {
        renotifyInterval: 0,
      },
      monitorPriority: 1,
      noScreenshot: true,
      retry: {
        count: 1,
        interval: 3.14,
      },
      tickEvery: 30,
    },
    status: "live",
    subtype: "http",
    tags: ["env:production"],
    type: "api",
  },
};

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

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"
import java.util.*;
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.SyntheticsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();

        SyntheticsApi apiInstance = new SyntheticsApi(defaultClient);
        String publicId = "publicId_example"; // String | The public ID of the test to get details from.
        SyntheticsAPITest body = new SyntheticsAPITest(); // SyntheticsAPITest | New test details to be saved.
        try {
            SyntheticsAPITest result = apiInstance.updateAPITest(publicId, body);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling SyntheticsApi#updateAPITest");
            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 and then save the example to Example.java and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"

PUT https://api.datadoghq.eu/api/v1/synthetics/tests/browser/{public_id}https://api.ddog-gov.com/api/v1/synthetics/tests/browser/{public_id}https://api.datadoghq.com/api/v1/synthetics/tests/browser/{public_id}https://api.us3.datadoghq.com/api/v1/synthetics/tests/browser/{public_id}https://api.us5.datadoghq.com/api/v1/synthetics/tests/browser/{public_id}

Overview

Edit the configuration of a Synthetic browser test.

Arguments

Path Parameters

Name

Type

Description

public_id [required]

string

The public ID of the test to get details from.

Request

Body Data (required)

New test details to be saved.

Expand All

Field

Type

Description

config

object

Configuration object for a Synthetic browser test.

assertions [required]

[object <oneOf>]

Array of assertions used for the test.

Option 1

object

An assertion which uses a simple target.

operator [required]

enum

Assertion operator to apply. Allowed enum values: contains,doesNotContain,is,isNot,lessThan,lessThanOrEqual,moreThan,moreThanOrEqual,matches,doesNotMatch,validates,isInMoreThan,isInLessThan

property

string

The associated assertion property.

target

Value used by the operator.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion,latency,packetLossPercentage,packetsReceived,networkHop

Option 2

object

An assertion for the validatesJSONPath operator.

operator [required]

enum

Assertion operator to apply. Allowed enum values: validatesJSONPath

property

string

The associated assertion property.

target

object

Composed target for validatesJSONPath operator.

jsonPath

string

The JSON path to assert.

operator

string

The specific operator to use on the path.

targetValue

The path target value to compare to.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion,latency,packetLossPercentage,packetsReceived,networkHop

configVariables

[object]

Array of variables used for the test.

example

string

Example for the variable.

id

string

ID of the variable for global variables.

name [required]

string

Name of the variable.

pattern

string

Pattern of the variable.

type [required]

enum

Type of the configuration variable. Allowed enum values: global,text

request [required]

object

Object describing the Synthetic test request.

allow_insecure

boolean

Allows loading insecure content for an HTTP request in a multistep test step.

basicAuth

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authentication.

username [required]

string

Username to use for the basic authentication.

body

string

Body to include in the test.

certificate

object

Client certificate to use when performing the test request.

cert

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

key

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

dnsServer

string

DNS server to use for DNS tests.

dnsServerPort

int32

DNS server port to use for DNS tests.

follow_redirects

boolean

Specifies whether or not the request follows redirects.

headers

object

Headers to include when performing the test.

<any-key>

string

A single Header.

host

string

Host name to perform the test with.

method

enum

The HTTP method. Allowed enum values: GET,POST,PATCH,PUT,DELETE,HEAD,OPTIONS

noSavingResponseBody

boolean

Determines whether or not to save the response body.

numberOfPackets

int32

Number of pings to use per test.

port

int64

Port to use when performing the test.

query

object

Query to use for the test.

servername

string

For SSL tests, it specifies on which server you want to initiate the TLS handshake, allowing the server to present one of multiple possible certificates on the same IP address and TCP port number.

shouldTrackHops

boolean

Turns on a traceroute probe to discover all gateways along the path to the host destination.

timeout

double

Timeout in seconds for the test.

url

string

URL to perform the test with.

setCookie

string

Cookies to be used for the request, using the Set-Cookie syntax.

variables

[object]

Array of variables used for the test steps.

example

string

Example for the variable.

id

string

ID for the variable.

name [required]

string

Name of the variable.

pattern

string

Pattern of the variable.

type [required]

enum

Type of browser test variable. Allowed enum values: element,email,global,javascript,text

locations

[string]

Array of locations used to run the test.

message [required]

string

Notification message associated with the test. Message can either be text or an empty string.

monitor_id

int64

The associated monitor ID.

name

string

Name of the test.

options

object

Object describing the extra options for a Synthetic test.

accept_self_signed

boolean

For SSL test, whether or not the test should allow self signed certificates.

allow_insecure

boolean

Allows loading insecure content for an HTTP request.

device_ids

[string]

For browser test, array with the different device IDs used to run the test.

disableCors

boolean

Whether or not to disable CORS mechanism.

follow_redirects

boolean

For API HTTP test, whether or not the test should follow redirects.

min_failure_duration

int64

Minimum amount of time in failure required to trigger an alert.

min_location_failed

int64

Minimum number of locations in failure required to trigger an alert.

monitor_name

string

The monitor name is used for the alert title as well as for all monitor dashboard widgets and SLOs.

monitor_options

object

Object containing the options for a Synthetic test as a monitor (for example, renotification).

renotify_interval

int64

Time interval before renotifying if the test is still failing (in minutes).

monitor_priority

int32

Integer from 1 (high) to 5 (low) indicating alert severity.

noScreenshot

boolean

Prevents saving screenshots of the steps.

retry

object

Object describing the retry strategy to apply to a Synthetic test.

count

int64

Number of times a test needs to be retried before marking a location as failed. Defaults to 0.

interval

double

Time interval between retries (in milliseconds). Defaults to 300ms.

tick_every

int64

The frequency at which to run the Synthetic test (in seconds).

public_id

string

The public ID of the test.

status

enum

Define whether you want to start (live) or pause (paused) a Synthetic test. Allowed enum values: live,paused

steps

[object]

The steps of the test.

allowFailure

boolean

A boolean set to allow this step to fail.

name

string

The name of the step.

params

object

The parameters of the step.

timeout

int64

The time before declaring a step failed.

type

enum

Step type used in your Synthetic test. Allowed enum values: assertCurrentUrl,assertElementAttribute,assertElementContent,assertElementPresent,assertEmail,assertFileDownload,assertFromJavascript,assertPageContains,assertPageLacks,click,extractFromJavascript,extractVariable,goToEmailLink,goToUrl,goToUrlAndMeasureTti,hover,playSubTest,pressKey,refresh,runApiTest,scroll,selectOption,typeText,uploadFiles,wait

tags

[string]

Array of tags attached to the test.

type

enum

Type of the Synthetic test, browser. Allowed enum values: browser

{
  "config": {
    "assertions": [
      {
        "operator": "contains",
        "property": "string",
        "target": "undefined",
        "type": "statusCode"
      }
    ],
    "configVariables": [
      {
        "example": "string",
        "id": "string",
        "name": "VARIABLE_NAME",
        "pattern": "string",
        "type": "text"
      }
    ],
    "request": {
      "allow_insecure": false,
      "basicAuth": {
        "password": "",
        "username": ""
      },
      "body": "string",
      "certificate": {
        "cert": {
          "content": "string",
          "filename": "string",
          "updatedAt": "string"
        },
        "key": {
          "content": "string",
          "filename": "string",
          "updatedAt": "string"
        }
      },
      "dnsServer": "string",
      "dnsServerPort": "integer",
      "follow_redirects": false,
      "headers": {
        "<any-key>": "string"
      },
      "host": "string",
      "method": "GET",
      "noSavingResponseBody": false,
      "numberOfPackets": "integer",
      "port": "integer",
      "query": {},
      "servername": "string",
      "shouldTrackHops": false,
      "timeout": "number",
      "url": "https://example.com"
    },
    "setCookie": "string",
    "variables": [
      {
        "example": "string",
        "id": "string",
        "name": "VARIABLE_NAME",
        "pattern": "string",
        "type": "text"
      }
    ]
  },
  "locations": [],
  "message": "",
  "name": "string",
  "options": {
    "accept_self_signed": false,
    "allow_insecure": false,
    "device_ids": [
      "laptop_large"
    ],
    "disableCors": false,
    "follow_redirects": false,
    "min_failure_duration": "integer",
    "min_location_failed": "integer",
    "monitor_name": "string",
    "monitor_options": {
      "renotify_interval": "integer"
    },
    "monitor_priority": "integer",
    "noScreenshot": false,
    "retry": {
      "count": "integer",
      "interval": "number"
    },
    "tick_every": "integer"
  },
  "status": "live",
  "steps": [
    {
      "allowFailure": false,
      "name": "string",
      "params": {},
      "timeout": "integer",
      "type": "assertElementContent"
    }
  ],
  "tags": [],
  "type": "browser"
}

Response

OK

Object containing details about a Synthetic browser test.

Expand All

Field

Type

Description

config

object

Configuration object for a Synthetic browser test.

assertions [required]

[object <oneOf>]

Array of assertions used for the test.

Option 1

object

An assertion which uses a simple target.

operator [required]

enum

Assertion operator to apply. Allowed enum values: contains,doesNotContain,is,isNot,lessThan,lessThanOrEqual,moreThan,moreThanOrEqual,matches,doesNotMatch,validates,isInMoreThan,isInLessThan

property

string

The associated assertion property.

target

Value used by the operator.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion,latency,packetLossPercentage,packetsReceived,networkHop

Option 2

object

An assertion for the validatesJSONPath operator.

operator [required]

enum

Assertion operator to apply. Allowed enum values: validatesJSONPath

property

string

The associated assertion property.

target

object

Composed target for validatesJSONPath operator.

jsonPath

string

The JSON path to assert.

operator

string

The specific operator to use on the path.

targetValue

The path target value to compare to.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion,latency,packetLossPercentage,packetsReceived,networkHop

configVariables

[object]

Array of variables used for the test.

example

string

Example for the variable.

id

string

ID of the variable for global variables.

name [required]

string

Name of the variable.

pattern

string

Pattern of the variable.

type [required]

enum

Type of the configuration variable. Allowed enum values: global,text

request [required]

object

Object describing the Synthetic test request.

allow_insecure

boolean

Allows loading insecure content for an HTTP request in a multistep test step.

basicAuth

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authentication.

username [required]

string

Username to use for the basic authentication.

body

string

Body to include in the test.

certificate

object

Client certificate to use when performing the test request.

cert

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

key

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

dnsServer

string

DNS server to use for DNS tests.

dnsServerPort

int32

DNS server port to use for DNS tests.

follow_redirects

boolean

Specifies whether or not the request follows redirects.

headers

object

Headers to include when performing the test.

<any-key>

string

A single Header.

host

string

Host name to perform the test with.

method

enum

The HTTP method. Allowed enum values: GET,POST,PATCH,PUT,DELETE,HEAD,OPTIONS

noSavingResponseBody

boolean

Determines whether or not to save the response body.

numberOfPackets

int32

Number of pings to use per test.

port

int64

Port to use when performing the test.

query

object

Query to use for the test.

servername

string

For SSL tests, it specifies on which server you want to initiate the TLS handshake, allowing the server to present one of multiple possible certificates on the same IP address and TCP port number.

shouldTrackHops

boolean

Turns on a traceroute probe to discover all gateways along the path to the host destination.

timeout

double

Timeout in seconds for the test.

url

string

URL to perform the test with.

setCookie

string

Cookies to be used for the request, using the Set-Cookie syntax.

variables

[object]

Array of variables used for the test steps.

example

string

Example for the variable.

id

string

ID for the variable.

name [required]

string

Name of the variable.

pattern

string

Pattern of the variable.

type [required]

enum

Type of browser test variable. Allowed enum values: element,email,global,javascript,text

locations

[string]

Array of locations used to run the test.

message [required]

string

Notification message associated with the test. Message can either be text or an empty string.

monitor_id

int64

The associated monitor ID.

name

string

Name of the test.

options

object

Object describing the extra options for a Synthetic test.

accept_self_signed

boolean

For SSL test, whether or not the test should allow self signed certificates.

allow_insecure

boolean

Allows loading insecure content for an HTTP request.

device_ids

[string]

For browser test, array with the different device IDs used to run the test.

disableCors

boolean

Whether or not to disable CORS mechanism.

follow_redirects

boolean

For API HTTP test, whether or not the test should follow redirects.

min_failure_duration

int64

Minimum amount of time in failure required to trigger an alert.

min_location_failed

int64

Minimum number of locations in failure required to trigger an alert.

monitor_name

string

The monitor name is used for the alert title as well as for all monitor dashboard widgets and SLOs.

monitor_options

object

Object containing the options for a Synthetic test as a monitor (for example, renotification).

renotify_interval

int64

Time interval before renotifying if the test is still failing (in minutes).

monitor_priority

int32

Integer from 1 (high) to 5 (low) indicating alert severity.

noScreenshot

boolean

Prevents saving screenshots of the steps.

retry

object

Object describing the retry strategy to apply to a Synthetic test.

count

int64

Number of times a test needs to be retried before marking a location as failed. Defaults to 0.

interval

double

Time interval between retries (in milliseconds). Defaults to 300ms.

tick_every

int64

The frequency at which to run the Synthetic test (in seconds).

public_id

string

The public ID of the test.

status

enum

Define whether you want to start (live) or pause (paused) a Synthetic test. Allowed enum values: live,paused

steps

[object]

The steps of the test.

allowFailure

boolean

A boolean set to allow this step to fail.

name

string

The name of the step.

params

object

The parameters of the step.

timeout

int64

The time before declaring a step failed.

type

enum

Step type used in your Synthetic test. Allowed enum values: assertCurrentUrl,assertElementAttribute,assertElementContent,assertElementPresent,assertEmail,assertFileDownload,assertFromJavascript,assertPageContains,assertPageLacks,click,extractFromJavascript,extractVariable,goToEmailLink,goToUrl,goToUrlAndMeasureTti,hover,playSubTest,pressKey,refresh,runApiTest,scroll,selectOption,typeText,uploadFiles,wait

tags

[string]

Array of tags attached to the test.

type

enum

Type of the Synthetic test, browser. Allowed enum values: browser

{
  "config": {
    "assertions": [
      {
        "operator": "contains",
        "property": "string",
        "target": "undefined",
        "type": "statusCode"
      }
    ],
    "configVariables": [
      {
        "example": "string",
        "id": "string",
        "name": "VARIABLE_NAME",
        "pattern": "string",
        "type": "text"
      }
    ],
    "request": {
      "allow_insecure": false,
      "basicAuth": {
        "password": "",
        "username": ""
      },
      "body": "string",
      "certificate": {
        "cert": {
          "content": "string",
          "filename": "string",
          "updatedAt": "string"
        },
        "key": {
          "content": "string",
          "filename": "string",
          "updatedAt": "string"
        }
      },
      "dnsServer": "string",
      "dnsServerPort": "integer",
      "follow_redirects": false,
      "headers": {
        "<any-key>": "string"
      },
      "host": "string",
      "method": "GET",
      "noSavingResponseBody": false,
      "numberOfPackets": "integer",
      "port": "integer",
      "query": {},
      "servername": "string",
      "shouldTrackHops": false,
      "timeout": "number",
      "url": "https://example.com"
    },
    "setCookie": "string",
    "variables": [
      {
        "example": "string",
        "id": "string",
        "name": "VARIABLE_NAME",
        "pattern": "string",
        "type": "text"
      }
    ]
  },
  "locations": [],
  "message": "",
  "monitor_id": "integer",
  "name": "string",
  "options": {
    "accept_self_signed": false,
    "allow_insecure": false,
    "device_ids": [
      "laptop_large"
    ],
    "disableCors": false,
    "follow_redirects": false,
    "min_failure_duration": "integer",
    "min_location_failed": "integer",
    "monitor_name": "string",
    "monitor_options": {
      "renotify_interval": "integer"
    },
    "monitor_priority": "integer",
    "noScreenshot": false,
    "retry": {
      "count": "integer",
      "interval": "number"
    },
    "tick_every": "integer"
  },
  "public_id": "string",
  "status": "live",
  "steps": [
    {
      "allowFailure": false,
      "name": "string",
      "params": {},
      "timeout": "integer",
      "type": "assertElementContent"
    }
  ],
  "tags": [],
  "type": "browser"
}

- JSON format is wrong - Updating sub-type is forbidden

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Forbidden

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

- Synthetic Monitoring is not activated for the user - Test is not owned by the user - Test can't be found

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Code Example


# Path parameters
export public_id="CHANGE_ME"
# Curl command curl -X PUT "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/synthetics/tests/browser/${public_id}" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \ -d @- << EOF { "config": { "assertions": [ {} ], "configVariables": [ { "name": "VARIABLE_NAME", "type": "text" } ], "request": { "basicAuth": { "password": "", "username": "" } }, "variables": [ { "name": "VARIABLE_NAME", "type": "text" } ] }, "message": "" } EOF
package main

import (
    "context"
    "encoding/json"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := datadog.NewDefaultContext(context.Background())

    publicId := "publicId_example" // string | The public ID of the test to get details from.
    body := *datadog.NewSyntheticsBrowserTest("Message_example") // SyntheticsBrowserTest | New test details to be saved.

    configuration := datadog.NewConfiguration()

    apiClient := datadog.NewAPIClient(configuration)
    resp, r, err := apiClient.SyntheticsApi.UpdateBrowserTest(ctx, publicId, body)
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.UpdateBrowserTest`: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `UpdateBrowserTest`: SyntheticsBrowserTest
    responseContent, _ := json.MarshalIndent(resp, "", "  ")
    fmt.Fprintf(os.Stdout, "Response from SyntheticsApi.UpdateBrowserTest:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
import os
from dateutil.parser import parse as dateutil_parser
from datadog_api_client.v1 import ApiClient, ApiException, Configuration
from datadog_api_client.v1.api import synthetics_api
from datadog_api_client.v1.models import *
from pprint import pprint
# See configuration.py for a list of all supported configuration parameters.
configuration = Configuration()

# Enter a context with an instance of the API client
with ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = synthetics_api.SyntheticsApi(api_client)
    public_id = "public_id_example"  # str | The public ID of the test to get details from.
    body = SyntheticsBrowserTest(
        config=SyntheticsBrowserTestConfig(
            assertions=[
                SyntheticsAssertion(),
            ],
            config_variables=[
                SyntheticsConfigVariable(
                    example="example_example",
                    id="id_example",
                    name="VARIABLE_NAME",
                    pattern="pattern_example",
                    type=SyntheticsConfigVariableType("text"),
                ),
            ],
            request=SyntheticsTestRequest(
                allow_insecure=True,
                basic_auth=SyntheticsBasicAuth(
                    password="",
                    username="",
                ),
                body="body_example",
                certificate=SyntheticsTestRequestCertificate(
                    cert=SyntheticsTestRequestCertificateItem(
                        content="content_example",
                        filename="filename_example",
                        updated_at="updated_at_example",
                    ),
                    key=SyntheticsTestRequestCertificateItem(
                        content="content_example",
                        filename="filename_example",
                        updated_at="updated_at_example",
                    ),
                ),
                dns_server="dns_server_example",
                dns_server_port=1,
                follow_redirects=True,
                headers=SyntheticsTestHeaders(
                    key="key_example",
                ),
                host="host_example",
                method=HTTPMethod("GET"),
                no_saving_response_body=True,
                number_of_packets=0,
                port=1,
                query={},
                servername="servername_example",
                should_track_hops=True,
                timeout=3.14,
                url="https://example.com",
            ),
            set_cookie="set_cookie_example",
            variables=[
                SyntheticsBrowserVariable(
                    example="example_example",
                    id="id_example",
                    name="VARIABLE_NAME",
                    pattern="pattern_example",
                    type=SyntheticsBrowserVariableType("text"),
                ),
            ],
        ),
        locations=[
            "locations_example",
        ],
        message="",
        name="name_example",
        options=SyntheticsTestOptions(
            accept_self_signed=True,
            allow_insecure=True,
            device_ids=[
                SyntheticsDeviceID("laptop_large"),
            ],
            disable_cors=True,
            follow_redirects=True,
            min_failure_duration=1,
            min_location_failed=1,
            monitor_name="monitor_name_example",
            monitor_options=SyntheticsTestOptionsMonitorOptions(
                renotify_interval=0,
            ),
            monitor_priority=1,
            no_screenshot=True,
            retry=SyntheticsTestOptionsRetry(
                count=1,
                interval=3.14,
            ),
            tick_every=30,
        ),
        status=SyntheticsTestPauseStatus("live"),
        steps=[
            SyntheticsStep(
                allow_failure=True,
                name="name_example",
                params={},
                timeout=1,
                type=SyntheticsStepType("assertElementContent"),
            ),
        ],
        tags=[
            "tags_example",
        ],
        type=SyntheticsBrowserTestType("browser"),
    )  # SyntheticsBrowserTest | New test details to be saved.

    # example passing only required values which don't have defaults set
    try:
        # Edit a browser test
        api_response = api_instance.update_browser_test(public_id, body)
        pprint(api_response)
    except ApiException as e:
        print("Exception when calling SyntheticsApi->update_browser_test: %s\n" % e)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
require 'datadog_api_client'
api_instance = DatadogAPIClient::V1::SyntheticsAPI.new
public_id = 'public_id_example' # String | The public ID of the test to get details from.
body = DatadogAPIClient::V1::SyntheticsBrowserTest.new({message: 'message_example'}) # SyntheticsBrowserTest | New test details to be saved.

begin
  # Edit a browser test
  result = api_instance.update_browser_test(public_id, body)
  p result
rescue DatadogAPIClient::V1::APIError => e
  puts "Error when calling SyntheticsAPI->update_browser_test: #{e}"
end

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
import { v1 } from "@datadog/datadog-api-client";
import * as fs from "fs";

const configuration = v1.createConfiguration();
const apiInstance = new v1.SyntheticsApi(configuration);

let params: v1.SyntheticsApiUpdateBrowserTestRequest = {
  // string | The public ID of the test to get details from.
  publicId: "public_id_example",
  // SyntheticsBrowserTest | New test details to be saved.
  body: {
    config: {
      assertions: [],
      configVariables: [
        {
          example: "example_example",
          id: "id_example",
          name: "VARIABLE_NAME",
          pattern: "pattern_example",
          type: "text",
        },
      ],
      request: {
        allowInsecure: true,
        basicAuth: {
          password: "",
          username: "",
        },
        body: "body_example",
        certificate: {
          cert: {
            content: "content_example",
            filename: "filename_example",
            updatedAt: "updatedAt_example",
          },
          key: {
            content: "content_example",
            filename: "filename_example",
            updatedAt: "updatedAt_example",
          },
        },
        dnsServer: "dnsServer_example",
        dnsServerPort: 1,
        followRedirects: true,
        headers: {
          key: "key_example",
        },
        host: "host_example",
        method: "GET",
        noSavingResponseBody: true,
        numberOfPackets: 0,
        port: 1,
        query: {},
        servername: "servername_example",
        shouldTrackHops: true,
        timeout: 3.14,
        url: "https://example.com",
      },
      setCookie: "setCookie_example",
      variables: [
        {
          example: "example_example",
          id: "id_example",
          name: "VARIABLE_NAME",
          pattern: "pattern_example",
          type: "text",
        },
      ],
    },
    locations: ["locations_example"],
    message: "",
    name: "name_example",
    options: {
      acceptSelfSigned: true,
      allowInsecure: true,
      deviceIds: ["laptop_large"],
      disableCors: true,
      followRedirects: true,
      minFailureDuration: 1,
      minLocationFailed: 1,
      monitorName: "monitorName_example",
      monitorOptions: {
        renotifyInterval: 0,
      },
      monitorPriority: 1,
      noScreenshot: true,
      retry: {
        count: 1,
        interval: 3.14,
      },
      tickEvery: 30,
    },
    status: "live",
    steps: [
      {
        allowFailure: true,
        name: "name_example",
        params: {},
        timeout: 1,
        type: "assertElementContent",
      },
    ],
    tags: ["tags_example"],
    type: "browser",
  },
};

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

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"
import java.util.*;
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.SyntheticsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();

        SyntheticsApi apiInstance = new SyntheticsApi(defaultClient);
        String publicId = "publicId_example"; // String | The public ID of the test to get details from.
        SyntheticsBrowserTest body = new SyntheticsBrowserTest(); // SyntheticsBrowserTest | New test details to be saved.
        try {
            SyntheticsBrowserTest result = apiInstance.updateBrowserTest(publicId, body);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling SyntheticsApi#updateBrowserTest");
            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 and then save the example to Example.java and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"

PUT https://api.datadoghq.eu/api/v1/synthetics/tests/{public_id}/statushttps://api.ddog-gov.com/api/v1/synthetics/tests/{public_id}/statushttps://api.datadoghq.com/api/v1/synthetics/tests/{public_id}/statushttps://api.us3.datadoghq.com/api/v1/synthetics/tests/{public_id}/statushttps://api.us5.datadoghq.com/api/v1/synthetics/tests/{public_id}/status

Overview

Pause or start a Synthetics test by changing the status.

Arguments

Path Parameters

Name

Type

Description

public_id [required]

string

The public ID of the Synthetic test to update.

Request

Body Data (required)

Status to set the given Synthetic test to.

Expand All

Field

Type

Description

new_status

enum

Define whether you want to start (live) or pause (paused) a Synthetic test. Allowed enum values: live,paused

{
  "new_status": "live"
}

Response

OK - Returns a boolean indicating if the update was successful.

Expand All

Field

Type

Description

No response body

{}

JSON format is wrong.

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Forbidden

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

- Synthetic is not activated for the user - Test is not owned by the user

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Code Example


# Path parameters
export public_id="CHANGE_ME"
# Curl command curl -X PUT "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/synthetics/tests/${public_id}/status" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \ -d @- << EOF {} EOF
package main

import (
    "context"
    "encoding/json"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := datadog.NewDefaultContext(context.Background())

    publicId := "publicId_example" // string | The public ID of the Synthetic test to update.
    body := *datadog.NewSyntheticsUpdateTestPauseStatusPayload() // SyntheticsUpdateTestPauseStatusPayload | Status to set the given Synthetic test to.

    configuration := datadog.NewConfiguration()

    apiClient := datadog.NewAPIClient(configuration)
    resp, r, err := apiClient.SyntheticsApi.UpdateTestPauseStatus(ctx, publicId, body)
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.UpdateTestPauseStatus`: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `UpdateTestPauseStatus`: bool
    responseContent, _ := json.MarshalIndent(resp, "", "  ")
    fmt.Fprintf(os.Stdout, "Response from SyntheticsApi.UpdateTestPauseStatus:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
import os
from dateutil.parser import parse as dateutil_parser
from datadog_api_client.v1 import ApiClient, ApiException, Configuration
from datadog_api_client.v1.api import synthetics_api
from datadog_api_client.v1.models import *
from pprint import pprint
# See configuration.py for a list of all supported configuration parameters.
configuration = Configuration()

# Enter a context with an instance of the API client
with ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = synthetics_api.SyntheticsApi(api_client)
    public_id = "public_id_example"  # str | The public ID of the Synthetic test to update.
    body = SyntheticsUpdateTestPauseStatusPayload(
        new_status=SyntheticsTestPauseStatus("live"),
    )  # SyntheticsUpdateTestPauseStatusPayload | Status to set the given Synthetic test to.

    # example passing only required values which don't have defaults set
    try:
        # Pause or start a test
        api_response = api_instance.update_test_pause_status(public_id, body)
        pprint(api_response)
    except ApiException as e:
        print("Exception when calling SyntheticsApi->update_test_pause_status: %s\n" % e)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
require 'datadog_api_client'
api_instance = DatadogAPIClient::V1::SyntheticsAPI.new
public_id = 'public_id_example' # String | The public ID of the Synthetic test to update.
body = DatadogAPIClient::V1::SyntheticsUpdateTestPauseStatusPayload.new # SyntheticsUpdateTestPauseStatusPayload | Status to set the given Synthetic test to.

begin
  # Pause or start a test
  result = api_instance.update_test_pause_status(public_id, body)
  p result
rescue DatadogAPIClient::V1::APIError => e
  puts "Error when calling SyntheticsAPI->update_test_pause_status: #{e}"
end

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
import { v1 } from "@datadog/datadog-api-client";
import * as fs from "fs";

const configuration = v1.createConfiguration();
const apiInstance = new v1.SyntheticsApi(configuration);

let params: v1.SyntheticsApiUpdateTestPauseStatusRequest = {
  // string | The public ID of the Synthetic test to update.
  publicId: "public_id_example",
  // SyntheticsUpdateTestPauseStatusPayload | Status to set the given Synthetic test to.
  body: {
    newStatus: "live",
  },
};

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

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"
import java.util.*;
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.SyntheticsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();

        SyntheticsApi apiInstance = new SyntheticsApi(defaultClient);
        String publicId = "publicId_example"; // String | The public ID of the Synthetic test to update.
        SyntheticsUpdateTestPauseStatusPayload body = new SyntheticsUpdateTestPauseStatusPayload(); // SyntheticsUpdateTestPauseStatusPayload | Status to set the given Synthetic test to.
        try {
            Boolean result = apiInstance.updateTestPauseStatus(publicId, body);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling SyntheticsApi#updateTestPauseStatus");
            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 and then save the example to Example.java and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"

POST https://api.datadoghq.eu/api/v1/synthetics/tests/trigger/cihttps://api.ddog-gov.com/api/v1/synthetics/tests/trigger/cihttps://api.datadoghq.com/api/v1/synthetics/tests/trigger/cihttps://api.us3.datadoghq.com/api/v1/synthetics/tests/trigger/cihttps://api.us5.datadoghq.com/api/v1/synthetics/tests/trigger/ci

Overview

Trigger a set of Synthetics tests for continuous integration.

Request

Body Data (required)

Details of the test to trigger.

Expand All

Field

Type

Description

tests

[object]

Individual synthetics test.

allowInsecureCertificates

boolean

Disable certificate checks in API tests.

basicAuth

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authentication.

username [required]

string

Username to use for the basic authentication.

body

string

Body to include in the test.

bodyType

string

Type of the data sent in a synthetics API test.

cookies

string

Cookies for the request.

deviceIds

[string]

For browser test, array with the different device IDs used to run the test.

followRedirects

boolean

For API HTTP test, whether or not the test should follow redirects.

headers

object

Headers to include when performing the test.

<any-key>

string

A single Header.

locations

[string]

Array of locations used to run the test.

metadata

object

Metadata for the Synthetics tests run.

ci

object

Description of the CI provider.

pipeline

string

Name of the pipeline.

provider

string

Name of the CI provider.

git

object

Git information.

branch

string

The branch name.

commit_sha

string

The commit SHA.

public_id [required]

string

The public ID of the Synthetics test to trigger.

retry

object

Object describing the retry strategy to apply to a Synthetic test.

count

int64

Number of times a test needs to be retried before marking a location as failed. Defaults to 0.

interval

double

Time interval between retries (in milliseconds). Defaults to 300ms.

startUrl

string

Starting URL for the browser test.

variables

object

Variables to replace in the test.

<any-key>

string

A single variable.

{
  "tests": [
    {
      "allowInsecureCertificates": false,
      "basicAuth": {
        "password": "",
        "username": ""
      },
      "body": "string",
      "bodyType": "string",
      "cookies": "string",
      "deviceIds": [
        "laptop_large"
      ],
      "followRedirects": false,
      "headers": {
        "<any-key>": "string"
      },
      "locations": [],
      "metadata": {
        "ci": {
          "pipeline": "string",
          "provider": "string"
        },
        "git": {
          "branch": "string",
          "commit_sha": "string"
        }
      },
      "public_id": "aaa-aaa-aaa",
      "retry": {
        "count": "integer",
        "interval": "number"
      },
      "startUrl": "string",
      "variables": {
        "<any-key>": "string"
      }
    }
  ]
}

Response

OK

Object containing information about the tests triggered.

Expand All

Field

Type

Description

batch_id

string

The public ID of the batch triggered.

locations

[object]

List of Synthetics locations.

id

int64

Unique identifier of the location.

name

string

Name of the location.

results

[object]

Information about the tests runs.

device

enum

The device ID. Allowed enum values: laptop_large,tablet,mobile_small,chrome.laptop_large,chrome.tablet,chrome.mobile_small,firefox.laptop_large,firefox.tablet,firefox.mobile_small,edge.laptop_large,edge.tablet,edge.mobile_small

location

int64

The location ID of the test run.

public_id

string

The public ID of the Synthetics test.

result_id

string

ID of the result.

triggered_check_ids

[string]

The public IDs of the Synthetics test triggered.

{
  "batch_id": "string",
  "locations": [
    {
      "id": "integer",
      "name": "string"
    }
  ],
  "results": [
    {
      "device": "laptop_large",
      "location": "integer",
      "public_id": "string",
      "result_id": "string"
    }
  ],
  "triggered_check_ids": []
}

JSON format is wrong

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Code Example


# Curl command
curl -X POST "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/synthetics/tests/trigger/ci" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
  "tests": [
    {
      "basicAuth": {
        "password": "",
        "username": ""
      },
      "public_id": "aaa-aaa-aaa"
    }
  ]
}
EOF
package main

import (
    "context"
    "encoding/json"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := datadog.NewDefaultContext(context.Background())

    body := *datadog.NewSyntheticsCITestBody() // SyntheticsCITestBody | Details of the test to trigger.

    configuration := datadog.NewConfiguration()

    apiClient := datadog.NewAPIClient(configuration)
    resp, r, err := apiClient.SyntheticsApi.TriggerCITests(ctx, body)
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.TriggerCITests`: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `TriggerCITests`: SyntheticsTriggerCITestsResponse
    responseContent, _ := json.MarshalIndent(resp, "", "  ")
    fmt.Fprintf(os.Stdout, "Response from SyntheticsApi.TriggerCITests:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
import os
from dateutil.parser import parse as dateutil_parser
from datadog_api_client.v1 import ApiClient, ApiException, Configuration
from datadog_api_client.v1.api import synthetics_api
from datadog_api_client.v1.models import *
from pprint import pprint
# See configuration.py for a list of all supported configuration parameters.
configuration = Configuration()

# Enter a context with an instance of the API client
with ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = synthetics_api.SyntheticsApi(api_client)
    body = SyntheticsCITestBody(
        tests=[
            SyntheticsCITest(
                allow_insecure_certificates=True,
                basic_auth=SyntheticsBasicAuth(
                    password="",
                    username="",
                ),
                body="body_example",
                body_type="body_type_example",
                cookies="cookies_example",
                device_ids=[
                    SyntheticsDeviceID("laptop_large"),
                ],
                follow_redirects=True,
                headers=SyntheticsTestHeaders(
                    key="key_example",
                ),
                locations=[
                    "locations_example",
                ],
                metadata=SyntheticsCIBatchMetadata(
                    ci=SyntheticsCIBatchMetadataCI(
                        pipeline="pipeline_example",
                        provider="provider_example",
                    ),
                    git=SyntheticsCIBatchMetadataGit(
                        branch="branch_example",
                        commit_sha="commit_sha_example",
                    ),
                ),
                public_id="aaa-aaa-aaa",
                retry=SyntheticsTestOptionsRetry(
                    count=1,
                    interval=3.14,
                ),
                start_url="start_url_example",
                variables={
                    "key": "key_example",
                },
            ),
        ],
    )  # SyntheticsCITestBody | Details of the test to trigger.

    # example passing only required values which don't have defaults set
    try:
        # Trigger tests from CI/CD pipelines
        api_response = api_instance.trigger_ci_tests(body)
        pprint(api_response)
    except ApiException as e:
        print("Exception when calling SyntheticsApi->trigger_ci_tests: %s\n" % e)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
require 'datadog_api_client'
api_instance = DatadogAPIClient::V1::SyntheticsAPI.new
body = DatadogAPIClient::V1::SyntheticsCITestBody.new # SyntheticsCITestBody | Details of the test to trigger.

begin
  # Trigger tests from CI/CD pipelines
  result = api_instance.trigger_ci_tests(body)
  p result
rescue DatadogAPIClient::V1::APIError => e
  puts "Error when calling SyntheticsAPI->trigger_ci_tests: #{e}"
end

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
import { v1 } from "@datadog/datadog-api-client";
import * as fs from "fs";

const configuration = v1.createConfiguration();
const apiInstance = new v1.SyntheticsApi(configuration);

let params: v1.SyntheticsApiTriggerCITestsRequest = {
  // SyntheticsCITestBody | Details of the test to trigger.
  body: {
    tests: [
      {
        allowInsecureCertificates: true,
        basicAuth: {
          password: "",
          username: "",
        },
        body: "body_example",
        bodyType: "bodyType_example",
        cookies: "cookies_example",
        deviceIds: ["laptop_large"],
        followRedirects: true,
        headers: {
          key: "key_example",
        },
        locations: ["locations_example"],
        metadata: {
          ci: {
            pipeline: "pipeline_example",
            provider: "provider_example",
          },
          git: {
            branch: "branch_example",
            commitSha: "commitSha_example",
          },
        },
        publicId: "aaa-aaa-aaa",
        retry: {
          count: 1,
          interval: 3.14,
        },
        startUrl: "startUrl_example",
        variables: {
          key: "key_example",
        },
      },
    ],
  },
};

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

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"
import java.util.*;
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.SyntheticsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();

        SyntheticsApi apiInstance = new SyntheticsApi(defaultClient);
        SyntheticsCITestBody body = new SyntheticsCITestBody(); // SyntheticsCITestBody | Details of the test to trigger.
        try {
            SyntheticsTriggerCITestsResponse result = apiInstance.triggerCITests(body);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling SyntheticsApi#triggerCITests");
            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 and then save the example to Example.java and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"

GET https://api.datadoghq.eu/api/v1/synthetics/tests/api/{public_id}https://api.ddog-gov.com/api/v1/synthetics/tests/api/{public_id}https://api.datadoghq.com/api/v1/synthetics/tests/api/{public_id}https://api.us3.datadoghq.com/api/v1/synthetics/tests/api/{public_id}https://api.us5.datadoghq.com/api/v1/synthetics/tests/api/{public_id}

Overview

Get the detailed configuration associated with a Synthetic API test.

Arguments

Path Parameters

Name

Type

Description

public_id [required]

string

The public ID of the test to get details from.

Response

OK

Object containing details about a Synthetic API test.

Expand All

Field

Type

Description

config

object

Configuration object for a Synthetic API test.

assertions

[object <oneOf>]

Array of assertions used for the test.

Option 1

object

An assertion which uses a simple target.

operator [required]

enum

Assertion operator to apply. Allowed enum values: contains,doesNotContain,is,isNot,lessThan,lessThanOrEqual,moreThan,moreThanOrEqual,matches,doesNotMatch,validates,isInMoreThan,isInLessThan

property

string

The associated assertion property.

target

Value used by the operator.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion,latency,packetLossPercentage,packetsReceived,networkHop

Option 2

object

An assertion for the validatesJSONPath operator.

operator [required]

enum

Assertion operator to apply. Allowed enum values: validatesJSONPath

property

string

The associated assertion property.

target

object

Composed target for validatesJSONPath operator.

jsonPath

string

The JSON path to assert.

operator

string

The specific operator to use on the path.

targetValue

The path target value to compare to.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion,latency,packetLossPercentage,packetsReceived,networkHop

configVariables

[object]

Array of variables used for the test.

example

string

Example for the variable.

id

string

ID of the variable for global variables.

name [required]

string

Name of the variable.

pattern

string

Pattern of the variable.

type [required]

enum

Type of the configuration variable. Allowed enum values: global,text

request

object

Object describing the Synthetic test request.

allow_insecure

boolean

Allows loading insecure content for an HTTP request in a multistep test step.

basicAuth

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authe