Créer un test mobile
https://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/mobilehttps://api.datadoghq.eu/api/v1/synthetics/tests/mobilehttps://api.ap1.datadoghq.com/api/v1/synthetics/tests/mobilehttps://api.ap2.datadoghq.com/api/v1/synthetics/tests/mobilehttps://api.uk1.datadoghq.com/api/v1/synthetics/tests/mobilehttps://api.ddog-gov.com/api/v1/synthetics/tests/mobilehttps://api.us2.ddog-gov.com/api/v1/synthetics/tests/mobilePrésentation
Créez un test mobile Synthetic.
OAuth apps require the synthetics_write authorization scope to access this endpoint.
Requête
Body Data (required)
Détails du test à créer.
config [required]Objet contenant les détails de votre test mobile Synthetic.
initialApplicationArgumentsInitial application arguments for a mobile test.
<any-key>A single application argument.
variablesArray of variables used for the test steps.
exampleExample for the variable.
idID of the variable for global variables.
name [required]Name of the variable.
patternPattern of the variable.
secureWhether the value of this variable will be obfuscated in test results. Only for config variables of type text.
type [required]Type of the configuration variable.
global, text, emaildevice_idsArray with the different device IDs used to run the test.
message [required]Notification message associated with the test.
name [required]Name of the test.
options [required]Object describing the extra options for a Synthetic test.
allowApplicationCrashA boolean to set if an application crash would mark the test as failed.
bindingsArray of bindings used for the mobile test.
principalsList of principals for a mobile test binding.
relationThe type of relation for the binding.
editor, viewerbits_ai_auto_investigateWhether Bits AI automatically investigates alerts from the test monitor.
ciCI/CD options for a Synthetic test.
executionRule [required]Execution rule for a Synthetic test.
blocking, non_blocking, skippeddefaultStepTimeoutThe default timeout for steps in the test (in seconds).
device_ids [required]For mobile test, array with the different device IDs used to run the test.
disableAutoAcceptAlertA boolean to disable auto accepting alerts.
min_failure_durationMinimum amount of time in failure required to trigger an alert.
mobileApplication [required]Mobile application for mobile synthetics test.
applicationId [required]Application ID of the mobile application.
referenceId [required]Reference ID of the mobile application.
referenceType [required]Reference type for the mobile application for a mobile synthetics test.
latest, versionmonitor_nameThe monitor name is used for the alert title as well as for all monitor dashboard widgets and SLOs.
monitor_optionsObject containing the options for a Synthetic test as a monitor (for example, renotification).
escalation_messageMessage to include in the escalation notification.
notification_preset_nameThe name of the preset for the notification for the monitor.
show_all, hide_all, hide_query, hide_handles, hide_query_and_handles, show_only_snapshot, hide_handles_and_footerrenotify_intervalTime interval before renotifying if the test is still failing (in minutes).
renotify_occurrencesThe number of times to renotify if the test is still failing.
monitor_priorityInteger from 1 (high) to 5 (low) indicating alert severity.
noScreenshotA boolean set to not take a screenshot for the step.
restricted_rolesDEPRECATED 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.
retryObject describing the retry strategy to apply to a Synthetic test.
countNumber of times a test needs to be retried before marking a location as failed. Defaults to 0.
intervalTime interval between retries (in milliseconds). Defaults to 300ms.
schedulingObject containing timeframes and timezone used for advanced scheduling.
timeframes [required]Array containing objects describing the scheduling pattern to apply to each day.
day [required]Number representing the day of the week.
from [required]The hour of the day on which scheduling starts.
to [required]The hour of the day on which scheduling ends.
timezone [required]Timezone in which the timeframe is based.
tick_every [required]The frequency at which to run the Synthetic test (in seconds).
verbosityThe level of verbosity for the mobile test. This field can not be set by a user.
statusDefine whether you want to start (live) or pause (paused) a
Synthetic test.
live, pausedstepsArray of steps for the test.
allowFailureA boolean set to allow this step to fail.
hasNewStepElementA boolean set to determine if the step has a new step element.
isCriticalA boolean to use in addition to allowFailure to determine if the test should be marked as failed when the step fails.
name [required]The name of the step.
noScreenshotA boolean set to not take a screenshot for the step.
params [required]The parameters of a mobile step.
checkType of assertion to apply in an API test.
equals, notEquals, contains, notContains, startsWith, notStartsWith, greater, lower, greaterEquals, lowerEqualsShow 4 more
matchRegex, between, isEmpty, notIsEmptydelayNumber of milliseconds to wait between inputs in a typeText step type.
directionThe direction of the scroll for a scrollToElement step type.
up, down, left, rightelementInformation about the element used for a step.
contextContext of the element.
contextTypeType of the context that the element is in.
native, webelementDescriptionDescription of the element.
multiLocatorMulti-locator to find the element.
relativePositionPosition of the action relative to the element.
xThe relativePosition on the x axis for the element.
yThe relativePosition on the y axis for the element.
textContentText content of the element.
userLocatorUser locator to find the element.
failTestOnCannotLocateWhether if the test should fail if the element cannot be found.
valuesValues of the user locator.
typeType of a user locator.
accessibility-id, id, ios-predicate-string, ios-class-chain, xpathvalueValue of a user locator.
viewNameName of the view of the element.
enabledBoolean to change the state of the wifi for a toggleWiFi step type.
maxScrollsMaximum number of scrolls to do for a scrollToElement step type.
positionsList of positions for the flick step type. The maximum is 10 flicks per step
xThe x position for the flick.
yThe y position for the flick.
subtestPublicIdPublic ID of the test to be played as part of a playSubTest step type.
valueValues used in the step for in multiple step types.
Object 1Value used in the step for in multiple step types.
Object 2Value used in the step for in multiple step types.
variableVariable object for extractVariable step type.
example [required]An example for the variable.
name [required]The variable name.
withEnterBoolean to indicate if Enter should be pressed at the end of the typeText step type.
xAmount to scroll by on the x axis for a scroll step type.
yAmount to scroll by on the y axis for a scroll step type.
publicIdThe public ID of the step.
timeoutThe time before declaring a step failed.
type [required]Step type used in your mobile Synthetic test.
assertElementContent, assertScreenContains, assertScreenLacks, doubleTap, extractVariable, flick, openDeeplink, playSubTest, pressBack, restartApplicationShow 7 more
rotate, scroll, scrollToElement, tap, toggleWiFi, typeText, waittagsArray of tags attached to the test.
type [required]Type of the Synthetic test, mobile.
mobilemobile{
"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": []
}Réponse
OK - Returns the created test details.
Object containing details about a Synthetic mobile test.
config [required]Configuration object for a Synthetic mobile test.
initialApplicationArgumentsInitial application arguments for a mobile test.
<any-key>A single application argument.
variablesArray of variables used for the test steps.
exampleExample for the variable.
idID of the variable for global variables.
name [required]Name of the variable.
patternPattern of the variable.
secureWhether the value of this variable will be obfuscated in test results. Only for config variables of type text.
type [required]Type of the configuration variable.
global, text, emaildevice_idsArray with the different device IDs used to run the test.
message [required]Notification message associated with the test.
monitor_idThe associated monitor ID.
name [required]Name of the test.
options [required]Object describing the extra options for a Synthetic test.
allowApplicationCrashA boolean to set if an application crash would mark the test as failed.
bindingsArray of bindings used for the mobile test.
principalsList of principals for a mobile test binding.
relationThe type of relation for the binding.
editor, viewerbits_ai_auto_investigateWhether Bits AI automatically investigates alerts from the test monitor.
ciCI/CD options for a Synthetic test.
executionRule [required]Execution rule for a Synthetic test.
blocking, non_blocking, skippeddefaultStepTimeoutThe default timeout for steps in the test (in seconds).
device_ids [required]For mobile test, array with the different device IDs used to run the test.
disableAutoAcceptAlertA boolean to disable auto accepting alerts.
min_failure_durationMinimum amount of time in failure required to trigger an alert.
mobileApplication [required]Mobile application for mobile synthetics test.
applicationId [required]Application ID of the mobile application.
referenceId [required]Reference ID of the mobile application.
referenceType [required]Reference type for the mobile application for a mobile synthetics test.
latest, versionmonitor_nameThe monitor name is used for the alert title as well as for all monitor dashboard widgets and SLOs.
monitor_optionsObject containing the options for a Synthetic test as a monitor (for example, renotification).
escalation_messageMessage to include in the escalation notification.
notification_preset_nameThe name of the preset for the notification for the monitor.
show_all, hide_all, hide_query, hide_handles, hide_query_and_handles, show_only_snapshot, hide_handles_and_footerrenotify_intervalTime interval before renotifying if the test is still failing (in minutes).
renotify_occurrencesThe number of times to renotify if the test is still failing.
monitor_priorityInteger from 1 (high) to 5 (low) indicating alert severity.
noScreenshotA boolean set to not take a screenshot for the step.
restricted_rolesDEPRECATED 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.
retryObject describing the retry strategy to apply to a Synthetic test.
countNumber of times a test needs to be retried before marking a location as failed. Defaults to 0.
intervalTime interval between retries (in milliseconds). Defaults to 300ms.
schedulingObject containing timeframes and timezone used for advanced scheduling.
timeframes [required]Array containing objects describing the scheduling pattern to apply to each day.
day [required]Number representing the day of the week.
from [required]The hour of the day on which scheduling starts.
to [required]The hour of the day on which scheduling ends.
timezone [required]Timezone in which the timeframe is based.
tick_every [required]The frequency at which to run the Synthetic test (in seconds).
verbosityThe level of verbosity for the mobile test. This field can not be set by a user.
public_idThe public ID of the test.
statusDefine whether you want to start (live) or pause (paused) a
Synthetic test.
live, pausedstepsArray of steps for the test.
allowFailureA boolean set to allow this step to fail.
hasNewStepElementA boolean set to determine if the step has a new step element.
isCriticalA boolean to use in addition to allowFailure to determine if the test should be marked as failed when the step fails.
name [required]The name of the step.
noScreenshotA boolean set to not take a screenshot for the step.
params [required]The parameters of a mobile step.
checkType of assertion to apply in an API test.
equals, notEquals, contains, notContains, startsWith, notStartsWith, greater, lower, greaterEquals, lowerEqualsShow 4 more
matchRegex, between, isEmpty, notIsEmptydelayNumber of milliseconds to wait between inputs in a typeText step type.
directionThe direction of the scroll for a scrollToElement step type.
up, down, left, rightelementInformation about the element used for a step.
contextContext of the element.
contextTypeType of the context that the element is in.
native, webelementDescriptionDescription of the element.
multiLocatorMulti-locator to find the element.
relativePositionPosition of the action relative to the element.
xThe relativePosition on the x axis for the element.
yThe relativePosition on the y axis for the element.
textContentText content of the element.
userLocatorUser locator to find the element.
failTestOnCannotLocateWhether if the test should fail if the element cannot be found.
valuesValues of the user locator.
typeType of a user locator.
accessibility-id, id, ios-predicate-string, ios-class-chain, xpathvalueValue of a user locator.
viewNameName of the view of the element.
enabledBoolean to change the state of the wifi for a toggleWiFi step type.
maxScrollsMaximum number of scrolls to do for a scrollToElement step type.
positionsList of positions for the flick step type. The maximum is 10 flicks per step
xThe x position for the flick.
yThe y position for the flick.
subtestPublicIdPublic ID of the test to be played as part of a playSubTest step type.
valueValues used in the step for in multiple step types.
Object 1Value used in the step for in multiple step types.
Object 2Value used in the step for in multiple step types.
variableVariable object for extractVariable step type.
example [required]An example for the variable.
name [required]The variable name.
withEnterBoolean to indicate if Enter should be pressed at the end of the typeText step type.
xAmount to scroll by on the x axis for a scroll step type.
yAmount to scroll by on the y axis for a scroll step type.
publicIdThe public ID of the step.
timeoutThe time before declaring a step failed.
type [required]Step type used in your mobile Synthetic test.
assertElementContent, assertScreenContains, assertScreenLacks, doubleTap, extractVariable, flick, openDeeplink, playSubTest, pressBack, restartApplicationShow 7 more
rotate, scroll, scrollToElement, tap, toggleWiFi, typeText, waittagsArray of tags attached to the test.
type [required]Type of the Synthetic test, mobile.
mobilemobile{
"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"
}
],
"bits_ai_auto_investigate": false,
"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.
errors [required]Array of errors returned by the API.
{
"errors": [
"Bad Request"
]
}Test quota is reached
Error response object.
errors [required]Array of errors returned by the API.
{
"errors": [
"Bad Request"
]
}Forbidden
Error response object.
errors [required]Array of errors returned by the API.
{
"errors": [
"Bad Request"
]
}Too many requests
Error response object.
errors [required]Array of errors returned by the API.
{
"errors": [
"Bad Request"
]
}Exemple de code
# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v1/synthetics/tests/mobile" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"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": []
}
EOF# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v1/synthetics/tests/mobile" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"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": []
}
EOF# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v1/synthetics/tests/mobile" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"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": []
}
EOF# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v1/synthetics/tests/mobile" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"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": []
}
EOF# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v1/synthetics/tests/mobile" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"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": []
}
EOF# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v1/synthetics/tests/mobile" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"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": []
}
EOF# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v1/synthetics/tests/mobile" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"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": []
}
EOF# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v1/synthetics/tests/mobile" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"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": []
}
EOF# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v1/synthetics/tests/mobile" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"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": []
}
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())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
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.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" 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();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
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.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java""""
Create a mobile test returns "OK - Returns the created test details." response
"""
from os import environ
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()
configuration.access_token = environ["DD_BEARER_TOKEN"]
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.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"# Create a mobile test returns "OK - Returns the created test details." response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
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.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us2.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({
authMethods: {
AuthZ: {
accessToken: process.env.DD_BEARER_TOKEN as string,
},
},
});
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.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"