# Quickcall

Source: https://docs.qvoice.net/api/quickcall/

HTTP endpoint to ring an extension and, once it answers, send the call to another extension.
A typical use is a hotel wake-up call: the property management system rings the room, and when
the guest picks up the call goes to the wake-up IVR.

This is the opposite order of [Click to Call](https://docs.qvoice.net/api/click-to-call/), which rings the caller's own
extension first and then dials the destination.

---

## How the call runs

```mermaid
sequenceDiagram
    participant App as Your application
    participant P as QVOICE Platform
    participant Room as Room phone (target_ext)
    participant IVR as route_to (e.g. wake-up IVR)
    App->>P: POST /api/v2/calls/quickcall
    P-->>App: 202 call_ids
    P->>Room: INVITE (your caller ID and SIP headers)
    Room-->>P: answered
    P->>IVR: the answered call runs the route_to callflow
    Note over P,Room: No answer within timeout: the call ends (no voicemail with no_voicemail)
```

1. `target_ext` is looked up: it must be a **user's or a device's extension**. The phones of that
   user (or that device) ring. The extension's own callflow is not run, so the user's voicemail box
   is never reached.
2. When a phone answers, the call is sent to `route_to`, which must be an extension with a callflow
   (an IVR, a webhook / pivot callflow, a user, ...).
3. The callflow at `route_to` sees **`target_ext` as the caller ID number**, so a webhook or pivot can
   tell which room answered.

The phone rings normally: the request never asks the phone to auto-answer.

---

## Authentication

An account administrator's access token (`Authorization: Bearer <token>`) or an
[API key](https://docs.qvoice.net/api/api-key-auth/) (`X-API-Key`). The call is placed in the working account
(`X-Account-ID` when you manage a sub-account).

---

## Endpoint

`POST /api/v2/calls/quickcall`

```
curl -X POST "https://{portalURL}:9443/api/v2/calls/quickcall" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "target_ext": "100",
    "route_to": "7000",
    "timeout": 30,
    "caller_id": {"name": "Wake-Up Call", "number": "7000"},
    "custom_sip_headers": {"X-Wakeup-Id": "abc-123"},
    "no_voicemail": true
  }'
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `target_ext` | string | yes | Extension to ring: 1 to 16 digits, a user's or a device's extension |
| `route_to` | string | yes | Extension the answered call is sent to: digits, `*` or `#`, at most 32. Must have a callflow |
| `timeout` | integer | no | How long to ring, in seconds: 5 to 300. Default 30 |
| `caller_id` | object | no | What the rung phone displays: `name` (at most 64 characters) and `number` (digits, `*`, `#`, optional leading `+`, at most 32). Default: name "Device QuickCall", number `route_to` |
| `custom_sip_headers` | object | no | SIP headers added to the call sent to the phones, see below |
| `no_voicemail` | boolean | no | Never let a voicemail answer an unanswered call, see below. Default `false` |
| `custom_application_vars` | object | no | Your own string values, carried on the call's events and its CDR, and in every status callback |
| `status_callback` | string | no | Absolute `http` or `https` URL that receives the call's status, see [Status callback](https://docs.qvoice.net/api/quickcall/#status-callback) |

Unknown fields are refused.

**Response: 202 Accepted**

```
{
  "call_ids": ["2a6fcf1c78eef7b22250226c6f54ada49b71-quickcall"],
  "target": {"type": "users", "id": "fe47c48dc24e4ff06c7f2fc2851e4798"}
}
```

`call_ids` has one call ID per phone rung. Each one is the `call_id` of that leg in the call records,
and the `Call-ID` a webhook or pivot at `route_to` receives.

The request returns as soon as the call is placed. To learn whether the phone answered, set
`status_callback` (below); it is also in the call records and in the requests your `route_to`
callflow makes.

| Status | When |
| --- | --- |
| 400 | Invalid field, `target_ext` is not a user or device extension, `route_to` has no callflow, or a refused SIP header or caller ID (the body says which) |
| 401 | Missing or invalid credentials |
| 404 | No callflow for `target_ext` |

There is no rate limit on this endpoint: a burst of calls (for example every wake-up at 7:00) is
placed at once.

---

## Custom SIP headers

`custom_sip_headers` is an object of header name to value (string or integer):
`{"X-Wakeup-Id": "abc-123", "X-Room": 100}`. The request is refused (400, nothing is dialled) when:

- there are more than 20 headers;
- a name is not letters, digits and `-` (at most 64), or is a header the platform owns, that carries
  caller identity, or that changes how the phone handles the call: `Via`, `From`, `To`, `Call-ID`,
  `CSeq`, `Contact`, `Max-Forwards`, `Content-Type`, `Content-Length`, `Route`, `Record-Route`,
  `Authorization`, `Proxy-Authorization`, `WWW-Authenticate`, `Proxy-Authenticate`, `Alert-Info`,
  `Call-Info`, `Allow`, `Supported`, `Require`, `Session-Expires`, `Min-SE`, `User-Agent`,
  `P-Asserted-Identity`, `P-Preferred-Identity`, `Remote-Party-ID`, `Diversion`, `Referred-By`,
  `Replaces`, and any `X-Kazoo-*`, `P-Kazoo-*` or `X-FS-*`;
- a value is empty, longer than 256 characters, or contains a line break, `$`, `{`, `}`, `'` or `^`.

The caller ID name follows the same character rules.

---

## Status callback

When the request sets `status_callback`, QVOICE Platform sends a `POST` with a JSON body to that
URL:

- `"event": "answered"` as soon as a phone answers (sent once, even when several phones rang);
- `"event": "completed"` once the call has ended, with the outcome in `status`.

An unanswered call gets only the `completed` request.

```
{
  "event": "completed",
  "status": "no_answer",
  "call_id": "086ec325e50da976ebe19c2a4588e3910894-quickcall",
  "call_ids": ["086ec325e50da976ebe19c2a4588e3910894-quickcall"],
  "target_ext": "100",
  "route_to": "7000",
  "hangup_cause": "NO_ANSWER",
  "talk_seconds": 0,
  "timestamp": 1796274719,
  "custom_application_vars": {"booking": "123"}
}
```

| Field | Description |
| --- | --- |
| `event` | `answered` or `completed` |
| `status` | `answered`, `no_answer` (rang out, or the phone declined without busy), `busy`, `failed` (could not ring, for example no registered phone), or `unknown` (the call was still up after 4 hours) |
| `call_id` | The leg that answered, or the leg whose cause is reported |
| `call_ids`, `target_ext`, `route_to` | As in the request and its response |
| `hangup_cause` | The telephony cause of that leg (`NORMAL_CLEARING`, `NO_ANSWER`, `USER_BUSY`, `NO_USER_RESPONSE`, ...) |
| `talk_seconds` | Answered time of the call, 0 when not answered |
| `timestamp` | When the request was sent (Unix seconds) |
| `custom_application_vars` | As sent in the request, so you can match the callback to your own record |

Your endpoint must answer `2xx`. Each request is tried up to 3 times (immediately, after 2 s and
after 5 s), with a 10 s timeout. Requests are not signed: put a secret of your own in the URL (for
example `?token=...`) and check it.

**Delivery:**

The callback is sent by the server that accepted the request. If that server restarts while the
call is in progress, the callback for that call is not sent; the call record still has the outcome.

## No voicemail

The extension's own voicemail box is never used by this endpoint. With `"no_voicemail": true`,
nothing else that could end in a voicemail is used either:

- the user's or device's **call forwarding** is ignored (no forwarded call, the phone itself rings);
- **failover** forwarding is not used;
- **cell phone** and **landline** devices of the user are not rung (their carrier's voicemail could
  answer).

If no phone is left to ring, nothing is dialled. Use it for wake-up calls and any call where a
recording or voicemail answering would be wrong.

**Unanswered calls:**

An unanswered call simply ends at `timeout`. Retrying (for example a wake-up call that was not
answered) is up to your application: the `completed` status callback tells you when.
