---
type: api
title: Trigger an on-demand test run for a monitor
description: **Spaces method and path for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/kibana-serverless/operation/operation-post-synthetics-monitor-test
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/kibana-serverless/operation/operation-post-synthetics-monitor-test
products:
  - Kibana
---

# Trigger an on-demand test run for a monitor

- Server: `https://{kibana_url}`

## Paths

- `POST` `/api/synthetics/monitor/test/{monitorId}`
- `POST` `/s/{space_id}/api/synthetics/monitor/test/{monitorId}`

#### Path parameters

- `monitorId` (string · min length: 1 · max length: 1024) — required
  The ID (config_id) of the monitor to test.

## Description

Refer to [Spaces](https://www.elastic.co/docs/deploy-manage/manage-spaces) for more information.

Trigger an immediate test execution for the specified monitor.
The response includes the generated `testRunId`. If the test encounters issues in one or more service locations, an `errors` array is also returned with details about the failures.<br/><br/>[Required authorization] Route required privileges: (uptime-read) AND (uptime-write OR monitor-run-manually).

## Authentication

- Api key: `Authorization: <value>`
  You must create an API key and use the encoded value in the request header. To learn about creating keys, go to [API keys](https://www.elastic.co/docs/current/serverless/api-keys).

## Header parameters

- `kbn-xsrf` (string) — required
  A required header to protect against CSRF attacks

## Responses

#### `200`

Test run triggered successfully.

`application/json`

- `errors` (object[])
  Array of errors encountered while triggering the test, one per service location.
  - `error` (object)
    - `failed_monitors` (object[]) — nullable
      Optional list of monitors that failed at the location.
    - `reason` (string)
      Human-readable explanation of the failure.
    - `status` (integer)
      HTTP status code returned by the agent.
  - `locationId` (string)
    Identifier of the service location where the error occurred.
- `testRunId` (string)
  Unique identifier for the triggered test run.
#### `404`

Monitor not found.

## Code examples

#### Console

```console
POST kbn://api/synthetics/monitor/test/monitor-id
```

#### curl

```curl
curl \
  -X POST "${KIBANA_URL}/api/synthetics/monitor/test/monitor-id" \
  -H "Authorization: ApiKey ${API_KEY}" \
  -H "kbn-xsrf: true"
```

## Response examples

#### Test now monitor response example1

```json
{
  "errors": [
    {
      "error": {
        "failed_monitors": "null",
        "reason": "no auth credentials provided",
        "status": 401
      },
      "locationId": "us_central_staging"
    }
  ],
  "testRunId": "2bd506e5-4f9a-4aa6-a019-7988500afba0"
}
```

