# Calls

The emergency calls Ella PSAP receives over [SIP](<https://docs.ellanetworks.com/psap/reference/sip/index.md>), and their callbacks, each in an [incident](<https://docs.ellanetworks.com/psap/reference/api/incidents/index.md>).

## List Calls

Returns the emergency calls and the calls placed by call takers, with their incident, number, locations and state.

| Method | Path |
| --- | --- |
| GET | `/api/v1/calls` |

### Query Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `incident` | string | Only the calls of the incident with this ID. |
| `order` | string | `asc`, oldest first, or `desc`, newest first. Default: `asc`. |
| `after` | integer | Only calls with a greater `id`. |
| `limit` | integer | 1 to 500. Default: 100. |
| `wait` | integer | Seconds, 0 to 30, to wait for a call when none matches. Default: 0. |

### Response Fields

| Field | Type | Description |
| --- | --- | --- |
| `items` | array | The calls. |
| `items[].id` | integer | ID of the call. |
| `items[].incident_id` | string | The ID of the [incident](<https://docs.ellanetworks.com/psap/reference/api/incidents/index.md>) of the call. |
| `items[].direction` | string | `in` for an emergency call, `out` for a call placed by a call taker. |
| `items[].callback_of` | integer | The emergency call that an `out` call returns. `null` for another `out` call and for an `in` call. |
| `items[].placed_by` | string | Email of the call taker who placed an `out` call. `null` for an `in` call. |
| `items[].end_code` | integer | The SIP status code that ended an `out` call that was not answered, or failed. `null` otherwise. |
| `items[].trunk` | string | The [SIP trunk](<https://docs.ellanetworks.com/psap/reference/api/sip_trunks/index.md>) the call came through. |
| `items[].service` | string | The Request-URI of the INVITE, such as `urn:service:sos`. |
| `items[].number` | string | The other party: for an `in` call, the callback number or SIP URI from `P-Asserted-Identity`, empty when there is none; for an `out` call, the number dialled. |
| `items[].state` | string | See [States](<#states>). |
| `items[].locations` | array | See [Locations](<#locations>). Empty when the call carries none. |
| `items[].answered_by` | string | Email of the call taker who answered. `null` until a call taker answers. |
| `items[].answered_at` | string | Time a call taker answered. `null` until a call taker answers. |
| `items[].created_at` | string | Time the call arrived. |
| `items[].updated_at` | string | Time of the last change. |
| `items[].ended_at` | string | Time the call ended. `null` while it rings or is answered. |
| `items[].cut_off_by` | string | Email of the call taker who marked the call cut off. `null` otherwise. |
| `items[].cut_off_at` | string | Time the call was marked cut off. `null` otherwise. |

### States

The state of a call.

| State | Meaning |
| --- | --- |
| `ringing` | The call waits for a call taker. |
| `calling` | The `out` call rings at the other party. |
| `answered` | A call taker answered the call, or the other party answered the `out` call, and the call is in progress. |
| `abandoned` | A CANCEL or a BYE ended the call while it rang. |
| `unanswered` | The other party did not answer the `out` call, was busy, declined it, or the call taker hung up first. |
| `failed` | The network refused the `out` call, or Ella PSAP restarted while it rang. |
| `ended` | The call ended after an answer, or for another reason, such as a restart of Ella PSAP. |

### Locations

One location carried in the call, by value in PIDF-LO or by reference.

| Field | Type | Description |
| --- | --- | --- |
| `shape` | object | See [Shapes](<#shapes>). Absent for a civic address or a reference. |
| `civic` | array | The civic address elements, in order, each a `name` (such as `RD` or `HNO`) and a `value`. An element outside the civic address namespaces is named `namespace:name`. |
| `lang` | string | The language of the civic address. |
| `method` | string | How the location was found, such as `Cell` or `GPS`. |
| `provided_by` | string | Who provided the location. |
| `confidence` | number | Percent. Absent means 95 for a shape other than a point, unless `confidence_unknown` is `true`. |
| `confidence_unknown` | boolean | The confidence is `unknown`, or could not be read. |
| `timestamp` | string | Time the location was found. |
| `reference` | string | A location URI from `Geolocation`. Ella PSAP does not fetch it. |
| `loc_src` | string | The `loc-src` of the `Geolocation` entry. |

### Shapes

A geodetic shape, in WGS 84. Lengths are in metres. `orientation` and `start_angle` are in degrees clockwise from north; `opening_angle` is in degrees clockwise from `start_angle`.

| Field | Type | Description |
| --- | --- | --- |
| `type` | string | `Point`, `Polygon`, `Circle`, `Ellipse`, `ArcBand`, `Sphere`, `Ellipsoid` or `Prism`. |
| `positions` | array | `latitude`, `longitude` and `altitude` in 3D. The centre, the site of an arc band, or the polygon's points. |
| `radius` | number | Circle and sphere. |
| `inner_radius`, `outer_radius`, `start_angle`, `opening_angle` | number | Arc band. |
| `semi_major_axis`, `semi_minor_axis`, `orientation` | number | Ellipse and ellipsoid. |
| `vertical_axis` | number | Ellipsoid. |
| `height` | number | Prism. |

### Sample Response

```
{
    "result": {
        "items": [
            {
                "id": 3,
                "incident_id": "urn:emergency:uid:incidentid:01M8Y7C5PW042B23ZTJQKQEQQ8:psap.example.org",
                "direction": "in",
                "placed_by": null,
                "end_code": null,
                "trunk": "ella-ims",
                "service": "urn:service:sos",
                "callback_of": null,
                "number": "+16135550142",
                "state": "ringing",
                "locations": [
                    {
                        "shape": {
                            "type": "Circle",
                            "positions": [{"latitude": 45.42153, "longitude": -75.69719}],
                            "radius": 120
                        },
                        "method": "Cell",
                        "provided_by": "ims.example.com",
                        "confidence": 90
                    }
                ],
                "answered_by": null,
                "answered_at": null,
                "created_at": "2026-12-01T22:19:45.120Z",
                "updated_at": "2026-12-01T22:19:45.120Z",
                "ended_at": null,
                "cut_off_by": null,
                "cut_off_at": null
            }
        ]
    }
}
```

## Count Calls

Returns how many emergency calls arrived in a time window, how fast they were answered, and how many ring now.

| Method | Path |
| --- | --- |
| GET | `/api/v1/calls/counts` |

### Query Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `start` | string | RFC 3339 time. Default: 24 hours before `end`. |
| `end` | string | RFC 3339 time, not before `start`. Default: now. |

### Response Fields

| Field | Type | Description |
| --- | --- | --- |
| `start`, `end` | string | The window of the count. |
| `received` | integer | Emergency calls that arrived in the window. |
| `ringing` | integer | Emergency calls that ring now. |
| `in_progress` | integer | Calls answered now, and callbacks that ring at the caller now. |
| `answered` | integer | Calls that arrived in the window and that a call taker answered. |
| `answered_within_15s` | integer | Answered calls answered 15 seconds or less after they arrived. |
| `answered_within_20s` | integer | Answered calls answered 20 seconds or less after they arrived. |
| `abandoned` | integer | Calls that arrived in the window and that the caller hung up while they rang. |

### Sample Response

```
{
    "result": {
        "start": "2026-11-30T22:30:00Z",
        "end": "2026-12-01T22:30:00Z",
        "received": 5,
        "ringing": 1,
        "in_progress": 1,
        "answered": 3,
        "answered_within_15s": 3,
        "answered_within_20s": 3,
        "abandoned": 1
    }
}
```

## Get a Call

Returns one call, with its incident, number, locations and state.

| Method | Path |
| --- | --- |
| GET | `/api/v1/calls/{id}` |

## Answer a Call

Answers a ringing call and connects the caller's audio to the call taker's browser.

| Method | Path |
| --- | --- |
| POST | `/api/v1/calls/{id}/answer` |

### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `sdp` | string | Yes | A WebRTC SDP offer with an audio stream in PCMU, with all its ICE candidates. |

### Response Fields

| Field | Type | Description |
| --- | --- | --- |
| `sdp` | string | The WebRTC SDP answer of Ella PSAP, with all its ICE candidates. |

## Call Back

Calls the caller of an ended call back, in the call's open incident, and connects them to the call taker's browser.

| Method | Path |
| --- | --- |
| POST | `/api/v1/calls/{id}/callback` |

### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `sdp` | string | Yes | A WebRTC SDP offer with an audio stream in PCMU, with all its ICE candidates. |

### Response Fields

| Field | Type | Description |
| --- | --- | --- |
| `id` | integer | ID of the callback, a call of direction `out` whose `callback_of` is the call. |
| `sdp` | string | The WebRTC SDP answer of Ella PSAP, with all its ICE candidates. |

## Hang Up a Call

Ends an answered call for both the caller and the call taker.

| Method | Path |
| --- | --- |
| POST | `/api/v1/calls/{id}/hangup` |

## Mark a Call as Cut Off

Marks an answered emergency call that ended as cut off before it was over, and returns it.

| Method | Path |
| --- | --- |
| POST | `/api/v1/calls/{id}/cut-off` |
