# Report a handler run — API reference

> Records that a local handler ran or was skipped for an incident event, with its outcome and timings but never its output.

Source: https://upfour.io/docs/api/runner/report-a-handler-run

[Developers](https://upfour.io/docs/api.md)/[Event stream (up4 CLI)](https://upfour.io/docs/api/runner.md)

Records that a local handler ran or was skipped for an incident event, with its outcome and timings but never its output.

POST https://app.upfour.io/v1/runner/runs

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

## Body

`application/json` optional 15 fields

event_idstring (required)

The confirmed stream event id. Reports are idempotent per runner, event, handler and stage.

handlerstring (required)

hoststring (required)

incident_iduuid (required)

kindstring (required)

execforwardnotify

runner_iduuid (required)

runner_namestring (required)

stagestring (required)

deliveredstartedfinishedskipped

All other fields7 fields

duration_msinteger · nullable

event_created_at_msinteger · nullable

Optional event creation time from the stream, in Unix milliseconds. The server records received_at itself.

exit_codeinteger · nullable

finished_atstring (date-time) · nullable

outcomestring

Required for finished reports. Handler output is never accepted or stored.

succeededfailedtimeout

skip_reasonstring

Required for skipped reports. lock_unavailable: the CLI could not reach upfour for the lock and did not run the handler. not_acting comes only from CLIs before the lock.

too_oldcooldownhourly_limitnot_actingsimulated_not_allowedconcurrency_limitdry_runlock_unavailable

started_atstring (date-time) · nullable

## Returns

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

Response fields 1 top-level fields

| Field | Type | Description |
| --- | --- | --- |
| `data` | RunnerRunResponse | |
| RunnerRunResponse · 1 fields FieldTypeDescription `id` uuid The durable report id. Repeating the same idempotency tuple returns the original id. | | |

## 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. |
| 409 | [runner_report_limit](https://upfour.io/docs/api/errors#code-runner_report_limit) | The incident already holds the most machine reports upfour stores for one incident. **When:** POST /v1/runner/runs with a new report for an incident that has reached the limit in error.details.max_reports. A repeated report that upfour already stored is still answered with its original id. **Fix:** Nothing to retry: the incident's history keeps the reports it has. Check whether a handler or script sends reports in a loop. |
| 404 | documented response | The incident is missing or outside the API key's client scope. |
| 409 | documented response | runner_report_limit when the incident already holds the most reports upfour stores for one incident (`error.details.max_reports`). A repeated report that upfour already stored is still answered with its id. |

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).

[PreviousEnd an action lock](https://upfour.io/docs/api/runner/end-an-action-lock.md) [NextAcknowledge received events](https://upfour.io/docs/api/runner/acknowledge-received-events.md)

## Request

### cURL

```bash
curl -s -X POST "https://app.upfour.io/v1/runner/runs" \
  -H "Authorization: Bearer $UP4_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "duration_ms": 2290,
    "event_id": "00000000-0000-4000-8000-000000000001",
    "exit_code": 0,
    "finished_at": "2026-11-19T10:00:02.410Z",
    "handler": "diagnose",
    "host": "nas.local",
    "incident_id": "00000000-0000-4000-8000-000000000004",
    "kind": "exec",
    "outcome": "succeeded",
    "runner_id": "00000000-0000-4000-8000-000000000003",
    "runner_name": "agency-nas",
    "stage": "finished",
    "started_at": "2026-11-19T10:00:00.120Z"
  }'
```

### JavaScript

```javascript
const res = await fetch("https://app.upfour.io/v1/runner/runs", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.UP4_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    duration_ms: 2290,
    event_id: "00000000-0000-4000-8000-000000000001",
    exit_code: 0,
    finished_at: "2026-11-19T10:00:02.410Z",
    handler: "diagnose",
    host: "nas.local",
    incident_id: "00000000-0000-4000-8000-000000000004",
    kind: "exec",
    outcome: "succeeded",
    runner_id: "00000000-0000-4000-8000-000000000003",
    runner_name: "agency-nas",
    stage: "finished",
    started_at: "2026-11-19T10:00:00.120Z",
  }),
});
console.log(res.status, await res.json());
```

### Python

```python
import os
import requests

res = requests.post(
    "https://app.upfour.io/v1/runner/runs",
    headers={"Authorization": f"Bearer {os.environ['UP4_API_KEY']}"},
    json={
        "duration_ms": 2290,
        "event_id": "00000000-0000-4000-8000-000000000001",
        "exit_code": 0,
        "finished_at": "2026-11-19T10:00:02.410Z",
        "handler": "diagnose",
        "host": "nas.local",
        "incident_id": "00000000-0000-4000-8000-000000000004",
        "kind": "exec",
        "outcome": "succeeded",
        "runner_id": "00000000-0000-4000-8000-000000000003",
        "runner_name": "agency-nas",
        "stage": "finished",
        "started_at": "2026-11-19T10:00:00.120Z",
    },
)
print(res.status_code, res.json())
```

### Go

```go
package main

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

func main() {
	payload := strings.NewReader(`{
  "duration_ms": 2290,
  "event_id": "00000000-0000-4000-8000-000000000001",
  "exit_code": 0,
  "finished_at": "2026-11-19T10:00:02.410Z",
  "handler": "diagnose",
  "host": "nas.local",
  "incident_id": "00000000-0000-4000-8000-000000000004",
  "kind": "exec",
  "outcome": "succeeded",
  "runner_id": "00000000-0000-4000-8000-000000000003",
  "runner_name": "agency-nas",
  "stage": "finished",
  "started_at": "2026-11-19T10:00:00.120Z"
}`)
	req, _ := http.NewRequest("POST", "https://app.upfour.io/v1/runner/runs", 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'
{
  "duration_ms": 2290,
  "event_id": "00000000-0000-4000-8000-000000000001",
  "exit_code": 0,
  "finished_at": "2026-11-19T10:00:02.410Z",
  "handler": "diagnose",
  "host": "nas.local",
  "incident_id": "00000000-0000-4000-8000-000000000004",
  "kind": "exec",
  "outcome": "succeeded",
  "runner_id": "00000000-0000-4000-8000-000000000003",
  "runner_name": "agency-nas",
  "stage": "finished",
  "started_at": "2026-11-19T10:00:00.120Z"
}
JSON;

$ch = curl_init("https://app.upfour.io/v1/runner/runs");
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

### 201

```json
{
  "data": {
    "id": "00000000-0000-4000-8000-000000000005"
  }
}
```

### 400

```json
{
  "error": {
    "code": "bad_request",
    "message": "The request is malformed or fails validation.",
    "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_report_limit",
    "message": "The incident already holds the most machine reports upfour stores for one incident.",
    "request_id": "req_…"
  }
}
```
