Create a mobile test

POST https://api.ap1.datadoghq.com/api/v1/synthetics/tests/mobilehttps://api.ap2.datadoghq.com/api/v1/synthetics/tests/mobilehttps://api.datadoghq.eu/api/v1/synthetics/tests/mobilehttps://api.ddog-gov.com/api/v1/synthetics/tests/mobilehttps://api.us2.ddog-gov.com/api/v1/synthetics/tests/mobilehttps://api.datadoghq.com/api/v1/synthetics/tests/mobilehttps://api.us3.datadoghq.com/api/v1/synthetics/tests/mobilehttps://api.us5.datadoghq.com/api/v1/synthetics/tests/mobile

Overview

Create a Synthetic mobile test. This endpoint requires the synthetics_write permission.

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

Request

Body Data (required)

Details of the test to create.

Expand All

Field

Type

Description

config [required]

object

Configuration object for a Synthetic mobile test.

initialApplicationArguments

object

Initial application arguments for a mobile test.

<any-key>

string

A single application argument.

variables

[object]

Array of variables used for the test steps.

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

device_ids

[string]

Array with the different device IDs 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.

allowApplicationCrash

boolean

A boolean to set if an application crash would mark the test as failed.

bindings

[object]

Array of bindings used for the mobile test.

principals

[string]

List of principals for a mobile test binding.

relation

enum

The type of relation for the binding. Allowed enum values: editor,viewer

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

defaultStepTimeout

int32

The default timeout for steps in the test (in seconds).

device_ids [required]

[string]

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

disableAutoAcceptAlert

boolean

A boolean to disable auto accepting alerts.

min_failure_duration

int64

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

mobileApplication [required]

object

Mobile application for mobile synthetics test.

applicationId [required]

string

Application ID of the mobile application.

referenceId [required]

string

Reference ID of the mobile application.

referenceType [required]

enum

Reference type for the mobile application for a mobile synthetics test. Allowed enum values: latest,version

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,hide_query_and_handles,show_only_snapshot,hide_handles_and_footer

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

A boolean set to not take a screenshot for the step.

restricted_roles

[string]

DEPRECATED: A list of role identifiers that can be pulled from the Roles API, for restricting read and write access. This field is deprecated. Use the restriction policies API to manage permissions.

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.

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

int64

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

verbosity

int32

The level of verbosity for the mobile test. This field can not be set by a user.

public_id

string

The public ID of the test.

status

enum

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

steps

[object]

Array of steps for the test.

allowFailure

boolean

A boolean set to allow this step to fail.

hasNewStepElement

boolean

A boolean set to determine if the step has a new step element.

isCritical

boolean

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

name [required]

string

The name of the step.

noScreenshot

boolean

A boolean set to not take a screenshot for the step.

params [required]

object

The parameters of a mobile step.

check

enum

Type of assertion to apply in an API test. Allowed enum values: equals,notEquals,contains,notContains,startsWith,notStartsWith,greater,lower,greaterEquals,lowerEquals

Show 4 more,matchRegex,between,isEmpty,notIsEmpty

delay

int64

Number of milliseconds to wait between inputs in a typeText step type.

direction

enum

The direction of the scroll for a scrollToElement step type. Allowed enum values: up,down,left,right

element

object

Information about the element used for a step.

context

string

Context of the element.

contextType

enum

Type of the context that the element is in. Allowed enum values: native,web

elementDescription

string

Description of the element.

multiLocator

object

Multi-locator to find the element.

relativePosition

object

Position of the action relative to the element.

x

double

The relativePosition on the x axis for the element.

y

double

The relativePosition on the y axis for the element.

textContent

string

Text content of the element.

userLocator

object

User locator to find the element.

failTestOnCannotLocate

boolean

Whether if the test should fail if the element cannot be found.

values

[object]

Values of the user locator.

type

enum

Type of a user locator. Allowed enum values: accessibility-id,id,ios-predicate-string,ios-class-chain,xpath

value

string

Value of a user locator.

viewName

string

Name of the view of the element.

enabled

boolean

Boolean to change the state of the wifi for a toggleWiFi step type.

maxScrolls

int64

Maximum number of scrolls to do for a scrollToElement step type.

positions

[object]

List of positions for the flick step type. The maximum is 10 flicks per step

x

double

The x position for the flick.

y

double

The y position for the flick.

subtestPublicId

string

Public ID of the test to be played as part of a playSubTest step type.

value

 <oneOf>

Values used in the step for in multiple step types.

Option 1

string

Value used in the step for in multiple step types.

Option 2

int64

Value used in the step for in multiple step types.

variable

object

Variable object for extractVariable step type.

example [required]

string

An example for the variable.

name [required]

string

The variable name.

withEnter

boolean

Boolean to indicate if Enter should be pressed at the end of the typeText step type.

x

double

Amount to scroll by on the x axis for a scroll step type.

y

double

Amount to scroll by on the y axis for a scroll step type.

publicId

string

The public ID of the step.

timeout

int64

The time before declaring a step failed.

type [required]

enum

Step type used in your mobile Synthetic test. Allowed enum values: assertElementContent,assertScreenContains,assertScreenLacks,doubleTap,extractVariable,flick,openDeeplink,playSubTest,pressBack,restartApplication

Show 7 more,rotate,scroll,scrollToElement,tap,toggleWiFi,typeText,wait

tags

[string]

Array of tags attached to the test.

type [required]

enum

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

default: mobile

{
  "name": "Example-Synthetic",
  "status": "paused",
  "type": "mobile",
  "config": {
    "variables": []
  },
  "message": "",
  "options": {
    "device_ids": [
      "synthetics:mobile:device:iphone_15_ios_17"
    ],
    "mobileApplication": {
      "applicationId": "ab0e0aed-536d-411a-9a99-5428c27d8f8e",
      "referenceId": "6115922a-5f5d-455e-bc7e-7955a57f3815",
      "referenceType": "version"
    },
    "tick_every": 3600
  },
  "steps": []
}

Response

OK - Returns the created test details.

Object containing details about a Synthetic mobile test.

Expand All

Field

Type

Description

config [required]

object

Configuration object for a Synthetic mobile test.

initialApplicationArguments

object

Initial application arguments for a mobile test.

<any-key>

string

A single application argument.

variables

[object]

Array of variables used for the test steps.

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

device_ids

[string]

Array with the different device IDs 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.

allowApplicationCrash

boolean

A boolean to set if an application crash would mark the test as failed.

bindings

[object]

Array of bindings used for the mobile test.

principals

[string]

List of principals for a mobile test binding.

relation

enum

The type of relation for the binding. Allowed enum values: editor,viewer

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

defaultStepTimeout

int32

The default timeout for steps in the test (in seconds).

device_ids [required]

[string]

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

disableAutoAcceptAlert

boolean

A boolean to disable auto accepting alerts.

min_failure_duration

int64

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

mobileApplication [required]

object

Mobile application for mobile synthetics test.

applicationId [required]

string

Application ID of the mobile application.

referenceId [required]

string

Reference ID of the mobile application.

referenceType [required]

enum

Reference type for the mobile application for a mobile synthetics test. Allowed enum values: latest,version

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,hide_query_and_handles,show_only_snapshot,hide_handles_and_footer

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

A boolean set to not take a screenshot for the step.

restricted_roles

[string]

DEPRECATED: A list of role identifiers that can be pulled from the Roles API, for restricting read and write access. This field is deprecated. Use the restriction policies API to manage permissions.

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.

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

int64

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

verbosity

int32

The level of verbosity for the mobile test. This field can not be set by a user.

public_id

string

The public ID of the test.

status

enum

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

steps

[object]

Array of steps for the test.

allowFailure

boolean

A boolean set to allow this step to fail.

hasNewStepElement

boolean

A boolean set to determine if the step has a new step element.

isCritical

boolean

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

name [required]

string

The name of the step.

noScreenshot

boolean

A boolean set to not take a screenshot for the step.

params [required]

object

The parameters of a mobile step.

check

enum

Type of assertion to apply in an API test. Allowed enum values: equals,notEquals,contains,notContains,startsWith,notStartsWith,greater,lower,greaterEquals,lowerEquals

Show 4 more,matchRegex,between,isEmpty,notIsEmpty

delay

int64

Number of milliseconds to wait between inputs in a typeText step type.

direction

enum

The direction of the scroll for a scrollToElement step type. Allowed enum values: up,down,left,right

element

object

Information about the element used for a step.

context

string

Context of the element.

contextType

enum

Type of the context that the element is in. Allowed enum values: native,web

elementDescription

string

Description of the element.

multiLocator

object

Multi-locator to find the element.

relativePosition

object

Position of the action relative to the element.

x

double

The relativePosition on the x axis for the element.

y

double

The relativePosition on the y axis for the element.

textContent

string

Text content of the element.

userLocator

object

User locator to find the element.

failTestOnCannotLocate

boolean

Whether if the test should fail if the element cannot be found.

values

[object]

Values of the user locator.

type

enum

Type of a user locator. Allowed enum values: accessibility-id,id,ios-predicate-string,ios-class-chain,xpath

value

string

Value of a user locator.

viewName

string

Name of the view of the element.

enabled

boolean

Boolean to change the state of the wifi for a toggleWiFi step type.

maxScrolls

int64

Maximum number of scrolls to do for a scrollToElement step type.

positions

[object]

List of positions for the flick step type. The maximum is 10 flicks per step

x

double

The x position for the flick.

y

double

The y position for the flick.

subtestPublicId

string

Public ID of the test to be played as part of a playSubTest step type.

value

 <oneOf>

Values used in the step for in multiple step types.

Option 1

string

Value used in the step for in multiple step types.

Option 2

int64

Value used in the step for in multiple step types.

variable

object

Variable object for extractVariable step type.

example [required]

string

An example for the variable.

name [required]

string

The variable name.

withEnter

boolean

Boolean to indicate if Enter should be pressed at the end of the typeText step type.

x

double

Amount to scroll by on the x axis for a scroll step type.

y

double

Amount to scroll by on the y axis for a scroll step type.

publicId

string

The public ID of the step.

timeout

int64

The time before declaring a step failed.

type [required]

enum

Step type used in your mobile Synthetic test. Allowed enum values: assertElementContent,assertScreenContains,assertScreenLacks,doubleTap,extractVariable,flick,openDeeplink,playSubTest,pressBack,restartApplication

Show 7 more,rotate,scroll,scrollToElement,tap,toggleWiFi,typeText,wait

tags

[string]

Array of tags attached to the test.

type [required]

enum

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

default: mobile

{
  "config": {
    "initialApplicationArguments": {
      "<any-key>": "string"
    },
    "variables": [
      {
        "example": "string",
        "id": "string",
        "name": "VARIABLE_NAME",
        "pattern": "string",
        "secure": false,
        "type": "text"
      }
    ]
  },
  "device_ids": [
    "chrome.laptop_large"
  ],
  "message": "Notification message",
  "monitor_id": 12345678,
  "name": "Example test name",
  "options": {
    "allowApplicationCrash": false,
    "bindings": [
      {
        "principals": [],
        "relation": "string"
      }
    ],
    "ci": {
      "executionRule": "blocking"
    },
    "defaultStepTimeout": "integer",
    "device_ids": [
      "synthetics:mobile:device:apple_ipad_10th_gen_2022_ios_16"
    ],
    "disableAutoAcceptAlert": false,
    "min_failure_duration": "integer",
    "mobileApplication": {
      "applicationId": "00000000-0000-0000-0000-aaaaaaaaaaaa",
      "referenceId": "00000000-0000-0000-0000-aaaaaaaaaaab",
      "referenceType": "latest"
    },
    "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"
    },
    "scheduling": {
      "timeframes": [
        {
          "day": 1,
          "from": "07:00",
          "to": "16:00"
        }
      ],
      "timezone": "America/New_York"
    },
    "tick_every": 300,
    "verbosity": "integer"
  },
  "public_id": "123-abc-456",
  "status": "live",
  "steps": [
    {
      "allowFailure": false,
      "hasNewStepElement": false,
      "isCritical": false,
      "name": "",
      "noScreenshot": false,
      "params": {
        "check": "string",
        "delay": "integer",
        "direction": "string",
        "element": {
          "context": "string",
          "contextType": "string",
          "elementDescription": "string",
          "multiLocator": {},
          "relativePosition": {
            "x": "number",
            "y": "number"
          },
          "textContent": "string",
          "userLocator": {
            "failTestOnCannotLocate": false,
            "values": [
              {
                "type": "string",
                "value": "string"
              }
            ]
          },
          "viewName": "string"
        },
        "enabled": false,
        "maxScrolls": "integer",
        "positions": [
          {
            "x": "number",
            "y": "number"
          }
        ],
        "subtestPublicId": "string",
        "value": {
          "description": "undefined",
          "type": "undefined"
        },
        "variable": {
          "example": "",
          "name": "VAR_NAME"
        },
        "withEnter": false,
        "x": "number",
        "y": "number"
      },
      "publicId": "pub-lic-id0",
      "timeout": "integer",
      "type": "assertElementContent"
    }
  ],
  "tags": [
    "env:production"
  ],
  "type": "mobile"
}

- JSON format is wrong - Creation failed

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Test quota is reached

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Forbidden

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Too many requests

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Code Example

                          ## default
# 

# Curl command
curl -X POST "https://api.ap1.datadoghq.com"https://api.ap2.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.us2.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/synthetics/tests/mobile" \ -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": { "variables": [] }, "message": "Notification message", "name": "Example mobile test", "options": { "device_ids": [ "synthetics:mobile:device:apple_iphone_14_ios_16" ], "min_failure_duration": 0, "mobileApplication": { "applicationId": "abc-123", "referenceId": "abc-456", "referenceType": "latest" }, "tick_every": 3600 }, "tags": [ "env:production" ], "type": "mobile" } EOF
// Create a mobile 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.SyntheticsMobileTest{
		Name:   "Example-Synthetic",
		Status: datadogV1.SYNTHETICSTESTPAUSESTATUS_PAUSED.Ptr(),
		Type:   datadogV1.SYNTHETICSMOBILETESTTYPE_MOBILE,
		Config: datadogV1.SyntheticsMobileTestConfig{
			Variables: []datadogV1.SyntheticsConfigVariable{},
		},
		Message: "",
		Options: datadogV1.SyntheticsMobileTestOptions{
			DeviceIds: []string{
				"synthetics:mobile:device:iphone_15_ios_17",
			},
			MobileApplication: datadogV1.SyntheticsMobileTestsMobileApplication{
				ApplicationId: "ab0e0aed-536d-411a-9a99-5428c27d8f8e",
				ReferenceId:   "6115922a-5f5d-455e-bc7e-7955a57f3815",
				ReferenceType: datadogV1.SYNTHETICSMOBILETESTSMOBILEAPPLICATIONREFERENCETYPE_VERSION,
			},
			TickEvery: 3600,
		},
		Steps: []datadogV1.SyntheticsMobileStep{},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV1.NewSyntheticsApi(apiClient)
	resp, r, err := api.CreateSyntheticsMobileTest(ctx, body)

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

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `SyntheticsApi.CreateSyntheticsMobileTest`:\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.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Create a mobile 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.SyntheticsMobileTest;
import com.datadog.api.client.v1.model.SyntheticsMobileTestConfig;
import com.datadog.api.client.v1.model.SyntheticsMobileTestOptions;
import com.datadog.api.client.v1.model.SyntheticsMobileTestType;
import com.datadog.api.client.v1.model.SyntheticsMobileTestsMobileApplication;
import com.datadog.api.client.v1.model.SyntheticsMobileTestsMobileApplicationReferenceType;
import com.datadog.api.client.v1.model.SyntheticsTestPauseStatus;
import java.util.Collections;

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

    SyntheticsMobileTest body =
        new SyntheticsMobileTest()
            .name("Example-Synthetic")
            .status(SyntheticsTestPauseStatus.PAUSED)
            .type(SyntheticsMobileTestType.MOBILE)
            .config(new SyntheticsMobileTestConfig())
            .message("")
            .options(
                new SyntheticsMobileTestOptions()
                    .deviceIds(
                        Collections.singletonList("synthetics:mobile:device:iphone_15_ios_17"))
                    .mobileApplication(
                        new SyntheticsMobileTestsMobileApplication()
                            .applicationId("ab0e0aed-536d-411a-9a99-5428c27d8f8e")
                            .referenceId("6115922a-5f5d-455e-bc7e-7955a57f3815")
                            .referenceType(
                                SyntheticsMobileTestsMobileApplicationReferenceType.VERSION))
                    .tickEvery(3600L));

    try {
      SyntheticsMobileTest result = apiInstance.createSyntheticsMobileTest(body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling SyntheticsApi#createSyntheticsMobileTest");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Instructions

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

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
"""
Create a mobile test returns "OK - Returns the created test details." response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.synthetics_api import SyntheticsApi
from datadog_api_client.v1.model.synthetics_mobile_test import SyntheticsMobileTest
from datadog_api_client.v1.model.synthetics_mobile_test_config import SyntheticsMobileTestConfig
from datadog_api_client.v1.model.synthetics_mobile_test_options import SyntheticsMobileTestOptions
from datadog_api_client.v1.model.synthetics_mobile_test_type import SyntheticsMobileTestType
from datadog_api_client.v1.model.synthetics_mobile_tests_mobile_application import (
    SyntheticsMobileTestsMobileApplication,
)
from datadog_api_client.v1.model.synthetics_mobile_tests_mobile_application_reference_type import (
    SyntheticsMobileTestsMobileApplicationReferenceType,
)
from datadog_api_client.v1.model.synthetics_test_pause_status import SyntheticsTestPauseStatus

body = SyntheticsMobileTest(
    name="Example-Synthetic",
    status=SyntheticsTestPauseStatus.PAUSED,
    type=SyntheticsMobileTestType.MOBILE,
    config=SyntheticsMobileTestConfig(
        variables=[],
    ),
    message="",
    options=SyntheticsMobileTestOptions(
        device_ids=[
            "synthetics:mobile:device:iphone_15_ios_17",
        ],
        mobile_application=SyntheticsMobileTestsMobileApplication(
            application_id="ab0e0aed-536d-411a-9a99-5428c27d8f8e",
            reference_id="6115922a-5f5d-455e-bc7e-7955a57f3815",
            reference_type=SyntheticsMobileTestsMobileApplicationReferenceType.VERSION,
        ),
        tick_every=3600,
    ),
    steps=[],
)

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

    print(response)

Instructions

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

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Create a mobile test returns "OK - Returns the created test details." response

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

body = DatadogAPIClient::V1::SyntheticsMobileTest.new({
  name: "Example-Synthetic",
  status: DatadogAPIClient::V1::SyntheticsTestPauseStatus::PAUSED,
  type: DatadogAPIClient::V1::SyntheticsMobileTestType::MOBILE,
  config: DatadogAPIClient::V1::SyntheticsMobileTestConfig.new({
    variables: [],
  }),
  message: "",
  options: DatadogAPIClient::V1::SyntheticsMobileTestOptions.new({
    device_ids: [
      "synthetics:mobile:device:iphone_15_ios_17",
    ],
    mobile_application: DatadogAPIClient::V1::SyntheticsMobileTestsMobileApplication.new({
      application_id: "ab0e0aed-536d-411a-9a99-5428c27d8f8e",
      reference_id: "6115922a-5f5d-455e-bc7e-7955a57f3815",
      reference_type: DatadogAPIClient::V1::SyntheticsMobileTestsMobileApplicationReferenceType::VERSION,
    }),
    tick_every: 3600,
  }),
  steps: [],
})
p api_instance.create_synthetics_mobile_test(body)

Instructions

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

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
// Create a mobile test returns "OK - Returns the created test details." response
use datadog_api_client::datadog;
use datadog_api_client::datadogV1::api_synthetics::SyntheticsAPI;
use datadog_api_client::datadogV1::model::SyntheticsMobileTest;
use datadog_api_client::datadogV1::model::SyntheticsMobileTestConfig;
use datadog_api_client::datadogV1::model::SyntheticsMobileTestOptions;
use datadog_api_client::datadogV1::model::SyntheticsMobileTestType;
use datadog_api_client::datadogV1::model::SyntheticsMobileTestsMobileApplication;
use datadog_api_client::datadogV1::model::SyntheticsMobileTestsMobileApplicationReferenceType;
use datadog_api_client::datadogV1::model::SyntheticsTestPauseStatus;

#[tokio::main]
async fn main() {
    let body = SyntheticsMobileTest::new(
        SyntheticsMobileTestConfig::new().variables(vec![]),
        "".to_string(),
        "Example-Synthetic".to_string(),
        SyntheticsMobileTestOptions::new(
            vec!["synthetics:mobile:device:iphone_15_ios_17".to_string()],
            SyntheticsMobileTestsMobileApplication::new(
                "ab0e0aed-536d-411a-9a99-5428c27d8f8e".to_string(),
                "6115922a-5f5d-455e-bc7e-7955a57f3815".to_string(),
                SyntheticsMobileTestsMobileApplicationReferenceType::VERSION,
            ),
            3600,
        ),
        SyntheticsMobileTestType::MOBILE,
    )
    .status(SyntheticsTestPauseStatus::PAUSED)
    .steps(vec![]);
    let configuration = datadog::Configuration::new();
    let api = SyntheticsAPI::with_config(configuration);
    let resp = api.create_synthetics_mobile_test(body).await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}

Instructions

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

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
/**
 * Create a mobile test returns "OK - Returns the created test details." response
 */

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

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

const params: v1.SyntheticsApiCreateSyntheticsMobileTestRequest = {
  body: {
    name: "Example-Synthetic",
    status: "paused",
    type: "mobile",
    config: {
      variables: [],
    },
    message: "",
    options: {
      deviceIds: ["synthetics:mobile:device:iphone_15_ios_17"],
      mobileApplication: {
        applicationId: "ab0e0aed-536d-411a-9a99-5428c27d8f8e",
        referenceId: "6115922a-5f5d-455e-bc7e-7955a57f3815",
        referenceType: "version",
      },
      tickEvery: 3600,
    },
    steps: [],
  },
};

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

Instructions

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

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"