---
title: "Get last message metadata for user chats"
method: GET
path: "/api/chat/chats/last-messages"
tags: ["chat"]
---

# Get last message metadata for user chats

`GET /api/chat/chats/last-messages`

Get last message metadata (id/sender/timestamp/preview) for each chat visible to the current user.

## Query parameters

- `device_id` string, uuid, nullable — Optional device UUID to filter encrypted payload

## Response `200`

Successful Response

- ChatsLastMessagesResponse — Last message metadata for all user chats.
  - `items` ChatLastMessageResponse[], required — Last-message entries by chat
    - `chat_id` string, required — Chat UUID
    - `message_id` string, nullable — Last message UUID
    - `sender_id` string, nullable — Last message sender user UUID
    - `created_at` string, date-time, nullable — Last message timestamp
    - `preview` string, nullable — Safe preview text for encrypted message
    - `encrypted_messages` EncryptedMessageData[], nullable — Encrypted payload(s) for this message (optionally filtered by device_id)
      - `device_id` string, required — Device UUID this message/attachment is encrypted for
      - `encrypted_content` string, nullable — Base64 encrypted message/attachment content. Required for messages, optional for attachments (file is stored separately in storage).
      - `encrypted_aes_key` string, required — Base64 encrypted AES key (encrypted with device RSA public key)
      - `iv` string, required — Base64 initialization vector for AES-GCM
      - `encrypted_at` string, date-time, required — When this message/attachment was encrypted for this device
    - `encryption_version` string, nullable — Encryption version
    - `content_length` integer, nullable — Original message length
    - `read_at` string, date-time, nullable — When the last message was marked as read
    - `is_read` boolean — Whether the last message has been read

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.dev/corabea/apis/corabea-api.md) · [All operations](https://skmtc.dev/corabea/apis/corabea-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/corabea/corabea-api/revisions/13c1bce1bdc4/schema)
