# Hand off an incident — API reference

> Moves the incident's alert plan to its next step now and returns which step is alerted next.

Source: https://upfour.io/docs/api/incidents/hand-off-an-incident

[Developers](https://upfour.io/docs/api.md)/[Incidents](https://upfour.io/docs/api/incidents.md)

Moves the incident's alert plan to its next step now and returns which step is alerted next.

POST https://app.upfour.io/v1/incidents/{incidentID}/hand-off

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

## Parameters

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

## Body

`application/json` optional 5 fields

All other fields5 fields

escalation_iduuid · nullable

The alert plan run the alert came from; another run answers 409 `stale_alert`.

incident_occurrenceinteger · nullable

The incident's occurrence the alert was sent for; another occurrence answers 409 `stale_alert`.

repeat_iterationinteger · nullable

The lap of the alert plan, starting at 0; another lap answers 409 `stale_alert`.

sourcestring

Where the person acted; kept in the timeline entry. Defaults to web, or app for the upfour app.

lock_screenappwebwatch

stepinteger · nullable

The alert-plan step, starting at 1; another step answers 409 `stale_alert`.

## Returns

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

Response fields 1 top-level fields

| Field | Type | Description |
| --- | --- | --- |
| `data` | HandOffResult | |
| HandOffResult · 33 fields FieldTypeDescription `escalation` IncidentEscalationView  · nullable IncidentEscalationView · 30 fields FieldTypeDescription `current_step` integer `escalation_id` uuid `has_escalation` boolean `manual_pending` boolean `policy_id` uuid The alert plan that runs. `policy_name` string The alert plan's name. `repeat_count` integer `repeat_iteration` integer `repeat_push_count` integer `repeat_push_max` integer `source_incident_id` uuid The incident that owns this alert plan run: this incident, the first short incident of its alert episode, or in a domain case the member that started the case's plan. POST /v1/incidents/{incidentID}/escalate works only on this incident; any other answers 400 naming it. `status` string one of`active` `paused` `completed` `stopped` `step_count` integer `current_step_label` string `current_step_recipients` IncidentEscalationRecipient[] Who the step that last fired reaches. Only on GET /v1/incidents/{incidentID}. Each item · 4 fields FieldTypeDescription `kind` string one of`user` `schedule` `channel` user for a person (the owner of an app channel, or who is on call for a rotation), schedule for a rotation nobody can be resolved for, channel for any other alert channel. `name` string The person's display name, the rotation's name or the channel's name. `channel_types` string[] The alert channel types the step reaches this recipient on, for example email, sms, voice or mobile. Absent for a rotation without anyone on call. `schedule_name` string For a person resolved from a rotation, the rotation's name. `next_reminder_at` string (date-time) When the next reminder goes out: next_step_at when that step belongs to a repeat lap of the plan, which every channel the plan reached before receives as a reminder. Absent during the first lap, when no step is scheduled, and while the incident is acknowledged. `next_repeat_push_at` string (date-time) `next_step` IncidentEscalationNextStep IncidentEscalationNextStep · 7 fields FieldTypeDescription `label` string `position` integer `recipients` IncidentEscalationRecipient[] Who the next step reaches, with rotations resolved for next_step_at. Only on GET /v1/incidents/{incidentID}. Each item · 4 fields FieldTypeDescription `kind` string one of`user` `schedule` `channel` user for a person (the owner of an app channel, or who is on call for a rotation), schedule for a rotation nobody can be resolved for, channel for any other alert channel. `name` string The person's display name, the rotation's name or the channel's name. `channel_types` string[] The alert channel types the step reaches this recipient on, for example email, sms, voice or mobile. Absent for a rotation without anyone on call. `schedule_name` string For a person resolved from a rotation, the rotation's name. `next_step_at` string (date-time) `incident_id` uuid The incident that was handed off. After a flap this is the later incident of the same alert that carries the alarm now. `outcome` string one of`advanced` `next_lap` `exhausted` advanced: the next step is alerted now. next_lap: the last step was handed off and the plan starts its next lap at step 1\. exhausted: no step and no lap is left; the plan ends, the incident stays open and the Company owner is told. | | |

## Errors

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

| Status | Code | Meaning |
| --- | --- | --- |
| 409 | [already_acknowledged](https://upfour.io/docs/api/errors#code-already_acknowledged) | Someone else acknowledged the incident first. **When:** Handing off an acknowledged incident, or acknowledging with the alert fields after another person acknowledged it. details names who and when. **Fix:** Nothing to do; the person in details.acknowledged_by is on it. |
| 400 | [bad_request](https://upfour.io/docs/api/errors#code-bad_request) | The request is malformed or fails validation. |
| 409 | [incident_already_open](https://upfour.io/docs/api/errors#code-incident_already_open) | The monitor already has an open or acknowledged incident. **When:** Declaring an incident on a monitor that still has an unresolved one. **Fix:** Open the existing incident instead, or resolve it first and declare a new one. |
| 409 | [incident_closed](https://upfour.io/docs/api/errors#code-incident_closed) | The incident is resolved. **When:** Handing off a resolved incident, or acknowledging one with the alert fields. **Fix:** Nothing to do; the incident is over. |
| 409 | [manual_escalation_pending](https://upfour.io/docs/api/errors#code-manual_escalation_pending) | A manual escalation still waits for its person. **When:** Handing off while a person the incident was escalated to by hand has not confirmed yet. **Fix:** Wait for that person or acknowledge the incident. |
| 409 | [no_escalation](https://upfour.io/docs/api/errors#code-no_escalation) | No alert plan runs for the incident. **When:** Handing off an incident without a running alert plan (direct alert channels, or a plan that already ended). **Fix:** Escalate to a person or acknowledge the incident instead. |
| 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 | [stale_alert](https://upfour.io/docs/api/errors#code-stale_alert) | The action answers an alert that is no longer current. **When:** Acknowledging or handing off with incident_occurrence, escalation_id, repeat_iteration or step of an earlier occurrence, step or lap of the incident, or acknowledging a step that was already handed off. **Fix:** Load the incident again and act on its current alert, or acknowledge without the alert fields. |

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

[PreviousEscalate an incident](https://upfour.io/docs/api/incidents/escalate-an-incident.md) [NextReopen an incident](https://upfour.io/docs/api/incidents/reopen-an-incident.md)

## Request

### cURL

```bash
curl -s -X POST "https://app.upfour.io/v1/incidents/3f6c1a52-8b1e-4f0d-9a43-2c5d7e8f1a90/hand-off" \
  -H "Authorization: Bearer $UP4_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
```

### JavaScript

```javascript
const res = await fetch("https://app.upfour.io/v1/incidents/3f6c1a52-8b1e-4f0d-9a43-2c5d7e8f1a90/hand-off", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.UP4_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({}),
});
console.log(res.status, await res.json());
```

### Python

```python
import os
import requests

res = requests.post(
    "https://app.upfour.io/v1/incidents/3f6c1a52-8b1e-4f0d-9a43-2c5d7e8f1a90/hand-off",
    headers={"Authorization": f"Bearer {os.environ['UP4_API_KEY']}"},
    json={},
)
print(res.status_code, res.json())
```

### Go

```go
package main

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

func main() {
	payload := strings.NewReader(`{}`)
	req, _ := http.NewRequest("POST", "https://app.upfour.io/v1/incidents/3f6c1a52-8b1e-4f0d-9a43-2c5d7e8f1a90/hand-off", 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'
{}
JSON;

$ch = curl_init("https://app.upfour.io/v1/incidents/3f6c1a52-8b1e-4f0d-9a43-2c5d7e8f1a90/hand-off");
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

### 200

```json
{
  "data": {
    "escalation": {
      "current_step": 1,
      "escalation_id": "3f6c1a52-8b1e-4f0d-9a43-2c5d7e8f1a90",
      "has_escalation": false,
      "manual_pending": false,
      "policy_id": "3f6c1a52-8b1e-4f0d-9a43-2c5d7e8f1a90",
      "policy_name": "example",
      "repeat_count": 1,
      "repeat_iteration": 1,
      "repeat_push_count": 1,
      "repeat_push_max": 1,
      "source_incident_id": "3f6c1a52-8b1e-4f0d-9a43-2c5d7e8f1a90",
      "status": "active",
      "step_count": 1
    },
    "incident_id": "3f6c1a52-8b1e-4f0d-9a43-2c5d7e8f1a90",
    "outcome": "advanced"
  }
}
```

### 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": "already_acknowledged",
    "message": "Someone else acknowledged the incident first.",
    "request_id": "req_…"
  }
}
```
