POST /api/synthetics/monitors

Spaces method and path for this operation:

post /s/{space_id}/api/synthetics/monitors

Refer to Spaces for more information.

Create a new monitor with the specified attributes. A monitor can be one of the following types: HTTP, TCP, ICMP, or Browser. The required and default fields may vary based on the monitor type.

You must have all privileges for the Synthetics feature in the Observability section of the Kibana feature privileges.

[Required authorization] Route required privileges: uptime-read AND uptime-write.

Headers

  • kbn-xsrf string Required

    A required header to protect against CSRF attacks

Query parameters

  • id string

    A custom ID for the new monitor. Generated if omitted.

    Maximum length is 1024.

  • preserve_namespace string | boolean

    If true, store the namespace as sent. Otherwise, a default namespace is replaced with one derived from the space ID.

    Values are true or false.

application/json
Body object

Create a synthetics monitor. Required and default fields vary by type (HTTP, TCP, ICMP, browser, or API).

One of:

Responses

  • 200 application/json

    A successful response. The response may include a warnings array when the monitor configuration has non-critical issues. For example, if a browser monitor specifies a timeout but has no private locations configured, a warning is returned indicating the timeout will have no effect.

    Hide response attribute Show response attribute object
    • warnings array[object]

      An optional array of warnings about the monitor configuration.

      Hide warnings attributes Show warnings attributes object
      • message string

        A human-readable warning message.

      • monitorId string

        The monitor ID associated with the warning.

      • publicLocationIds array[string]

        The public location IDs associated with the warning.

  • 400 application/json

    Bad request. For browser monitors, a 400 error is returned if the timeout is less than 30 seconds.

    Hide response attributes Show response attributes object
    • attributes object
      Hide attributes attribute Show attributes attribute object
      • details string
    • error string
    • message string
    • statusCode integer
POST /api/synthetics/monitors
curl \
  -X POST "${KIBANA_URL}/api/synthetics/monitors" \
  -H "Authorization: ApiKey ${API_KEY}" \
  -H "kbn-xsrf: true" \
  -H "Content-Type: application/json" \
  -d '{"type":"http","name":"Website Availability","url":"https://example.com","tags":["website","availability"],"locations":["united_kingdom"]}'
POST kbn://api/synthetics/monitors
{"type":"http","name":"Website Availability","url":"https://example.com","tags":["website","availability"],"locations":["united_kingdom"]}
Request examples
Create an HTTP monitor to check a website's availability.
{
  "locations": [
    "united_kingdom"
  ],
  "name": "Website Availability",
  "tags": [
    "website",
    "availability"
  ],
  "type": "http",
  "url": "https://example.com"
}
Create a TCP monitor to monitor a server's availability.
{
  "host": "example.com",
  "name": "Server Availability",
  "private_locations": [
    "my_private_location"
  ],
  "type": "tcp"
}
Create an ICMP monitor to perform ping checks.
{
  "host": "example.com",
  "locations": [
    "united_kingdom"
  ],
  "name": "Ping Test",
  "type": "icmp"
}
Create a browser monitor to check a website.
{
  "inline_script": "step('Go to https://google.com.co', () => page.goto('https://www.google.com'))",
  "locations": [
    "united_kingdom"
  ],
  "name": "Example journey",
  "type": "browser"
}
Response examples (200)
A response when a browser monitor specifies a timeout but has no private locations.
{
  "enabled": true,
  "name": "Example journey",
  "type": "browser",
  "warnings": [
    {
      "id": "monitor-id",
      "message": "For browser monitors, timeout is only supported on private locations. Browser monitor \"Example journey\" specifies a timeout and is running on public locations: \"public-1, public-2\". The timeout will have no effect on these locations.",
      "publicLocationIds": [
        "public-1",
        "public-2"
      ]
    }
  ]
}
Response examples (400)
A 400 error when a browser monitor timeout is below 30 seconds.
{
  "attributes": {
    "details": "Invalid timeout 20 seconds supplied. Minimum timeout for browser monitors is 30 seconds."
  },
  "error": "Bad Request",
  "message": "Browser Monitor timeout is invalid",
  "statusCode": 400
}