> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wede.pt/llms.txt
> Use this file to discover all available pages before exploring further.

# Missions

> Create and manage operational missions assigned to teams

## Overview

A mission is created when a team is dispatched to an event. It tracks the full lifecycle of the field response — from dispatch to completion — and provides the feedback channel for field operators.

Missions are the operational record of Wede. They are immutable once completed and form part of the audit trail.

***

## List Missions

`GET /v1/missions`

Requires `missions:view` permission.

### Query Parameters

| Parameter   | Type    | Description                            |
| ----------- | ------- | -------------------------------------- |
| `status`    | string  | Filter by status (see lifecycle below) |
| `team_id`   | string  | Filter by team                         |
| `member_id` | string  | Filter by assigned member              |
| `limit`     | integer | Max results (default 50)               |

### Response

```json theme={null}
{
  "data": [
    {
      "id": "uuid",
      "event_id": "uuid",
      "team_id": "uuid",
      "status": "ON_ROUTE",
      "channel_used": "internet",
      "vertical": "healthcare",
      "priority": "high",
      "notes": "Patient is conscious, use south entrance",
      "event_lat": 38.7169,
      "event_lng": -9.1395,
      "dispatched_at": "2026-06-09T18:00:00Z",
      "ack_at": "2026-06-09T18:01:30Z",
      "on_route_at": "2026-06-09T18:02:00Z",
      "on_site_at": null,
      "completed_at": null,
      "failed_at": null,
      "feedback": null,
      "created_at": "2026-06-09T18:00:00Z",
      "updated_at": "2026-06-09T18:02:00Z"
    }
  ],
  "count": 1
}
```

***

## Get Mission

`GET /v1/missions/:id`

Requires `missions:view` permission.

***

## Update Mission Status

`PATCH /v1/missions/:id/status`

Requires `missions:manage` **or** `missions:receive` permission.

Field operators use `missions:receive`. Supervisors and admins use `missions:manage`.

### Request Body

```json theme={null}
{
  "status": "ON_SITE",
  "feedback": {
    "patient_condition": "stable",
    "observations": "Patient responsive, BP 120/80"
  }
}
```

| Field      | Type   | Required | Description                                 |
| ---------- | ------ | -------- | ------------------------------------------- |
| `status`   | string | Yes      | Next status in lifecycle                    |
| `feedback` | object | No       | Opaque structured feedback (parser-defined) |

### Mission Lifecycle

Missions follow a strict forward-only progression:

| Status      | Description                    | Who sets it                  |
| ----------- | ------------------------------ | ---------------------------- |
| `CREATED`   | Mission created, team notified | System (on dispatch)         |
| `SENT`      | Notification delivered         | System (delivery engine)     |
| `ACK`       | Team acknowledged the mission  | Field operator               |
| `ON_ROUTE`  | Team is travelling to location | Field operator               |
| `ON_SITE`   | Team has arrived               | Field operator               |
| `COMPLETED` | Mission closed successfully    | Field operator or supervisor |
| `FAILED`    | Mission could not be completed | Field operator or supervisor |

When a mission reaches `COMPLETED` or `FAILED`:

* The assigned team is automatically returned to `available` status
* The originating event is closed

### Webhooks

Status updates fire the `mission.status_updated` webhook:

```json theme={null}
{
  "event": "mission.status_updated",
  "payload": {
    "mission_id": "uuid",
    "status": "ON_SITE",
    "feedback": {}
  }
}
```

***

## Backup Dispatch

To dispatch a second team to an active mission (reinforcement), use the standard dispatch endpoint with the same `event_id`:

`POST /v1/teams/dispatch`

```json theme={null}
{
  "event_id": "uuid-of-original-event",
  "team_id": "uuid-of-backup-team",
  "notes": "Backup team — reinforcement requested by field operator",
  "event_lat": 38.7169,
  "event_lng": -9.1395
}
```

This creates a new mission for the backup team while the original mission continues. Both missions are tracked independently.

### SDK Method

```typescript theme={null}
await client.requestBackup({
  mission_id: currentMission.id,
  event_id: currentMission.event_id,
  event_lat: currentLocation.lat,
  event_lng: currentLocation.lng
})
```
