# Get list of messages

## Service description

Use this service to get a list of pending messages. You can use this service to request a number of messages at the same time and actually process them in separate threads.

Use in combination with [mark-batch-of-messages-as-processed](https://docs.lhv.com/home/connect/services/messages/mark-batch-of-messages-as-processed "mention")

Use additional filters where needed.

* By default 10 messages are returned. The optional limit parameter changes this. See parameters section.&#x20;
* Messages are ordered starting from the oldest.
* The same header values are accepted as for `GET /messages/next` service - including `Filter-Response-Type` and Service Provider options.&#x20;

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

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

#### **Parameters**

<table><thead><tr><th width="165">Name</th><th width="181">Value</th><th>Description</th></tr></thead><tbody><tr><td>Limit</td><td><code>integer</code></td><td>Number of messages to return.</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><tr><td>Filter-Service-Provider</td><td>true / false or 1/0</td><td>Add this optional header to select service provider messages only when using Service Provider own value for Client-Code. Values: 1/true (filter is on) or 0/false (filter is off). This can be used by service providers to select only their own company messages in the queue. By default when Client-Code is the service provider itself, it returns the messages of all customers. Has no effect when Client-Code is not service provider.</td></tr><tr><td>Filter-Response-Type</td><td>CREDIT_DEBIT_NOTIFICATION, PAYMENT etc.</td><td>Add this optional header to filter specific service messages. The value can be any Message-Response-Type (e.g., ACCOUNT_STATEMENT, CREDIT_DEBIT_NOTIFICATION, PAYMENT). Using this parameter enables parallel processing of payment responses and debit-credit notifications separately. This allows immediate consumption of payment responses, even if there are thousands of pending notifications in the queue.</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
{
    "messages": [
        {
            "messageResponseId": "RES27dc481c24af499d8cab27ec8099a4d2",
            "messageRequestId": "REQ06d2e575a6c94061b7235ca160350680",
            "messageResponseType": "ACCOUNT_STATEMENT",
            "clientCode": "123123123",
            "clientCountry": "GB",
            "messageCreatedTime": "2024-05-23T16:51:30.939+01:00",
            "bankCode": "LHVUK"
        },
        {
            "messageResponseId": "RES271840cbb3b74578b04cbc4d97540680",
            "messageRequestId": "REQd6112ff55e824170b592e0ae79f917fe",
            "messageResponseType": "VIBAN_INFO",
            "clientCode": "123123123",
            "clientCountry": "GB",
            "messageCreatedTime": "2024-05-23T16:52:20.562+01:00",
            "bankCode": "LHVUK"
        },
        {
            "messageResponseId": "RES6bd75393a14f4c1fbcb4f3f5327c092f",
            "messageRequestId": "REQ2bda6fb658ce4ffdaa1bd4827310f6c2",
            "messageResponseType": "PAYMENT",
            "clientCode": "123123123",
            "clientCountry": "GB",
            "messageCreatedTime": "2024-05-23T16:52:00.339+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 %}
