> For the complete documentation index, see [llms.txt](https://docs.lhv.com/home/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.lhv.com/home/connect/fundamentals/messaging.md). Agents can also search and read this documentation through its [MCP server](https://docs.lhv.com/home/~gitbook/mcp).

# Messaging Pattern

Connect uses asynchronous messaging for many banking services. A request can be accepted before its business result is available, with the result delivered separately as one or more messages.

Messages can also be generated independently of a client request, such as notifications about account transactions.

Your integration can use webhook notifications to learn when messages become available, or retrieve messages through Messages Services.

### Receive and process messages

The message lifecycle consists of:

1. Submit a request, where applicable.
2. Receive a webhook notification or retrieve an available message.
3. Process the message in your system.
4. Mark the message as processed, according to your delivery configuration.

An HTTP response confirming request acceptance does not necessarily confirm that the underlying banking operation has completed. Follow the relevant service specification to interpret the resulting messages and statuses.

<figure><img src="https://2266620947-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHGywduAxJuxV3reZhASh%2Fuploads%2FbHgz3bgYv0OIWG3uwC4b%2F301026_msg_pattern.png?alt=media&amp;token=6c38ed4a-e828-4297-9ff9-043fe0b3e351" alt=""><figcaption></figcaption></figure>

#### Webhook notifications

Webhooks notify your integration when messages become available, reducing the need for repeated polling.

Depending on the subscription configuration, the webhook can include the full message body or identify a message that you retrieve separately.

See [Webhooks](https://docs.lhv.com/home/connect/services/webhooks) for subscription, security, and processing guidance.

#### Message retrieval

Your integration can retrieve messages through [Messages Services](https://docs.lhv.com/home/connect/services/messages).

For inbox-style retrieval, the default behaviour is to return the oldest unprocessed message. This may be a response to an earlier request or an independently generated event.

Do not assume that the next available message belongs to the request most recently submitted.

### Match responses to requests

Use message identifiers to associate responses with their originating requests and track processing.

| Identifier       | Purpose                                                                     |
| ---------------- | --------------------------------------------------------------------------- |
| Request ID       | Associates a response with the request that generated it, where applicable. |
| Response ID      | Identifies an individual Connect message for retrieval and processing.      |
| Webhook event ID | Identifies a webhook event, separately from the underlying Connect message. |
| Idempotency key  | Protects a logical request against duplicate submission.                    |

One request can produce multiple response messages. For example, payment processing can generate an initial status followed by further status updates.

Retain the relevant identifiers and use the service’s documented statuses to determine whether processing is complete.

### Mark messages as processed

After successfully processing a message, mark it as processed using the applicable [Messages Services](https://docs.lhv.com/home/connect/services/messages) operation.

The `DELETE` operation used in the inbox flow represents marking the message as processed. Retrieve, process, and acknowledge each message using its response ID.

For example:

```
POST [base-url]/account-statement
# Submit the request and retain the returned request identifiers.

GET [base-url]/messages/next
# Inspect the message type and its association with a request.
# Process the message successfully in your system.

DELETE [base-url]/messages/[Message-Response-Id]
# Mark that message as processed.
```

For webhooks, a subscription can be configured to mark messages as processed automatically following successful webhook delivery.

Choose the configuration that matches your processing flow. See [Webhook Format and Processing](https://docs.lhv.com/home/connect/services/webhooks/introduction-and-payload-format) for details.

Your integration should handle repeated deliveries without repeating the same business action. Webhook retries and replays can have different event-ID behaviour; use the underlying message identity when preventing duplicate message processing.

### Submit requests safely with idempotency keys

For services supporting idempotency keys, include the optional `X-Idempotency-Key` HTTP header to protect against duplicate request submission.

When supplied, the value must be a valid UUID. Invalid values return HTTP `400 Bad Request`.

For example:

```
X-Idempotency-Key: bfce988a-1bc1-47fc-93d6-a5b8115cea64
```

Generate a new key for each new logical request. Store it with the request before submission so that retries can reuse it, including after an application restart.

When retrying, use the same endpoint, payload, and idempotency key.

#### Uniqueness and duplicate detection

Connect checks uniqueness using the authenticated user ID and the idempotency key. The check applies across endpoints, so the same user must not reuse a key for a different request, even when calling a different endpoint.

Reusing a key returns HTTP `409 Conflict`, regardless of whether the payload is identical or different. Connect does not compare payloads when identifying duplicates.

Use the same key only when retrying the same logical request with the same payload. Generate a new key for a new or modified request.

#### Duplicate-detection window

Connect guarantees duplicate detection for 24 hours after the original submission. During this period, reusing the same key for the same authenticated user returns HTTP `409 Conflict`.

**The 24-hour window is not an expiry time.** After this period, the key may still be rejected, or the request may be accepted and processed again.

Never reuse an old key for a new request.&#x20;

### UK and EE integration considerations

Message availability and supported retrieval operations depend on your integration setup.

With the enhanced UK and EE integration included in your Connect agreement, EE-originating messages are stored in UK Connect and can be subscribed to through UK webhook subscription services.

Other setups use separate EE messaging and webhook services. Check the scope of each endpoint and subscription before implementation.

See [Accessing UK and EE services through UK Connect](https://docs.lhv.com/home/connect/fundamentals/lhv-uk-and-estonia-integrations) for details.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.lhv.com/home/connect/fundamentals/messaging.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
