# Get list of messages V2

## Service description

Version 2 of the [get-list-of-messages](https://docs.lhv.com/home/connect/services/messages/get-list-of-messages "mention") service differs by supporting pagination.

{% hint style="warning" %}
V2 version supports only LHV UK messages where x-bank-code = LHVUK. It does not include the messages from LHV EE where x-bank-code = LHVEE.

With these limitations the service could be more suitable for specific use cases like integrations testing and problem solving.
{% endhint %}

## Request <a href="#virtual-iban-open" id="virtual-iban-open"></a>

<mark style="color:green;">`GET`</mark> <https://connect.lhv.com/v2/messages>

#### **Parameters**

<table><thead><tr><th width="217">Name</th><th width="165">Value</th><th>Description</th></tr></thead><tbody><tr><td><code>pageSize</code></td><td><code>integer</code></td><td>Number of messages to return on one page. Max value is 1000!</td></tr><tr><td><code>pageNumber</code></td><td><code>integer</code></td><td>Page number</td></tr><tr><td><code>responseType</code></td><td><code>string</code></td><td>Optional. Filter specific service messages. The value can be any Message-Response-Type (e.g., ACCOUNT_STATEMENT, CREDIT_DEBIT_NOTIFICATION, PAYMENT). Similar to Filter-Response-Type header for V1 service.</td></tr><tr><td><code>messageRequestId</code></td><td><code>string</code></td><td>Optional. Filter by Request ID value from any previous service request like Payments, Account Statement etc.</td></tr><tr><td><code>includeProcessed</code></td><td><code>true/false</code></td><td>Optional. Also includes messages that are already processed by the Customer</td></tr><tr><td><code>includeMetadata</code></td><td><code>true/false</code></td><td>Optional. Includes Metadata block. Default is false.</td></tr><tr><td><code>serviceProvider</code></td><td><code>true/false</code></td><td>Optional. Filter only Service Provider messages. Similar to Filter-Service-Provider header for V1 service.</td></tr></tbody></table>

#### **Headers**

<table><thead><tr><th width="165">Name</th><th width="181">Value</th><th>Description</th></tr></thead><tbody><tr><td>Client-Code</td><td><code>customer value</code></td><td>For Service Providers only. Company registration code of the Service Provider or its customer. When using the Service Provider own value also related customers messages are returned by default - see also Filter-Service-Provider for more options.</td></tr><tr><td>Client-Country</td><td><code>customer value</code></td><td>For Service Providers only. Should match the value of Client-Code</td></tr></tbody></table>

#### **Body**

JSon with a list of messages metadata - type, timing, reference ID's.

### **Response**

**Headers**

<table><thead><tr><th width="241">Name</th><th width="186">Value</th><th>Description</th></tr></thead><tbody><tr><td>Content-Type</td><td><code>application/json</code></td><td>Format of the message body</td></tr><tr><td>X-Bank-Code</td><td><code>LHVUK</code>, <code>LHVEE</code></td><td>LHV Bank entity</td></tr><tr><td>Client-Code</td><td><code>customer value</code></td><td>When using service provider model - customer entity related to the message</td></tr><tr><td>Client-Country</td><td><code>customer value</code></td><td>When using service provider model - customer entity related to the message</td></tr></tbody></table>

#### Body

{% tabs %}
{% tab title="200 - list of messages" %}
{% hint style="success" %}
OK
{% endhint %}

```json
{
    "pageNumber": 1,
    "pageSize": 100,
    "totalPages": 2,
    "totalElements": 109,
    "messages": [
        {
            "messageResponseId": "RES27dc481c24af499d8cab27ec8099a4d2",
            "messageRequestId": "REQ06d2e575a6c94061b7235ca160350680",
            "messageResponseType": "ACCOUNT_STATEMENT",
            "clientCode": "123123123",
            "clientCountry": "GB",
            "messageCreatedTime": "2024-05-23T16:51:30.939+01:00",
            "bankCode": "LHVUK"
        },
        {
            "messageResponseId": "RESc8ea0a0a395c4f19b4eab32e8a8c0b04",
            "messageResponseType": "CREDIT_DEBIT_NOTIFICATION",
            "clientCode": "123123123",
            "clientCountry": "GB",
            "messageCreatedTime": "2024-05-23T16:54:13.477+01:00",
            "bankCode": "LHVUK"
        },
		....
        {
            "messageResponseId": "RESdf66d9bf1142439388f7ce47d3a02505",
            "messageRequestId": "REQb6057056347e47ef96729d76f265b292",
            "messageResponseType": "PAYMENT",
            "clientCode": "123123123",
            "clientCountry": "GB",
            "messageCreatedTime": "2024-05-24T07:42:07.538+01:00",
            "bankCode": "LHVUK"
        }
    ]
}
```

{% endtab %}

{% tab title="200 - including Metadata" %}
{% hint style="success" %}
OK&#x20;

Including Metadata info
{% endhint %}

```
{
    "pageNumber": 1,
    "pageSize": 100,
    "totalPages": 1,
    "totalElements": 2,
    "messages": [
        {
            "messageResponseId": "RESbca427c4ba9348558b3a3de5b57ab458",
            "messageRequestId": "REQ70cda19353504910812afe4fbf5c16f0",
            "messageResponseType": "HEARTBEAT",
            "messageCreatedTime": "2024-12-10T08:18:54.029+00:00",
            "bankCode": "LHVUK"
        },
        {
            "messageResponseId": "RESc7e74dba11624bad8918c27223bfdb41",
            "messageRequestId": "REQdbc9a823086c40f69d507f9fb875f851",
            "messageResponseType": "ACCOUNT_BALANCE",
            "messageCreatedTime": "2024-12-10T08:20:10.502+00:00",
            "bankCode": "LHVUK",
            "metadata": {
                "Reports": [
                    {
                        "Acct.Ccy": "GBP",
                        "Acct.IBAN": "GB98LHVB04031400001999"
                    }
                ]
            }
        }
    ]
}
```

{% endtab %}

{% tab title="200 - including processed" %}
{% hint style="success" %}
OK

With `includeProcessed=true parameter including also processed messages.`
{% endhint %}

````json
{
    "pageNumber": 1,
    "pageSize": 100,
    "totalPages": 6,
    "totalElements": 515,
    "messages": [
        {
            "messageResponseId": "RES39d1708ac07d4539ad4ba2da445dc5c7",
            "messageRequestId": "REQ9f4d04421b2c4aaf8d2cf05edd316b51",
            "messageResponseType": "ACCOUNT_BALANCE",
            "clientCode": "123123123",
            "clientCountry": "GB",
            "messageProcessed": true,
            "messageCreatedTime": "2024-06-24T12:04:02.791+01:00",
            "bankCode": "LHVUK"
        },
        {
            "messageResponseId": "RES73f3a32ac9614bef92bc10c528be014d",
            "messageRequestId": "REQb7de32f54fd44f188bf56b264e58a09e",
            "messageResponseType": "ACCOUNT_STATEMENT",
            "clientCode": "123123123",
            "clientCountry": "GB",
            "messageProcessed": true,
            "messageCreatedTime": "2024-06-24T12:04:04.591+01:00",
            "bankCode": "LHVUK"
        },
```
````

{% endtab %}

{% tab title="204 - no more messages" %}
{% hint style="info" %}
No content
{% endhint %}

{% endtab %}

{% tab title="403 - error" %}
{% hint style="danger" %}
Error code and description
{% endhint %}

<pre><code>&#x3C;Errors>
<strong>    &#x3C;Error>
</strong>        &#x3C;ErrorCode>FORBIDDEN&#x3C;/ErrorCode>
        &#x3C;Description>User doesn't exist&#x3C;/Description>
    &#x3C;/Error>
&#x3C;/Errors>

</code></pre>

{% endtab %}
{% endtabs %}
