> ## Documentation Index
> Fetch the complete documentation index at: https://developer.omni.z-api.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Mark message as read

> Mark as read a message received from the contact

## Overview

Method for marking as read a message the channel received from the contact. It works on **Official WhatsApp** channels (Meta official API) and on **WhatsApp Web** channels, with WhatsApp Web enabled in the workspace.

## Attributes

| Attribute | Use |
| - | - |
| `messageId` | Required. The `messageId` that came in the received message webhook. |
| `phone` | Required, as in Z-API, but not used: the message is found by the `messageId`. |

The body goes as JSON or as a form (`application/x-www-form-urlencoded` or `multipart/form-data`).

The success response is `200`:

```json theme={null}
{ "value": true }
```

## Differences from Z-API

* The `messageId` is the message id in Omni Z-API, the same one that comes in the webhook. In the default webhook format, it is `message._id`. It is not the message id in WhatsApp.
* On Official WhatsApp, Meta's API (Cloud API) also marks as read the earlier messages of the conversation.
* A message sent by the channel itself answers `200`, with no effect.

> [!NOTE]
>
> On Official WhatsApp, [`send-text`](https://developer.omni.z-api.io/en/z-api/messages/send-text) with `delayTyping` also marks as read the last message received from the contact, because Meta only shows "typing" together with the read. If you use that option, the message shows as read without a call to this route.

## Errors

| Status | `error` | When |
| - | - | - |
| `400` | `phone is required` / `messageId is required` | `phone` or `messageId` missing or empty |
| `400` | `messageId is invalid` | `messageId` is `.` or `..` |
| `400` | Varies, such as `invalid character 'n' looking for beginning of object key string` | The body could not be read, such as malformed JSON |
| `404` | `message not found` | The message does not exist or belongs to another channel, with the channel connected |
| `422` | `message cannot be marked as read: it has no id at the channel provider` | The message has no WhatsApp id |
| `422` | `channel is disconnected` | The channel is disconnected. It applies to any `messageId`, even one that does not exist: the connection is checked before the message |
| `422` | `the channel provider refused the request` | The channel provider refused the read |
| `422` | `instance subscription is not active` | The channel subscription is not active |
| `422` | `Z-API (WhatsApp Web) instances are not enabled for this workspace` | WhatsApp Web channel, with WhatsApp Web not enabled in the workspace |
| `422` | `the Z-API instance of this channel is not provisioned` | WhatsApp Web channel whose instance is not provisioned yet. It is checked before the message |
| `422` | `message cannot be marked as read: its chat is not supported` | WhatsApp Web channel, with a message from a chat the route does not serve |
| `422` | `message action route is not available for <type> channels; ...` | The channel is neither Official WhatsApp nor WhatsApp Web, such as a Telegram channel |
| `502` | `failed to mark message as read` | Failed to mark as read |

The refusal by channel type ends with `available only on Z-API (WhatsApp Web) instances`. That ending is the same for every refused route. This route also works on Official WhatsApp.

The API does not repeat the call after a `502`. You can call again.


## OpenAPI

````yaml en/z-api/openapi.json POST /read-message
openapi: 3.1.0
info:
  title: Omni Z-API - Z-API Compatibility
  description: Z-API compatible API to facilitate migration to Omni Z-API
  version: 1.0.0
servers:
  - url: https://zapi.omni.z-api.io/channels/{channel_id}/token/{channel_token}
    variables:
      channel_id:
        description: Channel ID (equivalent to Z-API instance_id)
        default: YOUR_CHANNEL
      channel_token:
        description: Channel token (equivalent to Z-API token)
        default: YOUR_TOKEN
security:
  - bearerAuth: []
paths:
  /read-message:
    post:
      tags:
        - Messages
      summary: Mark message as read
      description: >-
        Marks as read a message the channel received from the contact. It works
        on Official WhatsApp channels and on WhatsApp Web channels, with
        WhatsApp Web enabled in the workspace. The body goes as JSON or as a
        form (`application/x-www-form-urlencoded` or `multipart/form-data`). The
        `messageId` is the one that came in the received message webhook;
        `phone` is required, but not used.
      operationId: readMessage
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReadMessageRequest'
            example:
              phone: '5511999999999'
              messageId: 019E6F1A93FE78DCB54332F9FF0CCAE7
      responses:
        '200':
          description: >-
            Message marked as read. A message sent by the channel itself also
            answers `200`, with no effect.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ReadMessageResponse'
              example:
                value: true
        '400':
          description: >-
            `phone` or `messageId` missing or empty, `messageId` equal to `.` or
            `..`, or a body that could not be read, such as malformed JSON. For
            a body that could not be read, the text describes the reading error.
            Nothing is marked.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ReadMessageError'
              examples:
                messageIdRequired:
                  summary: Missing messageId
                  value:
                    error: messageId is required
                messageIdInvalid:
                  summary: Invalid messageId
                  value:
                    error: messageId is invalid
                malformedBody:
                  summary: Malformed JSON
                  value:
                    error: >-
                      invalid character 'n' looking for beginning of object key
                      string
        '404':
          description: >-
            The message does not exist or belongs to another channel, with the
            channel connected. With the channel disconnected, the answer is
            `422` with `channel is disconnected`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ReadMessageError'
              example:
                error: message not found
        '405':
          $ref: '#/components/responses/MethodNotAllowed'
        '422':
          description: >-
            The message cannot be marked as read: it has no WhatsApp id, the
            channel is disconnected, the channel provider refused, or the
            channel subscription is not active. The connection is checked before
            the message: with the channel disconnected, any `messageId` gets
            `channel is disconnected`, even one that does not exist. On a
            WhatsApp Web channel, `422` also comes for a workspace without
            WhatsApp Web enabled, an instance not provisioned yet (checked
            before the message) and a message from a chat the route does not
            serve. A channel that is neither Official WhatsApp nor WhatsApp Web,
            such as Telegram, gets `422` with the channel type in the text. That
            text ends with `available only on Z-API (WhatsApp Web) instances`,
            the same ending of every refused route; this route also works on
            Official WhatsApp.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ReadMessageError'
              examples:
                channelDisconnected:
                  summary: Channel disconnected
                  value:
                    error: channel is disconnected
                channelType:
                  summary: Telegram channel
                  value:
                    error: >-
                      message action route is not available for BOT_TELEGRAM
                      channels; available only on Z-API (WhatsApp Web) instances
                zapiDisabled:
                  summary: WhatsApp Web not enabled in the workspace
                  value:
                    error: >-
                      Z-API (WhatsApp Web) instances are not enabled for this
                      workspace
                notProvisioned:
                  summary: WhatsApp Web instance not provisioned
                  value:
                    error: the Z-API instance of this channel is not provisioned
                chatNotSupported:
                  summary: Chat not served on WhatsApp Web
                  value:
                    error: >-
                      message cannot be marked as read: its chat is not
                      supported
        '502':
          description: >-
            Failed to mark as read. The API does not repeat the call: you can
            call again.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ReadMessageError'
              example:
                error: failed to mark message as read
components:
  schemas:
    ReadMessageRequest:
      type: object
      required:
        - phone
        - messageId
      properties:
        phone:
          type: string
          description: >-
            Contact phone number (country code + area code + number). Required,
            as in Z-API, but not used
          example: '5511999999999'
        messageId:
          type: string
          description: >-
            The `messageId` of the received message, as it came in the webhook.
            It is the message id in Omni Z-API, not the WhatsApp id
          example: 019E6F1A93FE78DCB54332F9FF0CCAE7
    ReadMessageResponse:
      type: object
      properties:
        value:
          type: boolean
          description: '`true` when the read was accepted'
    ReadMessageError:
      type: object
      properties:
        error:
          type: string
          description: Error message
    Error:
      type: object
      properties:
        error:
          type: string
          description: Error message
  responses:
    MethodNotAllowed:
      description: >-
        HTTP method the route does not accept. The `error` and the `Allow`
        header list the methods the route accepts; on the send routes, only
        `POST`.
      headers:
        Allow:
          description: Methods the route accepts, separated by commas
          schema:
            type: string
          example: POST
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: 'method not allowed: use POST'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Secret Key generated in the Omni Z-API Security panel

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.