Synthetics

Datadog Synthetic utilise des requêtes utilisateur simulées et le rendu du navigateur pour vous aider à optimiser votre uptime, à identifier les problèmes affectant une région spécifique et à surveiller les performances de l’application. Il existe deux types de tests Datadog Synthetic : les tests API et les tests Browser. Vous pouvez utiliser l’API Datadog pour gérer les deux types de tests automatiquement.

Pour en savoir plus sur Synthetic, consultez la présentation de Synthetic.

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

Présentation

Créez un test API Synthetic. This endpoint requires the synthetics_write authorization scope.

Requête

Body Data (required)

Détails du test à créer.

Expand All

Champ

Type

Description

config [required]

object

Configuration object for a Synthetic API test.

assertions

[object <oneOf>]

Array of assertions used for the test. Required for single API tests.

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,doesNotExist

property

string

The associated assertion property.

target [required]

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,receivedMessage,grpcHealthcheckStatus,connection

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,receivedMessage,grpcHealthcheckStatus,connection

Option 3

object

An assertion for the validatesXPath operator.

operator [required]

enum

Assertion operator to apply. Allowed enum values: validatesXPath

property

string

The associated assertion property.

target

object

Composed target for validatesXPath operator.

operator

string

The specific operator to use on the path.

targetValue

The path target value to compare to.

xPath

string

The X path to assert.

type [required]

enum

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

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 <oneOf>

Object to handle basic authentication when performing the test.

Option 1

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authentication.

type

enum

The type of basic authentication to use when performing the test. Allowed enum values: web

username [required]

string

Username to use for the basic authentication.

Option 2

object

Object to handle SIGV4 authentication when performing the test.

accessKey [required]

string

Access key for the SIGV4 authentication.

region

string

Region for the SIGV4 authentication.

secretKey [required]

string

Secret key for the SIGV4 authentication.

serviceName

string

Service name for the SIGV4 authentication.

sessionToken

string

Session token for the SIGV4 authentication.

type [required]

enum

The type of authentication to use when performing the test. Allowed enum values: sigv4

Option 3

object

Object to handle NTLM authentication when performing the test.

domain

string

Domain for the authentication to use when performing the test.

password

string

Password for the authentication to use when performing the test.

type [required]

enum

The type of authentication to use when performing the test. Allowed enum values: ntlm

username

string

Username for the authentication to use when performing the test.

workstation

string

Workstation for the authentication to use when performing the test.

Option 4

object

Object to handle digest authentication when performing the test.

password [required]

string

Password to use for the digest authentication.

type

enum

The type of basic authentication to use when performing the test. Allowed enum values: digest

username [required]

string

Username to use for the digest authentication.

Option 5

object

Object to handle oauth client authentication when performing the test.

accessTokenUrl [required]

string

Access token URL to use when performing the authentication.

audience

string

Audience to use when performing the authentication.

clientId [required]

string

Client ID to use when performing the authentication.

clientSecret [required]

string

Client secret to use when performing the authentication.

resource

string

Resource to use when performing the authentication.

scope

string

Scope to use when performing the authentication.

tokenApiAuthentication [required]

enum

Type of token to use when performing the authentication. Allowed enum values: header,body

type

enum

The type of basic authentication to use when performing the test. Allowed enum values: oauth-client

Option 6

object

Object to handle oauth rop authentication when performing the test.

accessTokenUrl [required]

string

Access token URL to use when performing the authentication.

audience

string

Audience to use when performing the authentication.

clientId

string

Client ID to use when performing the authentication.

clientSecret

string

Client secret to use when performing the authentication.

password [required]

string

Password to use when performing the authentication.

resource

string

Resource to use when performing the authentication.

scope

string

Scope to use when performing the authentication.

type

enum

The type of basic authentication to use when performing the test. Allowed enum values: oauth-rop

username [required]

string

Username to use when performing the authentication.

body

string

Body to include in the test.

bodyType

enum

Type of the request body. Allowed enum values: text/plain,application/json,text/xml,text/html,application/x-www-form-urlencoded,graphql

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.

certificateDomains

[string]

By default, the client certificate is applied on the domain of the starting URL for browser tests. If you want your client certificate to be applied on other domains instead, add them in certificateDomains.

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.

message

string

Message to send for UDP or WebSocket tests.

metadata

object

Metadata to include when performing the gRPC test.

<any-key>

string

A single Metadatum.

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.

proxy

object

The proxy to perform the test.

headers

object

Headers to include when performing the test.

<any-key>

string

A single Header.

url [required]

string

URL of the proxy to perform 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.

service

string

gRPC service on which you want to perform the healthcheck.

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 [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,doesNotExist

property

string

The associated assertion property.

target [required]

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,receivedMessage,grpcHealthcheckStatus,connection

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,receivedMessage,grpcHealthcheckStatus,connection

Option 3

object

An assertion for the validatesXPath operator.

operator [required]

enum

Assertion operator to apply. Allowed enum values: validatesXPath

property

string

The associated assertion property.

target

object

Composed target for validatesXPath operator.

operator

string

The specific operator to use on the path.

targetValue

The path target value to compare to.

xPath

string

The X path to assert.

type [required]

enum

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

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,local_variable

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 [required]

string

The name of the step.

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 <oneOf>

Object to handle basic authentication when performing the test.

Option 1

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authentication.

type

enum

The type of basic authentication to use when performing the test. Allowed enum values: web

username [required]

string

Username to use for the basic authentication.

Option 2

object

Object to handle SIGV4 authentication when performing the test.

accessKey [required]

string

Access key for the SIGV4 authentication.

region

string

Region for the SIGV4 authentication.

secretKey [required]

string

Secret key for the SIGV4 authentication.

serviceName

string

Service name for the SIGV4 authentication.

sessionToken

string

Session token for the SIGV4 authentication.

type [required]

enum

The type of authentication to use when performing the test. Allowed enum values: sigv4

Option 3

object

Object to handle NTLM authentication when performing the test.

domain

string

Domain for the authentication to use when performing the test.

password

string

Password for the authentication to use when performing the test.

type [required]

enum

The type of authentication to use when performing the test. Allowed enum values: ntlm

username

string

Username for the authentication to use when performing the test.

workstation

string

Workstation for the authentication to use when performing the test.

Option 4

object

Object to handle digest authentication when performing the test.

password [required]

string

Password to use for the digest authentication.

type

enum

The type of basic authentication to use when performing the test. Allowed enum values: digest

username [required]

string

Username to use for the digest authentication.

Option 5

object

Object to handle oauth client authentication when performing the test.

accessTokenUrl [required]

string

Access token URL to use when performing the authentication.

audience

string

Audience to use when performing the authentication.

clientId [required]

string

Client ID to use when performing the authentication.

clientSecret [required]

string

Client secret to use when performing the authentication.

resource

string

Resource to use when performing the authentication.

scope

string

Scope to use when performing the authentication.

tokenApiAuthentication [required]

enum

Type of token to use when performing the authentication. Allowed enum values: header,body

type

enum

The type of basic authentication to use when performing the test. Allowed enum values: oauth-client

Option 6

object

Object to handle oauth rop authentication when performing the test.

accessTokenUrl [required]

string

Access token URL to use when performing the authentication.

audience

string

Audience to use when performing the authentication.

clientId

string

Client ID to use when performing the authentication.

clientSecret

string

Client secret to use when performing the authentication.

password [required]

string

Password to use when performing the authentication.

resource

string

Resource to use when performing the authentication.

scope

string

Scope to use when performing the authentication.

type

enum

The type of basic authentication to use when performing the test. Allowed enum values: oauth-rop

username [required]

string

Username to use when performing the authentication.

body

string

Body to include in the test.

bodyType

enum

Type of the request body. Allowed enum values: text/plain,application/json,text/xml,text/html,application/x-www-form-urlencoded,graphql

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.

certificateDomains

[string]

By default, the client certificate is applied on the domain of the starting URL for browser tests. If you want your client certificate to be applied on other domains instead, add them in certificateDomains.

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.

message

string

Message to send for UDP or WebSocket tests.

metadata

object

Metadata to include when performing the gRPC test.

<any-key>

string

A single Metadatum.

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.

proxy

object

The proxy to perform the test.

headers

object

Headers to include when performing the test.

<any-key>

string

A single Header.

url [required]

string

URL of the proxy to perform 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.

service

string

gRPC service on which you want to perform the healthcheck.

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.

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.

subtype [required]

enum

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

locations [required]

[string]

Array of locations used to run the test.

message [required]

string

Notification message associated with the test.

monitor_id

int64

The associated monitor ID.

name [required]

string

Name of the test.

options [required]

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 in an API test.

checkCertificateRevocation

boolean

For SSL test, whether or not the test should fail on revoked certificate in stapled OCSP.

ci

object

CI/CD options for a Synthetic test.

executionRule

enum

Execution rule for a Synthetics test. Allowed enum values: blocking,non_blocking,skipped

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.

disableCsp

boolean

Disable Content Security Policy for browser tests.

follow_redirects

boolean

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

ignoreServerCertificateError

boolean

Ignore server certificate error for browser tests.

initialNavigationTimeout

int64

Timeout before declaring the initial step as failed (in seconds) for browser tests.

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.

restricted_roles

[string]

A list of role identifiers that can be pulled from the Roles API, for restricting read and write access.

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.

rumSettings

object

The RUM data collection settings for the Synthetic browser test. Note: There are 3 ways to format RUM settings:

{ isEnabled: false } RUM data is not collected.

{ isEnabled: true } RUM data is collected from the Synthetic test's default application.

{ isEnabled: true, applicationId: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", clientTokenId: 12345 } RUM data is collected using the specified application.

applicationId

string

RUM application ID used to collect RUM data for the browser test.

clientTokenId

int64

RUM application API key ID used to collect RUM data for the browser test.

isEnabled [required]

boolean

Determines whether RUM data is collected during test runs.

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, udp, websocket, grpc or multi. Allowed enum values: http,ssl,tcp,dns,multi,icmp,udp,websocket,grpc

tags

[string]

Array of tags attached to the test.

type [required]

enum

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

{
  "config": {
    "assertions": [
      {
        "operator": "is",
        "target": 1,
        "type": "grpcHealthcheckStatus"
      }
    ],
    "request": {
      "host": "localhost",
      "port": 50051,
      "service": "Hello",
      "method": "GET",
      "message": "",
      "metadata": {}
    }
  },
  "locations": [
    "aws:us-east-2"
  ],
  "message": "BDD test payload: synthetics_api_grpc_test_payload.json",
  "name": "Example-Create_an_API_GRPC_test_returns_OK_Returns_the_created_test_details_response",
  "options": {
    "min_failure_duration": 0,
    "min_location_failed": 1,
    "monitor_options": {
      "renotify_interval": 0
    },
    "monitor_name": "Example-Create_an_API_GRPC_test_returns_OK_Returns_the_created_test_details_response",
    "tick_every": 60
  },
  "subtype": "grpc",
  "tags": [
    "testing:api"
  ],
  "type": "api"
}
{
  "config": {
    "assertions": [
      {
        "operator": "is",
        "property": "{{ PROPERTY }}",
        "target": "text/html",
        "type": "header"
      },
      {
        "operator": "lessThan",
        "target": 2000,
        "type": "responseTime"
      },
      {
        "operator": "validatesJSONPath",
        "target": {
          "jsonPath": "topKey",
          "operator": "isNot",
          "targetValue": "0"
        },
        "type": "body"
      },
      {
        "operator": "validatesXPath",
        "target": {
          "xPath": "target-xpath",
          "targetValue": "0",
          "operator": "contains"
        },
        "type": "body"
      }
    ],
    "configVariables": [
      {
        "example": "content-type",
        "name": "PROPERTY",
        "pattern": "content-type",
        "type": "text"
      }
    ],
    "request": {
      "certificate": {
        "cert": {
          "content": "cert-content",
          "filename": "cert-filename",
          "updatedAt": "2020-10-16T09:23:24.857Z"
        },
        "key": {
          "content": "key-content",
          "filename": "key-filename",
          "updatedAt": "2020-10-16T09:23:24.857Z"
        }
      },
      "headers": {
        "unique": "examplecreateanapihttptestreturnsokreturnsthecreatedtestdetailsresponse"
      },
      "method": "GET",
      "timeout": 10,
      "url": "https://datadoghq.com",
      "proxy": {
        "url": "https://datadoghq.com",
        "headers": {}
      },
      "basicAuth": {
        "accessTokenUrl": "https://datadog-token.com",
        "audience": "audience",
        "clientId": "client-id",
        "clientSecret": "client-secret",
        "resource": "resource",
        "scope": "yoyo",
        "tokenApiAuthentication": "header",
        "type": "oauth-client"
      }
    }
  },
  "locations": [
    "aws:us-east-2"
  ],
  "message": "BDD test payload: synthetics_api_http_test_payload.json",
  "name": "Example-Create_an_API_HTTP_test_returns_OK_Returns_the_created_test_details_response",
  "options": {
    "accept_self_signed": false,
    "allow_insecure": true,
    "follow_redirects": true,
    "min_failure_duration": 10,
    "min_location_failed": 1,
    "monitor_name": "Example-Create_an_API_HTTP_test_returns_OK_Returns_the_created_test_details_response",
    "monitor_priority": 5,
    "retry": {
      "count": 3,
      "interval": 10
    },
    "tick_every": 60
  },
  "subtype": "http",
  "tags": [
    "testing:api"
  ],
  "type": "api"
}
{
  "config": {
    "assertions": [
      {
        "operator": "isInMoreThan",
        "target": 10,
        "type": "certificate"
      }
    ],
    "request": {
      "host": "datadoghq.com",
      "port": 443
    }
  },
  "locations": [
    "aws:us-east-2"
  ],
  "message": "BDD test payload: synthetics_api_ssl_test_payload.json",
  "name": "Example-Create_an_API_SSL_test_returns_OK_Returns_the_created_test_details_response",
  "options": {
    "accept_self_signed": true,
    "checkCertificateRevocation": true,
    "tick_every": 60
  },
  "subtype": "ssl",
  "tags": [
    "testing:api"
  ],
  "type": "api"
}

Réponse

OK - Returns the created test details.

Object containing details about a Synthetic API test.

Expand All

Champ

Type

Description

config [required]

object

Configuration object for a Synthetic API test.

assertions

[object <oneOf>]

Array of assertions used for the test. Required for single API tests.

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,doesNotExist

property

string

The associated assertion property.

target [required]

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,receivedMessage,grpcHealthcheckStatus,connection

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,receivedMessage,grpcHealthcheckStatus,connection

Option 3

object

An assertion for the validatesXPath operator.

operator [required]

enum

Assertion operator to apply. Allowed enum values: validatesXPath

property

string

The associated assertion property.

target

object

Composed target for validatesXPath operator.

operator

string

The specific operator to use on the path.

targetValue

The path target value to compare to.

xPath

string

The X path to assert.

type [required]

enum

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

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 <oneOf>

Object to handle basic authentication when performing the test.

Option 1

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authentication.

type

enum

The type of basic authentication to use when performing the test. Allowed enum values: web

username [required]

string

Username to use for the basic authentication.

Option 2

object

Object to handle SIGV4 authentication when performing the test.

accessKey [required]

string

Access key for the SIGV4 authentication.

region

string

Region for the SIGV4 authentication.

secretKey [required]

string

Secret key for the SIGV4 authentication.

serviceName

string

Service name for the SIGV4 authentication.

sessionToken

string

Session token for the SIGV4 authentication.

type [required]

enum

The type of authentication to use when performing the test. Allowed enum values: sigv4

Option 3

object

Object to handle NTLM authentication when performing the test.

domain

string

Domain for the authentication to use when performing the test.

password

string

Password for the authentication to use when performing the test.

type [required]

enum

The type of authentication to use when performing the test. Allowed enum values: ntlm

username

string

Username for the authentication to use when performing the test.

workstation

string

Workstation for the authentication to use when performing the test.

Option 4

object

Object to handle digest authentication when performing the test.

password [required]

string

Password to use for the digest authentication.

type

enum

The type of basic authentication to use when performing the test. Allowed enum values: digest

username [required]

string

Username to use for the digest authentication.

Option 5

object

Object to handle oauth client authentication when performing the test.

accessTokenUrl [required]

string

Access token URL to use when performing the authentication.

audience

string

Audience to use when performing the authentication.

clientId [required]

string

Client ID to use when performing the authentication.

clientSecret [required]

string

Client secret to use when performing the authentication.

resource

string

Resource to use when performing the authentication.

scope

string

Scope to use when performing the authentication.

tokenApiAuthentication [required]

enum

Type of token to use when performing the authentication. Allowed enum values: header,body

type

enum

The type of basic authentication to use when performing the test. Allowed enum values: oauth-client

Option 6

object

Object to handle oauth rop authentication when performing the test.

accessTokenUrl [required]

string

Access token URL to use when performing the authentication.

audience

string

Audience to use when performing the authentication.

clientId

string

Client ID to use when performing the authentication.

clientSecret

string

Client secret to use when performing the authentication.

password [required]

string

Password to use when performing the authentication.

resource

string

Resource to use when performing the authentication.

scope

string

Scope to use when performing the authentication.

type

enum

The type of basic authentication to use when performing the test. Allowed enum values: oauth-rop

username [required]

string

Username to use when performing the authentication.

body

string

Body to include in the test.

bodyType

enum

Type of the request body. Allowed enum values: text/plain,application/json,text/xml,text/html,application/x-www-form-urlencoded,graphql

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.

certificateDomains

[string]

By default, the client certificate is applied on the domain of the starting URL for browser tests. If you want your client certificate to be applied on other domains instead, add them in certificateDomains.

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.

message

string

Message to send for UDP or WebSocket tests.

metadata

object

Metadata to include when performing the gRPC test.

<any-key>

string

A single Metadatum.

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.

proxy

object

The proxy to perform the test.

headers

object

Headers to include when performing the test.

<any-key>

string

A single Header.

url [required]

string

URL of the proxy to perform 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.

service

string

gRPC service on which you want to perform the healthcheck.

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 [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,doesNotExist

property

string

The associated assertion property.

target [required]

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,receivedMessage,grpcHealthcheckStatus,connection

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,receivedMessage,grpcHealthcheckStatus,connection

Option 3

object

An assertion for the validatesXPath operator.

operator [required]

enum

Assertion operator to apply. Allowed enum values: validatesXPath

property

string

The associated assertion property.

target

object

Composed target for validatesXPath operator.

operator

string

The specific operator to use on the path.

targetValue

The path target value to compare to.

xPath

string

The X path to assert.

type [required]

enum

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

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,local_variable

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 [required]

string

The name of the step.

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 <oneOf>

Object to handle basic authentication when performing the test.

Option 1

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authentication.

type

enum

The type of basic authentication to use when performing the test. Allowed enum values: web

username [required]

string

Username to use for the basic authentication.

Option 2

object

Object to handle SIGV4 authentication when performing the test.

accessKey [required]

string

Access key for the SIGV4 authentication.

region

string

Region for the SIGV4 authentication.

secretKey [required]

string

Secret key for the SIGV4 authentication.

serviceName

string

Service name for the SIGV4 authentication.

sessionToken

string

Session token for the SIGV4 authentication.

type [required]

enum

The type of authentication to use when performing the test. Allowed enum values: sigv4

Option 3

object

Object to handle NTLM authentication when performing the test.

domain

string

Domain for the authentication to use when performing the test.

password

string

Password for the authentication to use when performing the test.

type [required]

enum

The type of authentication to use when performing the test. Allowed enum values: ntlm

username

string

Username for the authentication to use when performing the test.

workstation

string

Workstation for the authentication to use when performing the test.

Option 4

object

Object to handle digest authentication when performing the test.

password [required]

string

Password to use for the digest authentication.

type

enum

The type of basic authentication to use when performing the test. Allowed enum values: digest

username [required]

string

Username to use for the digest authentication.

Option 5

object

Object to handle oauth client authentication when performing the test.

accessTokenUrl [required]

string

Access token URL to use when performing the authentication.

audience

string

Audience to use when performing the authentication.

clientId [required]

string

Client ID to use when performing the authentication.

clientSecret [required]

string

Client secret to use when performing the authentication.

resource

string

Resource to use when performing the authentication.

scope

string

Scope to use when performing the authentication.

tokenApiAuthentication [required]

enum

Type of token to use when performing the authentication. Allowed enum values: header,body

type

enum

The type of basic authentication to use when performing the test. Allowed enum values: oauth-client

Option 6

object

Object to handle oauth rop authentication when performing the test.

accessTokenUrl [required]

string

Access token URL to use when performing the authentication.

audience

string

Audience to use when performing the authentication.

clientId

string

Client ID to use when performing the authentication.

clientSecret

string

Client secret to use when performing the authentication.

password [required]

string

Password to use when performing the authentication.

resource

string

Resource to use when performing the authentication.

scope

string

Scope to use when performing the authentication.

type

enum

The type of basic authentication to use when performing the test. Allowed enum values: oauth-rop

username [required]

string

Username to use when performing the authentication.

body

string

Body to include in the test.

bodyType

enum

Type of the request body. Allowed enum values: text/plain,application/json,text/xml,text/html,application/x-www-form-urlencoded,graphql

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.

certificateDomains

[string]

By default, the client certificate is applied on the domain of the starting URL for browser tests. If you want your client certificate to be applied on other domains instead, add them in certificateDomains.

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.

message

string

Message to send for UDP or WebSocket tests.

metadata

object

Metadata to include when performing the gRPC test.

<any-key>

string

A single Metadatum.

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.

proxy

object

The proxy to perform the test.

headers

object

Headers to include when performing the test.

<any-key>

string

A single Header.

url [required]

string

URL of the proxy to perform 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.

service

string

gRPC service on which you want to perform the healthcheck.

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.

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.

subtype [required]

enum

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

locations [required]

[string]

Array of locations used to run the test.

message [required]

string

Notification message associated with the test.

monitor_id

int64

The associated monitor ID.

name [required]

string

Name of the test.

options [required]

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 in an API test.

checkCertificateRevocation

boolean

For SSL test, whether or not the test should fail on revoked certificate in stapled OCSP.

ci

object

CI/CD options for a Synthetic test.

executionRule

enum

Execution rule for a Synthetics test. Allowed enum values: blocking,non_blocking,skipped

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.

disableCsp

boolean

Disable Content Security Policy for browser tests.

follow_redirects

boolean

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

ignoreServerCertificateError

boolean

Ignore server certificate error for browser tests.

initialNavigationTimeout

int64

Timeout before declaring the initial step as failed (in seconds) for browser tests.

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.

restricted_roles

[string]

A list of role identifiers that can be pulled from the Roles API, for restricting read and write access.

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.

rumSettings

object

The RUM data collection settings for the Synthetic browser test. Note: There are 3 ways to format RUM settings:

{ isEnabled: false } RUM data is not collected.

{ isEnabled: true } RUM data is collected from the Synthetic test's default application.

{ isEnabled: true, applicationId: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", clientTokenId: 12345 } RUM data is collected using the specified application.

applicationId

string

RUM application ID used to collect RUM data for the browser test.

clientTokenId

int64

RUM application API key ID used to collect RUM data for the browser test.

isEnabled [required]

boolean

Determines whether RUM data is collected during test runs.

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, udp, websocket, grpc or multi. Allowed enum values: http,ssl,tcp,dns,multi,icmp,udp,websocket,grpc

tags

[string]

Array of tags attached to the test.

type [required]

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": "PaSSw0RD!",
        "type": "web",
        "username": "my_username"
      },
      "body": "string",
      "bodyType": "text/plain",
      "certificate": {
        "cert": {
          "content": "string",
          "filename": "string",
          "updatedAt": "string"
        },
        "key": {
          "content": "string",
          "filename": "string",
          "updatedAt": "string"
        }
      },
      "certificateDomains": [],
      "dnsServer": "string",
      "dnsServerPort": "integer",
      "follow_redirects": false,
      "headers": {
        "<any-key>": "string"
      },
      "host": "string",
      "message": "string",
      "metadata": {
        "<any-key>": "string"
      },
      "method": "GET",
      "noSavingResponseBody": false,
      "numberOfPackets": "integer",
      "port": "integer",
      "proxy": {
        "headers": {
          "<any-key>": "string"
        },
        "url": "https://example.com"
      },
      "query": {},
      "servername": "string",
      "service": "string",
      "shouldTrackHops": false,
      "timeout": "number",
      "url": "https://example.com"
    },
    "steps": [
      {
        "allowFailure": false,
        "assertions": [
          {
            "operator": "contains",
            "property": "string",
            "target": 123456,
            "type": "statusCode"
          }
        ],
        "extractedValues": [
          {
            "field": "content-type",
            "name": "string",
            "parser": {
              "type": "raw",
              "value": "string"
            },
            "type": "http_body"
          }
        ],
        "isCritical": false,
        "name": "Example step name",
        "request": {
          "allow_insecure": false,
          "basicAuth": {
            "password": "PaSSw0RD!",
            "type": "web",
            "username": "my_username"
          },
          "body": "string",
          "bodyType": "text/plain",
          "certificate": {
            "cert": {
              "content": "string",
              "filename": "string",
              "updatedAt": "string"
            },
            "key": {
              "content": "string",
              "filename": "string",
              "updatedAt": "string"
            }
          },
          "certificateDomains": [],
          "dnsServer": "string",
          "dnsServerPort": "integer",
          "follow_redirects": false,
          "headers": {
            "<any-key>": "string"
          },
          "host": "string",
          "message": "string",
          "metadata": {
            "<any-key>": "string"
          },
          "method": "GET",
          "noSavingResponseBody": false,
          "numberOfPackets": "integer",
          "port": "integer",
          "proxy": {
            "headers": {
              "<any-key>": "string"
            },
            "url": "https://example.com"
          },
          "query": {},
          "servername": "string",
          "service": "string",
          "shouldTrackHops": false,
          "timeout": "number",
          "url": "https://example.com"
        },
        "retry": {
          "count": "integer",
          "interval": "number"
        },
        "subtype": "http"
      }
    ]
  },
  "locations": [
    "aws:eu-west-3"
  ],
  "message": "Notification message",
  "monitor_id": 12345678,
  "name": "Example test name",
  "options": {
    "accept_self_signed": false,
    "allow_insecure": false,
    "checkCertificateRevocation": false,
    "ci": {
      "executionRule": "string"
    },
    "device_ids": [
      "laptop_large"
    ],
    "disableCors": false,
    "disableCsp": false,
    "follow_redirects": false,
    "ignoreServerCertificateError": false,
    "initialNavigationTimeout": "integer",
    "min_failure_duration": "integer",
    "min_location_failed": "integer",
    "monitor_name": "string",
    "monitor_options": {
      "renotify_interval": "integer"
    },
    "monitor_priority": "integer",
    "noScreenshot": false,
    "restricted_roles": [
      "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
    ],
    "retry": {
      "count": "integer",
      "interval": "number"
    },
    "rumSettings": {
      "applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "clientTokenId": 12345,
      "isEnabled": true
    },
    "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

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Test quota is reached

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Forbidden

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Too many requests

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Exemple de code

  
  ## Create an API test.
# Example of an API test.
# 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 "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
  "config": {
    "assertions": [
      {
        "operator": "is",
        "target": 1,
        "type": "grpcHealthcheckStatus"
      }
    ],
    "request": {
      "host": "localhost",
      "port": 50051,
      "service": "Hello",
      "method": "GET",
      "message": "",
      "metadata": {}
    }
  },
  "locations": [
    "aws:us-east-2"
  ],
  "message": "BDD test payload: synthetics_api_grpc_test_payload.json",
  "name": "Example-Create_an_API_GRPC_test_returns_OK_Returns_the_created_test_details_response",
  "options": {
    "min_failure_duration": 0,
    "min_location_failed": 1,
    "monitor_options": {
      "renotify_interval": 0
    },
    "monitor_name": "Example-Create_an_API_GRPC_test_returns_OK_Returns_the_created_test_details_response",
    "tick_every": 60
  },
  "subtype": "grpc",
  "tags": [
    "testing:api"
  ],
  "type": "api"
}
EOF
## Create a Multistep API test # Example of a multistep API test running on a fake furniture store. # It creates a card, select a product and then add the product to the card. # 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 "Accept: application/json" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \ -d @- << EOF { "config": { "assertions": [ { "operator": "is", "target": 1, "type": "grpcHealthcheckStatus" } ], "request": { "host": "localhost", "port": 50051, "service": "Hello", "method": "GET", "message": "", "metadata": {} } }, "locations": [ "aws:us-east-2" ], "message": "BDD test payload: synthetics_api_grpc_test_payload.json", "name": "Example-Create_an_API_GRPC_test_returns_OK_Returns_the_created_test_details_response", "options": { "min_failure_duration": 0, "min_location_failed": 1, "monitor_options": { "renotify_interval": 0 }, "monitor_name": "Example-Create_an_API_GRPC_test_returns_OK_Returns_the_created_test_details_response", "tick_every": 60 }, "subtype": "grpc", "tags": [ "testing:api" ], "type": "api" } EOF
  
  ## Create an API test.
# Example of an API test.
# 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 "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
  "config": {
    "assertions": [
      {
        "operator": "is",
        "property": "{{ PROPERTY }}",
        "target": "text/html",
        "type": "header"
      },
      {
        "operator": "lessThan",
        "target": 2000,
        "type": "responseTime"
      },
      {
        "operator": "validatesJSONPath",
        "target": {
          "jsonPath": "topKey",
          "operator": "isNot",
          "targetValue": "0"
        },
        "type": "body"
      },
      {
        "operator": "validatesXPath",
        "target": {
          "xPath": "target-xpath",
          "targetValue": "0",
          "operator": "contains"
        },
        "type": "body"
      }
    ],
    "configVariables": [
      {
        "example": "content-type",
        "name": "PROPERTY",
        "pattern": "content-type",
        "type": "text"
      }
    ],
    "request": {
      "certificate": {
        "cert": {
          "content": "cert-content",
          "filename": "cert-filename",
          "updatedAt": "2020-10-16T09:23:24.857Z"
        },
        "key": {
          "content": "key-content",
          "filename": "key-filename",
          "updatedAt": "2020-10-16T09:23:24.857Z"
        }
      },
      "headers": {
        "unique": "examplecreateanapihttptestreturnsokreturnsthecreatedtestdetailsresponse"
      },
      "method": "GET",
      "timeout": 10,
      "url": "https://datadoghq.com",
      "proxy": {
        "url": "https://datadoghq.com",
        "headers": {}
      },
      "basicAuth": {
        "accessTokenUrl": "https://datadog-token.com",
        "audience": "audience",
        "clientId": "client-id",
        "clientSecret": "client-secret",
        "resource": "resource",
        "scope": "yoyo",
        "tokenApiAuthentication": "header",
        "type": "oauth-client"
      }
    }
  },
  "locations": [
    "aws:us-east-2"
  ],
  "message": "BDD test payload: synthetics_api_http_test_payload.json",
  "name": "Example-Create_an_API_HTTP_test_returns_OK_Returns_the_created_test_details_response",
  "options": {
    "accept_self_signed": false,
    "allow_insecure": true,
    "follow_redirects": true,
    "min_failure_duration": 10,
    "min_location_failed": 1,
    "monitor_name": "Example-Create_an_API_HTTP_test_returns_OK_Returns_the_created_test_details_response",
    "monitor_priority": 5,
    "retry": {
      "count": 3,
      "interval": 10
    },
    "tick_every": 60
  },
  "subtype": "http",
  "tags": [
    "testing:api"
  ],
  "type": "api"
}
EOF
## Create a Multistep API test # Example of a multistep API test running on a fake furniture store. # It creates a card, select a product and then add the product to the card. # 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 "Accept: application/json" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \ -d @- << EOF { "config": { "assertions": [ { "operator": "is", "property": "{{ PROPERTY }}", "target": "text/html", "type": "header" }, { "operator": "lessThan", "target": 2000, "type": "responseTime" }, { "operator": "validatesJSONPath", "target": { "jsonPath": "topKey", "operator": "isNot", "targetValue": "0" }, "type": "body" }, { "operator": "validatesXPath", "target": { "xPath": "target-xpath", "targetValue": "0", "operator": "contains" }, "type": "body" } ], "configVariables": [ { "example": "content-type", "name": "PROPERTY", "pattern": "content-type", "type": "text" } ], "request": { "certificate": { "cert": { "content": "cert-content", "filename": "cert-filename", "updatedAt": "2020-10-16T09:23:24.857Z" }, "key": { "content": "key-content", "filename": "key-filename", "updatedAt": "2020-10-16T09:23:24.857Z" } }, "headers": { "unique": "examplecreateanapihttptestreturnsokreturnsthecreatedtestdetailsresponse" }, "method": "GET", "timeout": 10, "url": "https://datadoghq.com", "proxy": { "url": "https://datadoghq.com", "headers": {} }, "basicAuth": { "accessTokenUrl": "https://datadog-token.com", "audience": "audience", "clientId": "client-id", "clientSecret": "client-secret", "resource": "resource", "scope": "yoyo", "tokenApiAuthentication": "header", "type": "oauth-client" } } }, "locations": [ "aws:us-east-2" ], "message": "BDD test payload: synthetics_api_http_test_payload.json", "name": "Example-Create_an_API_HTTP_test_returns_OK_Returns_the_created_test_details_response", "options": { "accept_self_signed": false, "allow_insecure": true, "follow_redirects": true, "min_failure_duration": 10, "min_location_failed": 1, "monitor_name": "Example-Create_an_API_HTTP_test_returns_OK_Returns_the_created_test_details_response", "monitor_priority": 5, "retry": { "count": 3, "interval": 10 }, "tick_every": 60 }, "subtype": "http", "tags": [ "testing:api" ], "type": "api" } EOF
  
  ## Create an API test.
# Example of an API test.
# 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 "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
  "config": {
    "assertions": [
      {
        "operator": "isInMoreThan",
        "target": 10,
        "type": "certificate"
      }
    ],
    "request": {
      "host": "datadoghq.com",
      "port": 443
    }
  },
  "locations": [
    "aws:us-east-2"
  ],
  "message": "BDD test payload: synthetics_api_ssl_test_payload.json",
  "name": "Example-Create_an_API_SSL_test_returns_OK_Returns_the_created_test_details_response",
  "options": {
    "accept_self_signed": true,
    "checkCertificateRevocation": true,
    "tick_every": 60
  },
  "subtype": "ssl",
  "tags": [
    "testing:api"
  ],
  "type": "api"
}
EOF
## Create a Multistep API test # Example of a multistep API test running on a fake furniture store. # It creates a card, select a product and then add the product to the card. # 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 "Accept: application/json" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \ -d @- << EOF { "config": { "assertions": [ { "operator": "isInMoreThan", "target": 10, "type": "certificate" } ], "request": { "host": "datadoghq.com", "port": 443 } }, "locations": [ "aws:us-east-2" ], "message": "BDD test payload: synthetics_api_ssl_test_payload.json", "name": "Example-Create_an_API_SSL_test_returns_OK_Returns_the_created_test_details_response", "options": { "accept_self_signed": true, "checkCertificateRevocation": true, "tick_every": 60 }, "subtype": "ssl", "tags": [ "testing:api" ], "type": "api" } EOF
// Create an API GRPC test returns "OK - Returns the created test details." response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

	"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
	"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
)

func main() {
	body := datadogV1.SyntheticsAPITest{
		Config: datadogV1.SyntheticsAPITestConfig{
			Assertions: []datadogV1.SyntheticsAssertion{
				datadogV1.SyntheticsAssertion{
					SyntheticsAssertionTarget: &datadogV1.SyntheticsAssertionTarget{
						Operator: datadogV1.SYNTHETICSASSERTIONOPERATOR_IS,
						Target:   1,
						Type:     datadogV1.SYNTHETICSASSERTIONTYPE_GRPC_HEALTHCHECK_STATUS,
					}},
			},
			Request: &datadogV1.SyntheticsTestRequest{
				Host:     datadog.PtrString("localhost"),
				Port:     datadog.PtrInt64(50051),
				Service:  datadog.PtrString("Hello"),
				Method:   datadogV1.HTTPMETHOD_GET.Ptr(),
				Message:  datadog.PtrString(""),
				Metadata: map[string]string{},
			},
		},
		Locations: []string{
			"aws:us-east-2",
		},
		Message: "BDD test payload: synthetics_api_grpc_test_payload.json",
		Name:    "Example-Create_an_API_GRPC_test_returns_OK_Returns_the_created_test_details_response",
		Options: datadogV1.SyntheticsTestOptions{
			MinFailureDuration: datadog.PtrInt64(0),
			MinLocationFailed:  datadog.PtrInt64(1),
			MonitorOptions: &datadogV1.SyntheticsTestOptionsMonitorOptions{
				RenotifyInterval: datadog.PtrInt64(0),
			},
			MonitorName: datadog.PtrString("Example-Create_an_API_GRPC_test_returns_OK_Returns_the_created_test_details_response"),
			TickEvery:   datadog.PtrInt64(60),
		},
		Subtype: datadogV1.SYNTHETICSTESTDETAILSSUBTYPE_GRPC.Ptr(),
		Tags: []string{
			"testing:api",
		},
		Type: datadogV1.SYNTHETICSAPITESTTYPE_API,
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV1.NewSyntheticsApi(apiClient)
	resp, r, err := api.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)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `SyntheticsApi.CreateSyntheticsAPITest`:\n%s\n", responseContent)
}
// Create an API HTTP test returns "OK - Returns the created test details." response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

	"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
	"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
)

func main() {
	body := datadogV1.SyntheticsAPITest{
		Config: datadogV1.SyntheticsAPITestConfig{
			Assertions: []datadogV1.SyntheticsAssertion{
				datadogV1.SyntheticsAssertion{
					SyntheticsAssertionTarget: &datadogV1.SyntheticsAssertionTarget{
						Operator: datadogV1.SYNTHETICSASSERTIONOPERATOR_IS,
						Property: datadog.PtrString("{{ PROPERTY }}"),
						Target:   "text/html",
						Type:     datadogV1.SYNTHETICSASSERTIONTYPE_HEADER,
					}},
				datadogV1.SyntheticsAssertion{
					SyntheticsAssertionTarget: &datadogV1.SyntheticsAssertionTarget{
						Operator: datadogV1.SYNTHETICSASSERTIONOPERATOR_LESS_THAN,
						Target:   2000,
						Type:     datadogV1.SYNTHETICSASSERTIONTYPE_RESPONSE_TIME,
					}},
				datadogV1.SyntheticsAssertion{
					SyntheticsAssertionJSONPathTarget: &datadogV1.SyntheticsAssertionJSONPathTarget{
						Operator: datadogV1.SYNTHETICSASSERTIONJSONPATHOPERATOR_VALIDATES_JSON_PATH,
						Target: &datadogV1.SyntheticsAssertionJSONPathTargetTarget{
							JsonPath:    datadog.PtrString("topKey"),
							Operator:    datadog.PtrString("isNot"),
							TargetValue: "0",
						},
						Type: datadogV1.SYNTHETICSASSERTIONTYPE_BODY,
					}},
				datadogV1.SyntheticsAssertion{
					SyntheticsAssertionXPathTarget: &datadogV1.SyntheticsAssertionXPathTarget{
						Operator: datadogV1.SYNTHETICSASSERTIONXPATHOPERATOR_VALIDATES_X_PATH,
						Target: &datadogV1.SyntheticsAssertionXPathTargetTarget{
							XPath:       datadog.PtrString("target-xpath"),
							TargetValue: "0",
							Operator:    datadog.PtrString("contains"),
						},
						Type: datadogV1.SYNTHETICSASSERTIONTYPE_BODY,
					}},
			},
			ConfigVariables: []datadogV1.SyntheticsConfigVariable{
				{
					Example: datadog.PtrString("content-type"),
					Name:    "PROPERTY",
					Pattern: datadog.PtrString("content-type"),
					Type:    datadogV1.SYNTHETICSCONFIGVARIABLETYPE_TEXT,
				},
			},
			Request: &datadogV1.SyntheticsTestRequest{
				Certificate: &datadogV1.SyntheticsTestRequestCertificate{
					Cert: &datadogV1.SyntheticsTestRequestCertificateItem{
						Content:   datadog.PtrString("cert-content"),
						Filename:  datadog.PtrString("cert-filename"),
						UpdatedAt: datadog.PtrString("2020-10-16T09:23:24.857Z"),
					},
					Key: &datadogV1.SyntheticsTestRequestCertificateItem{
						Content:   datadog.PtrString("key-content"),
						Filename:  datadog.PtrString("key-filename"),
						UpdatedAt: datadog.PtrString("2020-10-16T09:23:24.857Z"),
					},
				},
				Headers: map[string]string{
					"unique": "examplecreateanapihttptestreturnsokreturnsthecreatedtestdetailsresponse",
				},
				Method:  datadogV1.HTTPMETHOD_GET.Ptr(),
				Timeout: datadog.PtrFloat64(10),
				Url:     datadog.PtrString("https://datadoghq.com"),
				Proxy: &datadogV1.SyntheticsTestRequestProxy{
					Url:     "https://datadoghq.com",
					Headers: map[string]string{},
				},
			},
		},
		Locations: []string{
			"aws:us-east-2",
		},
		Message: "BDD test payload: synthetics_api_http_test_payload.json",
		Name:    "Example-Create_an_API_HTTP_test_returns_OK_Returns_the_created_test_details_response",
		Options: datadogV1.SyntheticsTestOptions{
			AcceptSelfSigned:   datadog.PtrBool(false),
			AllowInsecure:      datadog.PtrBool(true),
			FollowRedirects:    datadog.PtrBool(true),
			MinFailureDuration: datadog.PtrInt64(10),
			MinLocationFailed:  datadog.PtrInt64(1),
			MonitorName:        datadog.PtrString("Example-Create_an_API_HTTP_test_returns_OK_Returns_the_created_test_details_response"),
			MonitorPriority:    datadog.PtrInt32(5),
			Retry: &datadogV1.SyntheticsTestOptionsRetry{
				Count:    datadog.PtrInt64(3),
				Interval: datadog.PtrFloat64(10),
			},
			TickEvery: datadog.PtrInt64(60),
		},
		Subtype: datadogV1.SYNTHETICSTESTDETAILSSUBTYPE_HTTP.Ptr(),
		Tags: []string{
			"testing:api",
		},
		Type: datadogV1.SYNTHETICSAPITESTTYPE_API,
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV1.NewSyntheticsApi(apiClient)
	resp, r, err := api.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)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `SyntheticsApi.CreateSyntheticsAPITest`:\n%s\n", responseContent)
}
// Create an API SSL test returns "OK - Returns the created test details." response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

	"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
	"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
)

func main() {
	body := datadogV1.SyntheticsAPITest{
		Config: datadogV1.SyntheticsAPITestConfig{
			Assertions: []datadogV1.SyntheticsAssertion{
				datadogV1.SyntheticsAssertion{
					SyntheticsAssertionTarget: &datadogV1.SyntheticsAssertionTarget{
						Operator: datadogV1.SYNTHETICSASSERTIONOPERATOR_IS_IN_MORE_DAYS_THAN,
						Target:   10,
						Type:     datadogV1.SYNTHETICSASSERTIONTYPE_CERTIFICATE,
					}},
			},
			Request: &datadogV1.SyntheticsTestRequest{
				Host: datadog.PtrString("datadoghq.com"),
				Port: datadog.PtrInt64(443),
			},
		},
		Locations: []string{
			"aws:us-east-2",
		},
		Message: "BDD test payload: synthetics_api_ssl_test_payload.json",
		Name:    "Example-Create_an_API_SSL_test_returns_OK_Returns_the_created_test_details_response",
		Options: datadogV1.SyntheticsTestOptions{
			AcceptSelfSigned:           datadog.PtrBool(true),
			CheckCertificateRevocation: datadog.PtrBool(true),
			TickEvery:                  datadog.PtrInt64(60),
		},
		Subtype: datadogV1.SYNTHETICSTESTDETAILSSUBTYPE_SSL.Ptr(),
		Tags: []string{
			"testing:api",
		},
		Type: datadogV1.SYNTHETICSAPITESTTYPE_API,
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV1.NewSyntheticsApi(apiClient)
	resp, r, err := api.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)
	}

	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:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Create an API GRPC test returns "OK - Returns the created test details." response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.SyntheticsApi;
import com.datadog.api.client.v1.model.HTTPMethod;
import com.datadog.api.client.v1.model.SyntheticsAPITest;
import com.datadog.api.client.v1.model.SyntheticsAPITestConfig;
import com.datadog.api.client.v1.model.SyntheticsAPITestType;
import com.datadog.api.client.v1.model.SyntheticsAssertion;
import com.datadog.api.client.v1.model.SyntheticsAssertionOperator;
import com.datadog.api.client.v1.model.SyntheticsAssertionTarget;
import com.datadog.api.client.v1.model.SyntheticsAssertionType;
import com.datadog.api.client.v1.model.SyntheticsTestDetailsSubType;
import com.datadog.api.client.v1.model.SyntheticsTestOptions;
import com.datadog.api.client.v1.model.SyntheticsTestOptionsMonitorOptions;
import com.datadog.api.client.v1.model.SyntheticsTestRequest;
import java.util.Collections;
import java.util.Map;

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

    SyntheticsAPITest body =
        new SyntheticsAPITest()
            .config(
                new SyntheticsAPITestConfig()
                    .assertions(
                        Collections.singletonList(
                            new SyntheticsAssertion(
                                new SyntheticsAssertionTarget()
                                    .operator(SyntheticsAssertionOperator.IS)
                                    .target(1)
                                    .type(SyntheticsAssertionType.GRPC_HEALTHCHECK_STATUS))))
                    .request(
                        new SyntheticsTestRequest()
                            .host("localhost")
                            .port(50051L)
                            .service("Hello")
                            .method(HTTPMethod.GET)
                            .message("")
                            .metadata(Map.ofEntries())))
            .locations(Collections.singletonList("aws:us-east-2"))
            .message("BDD test payload: synthetics_api_grpc_test_payload.json")
            .name(
                "Example-Create_an_API_GRPC_test_returns_OK_Returns_the_created_test_details_response")
            .options(
                new SyntheticsTestOptions()
                    .minFailureDuration(0L)
                    .minLocationFailed(1L)
                    .monitorOptions(new SyntheticsTestOptionsMonitorOptions().renotifyInterval(0L))
                    .monitorName(
                        "Example-Create_an_API_GRPC_test_returns_OK_Returns_the_created_test_details_response")
                    .tickEvery(60L))
            .subtype(SyntheticsTestDetailsSubType.GRPC)
            .tags(Collections.singletonList("testing:api"))
            .type(SyntheticsAPITestType.API);

    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();
    }
  }
}
// Create an API HTTP test returns "OK - Returns the created test details." response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.SyntheticsApi;
import com.datadog.api.client.v1.model.HTTPMethod;
import com.datadog.api.client.v1.model.SyntheticsAPITest;
import com.datadog.api.client.v1.model.SyntheticsAPITestConfig;
import com.datadog.api.client.v1.model.SyntheticsAPITestType;
import com.datadog.api.client.v1.model.SyntheticsAssertion;
import com.datadog.api.client.v1.model.SyntheticsAssertionJSONPathOperator;
import com.datadog.api.client.v1.model.SyntheticsAssertionJSONPathTarget;
import com.datadog.api.client.v1.model.SyntheticsAssertionJSONPathTargetTarget;
import com.datadog.api.client.v1.model.SyntheticsAssertionOperator;
import com.datadog.api.client.v1.model.SyntheticsAssertionTarget;
import com.datadog.api.client.v1.model.SyntheticsAssertionType;
import com.datadog.api.client.v1.model.SyntheticsAssertionXPathOperator;
import com.datadog.api.client.v1.model.SyntheticsAssertionXPathTarget;
import com.datadog.api.client.v1.model.SyntheticsAssertionXPathTargetTarget;
import com.datadog.api.client.v1.model.SyntheticsConfigVariable;
import com.datadog.api.client.v1.model.SyntheticsConfigVariableType;
import com.datadog.api.client.v1.model.SyntheticsTestDetailsSubType;
import com.datadog.api.client.v1.model.SyntheticsTestOptions;
import com.datadog.api.client.v1.model.SyntheticsTestOptionsRetry;
import com.datadog.api.client.v1.model.SyntheticsTestRequest;
import com.datadog.api.client.v1.model.SyntheticsTestRequestCertificate;
import com.datadog.api.client.v1.model.SyntheticsTestRequestCertificateItem;
import com.datadog.api.client.v1.model.SyntheticsTestRequestProxy;
import java.util.Arrays;
import java.util.Collections;
import java.util.Map;

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

    SyntheticsAPITest body =
        new SyntheticsAPITest()
            .config(
                new SyntheticsAPITestConfig()
                    .assertions(
                        Arrays.asList(
                            new SyntheticsAssertion(
                                new SyntheticsAssertionTarget()
                                    .operator(SyntheticsAssertionOperator.IS)
                                    .property("{{ PROPERTY }}")
                                    .target("text/html")
                                    .type(SyntheticsAssertionType.HEADER)),
                            new SyntheticsAssertion(
                                new SyntheticsAssertionTarget()
                                    .operator(SyntheticsAssertionOperator.LESS_THAN)
                                    .target(2000)
                                    .type(SyntheticsAssertionType.RESPONSE_TIME)),
                            new SyntheticsAssertion(
                                new SyntheticsAssertionJSONPathTarget()
                                    .operator(
                                        SyntheticsAssertionJSONPathOperator.VALIDATES_JSON_PATH)
                                    .target(
                                        new SyntheticsAssertionJSONPathTargetTarget()
                                            .jsonPath("topKey")
                                            .operator("isNot")
                                            .targetValue("0"))
                                    .type(SyntheticsAssertionType.BODY)),
                            new SyntheticsAssertion(
                                new SyntheticsAssertionXPathTarget()
                                    .operator(SyntheticsAssertionXPathOperator.VALIDATES_X_PATH)
                                    .target(
                                        new SyntheticsAssertionXPathTargetTarget()
                                            .xPath("target-xpath")
                                            .targetValue("0")
                                            .operator("contains"))
                                    .type(SyntheticsAssertionType.BODY))))
                    .configVariables(
                        Collections.singletonList(
                            new SyntheticsConfigVariable()
                                .example("content-type")
                                .name("PROPERTY")
                                .pattern("content-type")
                                .type(SyntheticsConfigVariableType.TEXT)))
                    .request(
                        new SyntheticsTestRequest()
                            .certificate(
                                new SyntheticsTestRequestCertificate()
                                    .cert(
                                        new SyntheticsTestRequestCertificateItem()
                                            .content("cert-content")
                                            .filename("cert-filename")
                                            .updatedAt("2020-10-16T09:23:24.857Z"))
                                    .key(
                                        new SyntheticsTestRequestCertificateItem()
                                            .content("key-content")
                                            .filename("key-filename")
                                            .updatedAt("2020-10-16T09:23:24.857Z")))
                            .headers(
                                Map.ofEntries(
                                    Map.entry(
                                        "unique",
                                        "examplecreateanapihttptestreturnsokreturnsthecreatedtestdetailsresponse")))
                            .method(HTTPMethod.GET)
                            .timeout(10.0)
                            .url("https://datadoghq.com")
                            .proxy(
                                new SyntheticsTestRequestProxy()
                                    .url("https://datadoghq.com")
                                    .headers(Map.ofEntries()))))
            .locations(Collections.singletonList("aws:us-east-2"))
            .message("BDD test payload: synthetics_api_http_test_payload.json")
            .name(
                "Example-Create_an_API_HTTP_test_returns_OK_Returns_the_created_test_details_response")
            .options(
                new SyntheticsTestOptions()
                    .acceptSelfSigned(false)
                    .allowInsecure(true)
                    .followRedirects(true)
                    .minFailureDuration(10L)
                    .minLocationFailed(1L)
                    .monitorName(
                        "Example-Create_an_API_HTTP_test_returns_OK_Returns_the_created_test_details_response")
                    .monitorPriority(5)
                    .retry(new SyntheticsTestOptionsRetry().count(3L).interval(10.0))
                    .tickEvery(60L))
            .subtype(SyntheticsTestDetailsSubType.HTTP)
            .tags(Collections.singletonList("testing:api"))
            .type(SyntheticsAPITestType.API);

    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();
    }
  }
}
// Create an API SSL test returns "OK - Returns the created test details." response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.SyntheticsApi;
import com.datadog.api.client.v1.model.SyntheticsAPITest;
import com.datadog.api.client.v1.model.SyntheticsAPITestConfig;
import com.datadog.api.client.v1.model.SyntheticsAPITestType;
import com.datadog.api.client.v1.model.SyntheticsAssertion;
import com.datadog.api.client.v1.model.SyntheticsAssertionOperator;
import com.datadog.api.client.v1.model.SyntheticsAssertionTarget;
import com.datadog.api.client.v1.model.SyntheticsAssertionType;
import com.datadog.api.client.v1.model.SyntheticsTestDetailsSubType;
import com.datadog.api.client.v1.model.SyntheticsTestOptions;
import com.datadog.api.client.v1.model.SyntheticsTestRequest;
import java.util.Collections;

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

    SyntheticsAPITest body =
        new SyntheticsAPITest()
            .config(
                new SyntheticsAPITestConfig()
                    .assertions(
                        Collections.singletonList(
                            new SyntheticsAssertion(
                                new SyntheticsAssertionTarget()
                                    .operator(SyntheticsAssertionOperator.IS_IN_MORE_DAYS_THAN)
                                    .target(10)
                                    .type(SyntheticsAssertionType.CERTIFICATE))))
                    .request(new SyntheticsTestRequest().host("datadoghq.com").port(443L)))
            .locations(Collections.singletonList("aws:us-east-2"))
            .message("BDD test payload: synthetics_api_ssl_test_payload.json")
            .name(
                "Example-Create_an_API_SSL_test_returns_OK_Returns_the_created_test_details_response")
            .options(
                new SyntheticsTestOptions()
                    .acceptSelfSigned(true)
                    .checkCertificateRevocation(true)
                    .tickEvery(60L))
            .subtype(SyntheticsTestDetailsSubType.SSL)
            .tags(Collections.singletonList("testing:api"))
            .type(SyntheticsAPITestType.API);

    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:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
"""
Create an API GRPC test returns "OK - Returns the created test details." response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.synthetics_api import SyntheticsApi
from datadog_api_client.v1.model.http_method import HTTPMethod
from datadog_api_client.v1.model.synthetics_api_test import SyntheticsAPITest
from datadog_api_client.v1.model.synthetics_api_test_config import SyntheticsAPITestConfig
from datadog_api_client.v1.model.synthetics_api_test_type import SyntheticsAPITestType
from datadog_api_client.v1.model.synthetics_assertion_operator import SyntheticsAssertionOperator
from datadog_api_client.v1.model.synthetics_assertion_target import SyntheticsAssertionTarget
from datadog_api_client.v1.model.synthetics_assertion_type import SyntheticsAssertionType
from datadog_api_client.v1.model.synthetics_test_details_sub_type import SyntheticsTestDetailsSubType
from datadog_api_client.v1.model.synthetics_test_metadata import SyntheticsTestMetadata
from datadog_api_client.v1.model.synthetics_test_options import SyntheticsTestOptions
from datadog_api_client.v1.model.synthetics_test_options_monitor_options import SyntheticsTestOptionsMonitorOptions
from datadog_api_client.v1.model.synthetics_test_request import SyntheticsTestRequest

body = SyntheticsAPITest(
    config=SyntheticsAPITestConfig(
        assertions=[
            SyntheticsAssertionTarget(
                operator=SyntheticsAssertionOperator.IS,
                target=1,
                type=SyntheticsAssertionType.GRPC_HEALTHCHECK_STATUS,
            ),
        ],
        request=SyntheticsTestRequest(
            host="localhost",
            port=50051,
            service="Hello",
            method=HTTPMethod.GET,
            message="",
            metadata=SyntheticsTestMetadata(),
        ),
    ),
    locations=[
        "aws:us-east-2",
    ],
    message="BDD test payload: synthetics_api_grpc_test_payload.json",
    name="Example-Create_an_API_GRPC_test_returns_OK_Returns_the_created_test_details_response",
    options=SyntheticsTestOptions(
        min_failure_duration=0,
        min_location_failed=1,
        monitor_options=SyntheticsTestOptionsMonitorOptions(
            renotify_interval=0,
        ),
        monitor_name="Example-Create_an_API_GRPC_test_returns_OK_Returns_the_created_test_details_response",
        tick_every=60,
    ),
    subtype=SyntheticsTestDetailsSubType.GRPC,
    tags=[
        "testing:api",
    ],
    type=SyntheticsAPITestType.API,
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = SyntheticsApi(api_client)
    response = api_instance.create_synthetics_api_test(body=body)

    print(response)
"""
Create an API HTTP test returns "OK - Returns the created test details." response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.synthetics_api import SyntheticsApi
from datadog_api_client.v1.model.http_method import HTTPMethod
from datadog_api_client.v1.model.synthetics_api_test import SyntheticsAPITest
from datadog_api_client.v1.model.synthetics_api_test_config import SyntheticsAPITestConfig
from datadog_api_client.v1.model.synthetics_api_test_type import SyntheticsAPITestType
from datadog_api_client.v1.model.synthetics_assertion_json_path_operator import SyntheticsAssertionJSONPathOperator
from datadog_api_client.v1.model.synthetics_assertion_json_path_target import SyntheticsAssertionJSONPathTarget
from datadog_api_client.v1.model.synthetics_assertion_json_path_target_target import (
    SyntheticsAssertionJSONPathTargetTarget,
)
from datadog_api_client.v1.model.synthetics_assertion_operator import SyntheticsAssertionOperator
from datadog_api_client.v1.model.synthetics_assertion_target import SyntheticsAssertionTarget
from datadog_api_client.v1.model.synthetics_assertion_type import SyntheticsAssertionType
from datadog_api_client.v1.model.synthetics_assertion_x_path_operator import SyntheticsAssertionXPathOperator
from datadog_api_client.v1.model.synthetics_assertion_x_path_target import SyntheticsAssertionXPathTarget
from datadog_api_client.v1.model.synthetics_assertion_x_path_target_target import SyntheticsAssertionXPathTargetTarget
from datadog_api_client.v1.model.synthetics_config_variable import SyntheticsConfigVariable
from datadog_api_client.v1.model.synthetics_config_variable_type import SyntheticsConfigVariableType
from datadog_api_client.v1.model.synthetics_test_details_sub_type import SyntheticsTestDetailsSubType
from datadog_api_client.v1.model.synthetics_test_headers import SyntheticsTestHeaders
from datadog_api_client.v1.model.synthetics_test_options import SyntheticsTestOptions
from datadog_api_client.v1.model.synthetics_test_options_retry import SyntheticsTestOptionsRetry
from datadog_api_client.v1.model.synthetics_test_request import SyntheticsTestRequest
from datadog_api_client.v1.model.synthetics_test_request_certificate import SyntheticsTestRequestCertificate
from datadog_api_client.v1.model.synthetics_test_request_certificate_item import SyntheticsTestRequestCertificateItem
from datadog_api_client.v1.model.synthetics_test_request_proxy import SyntheticsTestRequestProxy

body = SyntheticsAPITest(
    config=SyntheticsAPITestConfig(
        assertions=[
            SyntheticsAssertionTarget(
                operator=SyntheticsAssertionOperator.IS,
                _property="{{ PROPERTY }}",
                target="text/html",
                type=SyntheticsAssertionType.HEADER,
            ),
            SyntheticsAssertionTarget(
                operator=SyntheticsAssertionOperator.LESS_THAN,
                target=2000,
                type=SyntheticsAssertionType.RESPONSE_TIME,
            ),
            SyntheticsAssertionJSONPathTarget(
                operator=SyntheticsAssertionJSONPathOperator.VALIDATES_JSON_PATH,
                target=SyntheticsAssertionJSONPathTargetTarget(
                    json_path="topKey",
                    operator="isNot",
                    target_value="0",
                ),
                type=SyntheticsAssertionType.BODY,
            ),
            SyntheticsAssertionXPathTarget(
                operator=SyntheticsAssertionXPathOperator.VALIDATES_X_PATH,
                target=SyntheticsAssertionXPathTargetTarget(
                    x_path="target-xpath",
                    target_value="0",
                    operator="contains",
                ),
                type=SyntheticsAssertionType.BODY,
            ),
        ],
        config_variables=[
            SyntheticsConfigVariable(
                example="content-type",
                name="PROPERTY",
                pattern="content-type",
                type=SyntheticsConfigVariableType.TEXT,
            ),
        ],
        request=SyntheticsTestRequest(
            certificate=SyntheticsTestRequestCertificate(
                cert=SyntheticsTestRequestCertificateItem(
                    content="cert-content",
                    filename="cert-filename",
                    updated_at="2020-10-16T09:23:24.857Z",
                ),
                key=SyntheticsTestRequestCertificateItem(
                    content="key-content",
                    filename="key-filename",
                    updated_at="2020-10-16T09:23:24.857Z",
                ),
            ),
            headers=SyntheticsTestHeaders(
                unique="examplecreateanapihttptestreturnsokreturnsthecreatedtestdetailsresponse",
            ),
            method=HTTPMethod.GET,
            timeout=10.0,
            url="https://datadoghq.com",
            proxy=SyntheticsTestRequestProxy(
                url="https://datadoghq.com",
                headers=SyntheticsTestHeaders(),
            ),
        ),
    ),
    locations=[
        "aws:us-east-2",
    ],
    message="BDD test payload: synthetics_api_http_test_payload.json",
    name="Example-Create_an_API_HTTP_test_returns_OK_Returns_the_created_test_details_response",
    options=SyntheticsTestOptions(
        accept_self_signed=False,
        allow_insecure=True,
        follow_redirects=True,
        min_failure_duration=10,
        min_location_failed=1,
        monitor_name="Example-Create_an_API_HTTP_test_returns_OK_Returns_the_created_test_details_response",
        monitor_priority=5,
        retry=SyntheticsTestOptionsRetry(
            count=3,
            interval=10.0,
        ),
        tick_every=60,
    ),
    subtype=SyntheticsTestDetailsSubType.HTTP,
    tags=[
        "testing:api",
    ],
    type=SyntheticsAPITestType.API,
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = SyntheticsApi(api_client)
    response = api_instance.create_synthetics_api_test(body=body)

    print(response)
"""
Create an API SSL test returns "OK - Returns the created test details." response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.synthetics_api import SyntheticsApi
from datadog_api_client.v1.model.synthetics_api_test import SyntheticsAPITest
from datadog_api_client.v1.model.synthetics_api_test_config import SyntheticsAPITestConfig
from datadog_api_client.v1.model.synthetics_api_test_type import SyntheticsAPITestType
from datadog_api_client.v1.model.synthetics_assertion_operator import SyntheticsAssertionOperator
from datadog_api_client.v1.model.synthetics_assertion_target import SyntheticsAssertionTarget
from datadog_api_client.v1.model.synthetics_assertion_type import SyntheticsAssertionType
from datadog_api_client.v1.model.synthetics_test_details_sub_type import SyntheticsTestDetailsSubType
from datadog_api_client.v1.model.synthetics_test_options import SyntheticsTestOptions
from datadog_api_client.v1.model.synthetics_test_request import SyntheticsTestRequest

body = SyntheticsAPITest(
    config=SyntheticsAPITestConfig(
        assertions=[
            SyntheticsAssertionTarget(
                operator=SyntheticsAssertionOperator.IS_IN_MORE_DAYS_THAN,
                target=10,
                type=SyntheticsAssertionType.CERTIFICATE,
            ),
        ],
        request=SyntheticsTestRequest(
            host="datadoghq.com",
            port=443,
        ),
    ),
    locations=[
        "aws:us-east-2",
    ],
    message="BDD test payload: synthetics_api_ssl_test_payload.json",
    name="Example-Create_an_API_SSL_test_returns_OK_Returns_the_created_test_details_response",
    options=SyntheticsTestOptions(
        accept_self_signed=True,
        check_certificate_revocation=True,
        tick_every=60,
    ),
    subtype=SyntheticsTestDetailsSubType.SSL,
    tags=[
        "testing:api",
    ],
    type=SyntheticsAPITestType.API,
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = SyntheticsApi(api_client)
    response = api_instance.create_synthetics_api_test(body=body)

    print(response)

Instructions

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

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Create an API GRPC test returns "OK - Returns the created test details." response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::SyntheticsAPI.new

body = DatadogAPIClient::V1::SyntheticsAPITest.new({
  config: DatadogAPIClient::V1::SyntheticsAPITestConfig.new({
    assertions: [
      DatadogAPIClient::V1::SyntheticsAssertionTarget.new({
        operator: DatadogAPIClient::V1::SyntheticsAssertionOperator::IS,
        target: 1,
        type: DatadogAPIClient::V1::SyntheticsAssertionType::GRPC_HEALTHCHECK_STATUS,
      }),
    ],
    request: DatadogAPIClient::V1::SyntheticsTestRequest.new({
      host: "localhost",
      port: 50051,
      service: "Hello",
      method: DatadogAPIClient::V1::HTTPMethod::GET,
      message: "",
      metadata: {},
    }),
  }),
  locations: [
    "aws:us-east-2",
  ],
  message: "BDD test payload: synthetics_api_grpc_test_payload.json",
  name: "Example-Create_an_API_GRPC_test_returns_OK_Returns_the_created_test_details_response",
  options: DatadogAPIClient::V1::SyntheticsTestOptions.new({
    min_failure_duration: 0,
    min_location_failed: 1,
    monitor_options: DatadogAPIClient::V1::SyntheticsTestOptionsMonitorOptions.new({
      renotify_interval: 0,
    }),
    monitor_name: "Example-Create_an_API_GRPC_test_returns_OK_Returns_the_created_test_details_response",
    tick_every: 60,
  }),
  subtype: DatadogAPIClient::V1::SyntheticsTestDetailsSubType::GRPC,
  tags: [
    "testing:api",
  ],
  type: DatadogAPIClient::V1::SyntheticsAPITestType::API,
})
p api_instance.create_synthetics_api_test(body)
# Create an API HTTP test returns "OK - Returns the created test details." response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::SyntheticsAPI.new

body = DatadogAPIClient::V1::SyntheticsAPITest.new({
  config: DatadogAPIClient::V1::SyntheticsAPITestConfig.new({
    assertions: [
      DatadogAPIClient::V1::SyntheticsAssertionTarget.new({
        operator: DatadogAPIClient::V1::SyntheticsAssertionOperator::IS,
        property: "{{ PROPERTY }}",
        target: "text/html",
        type: DatadogAPIClient::V1::SyntheticsAssertionType::HEADER,
      }),
      DatadogAPIClient::V1::SyntheticsAssertionTarget.new({
        operator: DatadogAPIClient::V1::SyntheticsAssertionOperator::LESS_THAN,
        target: 2000,
        type: DatadogAPIClient::V1::SyntheticsAssertionType::RESPONSE_TIME,
      }),
      DatadogAPIClient::V1::SyntheticsAssertionJSONPathTarget.new({
        operator: DatadogAPIClient::V1::SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH,
        target: DatadogAPIClient::V1::SyntheticsAssertionJSONPathTargetTarget.new({
          json_path: "topKey",
          operator: "isNot",
          target_value: "0",
        }),
        type: DatadogAPIClient::V1::SyntheticsAssertionType::BODY,
      }),
      DatadogAPIClient::V1::SyntheticsAssertionXPathTarget.new({
        operator: DatadogAPIClient::V1::SyntheticsAssertionXPathOperator::VALIDATES_X_PATH,
        target: DatadogAPIClient::V1::SyntheticsAssertionXPathTargetTarget.new({
          x_path: "target-xpath",
          target_value: "0",
          operator: "contains",
        }),
        type: DatadogAPIClient::V1::SyntheticsAssertionType::BODY,
      }),
    ],
    config_variables: [
      DatadogAPIClient::V1::SyntheticsConfigVariable.new({
        example: "content-type",
        name: "PROPERTY",
        pattern: "content-type",
        type: DatadogAPIClient::V1::SyntheticsConfigVariableType::TEXT,
      }),
    ],
    request: DatadogAPIClient::V1::SyntheticsTestRequest.new({
      certificate: DatadogAPIClient::V1::SyntheticsTestRequestCertificate.new({
        cert: DatadogAPIClient::V1::SyntheticsTestRequestCertificateItem.new({
          content: "cert-content",
          filename: "cert-filename",
          updated_at: "2020-10-16T09:23:24.857Z",
        }),
        key: DatadogAPIClient::V1::SyntheticsTestRequestCertificateItem.new({
          content: "key-content",
          filename: "key-filename",
          updated_at: "2020-10-16T09:23:24.857Z",
        }),
      }),
      headers: {
        unique: "examplecreateanapihttptestreturnsokreturnsthecreatedtestdetailsresponse",
      },
      method: DatadogAPIClient::V1::HTTPMethod::GET,
      timeout: 10,
      url: "https://datadoghq.com",
      proxy: DatadogAPIClient::V1::SyntheticsTestRequestProxy.new({
        url: "https://datadoghq.com",
        headers: {},
      }),
    }),
  }),
  locations: [
    "aws:us-east-2",
  ],
  message: "BDD test payload: synthetics_api_http_test_payload.json",
  name: "Example-Create_an_API_HTTP_test_returns_OK_Returns_the_created_test_details_response",
  options: DatadogAPIClient::V1::SyntheticsTestOptions.new({
    accept_self_signed: false,
    allow_insecure: true,
    follow_redirects: true,
    min_failure_duration: 10,
    min_location_failed: 1,
    monitor_name: "Example-Create_an_API_HTTP_test_returns_OK_Returns_the_created_test_details_response",
    monitor_priority: 5,
    _retry: DatadogAPIClient::V1::SyntheticsTestOptionsRetry.new({
      count: 3,
      interval: 10,
    }),
    tick_every: 60,
  }),
  subtype: DatadogAPIClient::V1::SyntheticsTestDetailsSubType::HTTP,
  tags: [
    "testing:api",
  ],
  type: DatadogAPIClient::V1::SyntheticsAPITestType::API,
})
p api_instance.create_synthetics_api_test(body)
# Create an API SSL test returns "OK - Returns the created test details." response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::SyntheticsAPI.new

body = DatadogAPIClient::V1::SyntheticsAPITest.new({
  config: DatadogAPIClient::V1::SyntheticsAPITestConfig.new({
    assertions: [
      DatadogAPIClient::V1::SyntheticsAssertionTarget.new({
        operator: DatadogAPIClient::V1::SyntheticsAssertionOperator::IS_IN_MORE_DAYS_THAN,
        target: 10,
        type: DatadogAPIClient::V1::SyntheticsAssertionType::CERTIFICATE,
      }),
    ],
    request: DatadogAPIClient::V1::SyntheticsTestRequest.new({
      host: "datadoghq.com",
      port: 443,
    }),
  }),
  locations: [
    "aws:us-east-2",
  ],
  message: "BDD test payload: synthetics_api_ssl_test_payload.json",
  name: "Example-Create_an_API_SSL_test_returns_OK_Returns_the_created_test_details_response",
  options: DatadogAPIClient::V1::SyntheticsTestOptions.new({
    accept_self_signed: true,
    check_certificate_revocation: true,
    tick_every: 60,
  }),
  subtype: DatadogAPIClient::V1::SyntheticsTestDetailsSubType::SSL,
  tags: [
    "testing:api",
  ],
  type: DatadogAPIClient::V1::SyntheticsAPITestType::API,
})
p api_instance.create_synthetics_api_test(body)

Instructions

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

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
/**
 * Create an API GRPC test returns "OK - Returns the created test details." response
 */

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

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

const params: v1.SyntheticsApiCreateSyntheticsAPITestRequest = {
  body: {
    config: {
      assertions: [
        {
          operator: "is",
          target: 1,
          type: "grpcHealthcheckStatus",
        },
      ],
      request: {
        host: "localhost",
        port: 50051,
        service: "Hello",
        method: "GET",
        message: "",
        metadata: {},
      },
    },
    locations: ["aws:us-east-2"],
    message: "BDD test payload: synthetics_api_grpc_test_payload.json",
    name: "Example-Create_an_API_GRPC_test_returns_OK_Returns_the_created_test_details_response",
    options: {
      minFailureDuration: 0,
      minLocationFailed: 1,
      monitorOptions: {
        renotifyInterval: 0,
      },
      monitorName:
        "Example-Create_an_API_GRPC_test_returns_OK_Returns_the_created_test_details_response",
      tickEvery: 60,
    },
    subtype: "grpc",
    tags: ["testing:api"],
    type: "api",
  },
};

apiInstance
  .createSyntheticsAPITest(params)
  .then((data: v1.SyntheticsAPITest) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));
/**
 * Create an API HTTP test returns "OK - Returns the created test details." response
 */

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

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

const params: v1.SyntheticsApiCreateSyntheticsAPITestRequest = {
  body: {
    config: {
      assertions: [
        {
          operator: "is",
          property: "{{ PROPERTY }}",
          target: "text/html",
          type: "header",
        },
        {
          operator: "lessThan",
          target: 2000,
          type: "responseTime",
        },
        {
          operator: "validatesJSONPath",
          target: {
            jsonPath: "topKey",
            operator: "isNot",
            targetValue: "0",
          },
          type: "body",
        },
        {
          operator: "validatesXPath",
          target: {
            xPath: "target-xpath",
            targetValue: "0",
            operator: "contains",
          },
          type: "body",
        },
      ],
      configVariables: [
        {
          example: "content-type",
          name: "PROPERTY",
          pattern: "content-type",
          type: "text",
        },
      ],
      request: {
        certificate: {
          cert: {
            content: "cert-content",
            filename: "cert-filename",
            updatedAt: "2020-10-16T09:23:24.857Z",
          },
          key: {
            content: "key-content",
            filename: "key-filename",
            updatedAt: "2020-10-16T09:23:24.857Z",
          },
        },
        headers: {
          unique:
            "examplecreateanapihttptestreturnsokreturnsthecreatedtestdetailsresponse",
        },
        method: "GET",
        timeout: 10,
        url: "https://datadoghq.com",
        proxy: {
          url: "https://datadoghq.com",
          headers: {},
        },
      },
    },
    locations: ["aws:us-east-2"],
    message: "BDD test payload: synthetics_api_http_test_payload.json",
    name: "Example-Create_an_API_HTTP_test_returns_OK_Returns_the_created_test_details_response",
    options: {
      acceptSelfSigned: false,
      allowInsecure: true,
      followRedirects: true,
      minFailureDuration: 10,
      minLocationFailed: 1,
      monitorName:
        "Example-Create_an_API_HTTP_test_returns_OK_Returns_the_created_test_details_response",
      monitorPriority: 5,
      retry: {
        count: 3,
        interval: 10,
      },
      tickEvery: 60,
    },
    subtype: "http",
    tags: ["testing:api"],
    type: "api",
  },
};

apiInstance
  .createSyntheticsAPITest(params)
  .then((data: v1.SyntheticsAPITest) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));
/**
 * Create an API SSL test returns "OK - Returns the created test details." response
 */

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

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

const params: v1.SyntheticsApiCreateSyntheticsAPITestRequest = {
  body: {
    config: {
      assertions: [
        {
          operator: "isInMoreThan",
          target: 10,
          type: "certificate",
        },
      ],
      request: {
        host: "datadoghq.com",
        port: 443,
      },
    },
    locations: ["aws:us-east-2"],
    message: "BDD test payload: synthetics_api_ssl_test_payload.json",
    name: "Example-Create_an_API_SSL_test_returns_OK_Returns_the_created_test_details_response",
    options: {
      acceptSelfSigned: true,
      checkCertificateRevocation: true,
      tickEvery: 60,
    },
    subtype: "ssl",
    tags: ["testing:api"],
    type: "api",
  },
};

apiInstance
  .createSyntheticsAPITest(params)
  .then((data: v1.SyntheticsAPITest) => {
    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:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"

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

Présentation

Créez un test Browser Synthetic. This endpoint requires the synthetics_write authorization scope.

Requête

Body Data (required)

Détails du test à créer.

Expand All

Champ

Type

Description

config [required]

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,doesNotExist

property

string

The associated assertion property.

target [required]

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,receivedMessage,grpcHealthcheckStatus,connection

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,receivedMessage,grpcHealthcheckStatus,connection

Option 3

object

An assertion for the validatesXPath operator.

operator [required]

enum

Assertion operator to apply. Allowed enum values: validatesXPath

property

string

The associated assertion property.

target

object

Composed target for validatesXPath operator.

operator

string

The specific operator to use on the path.

targetValue

The path target value to compare to.

xPath

string

The X path to assert.

type [required]

enum

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

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 <oneOf>

Object to handle basic authentication when performing the test.

Option 1

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authentication.

type

enum

The type of basic authentication to use when performing the test. Allowed enum values: web

username [required]

string

Username to use for the basic authentication.

Option 2

object

Object to handle SIGV4 authentication when performing the test.

accessKey [required]

string

Access key for the SIGV4 authentication.

region

string

Region for the SIGV4 authentication.

secretKey [required]

string

Secret key for the SIGV4 authentication.

serviceName

string

Service name for the SIGV4 authentication.

sessionToken

string

Session token for the SIGV4 authentication.

type [required]

enum

The type of authentication to use when performing the test. Allowed enum values: sigv4

Option 3

object

Object to handle NTLM authentication when performing the test.

domain

string

Domain for the authentication to use when performing the test.

password

string

Password for the authentication to use when performing the test.

type [required]

enum

The type of authentication to use when performing the test. Allowed enum values: ntlm

username

string

Username for the authentication to use when performing the test.

workstation

string

Workstation for the authentication to use when performing the test.

Option 4

object

Object to handle digest authentication when performing the test.

password [required]

string

Password to use for the digest authentication.

type

enum

The type of basic authentication to use when performing the test. Allowed enum values: digest

username [required]

string

Username to use for the digest authentication.

Option 5

object

Object to handle oauth client authentication when performing the test.

accessTokenUrl [required]

string

Access token URL to use when performing the authentication.

audience

string

Audience to use when performing the authentication.

clientId [required]

string

Client ID to use when performing the authentication.

clientSecret [required]

string

Client secret to use when performing the authentication.

resource

string

Resource to use when performing the authentication.

scope

string

Scope to use when performing the authentication.

tokenApiAuthentication [required]

enum

Type of token to use when performing the authentication. Allowed enum values: header,body

type

enum

The type of basic authentication to use when performing the test. Allowed enum values: oauth-client

Option 6

object

Object to handle oauth rop authentication when performing the test.

accessTokenUrl [required]

string

Access token URL to use when performing the authentication.

audience

string

Audience to use when performing the authentication.

clientId

string

Client ID to use when performing the authentication.

clientSecret

string

Client secret to use when performing the authentication.

password [required]

string

Password to use when performing the authentication.

resource

string

Resource to use when performing the authentication.

scope

string

Scope to use when performing the authentication.

type

enum

The type of basic authentication to use when performing the test. Allowed enum values: oauth-rop

username [required]

string

Username to use when performing the authentication.

body

string

Body to include in the test.

bodyType

enum

Type of the request body. Allowed enum values: text/plain,application/json,text/xml,text/html,application/x-www-form-urlencoded,graphql

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.

certificateDomains

[string]

By default, the client certificate is applied on the domain of the starting URL for browser tests. If you want your client certificate to be applied on other domains instead, add them in certificateDomains.

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.

message

string

Message to send for UDP or WebSocket tests.

metadata

object

Metadata to include when performing the gRPC test.

<any-key>

string

A single Metadatum.

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.

proxy

object

The proxy to perform the test.

headers

object

Headers to include when performing the test.

<any-key>

string

A single Header.

url [required]

string

URL of the proxy to perform 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.

service

string

gRPC service on which you want to perform the healthcheck.

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. Global variables require an ID.

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 [required]

[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 [required]

string

Name of the test.

options [required]

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 in an API test.

checkCertificateRevocation

boolean

For SSL test, whether or not the test should fail on revoked certificate in stapled OCSP.

ci

object

CI/CD options for a Synthetic test.

executionRule

enum

Execution rule for a Synthetics test. Allowed enum values: blocking,non_blocking,skipped

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.

disableCsp

boolean

Disable Content Security Policy for browser tests.

follow_redirects

boolean

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

ignoreServerCertificateError

boolean

Ignore server certificate error for browser tests.

initialNavigationTimeout

int64

Timeout before declaring the initial step as failed (in seconds) for browser tests.

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.

restricted_roles

[string]

A list of role identifiers that can be pulled from the Roles API, for restricting read and write access.

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.

rumSettings

object

The RUM data collection settings for the Synthetic browser test. Note: There are 3 ways to format RUM settings:

{ isEnabled: false } RUM data is not collected.

{ isEnabled: true } RUM data is collected from the Synthetic test's default application.

{ isEnabled: true, applicationId: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", clientTokenId: 12345 } RUM data is collected using the specified application.

applicationId

string

RUM application ID used to collect RUM data for the browser test.

clientTokenId

int64

RUM application API key ID used to collect RUM data for the browser test.

isEnabled [required]

boolean

Determines whether RUM data is collected during test runs.

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]

Array of steps for the test.

allowFailure

boolean

A boolean set to allow this step to fail.

isCritical

boolean

A boolean to use in addition to allowFailure to determine if the test should be marked as failed when the step fails.

name

string

The name of the step.

noScreenshot

boolean

A boolean set to not take a screenshot for 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 [required]

enum

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

{
  "config": {
    "assertions": [],
    "configVariables": [
      {
        "example": "content-type",
        "name": "PROPERTY",
        "pattern": "content-type",
        "type": "text"
      }
    ],
    "request": {
      "method": "GET",
      "url": "https://datadoghq.com",
      "certificateDomains": [
        "https://datadoghq.com"
      ]
    },
    "setCookie": "name:test"
  },
  "locations": [
    "aws:us-east-2"
  ],
  "message": "Test message",
  "name": "Example-Create_a_browser_test_returns_OK_Returns_saved_rumSettings_response",
  "options": {
    "accept_self_signed": false,
    "allow_insecure": true,
    "device_ids": [
      "tablet"
    ],
    "disableCors": true,
    "follow_redirects": true,
    "min_failure_duration": 10,
    "min_location_failed": 1,
    "noScreenshot": true,
    "retry": {
      "count": 3,
      "interval": 10
    },
    "rumSettings": {
      "isEnabled": true,
      "applicationId": "mockApplicationId",
      "clientTokenId": 12345
    },
    "tick_every": 300,
    "ci": {
      "executionRule": "skipped"
    },
    "ignoreServerCertificateError": true,
    "disableCsp": true,
    "initialNavigationTimeout": 200
  },
  "tags": [
    "testing:browser"
  ],
  "type": "browser",
  "steps": [
    {
      "allowFailure": false,
      "isCritical": true,
      "name": "Refresh page",
      "params": {},
      "type": "refresh"
    }
  ]
}
{
  "config": {
    "assertions": [],
    "configVariables": [
      {
        "example": "content-type",
        "name": "PROPERTY",
        "pattern": "content-type",
        "type": "text"
      }
    ],
    "request": {
      "method": "GET",
      "url": "https://datadoghq.com"
    },
    "setCookie": "name:test"
  },
  "locations": [
    "aws:us-east-2"
  ],
  "message": "Test message",
  "name": "Example-Create_a_browser_test_returns_OK_Returns_the_created_test_details_response",
  "options": {
    "accept_self_signed": false,
    "allow_insecure": true,
    "device_ids": [
      "tablet"
    ],
    "disableCors": true,
    "follow_redirects": true,
    "min_failure_duration": 10,
    "min_location_failed": 1,
    "noScreenshot": true,
    "retry": {
      "count": 3,
      "interval": 10
    },
    "tick_every": 300
  },
  "tags": [
    "testing:browser"
  ],
  "type": "browser",
  "steps": [
    {
      "allowFailure": false,
      "isCritical": true,
      "name": "Refresh page",
      "params": {},
      "type": "refresh"
    }
  ]
}

Réponse

OK - Returns the created test details.

Object containing details about a Synthetic browser test.

Expand All

Champ

Type

Description

config [required]

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,doesNotExist

property

string

The associated assertion property.

target [required]

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,receivedMessage,grpcHealthcheckStatus,connection

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,receivedMessage,grpcHealthcheckStatus,connection

Option 3

object

An assertion for the validatesXPath operator.

operator [required]

enum

Assertion operator to apply. Allowed enum values: validatesXPath

property

string

The associated assertion property.

target

object

Composed target for validatesXPath operator.

operator

string

The specific operator to use on the path.

targetValue

The path target value to compare to.

xPath

string

The X path to assert.

type [required]

enum

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

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 <oneOf>

Object to handle basic authentication when performing the test.

Option 1

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authentication.

type

enum

The type of basic authentication to use when performing the test. Allowed enum values: web

username [required]

string

Username to use for the basic authentication.

Option 2

object

Object to handle SIGV4 authentication when performing the test.

accessKey [required]

string

Access key for the SIGV4 authentication.

region

string

Region for the SIGV4 authentication.

secretKey [required]

string

Secret key for the SIGV4 authentication.

serviceName

string

Service name for the SIGV4 authentication.

sessionToken

string

Session token for the SIGV4 authentication.

type [required]

enum

The type of authentication to use when performing the test. Allowed enum values: sigv4

Option 3

object

Object to handle NTLM authentication when performing the test.

domain

string

Domain for the authentication to use when performing the test.

password

string

Password for the authentication to use when performing the test.

type [required]

enum

The type of authentication to use when performing the test. Allowed enum values: ntlm

username

string

Username for the authentication to use when performing the test.

workstation

string

Workstation for the authentication to use when performing the test.

Option 4

object

Object to handle digest authentication when performing the test.

password [required]

string

Password to use for the digest authentication.

type

enum

The type of basic authentication to use when performing the test. Allowed enum values: digest

username [required]

string

Username to use for the digest authentication.

Option 5

object

Object to handle oauth client authentication when performing the test.

accessTokenUrl [required]

string

Access token URL to use when performing the authentication.

audience

string

Audience to use when performing the authentication.

clientId [required]

string

Client ID to use when performing the authentication.

clientSecret [required]

string

Client secret to use when performing the authentication.

resource

string

Resource to use when performing the authentication.

scope

string

Scope to use when performing the authentication.

tokenApiAuthentication [required]

enum

Type of token to use when performing the authentication. Allowed enum values: header,body

type

enum

The type of basic authentication to use when performing the test. Allowed enum values: oauth-client

Option 6

object

Object to handle oauth rop authentication when performing the test.

accessTokenUrl [required]

string

Access token URL to use when performing the authentication.

audience

string

Audience to use when performing the authentication.

clientId

string

Client ID to use when performing the authentication.

clientSecret

string

Client secret to use when performing the authentication.

password [required]

string

Password to use when performing the authentication.

resource

string

Resource to use when performing the authentication.

scope

string

Scope to use when performing the authentication.

type

enum

The type of basic authentication to use when performing the test. Allowed enum values: oauth-rop

username [required]

string

Username to use when performing the authentication.

body

string

Body to include in the test.

bodyType

enum

Type of the request body. Allowed enum values: text/plain,application/json,text/xml,text/html,application/x-www-form-urlencoded,graphql

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.

certificateDomains

[string]

By default, the client certificate is applied on the domain of the starting URL for browser tests. If you want your client certificate to be applied on other domains instead, add them in certificateDomains.

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.

message

string

Message to send for UDP or WebSocket tests.

metadata

object

Metadata to include when performing the gRPC test.

<any-key>

string

A single Metadatum.

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.

proxy

object

The proxy to perform the test.

headers

object

Headers to include when performing the test.

<any-key>

string

A single Header.

url [required]

string

URL of the proxy to perform 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.

service

string

gRPC service on which you want to perform the healthcheck.

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. Global variables require an ID.

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 [required]

[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 [required]

string

Name of the test.

options [required]

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 in an API test.

checkCertificateRevocation

boolean

For SSL test, whether or not the test should fail on revoked certificate in stapled OCSP.

ci

object

CI/CD options for a Synthetic test.

executionRule

enum

Execution rule for a Synthetics test. Allowed enum values: blocking,non_blocking,skipped

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.

disableCsp

boolean

Disable Content Security Policy for browser tests.

follow_redirects

boolean

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

ignoreServerCertificateError

boolean

Ignore server certificate error for browser tests.

initialNavigationTimeout

int64

Timeout before declaring the initial step as failed (in seconds) for browser tests.

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.

restricted_roles

[string]

A list of role identifiers that can be pulled from the Roles API, for restricting read and write access.

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.

rumSettings

object

The RUM data collection settings for the Synthetic browser test. Note: There are 3 ways to format RUM settings:

{ isEnabled: false } RUM data is not collected.

{ isEnabled: true } RUM data is collected from the Synthetic test's default application.

{ isEnabled: true, applicationId: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", clientTokenId: 12345 } RUM data is collected using the specified application.

applicationId

string

RUM application ID used to collect RUM data for the browser test.

clientTokenId

int64

RUM application API key ID used to collect RUM data for the browser test.

isEnabled [required]

boolean

Determines whether RUM data is collected during test runs.

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]

Array of steps for the test.

allowFailure

boolean

A boolean set to allow this step to fail.

isCritical

boolean

A boolean to use in addition to allowFailure to determine if the test should be marked as failed when the step fails.

name

string

The name of the step.

noScreenshot

boolean

A boolean set to not take a screenshot for 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 [required]

enum

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

{
  "config": {
    "assertions": [
      {
        "operator": "contains",
        "property": "string",
        "target": 123456,
        "type": "statusCode"
      }
    ],
    "configVariables": [
      {
        "example": "string",
        "id": "string",
        "name": "VARIABLE_NAME",
        "pattern": "string",
        "type": "text"
      }
    ],
    "request": {
      "allow_insecure": false,
      "basicAuth": {
        "password": "PaSSw0RD!",
        "type": "web",
        "username": "my_username"
      },
      "body": "string",
      "bodyType": "text/plain",
      "certificate": {
        "cert": {
          "content": "string",
          "filename": "string",
          "updatedAt": "string"
        },
        "key": {
          "content": "string",
          "filename": "string",
          "updatedAt": "string"
        }
      },
      "certificateDomains": [],
      "dnsServer": "string",
      "dnsServerPort": "integer",
      "follow_redirects": false,
      "headers": {
        "<any-key>": "string"
      },
      "host": "string",
      "message"