# Public API FAQ

**What are the session states it goes through? How to find out how long a session has been in a particular state?**

In general, the **Public API** `GET /api/v1/Sessions/{id}` is used to find out information about a session, it also contains all the information about the change of the session state and the time it has been in each state. Additional information is also provided by the `GET /api/v1/Sessions/{id}/routingHistory`

**Duration of selected states and phases:**

* CREATED (from session creation to start of routing):

```
 Common.RoutingTimeLine[activityType="RoutingRequestCreated"].First().timestamp - Sessions.SessionModel.created
```

* IN\_QUEUE (from the start of routing after the first suitable operator is selected):

```
 Common.RoutingTimeLine[activityType="AssignedToOperator"].First().timestamp - Common.RoutingTimeLine[activityType="RoutingRequestCreated"].First().timestamp
```

* WAITING (from when the first suitable operator is selected to when the session is accepted):

```
 Common.RoutingTimeLine[activityType="AcceptedByOperator"].First().timestamp - Common.RoutingTimeLine[activityType="AssignedToOperator"].First().timestamp
```

* BCW (before call work; od přijetí sezení po spojení s klientem):

```
 Sessions.SessionModel.guestJoined - Sessions.SessionModel.started (only if the result is positive)
```

* ACTIVE (for the duration of the two-way communication):

```
 Sessions.SessionModel.length
```

* ACW (after call work; from the end of two-way communication after the last operator has closed the session):

```
 Sessions.SessionModel.operators.Max(concluded) - Sessions.SessionModel.operators.Max(left)
```

* The time in the queue of a specific operator with userId = X:

```
 Common.RoutingTimeLine[activityType="AcceptedByOperator"].First().timestamp - Common.RoutingTimeLine[activityType="AssignedToOperator" & operator.userId=X].First().timestamp
```

* The ACW time of the specific operator with userId=X:

```
 Sessions.SessionModel.operators[userId=X].concluded - Sessions.SessionModel.operators[userId=X].left
```

* Ring time:

```
 Sessions.SessionModel.guestJoined - Sessions.SessionModel.created (neplatí u náhledové kampaně)
```

* The time from the connection to the PBX to the connection to the operator:

```
 Sessions.SessionModel.waited
```

Some session types (session sources) do not go through all states, but some states skip.

### Explanation of some items in the response to GET /api/v1/Sessions/{id}

| Item                                      | Description                                                                                                                                                                           |
| ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Sessions.SessionModel.directCallNumber    | The number that the client entered to create the session, e.g. the invitation number.                                                                                                 |
| Sessions.SessionModel.phoneCallbackNumber | The number that was entered by the operator or selected in the campaign to contact the client, for example.                                                                           |
| Sessions.SessionModel.operators.left      | The moment when the operator left direct communication with the client. He then has the opportunity to fill in his notes for the session within the ACW.                              |
| Sessions.SessionModel.operators.concluded | The moment when the operator has closed the ACW. It applies that Sessions.SessionModel.operators.left <= Sessions.SessionModel.operators.concluded                                    |
| Sessions.SessionModel.started             | The moment when the first operator accepted or created the session.                                                                                                                   |
| Sessions.SessionModel.ended               | The moment when the last operator left direct communication with the client. After that, it is not possible to resume direct communication with the client again within this session. |
| Sessions.SessionModel.waited              | The amount of time the client waited to connect with an operator.                                                                                                                     |
| Sessions.SessionModel.length              | The time of direct two-way communication.                                                                                                                                             |

### How to download recordings and files from the sessions?

You can get the address of the file from e.g.

```
Sessions.SessionModel.recordings.downloadUrl
```

or

```
Sessions.SessionModel.activities.file.downloadUrl
```

{% hint style="info" %}
*You can get the file from this address in the same way as you communicate with Public Api, i.e. by adding **Authorization to the GET request header** (see* [*Authentication section*](https://docs.mluvii.com/en/for-it-specialists/public-api/authentication)*).*
{% endhint %}
