Synthetics

La monitorización Synthetic Datadog utiliza solicitudes de usuario simuladas y la renderización del navegador para ayudarte a garantizar el tiempo de actividad, identificar problemas regionales y realizar un seguimiento del rendimiento de tu aplicación. Los tests Synthetics vienen en dos formatos diferentes, [tests de API]((https://docs.datadoghq.com/synthetics/api_tests/?tab=httptest) y tests de navegador. Puedes utilizar la API Datadog para gestionar ambos tipos de tests mediante programación.

Para obtener más información, consulta la documentación de la monitorización Synthetic.

POST https://api.ap1.datadoghq.com/api/v1/synthetics/tests/apihttps://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

Información general

Crea un test de API Synthetic. This endpoint requires the synthetics_write permission.

OAuth apps require the synthetics_write authorization scope to access this endpoint.

Solicitud

Body Data (required)

Detalles del test a crear.

Expand All

Campo

Tipo

Descripción

config [required]

object

Configuration object for a Synthetic API test.

assertions

[ <oneOf>]

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

default:

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

property

string

The associated assertion property.

target [required]

Value used by the operator.

timingsScope

enum

Timings scope for response time assertions. Allowed enum values: all,withoutDNS

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,grpcMetadata,grpcProto,connection

Option 2

object

An assertion which targets body hash.

operator [required]

enum

Assertion operator to apply. Allowed enum values: md5,sha1,sha256

target [required]

Value used by the operator.

type [required]

enum

Type of the assertion. Allowed enum values: bodyHash

Option 3

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.

elementsOperator

string

The element from the list of results to assert on. To choose from the first element in the list firstElementMatches, every element in the list everyElementMatches, at least one element in the list atLeastOneElementMatches or the serialized value of the list serializationMatches.

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,grpcMetadata,grpcProto,connection

Option 4

object

An assertion for the validatesJSONSchema operator.

operator [required]

enum

Assertion operator to apply. Allowed enum values: validatesJSONSchema

target

object

Composed target for validatesJSONSchema operator.

jsonSchema

string

The JSON Schema to assert.

metaSchema

enum

The JSON Schema meta-schema version used in the assertion. Allowed enum values: draft-07,draft-06

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,grpcMetadata,grpcProto,connection

Option 5

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,grpcMetadata,grpcProto,connection

Option 6

object

A JavaScript assertion.

code [required]

string

The JavaScript code that performs the assertions.

type [required]

enum

Type of the assertion. Allowed enum values: javascript

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.

secure

boolean

Whether the value of this variable will be obfuscated in test results. Only for config variables of type text.

type [required]

enum

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

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

 <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

default: 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

default: 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

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

enum

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

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

enum

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

default: 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.

tokenApiAuthentication [required]

enum

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

type [required]

enum

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

default: 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,application/octet-stream,multipart/form-data

callType

enum

The type of gRPC call to perform. Allowed enum values: healthcheck,unary

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.

default:

compressedJsonDescriptor

string

A protobuf JSON descriptor that needs to be gzipped first then base64 encoded.

compressedProtoFile

string

A protobuf file that needs to be gzipped first then base64 encoded.

dnsServer

string

DNS server to use for DNS tests.

dnsServerPort

string

DNS server port to use for DNS tests.

files

[object]

Files to be used as part of the request in the test.

bucketKey

string

Bucket key of the file.

content

string

Content of the file.

name

string

Name of the file.

originalFileName

string

Original name of the file.

size

int64

Size of the file.

type

string

Type of the file.

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.

httpVersion

enum

HTTP version to use for a Synthetic test. Allowed enum values: http1,http2,any

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

string

Either the HTTP method/verb to use or a gRPC method available on the service set in the service field. Required if subtype is HTTP or if subtype is grpc and callType is unary.

noSavingResponseBody

boolean

Determines whether or not to save the response body.

numberOfPackets

int32

Number of pings to use per test.

persistCookies

boolean

Persist cookies across redirects.

port

 <oneOf>

Port to use when performing the test.

Option 1

int64

Integer Port number to use when performing the test.

Option 2

string

String Port number to use when performing the test. Supports templated variables.

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

The gRPC service on which you want to perform the gRPC call.

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

[ <oneOf>]

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

Option 1

object

The Test step used in a Synthetic multi-step API test.

allowFailure

boolean

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

assertions [required]

[ <oneOf>]

Array of assertions used for the test.

default:

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

property

string

The associated assertion property.

target [required]

Value used by the operator.

timingsScope

enum

Timings scope for response time assertions. Allowed enum values: all,withoutDNS

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,grpcMetadata,grpcProto,connection

Option 2

object

An assertion which targets body hash.

operator [required]

enum

Assertion operator to apply. Allowed enum values: md5,sha1,sha256

target [required]

Value used by the operator.

type [required]

enum

Type of the assertion. Allowed enum values: bodyHash

Option 3

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.

elementsOperator

string

The element from the list of results to assert on. To choose from the first element in the list firstElementMatches, every element in the list everyElementMatches, at least one element in the list atLeastOneElementMatches or the serialized value of the list serializationMatches.

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,grpcMetadata,grpcProto,connection

Option 4

object

An assertion for the validatesJSONSchema operator.

operator [required]

enum

Assertion operator to apply. Allowed enum values: validatesJSONSchema

target

object

Composed target for validatesJSONSchema operator.

jsonSchema

string

The JSON Schema to assert.

metaSchema

enum

The JSON Schema meta-schema version used in the assertion. Allowed enum values: draft-07,draft-06

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,grpcMetadata,grpcProto,connection

Option 5

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,grpcMetadata,grpcProto,connection

Option 6

object

A JavaScript assertion.

code [required]

string

The JavaScript code that performs the assertions.

type [required]

enum

Type of the assertion. Allowed enum values: javascript

extractedValues

[object]

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

field

string

When type is http_header or grpc_metadata, name of the header or metadatum to extract.

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 Synthetic 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.

secure

boolean

Determines whether or not the extracted value will be obfuscated.

type

enum

Property of the Synthetic Test Response to extract into a local variable. Allowed enum values: grpc_message,grpc_metadata,http_body,http_header,http_status_code

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

 <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

default: 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

default: 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

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

enum

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

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

enum

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

default: 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.

tokenApiAuthentication [required]

enum

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

type [required]

enum

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

default: 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,application/octet-stream,multipart/form-data

callType

enum

The type of gRPC call to perform. Allowed enum values: healthcheck,unary

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.

default:

compressedJsonDescriptor

string

A protobuf JSON descriptor that needs to be gzipped first then base64 encoded.

compressedProtoFile

string

A protobuf file that needs to be gzipped first then base64 encoded.

dnsServer

string

DNS server to use for DNS tests.

dnsServerPort

string

DNS server port to use for DNS tests.

files

[object]

Files to be used as part of the request in the test.

bucketKey

string

Bucket key of the file.

content

string

Content of the file.

name

string

Name of the file.

originalFileName

string

Original name of the file.

size

int64

Size of the file.

type

string

Type of the file.

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.

httpVersion

enum

HTTP version to use for a Synthetic test. Allowed enum values: http1,http2,any

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

string

Either the HTTP method/verb to use or a gRPC method available on the service set in the service field. Required if subtype is HTTP or if subtype is grpc and callType is unary.

noSavingResponseBody

boolean

Determines whether or not to save the response body.

numberOfPackets

int32

Number of pings to use per test.

persistCookies

boolean

Persist cookies across redirects.

port

 <oneOf>

Port to use when performing the test.

Option 1

int64

Integer Port number to use when performing the test.

Option 2

string

String Port number to use when performing the test. Supports templated variables.

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

The gRPC service on which you want to perform the gRPC call.

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 multi-step API test step. Allowed enum values: http,grpc

Option 2

object

The Wait step used in a Synthetic multi-step API test.

name [required]

string

The name of the step.

subtype [required]

enum

The subtype of the Synthetic multi-step API wait step. Allowed enum values: wait

value [required]

int32

The time to wait in seconds. Minimum value: 0. Maximum value: 180.

variablesFromScript

string

Variables defined from JavaScript code.

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

enum

Execution rule for a Synthetic 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.

enableProfiling

boolean

Enable profiling for browser tests.

enableSecurityTesting

boolean

DEPRECATED: Enable security testing for browser tests. Security testing is not available anymore. This field is deprecated and won't be used.

follow_redirects

boolean

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

httpVersion

enum

HTTP version to use for a Synthetic test. Allowed enum values: http1,http2,any

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).

escalation_message

string

Message to include in the escalation notification.

notification_preset_name

enum

The name of the preset for the notification for the monitor. Allowed enum values: show_all,hide_all,hide_query,hide_handles

renotify_interval

int64

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

renotify_occurrences

int64

The number of times to renotify if the test is still failing.

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.

scheduling

object

Object containing timeframes and timezone used for advanced scheduling.

timeframes [required]

[object]

Array containing objects describing the scheduling pattern to apply to each day.

day [required]

int32

Number representing the day of the week.

from [required]

string

The hour of the day on which scheduling starts.

to [required]

string

The hour of the day on which scheduling ends.

timezone [required]

string

Timezone in which the timeframe is based.

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

default: api

{
  "config": {
    "steps": [
      {
        "assertions": [
          {
            "operator": "is",
            "type": "statusCode",
            "target": 200
          }
        ],
        "name": "request is sent",
        "request": {
          "url": "https://httpbin.org/status/200",
          "method": "GET",
          "basicAuth": {
            "password": "password",
            "username": "username"
          }
        },
        "subtype": "http"
      },
      {
        "assertions": [
          {
            "operator": "is",
            "type": "statusCode",
            "target": 200
          }
        ],
        "name": "request is sent",
        "request": {
          "url": "https://httpbin.org/status/200",
          "method": "GET",
          "basicAuth": {
            "password": "password",
            "username": "username",
            "type": "web"
          }
        },
        "subtype": "http"
      },
      {
        "assertions": [
          {
            "operator": "is",
            "type": "statusCode",
            "target": 200
          }
        ],
        "name": "request is sent",
        "request": {
          "url": "https://httpbin.org/status/200",
          "method": "GET",
          "basicAuth": {
            "accessKey": "accessKey",
            "secretKey": "secretKey",
            "type": "sigv4"
          }
        },
        "subtype": "http"
      },
      {
        "assertions": [
          {
            "operator": "is",
            "type": "statusCode",
            "target": 200
          }
        ],
        "name": "request is sent",
        "request": {
          "url": "https://httpbin.org/status/200",
          "method": "GET",
          "basicAuth": {
            "type": "ntlm"
          }
        },
        "subtype": "http"
      },
      {
        "assertions": [
          {
            "operator": "is",
            "type": "statusCode",
            "target": 200
          }
        ],
        "name": "request is sent",
        "request": {
          "url": "https://httpbin.org/status/200",
          "method": "GET",
          "basicAuth": {
            "password": "password",
            "username": "username",
            "type": "digest"
          }
        },
        "subtype": "http"
      },
      {
        "assertions": [
          {
            "operator": "is",
            "type": "statusCode",
            "target": 200
          }
        ],
        "name": "request is sent",
        "request": {
          "url": "https://httpbin.org/status/200",
          "method": "GET",
          "basicAuth": {
            "accessTokenUrl": "accessTokenUrl",
            "tokenApiAuthentication": "header",
            "clientId": "clientId",
            "clientSecret": "clientSecret",
            "type": "oauth-client"
          }
        },
        "subtype": "http"
      },
      {
        "assertions": [
          {
            "operator": "is",
            "type": "statusCode",
            "target": 200
          }
        ],
        "name": "request is sent",
        "request": {
          "url": "https://httpbin.org/status/200",
          "method": "GET",
          "basicAuth": {
            "accessTokenUrl": "accessTokenUrl",
            "password": "password",
            "tokenApiAuthentication": "header",
            "username": "username",
            "type": "oauth-rop"
          }
        },
        "subtype": "http"
      }
    ]
  },
  "locations": [
    "aws:us-east-2"
  ],
  "message": "BDD test payload: synthetics_api_test_multi_step_with_every_type_of_basic_auth.json",
  "name": "Example-Synthetic",
  "options": {
    "tick_every": 60
  },
  "subtype": "multi",
  "type": "api"
}
{
  "config": {
    "assertions": [
      {
        "operator": "is",
        "target": 1,
        "type": "grpcHealthcheckStatus"
      },
      {
        "operator": "is",
        "target": "proto target",
        "type": "grpcProto"
      },
      {
        "operator": "is",
        "target": "123",
        "property": "property",
        "type": "grpcMetadata"
      }
    ],
    "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-Synthetic",
  "options": {
    "min_failure_duration": 0,
    "min_location_failed": 1,
    "monitor_options": {
      "renotify_interval": 0
    },
    "monitor_name": "Example-Synthetic",
    "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",
        "timingsScope": "withoutDNS"
      },
      {
        "operator": "validatesJSONPath",
        "target": {
          "jsonPath": "topKey",
          "operator": "isNot",
          "targetValue": "0"
        },
        "type": "body"
      },
      {
        "operator": "validatesJSONPath",
        "target": {
          "elementsOperator": "atLeastOneElementMatches",
          "jsonPath": "topKey",
          "operator": "isNot",
          "targetValue": "0"
        },
        "type": "body"
      },
      {
        "operator": "validatesJSONSchema",
        "target": {
          "metaSchema": "draft-07",
          "jsonSchema": "{\"type\": \"object\", \"properties\":{\"slideshow\":{\"type\":\"object\"}}}"
        },
        "type": "body"
      },
      {
        "operator": "validatesXPath",
        "target": {
          "xPath": "target-xpath",
          "targetValue": "0",
          "operator": "contains"
        },
        "type": "body"
      },
      {
        "operator": "md5",
        "target": "a",
        "type": "bodyHash"
      },
      {
        "code": "const hello = 'world';",
        "type": "javascript"
      }
    ],
    "configVariables": [
      {
        "example": "content-type",
        "name": "PROPERTY",
        "pattern": "content-type",
        "type": "text"
      }
    ],
    "variablesFromScript": "dd.variable.set(\"FOO\", \"foo\")",
    "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": "examplesynthetic"
      },
      "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"
      },
      "persistCookies": true
    }
  },
  "locations": [
    "aws:us-east-2"
  ],
  "message": "BDD test payload: synthetics_api_http_test_payload.json",
  "name": "Example-Synthetic",
  "options": {
    "accept_self_signed": false,
    "allow_insecure": true,
    "follow_redirects": true,
    "min_failure_duration": 10,
    "min_location_failed": 1,
    "monitor_name": "Example-Synthetic",
    "monitor_priority": 5,
    "retry": {
      "count": 3,
      "interval": 10
    },
    "tick_every": 60,
    "httpVersion": "http2"
  },
  "subtype": "http",
  "tags": [
    "testing:api"
  ],
  "type": "api"
}

Respuesta

OK - Returns the created test details.

Object containing details about a Synthetic API test.

Expand All

Campo

Tipo

Descripción

config [required]

object

Configuration object for a Synthetic API test.

assertions

[ <oneOf>]

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

default:

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

property

string

The associated assertion property.

target [required]

Value used by the operator.

timingsScope

enum

Timings scope for response time assertions. Allowed enum values: all,withoutDNS

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,grpcMetadata,grpcProto,connection

Option 2

object

An assertion which targets body hash.

operator [required]

enum

Assertion operator to apply. Allowed enum values: md5,sha1,sha256

target [required]

Value used by the operator.

type [required]

enum

Type of the assertion. Allowed enum values: bodyHash

Option 3

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.

elementsOperator

string

The element from the list of results to assert on. To choose from the first element in the list firstElementMatches, every element in the list everyElementMatches, at least one element in the list atLeastOneElementMatches or the serialized value of the list serializationMatches.

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,grpcMetadata,grpcProto,connection

Option 4

object

An assertion for the validatesJSONSchema operator.

operator [required]

enum

Assertion operator to apply. Allowed enum values: validatesJSONSchema

target

object

Composed target for validatesJSONSchema operator.

jsonSchema

string

The JSON Schema to assert.

metaSchema

enum

The JSON Schema meta-schema version used in the assertion. Allowed enum values: draft-07,draft-06

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,grpcMetadata,grpcProto,connection

Option 5

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,grpcMetadata,grpcProto,connection

Option 6

object

A JavaScript assertion.

code [required]

string

The JavaScript code that performs the assertions.

type [required]

enum

Type of the assertion. Allowed enum values: javascript

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.

secure

boolean

Whether the value of this variable will be obfuscated in test results. Only for config variables of type text.

type [required]

enum

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

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

 <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

default: 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

default: 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

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

enum

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

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

enum

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

default: 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.

tokenApiAuthentication [required]

enum

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

type [required]

enum

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

default: 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,application/octet-stream,multipart/form-data

callType

enum

The type of gRPC call to perform. Allowed enum values: healthcheck,unary

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.

default:

compressedJsonDescriptor

string

A protobuf JSON descriptor that needs to be gzipped first then base64 encoded.

compressedProtoFile

string

A protobuf file that needs to be gzipped first then base64 encoded.

dnsServer

string

DNS server to use for DNS tests.

dnsServerPort

string

DNS server port to use for DNS tests.

files

[object]

Files to be used as part of the request in the test.

bucketKey

string

Bucket key of the file.

content

string

Content of the file.

name

string

Name of the file.

originalFileName

string

Original name of the file.

size

int64

Size of the file.

type

string

Type of the file.

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.

httpVersion

enum

HTTP version to use for a Synthetic test. Allowed enum values: http1,http2,any

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

string

Either the HTTP method/verb to use or a gRPC method available on the service set in the service field. Required if subtype is HTTP or if subtype is grpc and callType is unary.

noSavingResponseBody

boolean

Determines whether or not to save the response body.

numberOfPackets

int32

Number of pings to use per test.

persistCookies

boolean

Persist cookies across redirects.

port

 <oneOf>

Port to use when performing the test.

Option 1

int64

Integer Port number to use when performing the test.

Option 2

string

String Port number to use when performing the test. Supports templated variables.

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

The gRPC service on which you want to perform the gRPC call.

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

[ <oneOf>]

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

Option 1

object

The Test step used in a Synthetic multi-step API test.

allowFailure

boolean

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

assertions [required]

[ <oneOf>]

Array of assertions used for the test.

default:

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

property

string

The associated assertion property.

target [required]

Value used by the operator.

timingsScope

enum

Timings scope for response time assertions. Allowed enum values: all,withoutDNS

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,grpcMetadata,grpcProto,connection

Option 2

object

An assertion which targets body hash.

operator [required]

enum

Assertion operator to apply. Allowed enum values: md5,sha1,sha256

target [required]

Value used by the operator.

type [required]

enum

Type of the assertion. Allowed enum values: bodyHash

Option 3

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.

elementsOperator

string

The element from the list of results to assert on. To choose from the first element in the list firstElementMatches, every element in the list everyElementMatches, at least one element in the list atLeastOneElementMatches or the serialized value of the list serializationMatches.

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,grpcMetadata,grpcProto,connection

Option 4

object

An assertion for the validatesJSONSchema operator.

operator [required]

enum

Assertion operator to apply. Allowed enum values: validatesJSONSchema

target

object

Composed target for validatesJSONSchema operator.

jsonSchema

string

The JSON Schema to assert.

metaSchema

enum

The JSON Schema meta-schema version used in the assertion. Allowed enum values: draft-07,draft-06

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,grpcMetadata,grpcProto,connection

Option 5

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,grpcMetadata,grpcProto,connection

Option 6

object

A JavaScript assertion.

code [required]

string

The JavaScript code that performs the assertions.

type [required]

enum

Type of the assertion. Allowed enum values: javascript

extractedValues

[object]

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

field

string

When type is http_header or grpc_metadata, name of the header or metadatum to extract.

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 Synthetic 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.

secure

boolean

Determines whether or not the extracted value will be obfuscated.

type

enum

Property of the Synthetic Test Response to extract into a local variable. Allowed enum values: grpc_message,grpc_metadata,http_body,http_header,http_status_code

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

 <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

default: 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

default: 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

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

enum

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

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

enum

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

default: 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.

tokenApiAuthentication [required]

enum

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

type [required]

enum

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

default: 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,application/octet-stream,multipart/form-data

callType

enum

The type of gRPC call to perform. Allowed enum values: healthcheck,unary

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.

default:

compressedJsonDescriptor

string

A protobuf JSON descriptor that needs to be gzipped first then base64 encoded.

compressedProtoFile

string

A protobuf file that needs to be gzipped first then base64 encoded.

dnsServer

string

DNS server to use for DNS tests.

dnsServerPort

string

DNS server port to use for DNS tests.

files

[object]

Files to be used as part of the request in the test.

bucketKey

string

Bucket key of the file.

content

string

Content of the file.

name

string

Name of the file.

originalFileName

string

Original name of the file.

size

int64

Size of the file.

type

string

Type of the file.

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.

httpVersion

enum

HTTP version to use for a Synthetic test. Allowed enum values: http1,http2,any

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

string

Either the HTTP method/verb to use or a gRPC method available on the service set in the service field. Required if subtype is HTTP or if subtype is grpc and callType is unary.

noSavingResponseBody

boolean

Determines whether or not to save the response body.

numberOfPackets

int32

Number of pings to use per test.

persistCookies

boolean

Persist cookies across redirects.

port

 <oneOf>

Port to use when performing the test.

Option 1

int64

Integer Port number to use when performing the test.

Option 2

string

String Port number to use when performing the test. Supports templated variables.

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

The gRPC service on which you want to perform the gRPC call.

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 multi-step API test step. Allowed enum values: http,grpc

Option 2

object

The Wait step used in a Synthetic multi-step API test.

name [required]

string

The name of the step.

subtype [required]

enum

The subtype of the Synthetic multi-step API wait step. Allowed enum values: wait

value [required]

int32

The time to wait in seconds. Minimum value: 0. Maximum value: 180.

variablesFromScript

string

Variables defined from JavaScript code.

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

enum

Execution rule for a Synthetic 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.

enableProfiling

boolean

Enable profiling for browser tests.

enableSecurityTesting

boolean

DEPRECATED: Enable security testing for browser tests. Security testing is not available anymore. This field is deprecated and won't be used.

follow_redirects

boolean

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

httpVersion

enum

HTTP version to use for a Synthetic test. Allowed enum values: http1,http2,any

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).

escalation_message

string

Message to include in the escalation notification.

notification_preset_name

enum

The name of the preset for the notification for the monitor. Allowed enum values: show_all,hide_all,hide_query,hide_handles

renotify_interval

int64

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

renotify_occurrences

int64

The number of times to renotify if the test is still failing.

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.

scheduling

object

Object containing timeframes and timezone used for advanced scheduling.

timeframes [required]

[object]

Array containing objects describing the scheduling pattern to apply to each day.

day [required]

int32

Number representing the day of the week.

from [required]

string

The hour of the day on which scheduling starts.

to [required]

string

The hour of the day on which scheduling ends.

timezone [required]

string

Timezone in which the timeframe is based.

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

default: api

{
  "config": {
    "assertions": [
      []
    ],
    "configVariables": [
      {
        "example": "string",
        "id": "string",
        "name": "VARIABLE_NAME",
        "pattern": "string",
        "secure": false,
        "type": "text"
      }
    ],
    "request": {
      "allow_insecure": false,
      "basicAuth": {
        "password": "PaSSw0RD!",
        "type": "web",
        "username": "my_username"
      },
      "body": "string",
      "bodyType": "text/plain",
      "callType": "unary",
      "certificate": {
        "cert": {
          "content": "string",
          "filename": "string",
          "updatedAt": "string"
        },
        "key": {
          "content": "string",
          "filename": "string",
          "updatedAt": "string"
        }
      },
      "certificateDomains": [],
      "compressedJsonDescriptor": "string",
      "compressedProtoFile": "string",
      "dnsServer": "string",
      "dnsServerPort": "string",
      "files": [
        {
          "bucketKey": "string",
          "content": "string",
          "name": "string",
          "originalFileName": "string",
          "size": "integer",
          "type": "string"
        }
      ],
      "follow_redirects": false,
      "headers": {
        "<any-key>": "string"
      },
      "host": "string",
      "httpVersion": "string",
      "message": "string",
      "metadata": {
        "<any-key>": "string"
      },
      "method": "string",
      "noSavingResponseBody": false,
      "numberOfPackets": "integer",
      "persistCookies": false,
      "port": {
        "description": "undefined",
        "format": "undefined",
        "type": "undefined"
      },
      "proxy": {
        "headers": {
          "<any-key>": "string"
        },
        "url": "https://example.com"
      },
      "query": {},
      "servername": "string",
      "service": "Greeter",
      "shouldTrackHops": false,
      "timeout": "number",
      "url": "https://example.com"
    },
    "steps": [],
    "variablesFromScript": "dd.variable.set(\"FOO\", \"foo\")"
  },
  "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": "blocking"
    },
    "device_ids": [
      "chrome.laptop_large"
    ],
    "disableCors": false,
    "disableCsp": false,
    "enableProfiling": false,
    "enableSecurityTesting": false,
    "follow_redirects": false,
    "httpVersion": "string",
    "ignoreServerCertificateError": false,
    "initialNavigationTimeout": "integer",
    "min_failure_duration": "integer",
    "min_location_failed": "integer",
    "monitor_name": "string",
    "monitor_options": {
      "escalation_message": "string",
      "notification_preset_name": "string",
      "renotify_interval": "integer",
      "renotify_occurrences": "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
    },
    "scheduling": {
      "timeframes": [
        {
          "day": 1,
          "from": "07:00",
          "to": "16:00"
        }
      ],
      "timezone": "America/New_York"
    },
    "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

Campo

Tipo

Descripción

errors [required]

[string]

Array of errors returned by the API.

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

Test quota is reached

Error response object.

Expand All

Campo

Tipo

Descripción

errors [required]

[string]

Array of errors returned by the API.

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

Forbidden

Error response object.

Expand All

Campo

Tipo

Descripción

errors [required]

[string]

Array of errors returned by the API.

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

Too many requests

Error response object.

Expand All

Campo

Tipo

Descripción

errors [required]

[string]

Array of errors returned by the API.

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

Ejemplo de código

                          ## Create an API test.
# Example of an API test.

# Curl command
curl -X POST "https://api.ap1.datadoghq.com"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": "lessThan", "target": 1000, "type": "responseTime" }, { "operator": "is", "target": 200, "type": "statusCode" }, { "operator": "is", "property": "content-type", "target": "text/html; charset=UTF-8", "type": "header" } ], "request": { "method": "GET", "url": "https://example.com" } }, "locations": [ "azure:eastus", "aws:eu-west-3" ], "message": "MY_NOTIFICATION_MESSAGE", "name": "MY_TEST_NAME", "options": { "min_failure_duration": 0, "min_location_failed": 1, "monitor_options": { "include_tags": true, "locked": false, "new_host_delay": 300, "notify_audit": false, "notify_no_data": false, "renotify_interval": 0 }, "tick_every": 60 }, "status": "live", "subtype": "http", "tags": [ "env:production" ], "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.ap1.datadoghq.com"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": { "steps": [ { "assertions": [ { "operator": "lessThan", "target": 30000, "type": "responseTime" } ], "extractedValues": [ { "field": "location", "name": "CART_ID", "parser": { "type": "regex", "value": "(?:[^\\\\/](?!(\\\\|/)))+$" }, "type": "http_header" } ], "name": "Get a cart", "request": { "method": "POST", "timeout": 30, "url": "https://api.shopist.io/carts" }, "subtype": "http" }, { "assertions": [ { "operator": "is", "target": 200, "type": "statusCode" } ], "extractedValues": [ { "name": "PRODUCT_ID", "parser": { "type": "json_path", "value": "$[0].id['$oid']" }, "type": "http_body" } ], "name": "Get a product", "request": { "method": "GET", "timeout": 30, "url": "https://api.shopist.io/products.json" }, "subtype": "http" }, { "assertions": [ { "operator": "is", "target": 201, "type": "statusCode" } ], "name": "Add product to cart", "request": { "body": "{\n \"cart_item\": {\n \"product_id\": \"{{ PRODUCT_ID }}\",\n \"amount_paid\": 500,\n \"quantity\": 1\n },\n \"cart_id\": \"{{ CART_ID }}\"\n}", "headers": { "content-type": "application/json" }, "method": "POST", "timeout": 30, "url": "https://api.shopist.io/add_item.json" }, "subtype": "http" } ] }, "locations": [ "aws:us-west-2" ], "message": "MY_NOTIFICATION_MESSAGE", "name": "MY_TEST_NAME", "options": { "ci": { "executionRule": "blocking" }, "min_failure_duration": 5400, "min_location_failed": 1, "monitor_options": { "renotify_interval": 0 }, "retry": { "count": 3, "interval": 300 }, "tick_every": 900 }, "status": "live", "subtype": "multi", "tags": [ "env:prod" ], "type": "api" } EOF
                          ## Create an API test.
# Example of an API test.

# Curl command
curl -X POST "https://api.ap1.datadoghq.com"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": "lessThan", "target": 1000, "type": "responseTime" }, { "operator": "is", "target": 200, "type": "statusCode" }, { "operator": "is", "property": "content-type", "target": "text/html; charset=UTF-8", "type": "header" } ], "request": { "method": "GET", "url": "https://example.com" } }, "locations": [ "azure:eastus", "aws:eu-west-3" ], "message": "MY_NOTIFICATION_MESSAGE", "name": "MY_TEST_NAME", "options": { "min_failure_duration": 0, "min_location_failed": 1, "monitor_options": { "include_tags": true, "locked": false, "new_host_delay": 300, "notify_audit": false, "notify_no_data": false, "renotify_interval": 0 }, "tick_every": 60 }, "status": "live", "subtype": "http", "tags": [ "env:production" ], "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.ap1.datadoghq.com"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": { "steps": [ { "assertions": [ { "operator": "lessThan", "target": 30000, "type": "responseTime" } ], "extractedValues": [ { "field": "location", "name": "CART_ID", "parser": { "type": "regex", "value": "(?:[^\\\\/](?!(\\\\|/)))+$" }, "type": "http_header" } ], "name": "Get a cart", "request": { "method": "POST", "timeout": 30, "url": "https://api.shopist.io/carts" }, "subtype": "http" }, { "assertions": [ { "operator": "is", "target": 200, "type": "statusCode" } ], "extractedValues": [ { "name": "PRODUCT_ID", "parser": { "type": "json_path", "value": "$[0].id['$oid']" }, "type": "http_body" } ], "name": "Get a product", "request": { "method": "GET", "timeout": 30, "url": "https://api.shopist.io/products.json" }, "subtype": "http" }, { "assertions": [ { "operator": "is", "target": 201, "type": "statusCode" } ], "name": "Add product to cart", "request": { "body": "{\n \"cart_item\": {\n \"product_id\": \"{{ PRODUCT_ID }}\",\n \"amount_paid\": 500,\n \"quantity\": 1\n },\n \"cart_id\": \"{{ CART_ID }}\"\n}", "headers": { "content-type": "application/json" }, "method": "POST", "timeout": 30, "url": "https://api.shopist.io/add_item.json" }, "subtype": "http" } ] }, "locations": [ "aws:us-west-2" ], "message": "MY_NOTIFICATION_MESSAGE", "name": "MY_TEST_NAME", "options": { "ci": { "executionRule": "blocking" }, "min_failure_duration": 5400, "min_location_failed": 1, "monitor_options": { "renotify_interval": 0 }, "retry": { "count": 3, "interval": 300 }, "tick_every": 900 }, "status": "live", "subtype": "multi", "tags": [ "env:prod" ], "type": "api" } EOF
                          ## Create an API test.
# Example of an API test.

# Curl command
curl -X POST "https://api.ap1.datadoghq.com"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": "lessThan", "target": 1000, "type": "responseTime" }, { "operator": "is", "target": 200, "type": "statusCode" }, { "operator": "is", "property": "content-type", "target": "text/html; charset=UTF-8", "type": "header" } ], "request": { "method": "GET", "url": "https://example.com" } }, "locations": [ "azure:eastus", "aws:eu-west-3" ], "message": "MY_NOTIFICATION_MESSAGE", "name": "MY_TEST_NAME", "options": { "min_failure_duration": 0, "min_location_failed": 1, "monitor_options": { "include_tags": true, "locked": false, "new_host_delay": 300, "notify_audit": false, "notify_no_data": false, "renotify_interval": 0 }, "tick_every": 60 }, "status": "live", "subtype": "http", "tags": [ "env:production" ], "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.ap1.datadoghq.com"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": { "steps": [ { "assertions": [ { "operator": "lessThan", "target": 30000, "type": "responseTime" } ], "extractedValues": [ { "field": "location", "name": "CART_ID", "parser": { "type": "regex", "value": "(?:[^\\\\/](?!(\\\\|/)))+$" }, "type": "http_header" } ], "name": "Get a cart", "request": { "method": "POST", "timeout": 30, "url": "https://api.shopist.io/carts" }, "subtype": "http" }, { "assertions": [ { "operator": "is", "target": 200, "type": "statusCode" } ], "extractedValues": [ { "name": "PRODUCT_ID", "parser": { "type": "json_path", "value": "$[0].id['$oid']" }, "type": "http_body" } ], "name": "Get a product", "request": { "method": "GET", "timeout": 30, "url": "https://api.shopist.io/products.json" }, "subtype": "http" }, { "assertions": [ { "operator": "is", "target": 201, "type": "statusCode" } ], "name": "Add product to cart", "request": { "body": "{\n \"cart_item\": {\n \"product_id\": \"{{ PRODUCT_ID }}\",\n \"amount_paid\": 500,\n \"quantity\": 1\n },\n \"cart_id\": \"{{ CART_ID }}\"\n}", "headers": { "content-type": "application/json" }, "method": "POST", "timeout": 30, "url": "https://api.shopist.io/add_item.json" }, "subtype": "http" } ] }, "locations": [ "aws:us-west-2" ], "message": "MY_NOTIFICATION_MESSAGE", "name": "MY_TEST_NAME", "options": { "ci": { "executionRule": "blocking" }, "min_failure_duration": 5400, "min_location_failed": 1, "monitor_options": { "renotify_interval": 0 }, "retry": { "count": 3, "interval": 300 }, "tick_every": 900 }, "status": "live", "subtype": "multi", "tags": [ "env:prod" ], "type": "api" } EOF
// Create a multi-step api test with every type of basicAuth 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{
			Steps: []datadogV1.SyntheticsAPIStep{
				datadogV1.SyntheticsAPIStep{
					SyntheticsAPITestStep: &datadogV1.SyntheticsAPITestStep{
						Assertions: []datadogV1.SyntheticsAssertion{
							datadogV1.SyntheticsAssertion{
								SyntheticsAssertionTarget: &datadogV1.SyntheticsAssertionTarget{
									Operator: datadogV1.SYNTHETICSASSERTIONOPERATOR_IS,
									Type:     datadogV1.SYNTHETICSASSERTIONTYPE_STATUS_CODE,
									Target:   200,
								}},
						},
						Name: "request is sent",
						Request: datadogV1.SyntheticsTestRequest{
							Url:    datadog.PtrString("https://httpbin.org/status/200"),
							Method: datadog.PtrString("GET"),
							BasicAuth: &datadogV1.SyntheticsBasicAuth{
								SyntheticsBasicAuthWeb: &datadogV1.SyntheticsBasicAuthWeb{
									Password: "password",
									Username: "username",
								}},
						},
						Subtype: datadogV1.SYNTHETICSAPITESTSTEPSUBTYPE_HTTP,
					}},
				datadogV1.SyntheticsAPIStep{
					SyntheticsAPITestStep: &datadogV1.SyntheticsAPITestStep{
						Assertions: []datadogV1.SyntheticsAssertion{
							datadogV1.SyntheticsAssertion{
								SyntheticsAssertionTarget: &datadogV1.SyntheticsAssertionTarget{
									Operator: datadogV1.SYNTHETICSASSERTIONOPERATOR_IS,
									Type:     datadogV1.SYNTHETICSASSERTIONTYPE_STATUS_CODE,
									Target:   200,
								}},
						},
						Name: "request is sent",
						Request: datadogV1.SyntheticsTestRequest{
							Url:    datadog.PtrString("https://httpbin.org/status/200"),
							Method: datadog.PtrString("GET"),
							BasicAuth: &datadogV1.SyntheticsBasicAuth{
								SyntheticsBasicAuthWeb: &datadogV1.SyntheticsBasicAuthWeb{
									Password: "password",
									Username: "username",
									Type:     datadogV1.SYNTHETICSBASICAUTHWEBTYPE_WEB.Ptr(),
								}},
						},
						Subtype: datadogV1.SYNTHETICSAPITESTSTEPSUBTYPE_HTTP,
					}},
				datadogV1.SyntheticsAPIStep{
					SyntheticsAPITestStep: &datadogV1.SyntheticsAPITestStep{
						Assertions: []datadogV1.SyntheticsAssertion{
							datadogV1.SyntheticsAssertion{
								SyntheticsAssertionTarget: &datadogV1.SyntheticsAssertionTarget{
									Operator: datadogV1.SYNTHETICSASSERTIONOPERATOR_IS,
									Type:     datadogV1.SYNTHETICSASSERTIONTYPE_STATUS_CODE,
									Target:   200,
								}},
						},
						Name: "request is sent",
						Request: datadogV1.SyntheticsTestRequest{
							Url:    datadog.PtrString("https://httpbin.org/status/200"),
							Method: datadog.PtrString("GET"),
							BasicAuth: &datadogV1.SyntheticsBasicAuth{
								SyntheticsBasicAuthSigv4: &datadogV1.SyntheticsBasicAuthSigv4{
									AccessKey: "accessKey",
									SecretKey: "secretKey",
									Type:      datadogV1.SYNTHETICSBASICAUTHSIGV4TYPE_SIGV4,
								}},
						},
						Subtype: datadogV1.SYNTHETICSAPITESTSTEPSUBTYPE_HTTP,
					}},
				datadogV1.SyntheticsAPIStep{
					SyntheticsAPITestStep: &datadogV1.SyntheticsAPITestStep{
						Assertions: []datadogV1.SyntheticsAssertion{
							datadogV1.SyntheticsAssertion{
								SyntheticsAssertionTarget: &datadogV1.SyntheticsAssertionTarget{
									Operator: datadogV1.SYNTHETICSASSERTIONOPERATOR_IS,
									Type:     datadogV1.SYNTHETICSASSERTIONTYPE_STATUS_CODE,
									Target:   200,
								}},
						},
						Name: "request is sent",
						Request: datadogV1.SyntheticsTestRequest{
							Url:    datadog.PtrString("https://httpbin.org/status/200"),
							Method: datadog.PtrString("GET"),
							BasicAuth: &datadogV1.SyntheticsBasicAuth{
								SyntheticsBasicAuthNTLM: &datadogV1.SyntheticsBasicAuthNTLM{
									Type: datadogV1.SYNTHETICSBASICAUTHNTLMTYPE_NTLM,
								}},
						},
						Subtype: datadogV1.SYNTHETICSAPITESTSTEPSUBTYPE_HTTP,
					}},
				datadogV1.SyntheticsAPIStep{
					SyntheticsAPITestStep: &datadogV1.SyntheticsAPITestStep{
						Assertions: []datadogV1.SyntheticsAssertion{
							datadogV1.SyntheticsAssertion{
								SyntheticsAssertionTarget: &datadogV1.SyntheticsAssertionTarget{
									Operator: datadogV1.SYNTHETICSASSERTIONOPERATOR_IS,
									Type:     datadogV1.SYNTHETICSASSERTIONTYPE_STATUS_CODE,
									Target:   200,
								}},
						},
						Name: "request is sent",
						Request: datadogV1.SyntheticsTestRequest{
							Url:    datadog.PtrString("https://httpbin.org/status/200"),
							Method: datadog.PtrString("GET"),
							BasicAuth: &datadogV1.SyntheticsBasicAuth{
								SyntheticsBasicAuthDigest: &datadogV1.SyntheticsBasicAuthDigest{
									Password: "password",
									Username: "username",
									Type:     datadogV1.SYNTHETICSBASICAUTHDIGESTTYPE_DIGEST,
								}},
						},
						Subtype: datadogV1.SYNTHETICSAPITESTSTEPSUBTYPE_HTTP,
					}},
				datadogV1.SyntheticsAPIStep{
					SyntheticsAPITestStep: &datadogV1.SyntheticsAPITestStep{
						Assertions: []datadogV1.SyntheticsAssertion{
							datadogV1.SyntheticsAssertion{
								SyntheticsAssertionTarget: &datadogV1.SyntheticsAssertionTarget{
									Operator: datadogV1.SYNTHETICSASSERTIONOPERATOR_IS,
									Type:     datadogV1.SYNTHETICSASSERTIONTYPE_STATUS_CODE,
									Target:   200,
								}},
						},
						Name: "request is sent",
						Request: datadogV1.SyntheticsTestRequest{
							Url:    datadog.PtrString("https://httpbin.org/status/200"),
							Method: datadog.PtrString("GET"),
							BasicAuth: &datadogV1.SyntheticsBasicAuth{
								SyntheticsBasicAuthOauthClient: &datadogV1.SyntheticsBasicAuthOauthClient{
									AccessTokenUrl:         "accessTokenUrl",
									TokenApiAuthentication: datadogV1.SYNTHETICSBASICAUTHOAUTHTOKENAPIAUTHENTICATION_HEADER,
									ClientId:               "clientId",
									ClientSecret:           "clientSecret",
									Type:                   datadogV1.SYNTHETICSBASICAUTHOAUTHCLIENTTYPE_OAUTH_CLIENT,
								}},
						},
						Subtype: datadogV1.SYNTHETICSAPITESTSTEPSUBTYPE_HTTP,
					}},
				datadogV1.SyntheticsAPIStep{
					SyntheticsAPITestStep: &datadogV1.SyntheticsAPITestStep{
						Assertions: []datadogV1.SyntheticsAssertion{
							datadogV1.SyntheticsAssertion{
								SyntheticsAssertionTarget: &datadogV1.SyntheticsAssertionTarget{
									Operator: datadogV1.SYNTHETICSASSERTIONOPERATOR_IS,
									Type:     datadogV1.SYNTHETICSASSERTIONTYPE_STATUS_CODE,
									Target:   200,
								}},
						},
						Name: "request is sent",
						Request: datadogV1.SyntheticsTestRequest{
							Url:    datadog.PtrString("https://httpbin.org/status/200"),
							Method: datadog.PtrString("GET"),
							BasicAuth: &datadogV1.SyntheticsBasicAuth{
								SyntheticsBasicAuthOauthROP: &datadogV1.SyntheticsBasicAuthOauthROP{
									AccessTokenUrl:         "accessTokenUrl",
									Password:               "password",
									TokenApiAuthentication: datadogV1.SYNTHETICSBASICAUTHOAUTHTOKENAPIAUTHENTICATION_HEADER,
									Username:               "username",
									Type:                   datadogV1.SYNTHETICSBASICAUTHOAUTHROPTYPE_OAUTH_ROP,
								}},
						},
						Subtype: datadogV1.SYNTHETICSAPITESTSTEPSUBTYPE_HTTP,
					}},
			},
		},
		Locations: []string{
			"aws:us-east-2",
		},
		Message: "BDD test payload: synthetics_api_test_multi_step_with_every_type_of_basic_auth.json",
		Name:    "Example-Synthetic",
		Options: datadogV1.SyntheticsTestOptions{
			TickEvery: datadog.PtrInt64(60),
		},
		Subtype: datadogV1.SYNTHETICSTESTDETAILSSUBTYPE_MULTI.Ptr(),
		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 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,
					}},
				datadogV1.SyntheticsAssertion{
					SyntheticsAssertionTarget: &datadogV1.SyntheticsAssertionTarget{
						Operator: datadogV1.SYNTHETICSASSERTIONOPERATOR_IS,
						Target:   "proto target",
						Type:     datadogV1.SYNTHETICSASSERTIONTYPE_GRPC_PROTO,
					}},
				datadogV1.SyntheticsAssertion{
					SyntheticsAssertionTarget: &datadogV1.SyntheticsAssertionTarget{
						Operator: datadogV1.SYNTHETICSASSERTIONOPERATOR_IS,
						Target:   "123",
						Property: datadog.PtrString("property"),
						Type:     datadogV1.SYNTHETICSASSERTIONTYPE_GRPC_METADATA,
					}},
			},
			Request: &datadogV1.SyntheticsTestRequest{
				Host:     datadog.PtrString("localhost"),
				Port:     datadog.PtrString("50051"),
				Service:  datadog.PtrString("Hello"),
				Method:   datadog.PtrString("GET"),
				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-Synthetic",
		Options: datadogV1.SyntheticsTestOptions{
			MinFailureDuration: datadog.PtrInt64(0),
			MinLocationFailed:  datadog.PtrInt64(1),
			MonitorOptions: &datadogV1.SyntheticsTestOptionsMonitorOptions{
				RenotifyInterval: datadog.PtrInt64(0),
			},
			MonitorName: datadog.PtrString("Example-Synthetic"),
			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 has bodyHash filled out

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,
						TimingsScope: datadogV1.SYNTHETICSASSERTIONTIMINGSSCOPE_WITHOUT_DNS.Ptr(),
					}},
				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{
					SyntheticsAssertionJSONPathTarget: &datadogV1.SyntheticsAssertionJSONPathTarget{
						Operator: datadogV1.SYNTHETICSASSERTIONJSONPATHOPERATOR_VALIDATES_JSON_PATH,
						Target: &datadogV1.SyntheticsAssertionJSONPathTargetTarget{
							ElementsOperator: datadog.PtrString("atLeastOneElementMatches"),
							JsonPath:         datadog.PtrString("topKey"),
							Operator:         datadog.PtrString("isNot"),
							TargetValue:      "0",
						},
						Type: datadogV1.SYNTHETICSASSERTIONTYPE_BODY,
					}},
				datadogV1.SyntheticsAssertion{
					SyntheticsAssertionJSONSchemaTarget: &datadogV1.SyntheticsAssertionJSONSchemaTarget{
						Operator: datadogV1.SYNTHETICSASSERTIONJSONSCHEMAOPERATOR_VALIDATES_JSON_SCHEMA,
						Target: &datadogV1.SyntheticsAssertionJSONSchemaTargetTarget{
							MetaSchema: datadogV1.SYNTHETICSASSERTIONJSONSCHEMAMETASCHEMA_DRAFT_07.Ptr(),
							JsonSchema: datadog.PtrString(`{"type": "object", "properties":{"slideshow":{"type":"object"}}}`),
						},
						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,
					}},
				datadogV1.SyntheticsAssertion{
					SyntheticsAssertionBodyHashTarget: &datadogV1.SyntheticsAssertionBodyHashTarget{
						Operator: datadogV1.SYNTHETICSASSERTIONBODYHASHOPERATOR_MD5,
						Target:   "a",
						Type:     datadogV1.SYNTHETICSASSERTIONBODYHASHTYPE_BODY_HASH,
					}},
			},
			ConfigVariables: []datadogV1.SyntheticsConfigVariable{
				{
					Example: datadog.PtrString("content-type"),
					Name:    "PROPERTY",
					Pattern: datadog.PtrString("content-type"),
					Type:    datadogV1.SYNTHETICSCONFIGVARIABLETYPE_TEXT,
				},
			},
			VariablesFromScript: datadog.PtrString(`dd.variable.set("FOO", "foo")`),
			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": "examplesynthetic",
				},
				Method:  datadog.PtrString("GET"),
				Timeout: datadog.PtrFloat64(10),
				Url:     datadog.PtrString("https://datadoghq.com"),
				Proxy: &datadogV1.SyntheticsTestRequestProxy{
					Url:     "https://datadoghq.com",
					Headers: map[string]string{},
				},
				BasicAuth: &datadogV1.SyntheticsBasicAuth{
					SyntheticsBasicAuthOauthClient: &datadogV1.SyntheticsBasicAuthOauthClient{
						AccessTokenUrl:         "https://datadog-token.com",
						Audience:               datadog.PtrString("audience"),
						ClientId:               "client-id",
						ClientSecret:           "client-secret",
						Resource:               datadog.PtrString("resource"),
						Scope:                  datadog.PtrString("yoyo"),
						TokenApiAuthentication: datadogV1.SYNTHETICSBASICAUTHOAUTHTOKENAPIAUTHENTICATION_HEADER,
						Type:                   datadogV1.SYNTHETICSBASICAUTHOAUTHCLIENTTYPE_OAUTH_CLIENT,
					}},
				PersistCookies: datadog.PtrBool(true),
			},
		},
		Locations: []string{
			"aws:us-east-2",
		},
		Message: "BDD test payload: synthetics_api_http_test_payload.json",
		Name:    "Example-Synthetic",
		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-Synthetic"),
			MonitorPriority:    datadog.PtrInt32(5),
			Retry: &datadogV1.SyntheticsTestOptionsRetry{
				Count:    datadog.PtrInt64(3),
				Interval: datadog.PtrFloat64(10),
			},
			TickEvery:   datadog.PtrInt64(60),
			HttpVersion: datadogV1.SYNTHETICSTESTOPTIONSHTTPVERSION_HTTP2.Ptr(),
		},
		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)
}

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.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Create a multi-step api test with every type of basicAuth 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.SyntheticsAPIStep;
import com.datadog.api.client.v1.model.SyntheticsAPITest;
import com.datadog.api.client.v1.model.SyntheticsAPITestConfig;
import com.datadog.api.client.v1.model.SyntheticsAPITestStep;
import com.datadog.api.client.v1.model.SyntheticsAPITestStepSubtype;
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.SyntheticsBasicAuth;
import com.datadog.api.client.v1.model.SyntheticsBasicAuthDigest;
import com.datadog.api.client.v1.model.SyntheticsBasicAuthDigestType;
import com.datadog.api.client.v1.model.SyntheticsBasicAuthNTLM;
import com.datadog.api.client.v1.model.SyntheticsBasicAuthNTLMType;
import com.datadog.api.client.v1.model.SyntheticsBasicAuthOauthClient;
import com.datadog.api.client.v1.model.SyntheticsBasicAuthOauthClientType;
import com.datadog.api.client.v1.model.SyntheticsBasicAuthOauthROP;
import com.datadog.api.client.v1.model.SyntheticsBasicAuthOauthROPType;
import com.datadog.api.client.v1.model.SyntheticsBasicAuthOauthTokenApiAuthentication;
import com.datadog.api.client.v1.model.SyntheticsBasicAuthSigv4;
import com.datadog.api.client.v1.model.SyntheticsBasicAuthSigv4Type;
import com.datadog.api.client.v1.model.SyntheticsBasicAuthWeb;
import com.datadog.api.client.v1.model.SyntheticsBasicAuthWebType;
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.Arrays;
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()
                    .steps(
                        Arrays.asList(
                            new SyntheticsAPIStep(
                                new SyntheticsAPITestStep()
                                    .assertions(
                                        Collections.singletonList(
                                            new SyntheticsAssertion(
                                                new SyntheticsAssertionTarget()
                                                    .operator(SyntheticsAssertionOperator.IS)
                                                    .type(SyntheticsAssertionType.STATUS_CODE)
                                                    .target(200))))
                                    .name("request is sent")
                                    .request(
                                        new SyntheticsTestRequest()
                                            .url("https://httpbin.org/status/200")
                                            .method("GET")
                                            .basicAuth(
                                                new SyntheticsBasicAuth(
                                                    new SyntheticsBasicAuthWeb()
                                                        .password("password")
                                                        .username("username"))))
                                    .subtype(SyntheticsAPITestStepSubtype.HTTP)),
                            new SyntheticsAPIStep(
                                new SyntheticsAPITestStep()
                                    .assertions(
                                        Collections.singletonList(
                                            new SyntheticsAssertion(
                                                new SyntheticsAssertionTarget()
                                                    .operator(SyntheticsAssertionOperator.IS)
                                                    .type(SyntheticsAssertionType.STATUS_CODE)
                                                    .target(200))))
                                    .name("request is sent")
                                    .request(
                                        new SyntheticsTestRequest()
                                            .url("https://httpbin.org/status/200")
                                            .method("GET")
                                            .basicAuth(
                                                new SyntheticsBasicAuth(
                                                    new SyntheticsBasicAuthWeb()
                                                        .password("password")
                                                        .username("username")
                                                        .type(SyntheticsBasicAuthWebType.WEB))))
                                    .subtype(SyntheticsAPITestStepSubtype.HTTP)),
                            new SyntheticsAPIStep(
                                new SyntheticsAPITestStep()
                                    .assertions(
                                        Collections.singletonList(
                                            new SyntheticsAssertion(
                                                new SyntheticsAssertionTarget()
                                                    .operator(SyntheticsAssertionOperator.IS)
                                                    .type(SyntheticsAssertionType.STATUS_CODE)
                                                    .target(200))))
                                    .name("request is sent")
                                    .request(
                                        new SyntheticsTestRequest()
                                            .url("https://httpbin.org/status/200")
                                            .method("GET")
                                            .basicAuth(
                                                new SyntheticsBasicAuth(
                                                    new SyntheticsBasicAuthSigv4()
                                                        .accessKey("accessKey")
                                                        .secretKey("secretKey")
                                                        .type(SyntheticsBasicAuthSigv4Type.SIGV4))))
                                    .subtype(SyntheticsAPITestStepSubtype.HTTP)),
                            new SyntheticsAPIStep(
                                new SyntheticsAPITestStep()
                                    .assertions(
                                        Collections.singletonList(
                                            new SyntheticsAssertion(
                                                new SyntheticsAssertionTarget()
                                                    .operator(SyntheticsAssertionOperator.IS)
                                                    .type(SyntheticsAssertionType.STATUS_CODE)
                                                    .target(200))))
                                    .name("request is sent")
                                    .request(
                                        new SyntheticsTestRequest()
                                            .url("https://httpbin.org/status/200")
                                            .method("GET")
                                            .basicAuth(
                                                new SyntheticsBasicAuth(
                                                    new SyntheticsBasicAuthNTLM()
                                                        .type(SyntheticsBasicAuthNTLMType.NTLM))))
                                    .subtype(SyntheticsAPITestStepSubtype.HTTP)),
                            new SyntheticsAPIStep(
                                new SyntheticsAPITestStep()
                                    .assertions(
                                        Collections.singletonList(
                                            new SyntheticsAssertion(
                                                new SyntheticsAssertionTarget()
                                                    .operator(SyntheticsAssertionOperator.IS)
                                                    .type(SyntheticsAssertionType.STATUS_CODE)
                                                    .target(200))))
                                    .name("request is sent")
                                    .request(
                                        new SyntheticsTestRequest()
                                            .url("https://httpbin.org/status/200")
                                            .method("GET")
                                            .basicAuth(
                                                new SyntheticsBasicAuth(
                                                    new SyntheticsBasicAuthDigest()
                                                        .password("password")
                                                        .username("username")
                                                        .type(
                                                            SyntheticsBasicAuthDigestType.DIGEST))))
                                    .subtype(SyntheticsAPITestStepSubtype.HTTP)),
                            new SyntheticsAPIStep(
                                new SyntheticsAPITestStep()
                                    .assertions(
                                        Collections.singletonList(
                                            new SyntheticsAssertion(
                                                new SyntheticsAssertionTarget()
                                                    .operator(SyntheticsAssertionOperator.IS)
                                                    .type(SyntheticsAssertionType.STATUS_CODE)
                                                    .target(200))))
                                    .name("request is sent")
                                    .request(
                                        new SyntheticsTestRequest()
                                            .url("https://httpbin.org/status/200")
                                            .method("GET")
                                            .basicAuth(
                                                new SyntheticsBasicAuth(
                                                    new SyntheticsBasicAuthOauthClient()
                                                        .accessTokenUrl("accessTokenUrl")
                                                        .tokenApiAuthentication(
                                                            SyntheticsBasicAuthOauthTokenApiAuthentication
                                                                .HEADER)
                                                        .clientId("clientId")
                                                        .clientSecret("clientSecret")
                                                        .type(
                                                            SyntheticsBasicAuthOauthClientType
                                                                .OAUTH_CLIENT))))
                                    .subtype(SyntheticsAPITestStepSubtype.HTTP)),
                            new SyntheticsAPIStep(
                                new SyntheticsAPITestStep()
                                    .assertions(
                                        Collections.singletonList(
                                            new SyntheticsAssertion(
                                                new SyntheticsAssertionTarget()
                                                    .operator(SyntheticsAssertionOperator.IS)
                                                    .type(SyntheticsAssertionType.STATUS_CODE)
                                                    .target(200))))
                                    .name("request is sent")
                                    .request(
                                        new SyntheticsTestRequest()
                                            .url("https://httpbin.org/status/200")
                                            .method("GET")
                                            .basicAuth(
                                                new SyntheticsBasicAuth(
                                                    new SyntheticsBasicAuthOauthROP()
                                                        .accessTokenUrl("accessTokenUrl")
                                                        .password("password")
                                                        .tokenApiAuthentication(
                                                            SyntheticsBasicAuthOauthTokenApiAuthentication
                                                                .HEADER)
                                                        .username("username")
                                                        .type(
                                                            SyntheticsBasicAuthOauthROPType
                                                                .OAUTH_ROP))))
                                    .subtype(SyntheticsAPITestStepSubtype.HTTP)))))
            .locations(Collections.singletonList("aws:us-east-2"))
            .message(
                "BDD test payload:"
                    + " synthetics_api_test_multi_step_with_every_type_of_basic_auth.json")
            .name("Example-Synthetic")
            .options(new SyntheticsTestOptions().tickEvery(60L))
            .subtype(SyntheticsTestDetailsSubType.MULTI)
            .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 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.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.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)
                                    .target(1)
                                    .type(SyntheticsAssertionType.GRPC_HEALTHCHECK_STATUS)),
                            new SyntheticsAssertion(
                                new SyntheticsAssertionTarget()
                                    .operator(SyntheticsAssertionOperator.IS)
                                    .target("proto target")
                                    .type(SyntheticsAssertionType.GRPC_PROTO)),
                            new SyntheticsAssertion(
                                new SyntheticsAssertionTarget()
                                    .operator(SyntheticsAssertionOperator.IS)
                                    .target("123")
                                    .property("property")
                                    .type(SyntheticsAssertionType.GRPC_METADATA))))
                    .request(
                        new SyntheticsTestRequest()
                            .host("localhost")
                            .port("50051")
                            .service("Hello")
                            .method("GET")
                            .message("")
                            .metadata(Map.ofEntries())))
            .locations(Collections.singletonList("aws:us-east-2"))
            .message("BDD test payload: synthetics_api_grpc_test_payload.json")
            .name("Example-Synthetic")
            .options(
                new SyntheticsTestOptions()
                    .minFailureDuration(0L)
                    .minLocationFailed(1L)
                    .monitorOptions(new SyntheticsTestOptionsMonitorOptions().renotifyInterval(0L))
                    .monitorName("Example-Synthetic")
                    .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 has bodyHash filled out

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.SyntheticsAssertionBodyHashOperator;
import com.datadog.api.client.v1.model.SyntheticsAssertionBodyHashTarget;
import com.datadog.api.client.v1.model.SyntheticsAssertionBodyHashType;
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.SyntheticsAssertionJSONSchemaMetaSchema;
import com.datadog.api.client.v1.model.SyntheticsAssertionJSONSchemaOperator;
import com.datadog.api.client.v1.model.SyntheticsAssertionJSONSchemaTarget;
import com.datadog.api.client.v1.model.SyntheticsAssertionJSONSchemaTargetTarget;
import com.datadog.api.client.v1.model.SyntheticsAssertionOperator;
import com.datadog.api.client.v1.model.SyntheticsAssertionTarget;
import com.datadog.api.client.v1.model.SyntheticsAssertionTimingsScope;
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.SyntheticsBasicAuth;
import com.datadog.api.client.v1.model.SyntheticsBasicAuthOauthClient;
import com.datadog.api.client.v1.model.SyntheticsBasicAuthOauthClientType;
import com.datadog.api.client.v1.model.SyntheticsBasicAuthOauthTokenApiAuthentication;
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.SyntheticsTestOptionsHTTPVersion;
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)
                                    .timingsScope(SyntheticsAssertionTimingsScope.WITHOUT_DNS)),
                            new SyntheticsAssertion(
                                new SyntheticsAssertionJSONPathTarget()
                                    .operator(
                                        SyntheticsAssertionJSONPathOperator.VALIDATES_JSON_PATH)
                                    .target(
                                        new SyntheticsAssertionJSONPathTargetTarget()
                                            .jsonPath("topKey")
                                            .operator("isNot")
                                            .targetValue("0"))
                                    .type(SyntheticsAssertionType.BODY)),
                            new SyntheticsAssertion(
                                new SyntheticsAssertionJSONPathTarget()
                                    .operator(
                                        SyntheticsAssertionJSONPathOperator.VALIDATES_JSON_PATH)
                                    .target(
                                        new SyntheticsAssertionJSONPathTargetTarget()
                                            .elementsOperator("atLeastOneElementMatches")
                                            .jsonPath("topKey")
                                            .operator("isNot")
                                            .targetValue("0"))
                                    .type(SyntheticsAssertionType.BODY)),
                            new SyntheticsAssertion(
                                new SyntheticsAssertionJSONSchemaTarget()
                                    .operator(
                                        SyntheticsAssertionJSONSchemaOperator.VALIDATES_JSON_SCHEMA)
                                    .target(
                                        new SyntheticsAssertionJSONSchemaTargetTarget()
                                            .metaSchema(
                                                SyntheticsAssertionJSONSchemaMetaSchema.DRAFT_07)
                                            .jsonSchema(
                                                """
{"type": "object", "properties":{"slideshow":{"type":"object"}}}
"""))
                                    .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)),
                            new SyntheticsAssertion(
                                new SyntheticsAssertionBodyHashTarget()
                                    .operator(SyntheticsAssertionBodyHashOperator.MD5)
                                    .target("a")
                                    .type(SyntheticsAssertionBodyHashType.BODY_HASH))))
                    .configVariables(
                        Collections.singletonList(
                            new SyntheticsConfigVariable()
                                .example("content-type")
                                .name("PROPERTY")
                                .pattern("content-type")
                                .type(SyntheticsConfigVariableType.TEXT)))
                    .variablesFromScript("""
dd.variable.set("FOO", "foo")
""")
                    .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")
<