For AI agents: A markdown version of this page is available at https://dnd37xeb23o8n.cloudfront.net/stefon.simmons/docs-astro-web-10435/es/api/latest/synthetics/create-a-test.md. A documentation index is available at /llms.txt.
Language
Datadog site

Crear un test

POSThttps://api.datadoghq.com/api/v1/synthetics/testshttps://api.us3.datadoghq.com/api/v1/synthetics/testshttps://api.us5.datadoghq.com/api/v1/synthetics/testshttps://api.datadoghq.eu/api/v1/synthetics/testshttps://api.ap1.datadoghq.com/api/v1/synthetics/testshttps://api.ap2.datadoghq.com/api/v1/synthetics/testshttps://api.uk1.datadoghq.com/api/v1/synthetics/testshttps://api.ddog-gov.com/api/v1/synthetics/testshttps://api.us2.ddog-gov.com/api/v1/synthetics/tests

Descripción general

Este endpoint está obsoleto. Para crear un test, utiliza Crear un test de API, o Crear un test de navegador.

This endpoint requires the synthetics_write permission.

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

Solicitud

Body Data (required)

Información detallada del test a crear.

Campo
Type
Descripción
config
object

Objeto que contiene información detallada de tu test Synthetic.

locations
[string]

Array of locations used to run the test.

message
string

Notification message associated with the test.

name
string

Name of the test.

options
object

Object describing the extra options for a Synthetic test.

status
enum

Define whether you want to start (live) or pause (paused) a Synthetic test.

Allowed enum values: live, paused
steps
[object]

The steps of the test if they exist.

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
enum

Type of the Synthetic test.

Allowed enum values: api, browser, mobile, network

Respuesta

OK - Returns the created test details.

Object containing details about your Synthetic test.

Campo
Type
Descripción
config
object

Configuration object for a Synthetic test.

creator
object

Object describing the creator of the shared element.

locations
[string]

Array of locations used to run the test.

message
string

Notification message associated with the test.

monitor_id
int64

The associated monitor ID.

name
string

Name of the test.

options
object

Object describing the extra options for a Synthetic test.

public_id
string

The test public ID.

status
enum

Define whether you want to start (live) or pause (paused) a Synthetic test.

Allowed enum values: live, paused
steps
[object]

The steps of the test if they exist.

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
enum

Type of the Synthetic test.

Allowed enum values: api, browser, mobile, network

Ejemplo de código

Crear un test
# 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" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "config": {
    "assertions": [
      {
        "operator": "is",
        "target": 200,
        "type": "statusCode"
      }
    ],
    "request": {
      "method": "GET",
      "url": "https://example.com"
    }
  },
  "locations": [
    "aws:eu-west-3"
  ],
  "message": "Notification message",
  "name": "Example API test",
  "options": {
    "tick_every": 60
  },
  "status": "live",
  "type": "api"
}
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" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "config": {
    "assertions": [
      {
        "operator": "is",
        "target": 200,
        "type": "statusCode"
      }
    ],
    "request": {
      "method": "GET",
      "url": "https://example.com"
    }
  },
  "locations": [
    "aws:eu-west-3"
  ],
  "message": "Notification message",
  "name": "Example API test",
  "options": {
    "tick_every": 60
  },
  "status": "live",
  "type": "api"
}
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" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "config": {
    "assertions": [
      {
        "operator": "is",
        "target": 200,
        "type": "statusCode"
      }
    ],
    "request": {
      "method": "GET",
      "url": "https://example.com"
    }
  },
  "locations": [
    "aws:eu-west-3"
  ],
  "message": "Notification message",
  "name": "Example API test",
  "options": {
    "tick_every": 60
  },
  "status": "live",
  "type": "api"
}
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" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "config": {
    "assertions": [
      {
        "operator": "is",
        "target": 200,
        "type": "statusCode"
      }
    ],
    "request": {
      "method": "GET",
      "url": "https://example.com"
    }
  },
  "locations": [
    "aws:eu-west-3"
  ],
  "message": "Notification message",
  "name": "Example API test",
  "options": {
    "tick_every": 60
  },
  "status": "live",
  "type": "api"
}
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" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "config": {
    "assertions": [
      {
        "operator": "is",
        "target": 200,
        "type": "statusCode"
      }
    ],
    "request": {
      "method": "GET",
      "url": "https://example.com"
    }
  },
  "locations": [
    "aws:eu-west-3"
  ],
  "message": "Notification message",
  "name": "Example API test",
  "options": {
    "tick_every": 60
  },
  "status": "live",
  "type": "api"
}
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" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "config": {
    "assertions": [
      {
        "operator": "is",
        "target": 200,
        "type": "statusCode"
      }
    ],
    "request": {
      "method": "GET",
      "url": "https://example.com"
    }
  },
  "locations": [
    "aws:eu-west-3"
  ],
  "message": "Notification message",
  "name": "Example API test",
  "options": {
    "tick_every": 60
  },
  "status": "live",
  "type": "api"
}
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" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "config": {
    "assertions": [
      {
        "operator": "is",
        "target": 200,
        "type": "statusCode"
      }
    ],
    "request": {
      "method": "GET",
      "url": "https://example.com"
    }
  },
  "locations": [
    "aws:eu-west-3"
  ],
  "message": "Notification message",
  "name": "Example API test",
  "options": {
    "tick_every": 60
  },
  "status": "live",
  "type": "api"
}
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" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "config": {
    "assertions": [
      {
        "operator": "is",
        "target": 200,
        "type": "statusCode"
      }
    ],
    "request": {
      "method": "GET",
      "url": "https://example.com"
    }
  },
  "locations": [
    "aws:eu-west-3"
  ],
  "message": "Notification message",
  "name": "Example API test",
  "options": {
    "tick_every": 60
  },
  "status": "live",
  "type": "api"
}
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" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "config": {
    "assertions": [
      {
        "operator": "is",
        "target": 200,
        "type": "statusCode"
      }
    ],
    "request": {
      "method": "GET",
      "url": "https://example.com"
    }
  },
  "locations": [
    "aws:eu-west-3"
  ],
  "message": "Notification message",
  "name": "Example API test",
  "options": {
    "tick_every": 60
  },
  "status": "live",
  "type": "api"
}
EOF