# Send a test incident — API reference

> Plays a simulated incident on the machine, opened and two seconds later resolved; nobody is alerted.

Source: https://upfour.io/docs/api/runners/send-a-test-incident

[Developers](https://upfour.io/docs/api.md)/[Connected machines](https://upfour.io/docs/api/runners.md)

Plays a simulated incident on the machine, opened and two seconds later resolved; nobody is alerted.

POST https://app.upfour.io/v1/runners/{runnerID}/test

scope api_key.write stable [Idempotency-Key supported](https://upfour.io/docs/api/idempotency.md) returns 202

## Parameters

| Field | Type | Description |
| --- | --- | --- |
| `runnerID` required | uuid | path parameter |

## Body

`application/json` optional 1 field

All other fields1 fields

monitor_iduuid

Optional. The test names this monitor; without it a generic test monitor in the machine's first scope.

## Returns

A successful request returns `202` with application/json.

Response fields 1 top-level fields

| Field | Type | Description |
| --- | --- | --- |
| `data` | RunnerAppTestResponse | |
| RunnerAppTestResponse · 3 fields FieldTypeDescription `delivered` boolean `event_ids` string[]  · nullable The simulated incident.opened and its incident.resolved, two seconds apart. `incident_id` uuid | | |

## Errors

Only the errors this operation can return. Every error uses the [same envelope](https://upfour.io/docs/api/responses.md).

| Status | Code | Meaning |
| --- | --- | --- |
| 400 | [bad_request](https://upfour.io/docs/api/errors#code-bad_request) | The request is malformed or fails validation. |
| 404 | [not_found](https://upfour.io/docs/api/errors#code-not_found) | The requested resource does not exist or is outside the caller's scope. |
| 403 | [permission_denied](https://upfour.io/docs/api/errors#code-permission_denied) | The credentials do not permit this action. |
| 409 | [runner_not_connected](https://upfour.io/docs/api/errors#code-runner_not_connected) | No open stream of this machine received the test event. **When:** POST /v1/runner/test while the runner named in runner_id has no open stream with the same API key, or POST /v1/runners/{runnerID}/test while the machine has no open stream at all, or the stream closed before the event was handed over. **Fix:** Start the machine (up4 listen) and send the test again once it shows as connected. |
| 503 | [service_unavailable](https://upfour.io/docs/api/errors#code-service_unavailable) | The service or a required dependency is temporarily unavailable. |
| 404 | documented response | No such machine, or the monitor is not in the Company. |
| 409 | documented response | runner_not_connected when the machine has no open stream, or it closed before both events were handed over. |

Every call can also return `unauthorized` (401), `rate_limit_exceeded` (429) or `internal_error` (500 / 502). See [Responses and errors](https://upfour.io/docs/api/responses.md).

[PreviousRemove a connected machine](https://upfour.io/docs/api/runners/remove-a-connected-machine.md)

## Request

### cURL

```bash
curl -s -X POST "https://app.upfour.io/v1/runners/00000000-0000-4000-8000-000000000001/test" \
  -H "Authorization: Bearer $UP4_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "monitor_id": "00000000-0000-4000-8000-000000000003"
  }'
```

### JavaScript

```javascript
const res = await fetch("https://app.upfour.io/v1/runners/00000000-0000-4000-8000-000000000001/test", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.UP4_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    monitor_id: "00000000-0000-4000-8000-000000000003",
  }),
});
console.log(res.status, await res.json());
```

### Python

```python
import os
import requests

res = requests.post(
    "https://app.upfour.io/v1/runners/00000000-0000-4000-8000-000000000001/test",
    headers={"Authorization": f"Bearer {os.environ['UP4_API_KEY']}"},
    json={
        "monitor_id": "00000000-0000-4000-8000-000000000003",
    },
)
print(res.status_code, res.json())
```

### Go

```go
package main

import (
	"fmt"
	"io"
	"net/http"
	"os"
	"strings"
)

func main() {
	payload := strings.NewReader(`{
  "monitor_id": "00000000-0000-4000-8000-000000000003"
}`)
	req, _ := http.NewRequest("POST", "https://app.upfour.io/v1/runners/00000000-0000-4000-8000-000000000001/test", payload)
	req.Header.Set("Authorization", "Bearer "+os.Getenv("UP4_API_KEY"))
	req.Header.Set("Content-Type", "application/json")
	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()
	out, _ := io.ReadAll(res.Body)
	fmt.Println(res.StatusCode, string(out))
}
```

### PHP

```php
<?php
$payload = <<<'JSON'
{
  "monitor_id": "00000000-0000-4000-8000-000000000003"
}
JSON;

$ch = curl_init("https://app.upfour.io/v1/runners/00000000-0000-4000-8000-000000000001/test");
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer " . getenv("UP4_API_KEY"),
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => $payload,
]);
$response = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_RESPONSE_CODE), " ", $response, "\n";
curl_close($ch);
```

## Response

### 202

```json
{
  "data": {
    "delivered": true,
    "event_ids": [
      "00000000-0000-4000-8000-000000000005",
      "00000000-0000-4000-8000-000000000006"
    ],
    "incident_id": "00000000-0000-4000-8000-000000000004"
  }
}
```

### 400

```json
{
  "error": {
    "code": "bad_request",
    "message": "The request is malformed or fails validation.",
    "request_id": "req_…"
  }
}
```

### 403

```json
{
  "error": {
    "code": "permission_denied",
    "message": "The credentials do not permit this action.",
    "request_id": "req_…"
  }
}
```

### 404

```json
{
  "error": {
    "code": "not_found",
    "message": "The requested resource does not exist or is outside the caller's scope.",
    "request_id": "req_…"
  }
}
```

### 409

```json
{
  "error": {
    "code": "runner_not_connected",
    "message": "No open stream of this machine received the test event.",
    "request_id": "req_…"
  }
}
```

### 503

```json
{
  "error": {
    "code": "service_unavailable",
    "message": "The service or a required dependency is temporarily unavailable.",
    "request_id": "req_…"
  }
}
```
