> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# ListMessages

# Package: inbox

# Namespace: MessagesService

# Method link: https://dev.wix.com/docs/api-reference/crm/communication/inbox/messages/list-messages.md

## Permission Scopes:
Read Inbox Messages: SCOPE.DC-INBOX.READ-MSGS

## Introduction

Retrieves messages between the business and participant.

Up to 30 messages are returned per request. If the number of messages in a conversation is larger than 30,
`pagingMetadata.cursors` is returned in the response, indicating that another page of results is available.
To retrieve the next page of messages, specify the `next` cursor value
in the next request's `paging.cursor` parameter.

To ensure you'll always retrieve the next record,
use the same visibility and sorting
in the first request and all subsequent requests.

By default,
30 messages are retrieved and sorted by `sequence` in descending order
(the most recent messages are first in the list).

---

## REST API

### Schema

```
 Method: listMessages
 Description: Retrieves messages between the business and participant.  Up to 30 messages are returned per request. If the number of messages in a conversation is larger than 30, `pagingMetadata.cursors` is returned in the response, indicating that another page of results is available. To retrieve the next page of messages, specify the `next` cursor value in the next request's `paging.cursor` parameter.  To ensure you'll always retrieve the next record, use the same visibility and sorting in the first request and all subsequent requests.  By default, 30 messages are retrieved and sorted by `sequence` in descending order (the most recent messages are first in the list).
 URL: https://www.wixapis.com/inbox/v2/messages
 Method: GET
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  conversationId
 Method parameters: 
   query param name: conversationId | type: conversationId | description: GUID of the conversation that contains the intended messages. | required: true | validation: format GUID
   param name: paging | type: CursorPaging    
        - name: limit | type: integer | description: Maximum number of items to return in the results.  | validation: minimum 0, maximum 100, format int32
        - name: cursor | type: string | description: Pointer to the next or previous page in the list of results.  Pass the relevant cursor token from the `pagingMetadata` object in the previous call's response. Not relevant for the first request.  | validation: maxLength 16000
   param name: sorting | type: Sorting    
        - name: fieldName | type: string | description: Name of the field to sort by.  | validation: maxLength 512
        - name: order | type: SortOrder | description: Sort order.  
             - enum: ASC, DESC
        - name: origin | type: AddressLocation | description: Origin point for geo-distance sorting on a GEO field results are ordered by distance from this point (ASC = nearest first, DESC = farthest first).  
           - name: latitude | type: number | description: Address latitude.  | validation: format double
           - name: longitude | type: number | description: Address longitude.  | validation: format double
   param name: visibility | type: MessageVisibility    
      - enum:
           UNKNOWN_VISIBILITY - Unknown message visibility.
           BUSINESS_AND_PARTICIPANT - Visible to the participant and site collaborators.
           BUSINESS - Visible to site collaborators only.
 Return type: ListMessagesResponse
  - name: messages | type: array<Message> | description: List of messages between the specified visitor and the site.  
     - name: id | type: string | description: Message GUID.  | read-only: true 
     - name: content | type: MessageContent | description: Structured message content.  
        - ONE-OF: 
           - name: basic | type: BasicMessagePayload | description: Plain text, file, or image message.  
              - name: items | type: array<BasicMessageData> | description: List of plain text messages, images, and/or files. List items are displayed as separate messages in Inbox and the site's chat widget.  | validation: minItems 1
                 - ONE-OF: 
                    - name: text | type: string | description: Text message.  | validation: minLength 1, maxLength 16384
                    - name: image | type: ImageMessage | description: Image message. Can contain an image from Wix Media or from an external provider.  
                       - name: id | type: string | description: Wix Media GUID.  | validation: maxLength 2000
                       - name: url | type: string | description: URL where the image is hosted. This URL is valid for 10 hours from the time the message is sent.  | validation: maxLength 2000
                       - name: filename | type: string | description: File name of the original file.  | validation: maxLength 255
                       - name: width | type: integer | description: Original image width, in pixels.  | validation: minimum 0
                       - name: height | type: integer | description: Original image height, in pixels.  | validation: minimum 0
                       - name: urlExpiration | type: string | description: Expiration date and time of the URL in `YYYY-MM-DDThh:mm:ss.sssZ` format.  | read-only: true | validation: format date-time
                    - name: file | type: FileMessage | description: File attachment. Can contain a file from Wix Media or an external provider.  
                       - name: id | type: string | description: Wix Media GUID.  | validation: maxLength 2000
                       - name: url | type: string | description: URL where the image is hosted. This URL is valid for 10 hours from the time the message is sent.  | validation: maxLength 2000
                       - name: filename | type: string | description: File name of the original file.  | validation: maxLength 255
                       - name: mimeType | type: string | description: File [MIME type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types).  | validation: maxLength 100
                       - name: urlExpiration | type: string | description: Expiration date and time of the URL in `YYYY-MM-DDThh:mm:ss.sssZ` format.  | read-only: true | validation: format date-time
           - name: template | type: TemplateMessagePayload | description: Template containing an image, title, text, and/or up to 10 call-to-action buttons.  
              - name: title | type: string | description: Title displayed in the message.  
              - name: buttons | type: array<Button> | description: List of buttons to display with the message. Buttons can either open a URL or pass interaction details to the Button Interacted event.  Maximum: 10 buttons.  | validation: maxItems 10
                 - name: label | type: string | description: Button label text.  | validation: minLength 1, maxLength 16384
                 - name: launchUrl | type: string | description: If included, the button launches the specified URL.  | validation: maxLength 16384, format WEB_URL
                 - name: postbackProperties | type: PostbackProperties | description: Properties to pass to the Button Interacted event when the button is clicked.  
                    - name: appId | type: string | description: App GUID.  | read-only: true | validation: format GUID
                    - name: interactionId | type: string | description: GUID you define for the interaction, to be handled by your server.  | validation: minLength 1, maxLength 256
              - name: orientation | type: Orientation | description: Controls whether the message is displayed in portrait or landscape layout.  Default: `PORTRAIT`.  
                     - enum:
                     -     UNKNOWN_ORIENTATION: Unknown orientation.
                     -     PORTRAIT: Portrait layout.
                     -     LANDSCAPE: Landscape layout.
              - name: textLines | type: array<string> | description: List of lines of text. Each item in the array is displayed on a new line.  Max: 10 lines (up to 512 characters per line).  | validation: maxItems 10
              - name: imageUrl | type: string | description: URL where the icon is hosted.  | validation: maxLength 2000, format WEB_URL
           - name: minimal | type: MinimalMessagePayload | description: Minimal message containing a single line of text and an optional icon. Often reports an activity that took place.  
              - name: text | type: string | description: Message text.  | validation: minLength 1, maxLength 16384
              - name: iconUrl | type: string | description: URL where the icon is hosted.  | validation: maxLength 2000, format WEB_URL
              - name: url | type: string | description: If included, URL the user is redirected to when clicking the message.  | validation: maxLength 2000, format WEB_URL
           - name: form | type: FormMessagePayload | description: Message containing submitted form data. Typically sent with a `direction` of `PARTICIPANT_TO_BUSINESS` and message `visibility` of `BUSINESS`.  
              - name: title | type: string | description: Form title displayed in the message.  | validation: minLength 1, maxLength 256
              - name: description | type: string | description: Form description displayed below the title.  | validation: minLength 1, maxLength 16384
              - name: fields | type: array<FormField> | description: List of form fields and values.  | validation: minItems 1, maxItems 30
                 - name: name | type: string | description: Form field display name.  | validation: maxLength 8192
                 - name: value | type: string | description: Submitted value.  | validation: maxLength 8192
              - name: media | type: array<MediaItem> | description: List of files and/or images attached to the form.  List items are displayed as separate messages in Inbox and the site's chat widget.  | validation: maxItems 15
                 - ONE-OF: 
                    - name: image | type: ImageMessage | description: Image message. Can contain an image from Wix Media or from an external provider.  
                    - name: file | type: FileMessage | description: File attachment. Can contain a file from Wix Media or an external provider.  
           - name: system | type: SystemMessagePayload | description: System message. For internal use.  
              - name: text | type: string | description: Text message. `\n` renders as a line break.  | validation: maxLength 16384
              - name: buttons | type: array<Button> | description: List of buttons to display with the message. Buttons can either open a URL or pass interaction details to the Button Interacted event.  Maximum: 10 buttons.  | validation: maxItems 10
              - name: imageUrl | type: string | description: URL where the icon is hosted.  | validation: maxLength 2000, format WEB_URL
        - name: previewText | type: string | description: Summary of message contents. Displayed in Inbox in the [Message List](https://support.wix.com/en/article/wix-inbox-an-overview).  | validation: maxLength 256
        - name: title | type: string | description: Message title.  
     - name: sender | type: IdentificationData | description: GUID of the message sender.  Defaults to the caller's GUID using the property that matches their identity type. For 3rd-party apps, defaults to using the app's `appId`.  You can override the default behavior when calling the Send Message method by using the `sendAs` parameter.  | read-only: true 
        - ONE-OF: 
           - name: anonymousVisitorId | type: string | description: Anonymous site visitor GUID.  | validation: format GUID
           - name: memberId | type: string | description: Member GUID. See the Members API for more information.  | validation: format GUID
           - name: wixUserId | type: string | description: GUID of the Wix user.  | validation: format GUID
           - name: appId | type: string | description: App GUID.  | validation: format GUID
        - name: contactId | type: string | description: Contact GUID. See the Contacts API for more information.  | read-only: true | validation: format GUID
     - name: badges | type: array<Badge> | description: Optional icon and short text providing additional details about the message, such as the app from which the message was sent, or whether the message was an automated response.  Currently only 1 badge is supported.  | validation: maxItems 1
        - name: text | type: string | description: Display text.  
        - name: iconUrl | type: string | description: URL where the icon is hosted.  | validation: format WEB_URL
        - name: badgeVisibility | type: BadgeVisibility | description: Controls whether the badge is visible to the participant. Currently not supported in the Chat widget.  
             - enum:
             -     UNKNOWN_BADGE_VISIBILITY: Unkown visibility.
             -     BUSINESS_AND_PARTICIPANT: Visible to the participant and site collaborators.
             -     BUSINESS: Visible to site collaborators only.
     - name: appId | type: string | description: GUID of the app that sent the message.  Omitted if the message was sent with the Chat widget.  | read-only: true | validation: format GUID
     - name: visibility | type: MessageVisibility | description: __Required.__ Controls who can see the message.  
         - enum:
         -     UNKNOWN_VISIBILITY: Unknown message visibility.
         -     BUSINESS_AND_PARTICIPANT: Visible to the participant and site collaborators.
         -     BUSINESS: Visible to site collaborators only.
     - name: sequence | type: string | description: Sequential ordering of the message.  Ensures more accurate sorting than `createdDate` if two messages are sent at the same time.  | read-only: true | validation: format int64
     - name: direction | type: MessageDirection | description: __Required.__ Message direction.  
         - enum:
         -     UNKNOWN_DIRECTION: Unknown message direction.
         -     BUSINESS_TO_PARTICIPANT: The message was sent from the business to the participant.
         -     PARTICIPANT_TO_BUSINESS: The message was sent from the participant to the business.
     - name: createdDate | type: string | description: Date and time the message was sent.  | validation: format date-time
     - name: targetChannelIds | type: array<string> | description: Target channel GUIDs to send the message to.  | validation: maxItems 100, maxLength 100
     - name: sourceChannelId | type: string | description: The channel GUID from which the message was sent.  | validation: maxLength 100
     - name: silent | type: boolean | description: Controls whether the unread count and conversation summary are updated in the [Message List](https://support.wix.com/en/article/wix-inbox-an-overview).  If `true`, unread count and conversation summary are not updated.  Default: `false`  
     - name: edited | type: boolean | description: Whether the message was edited on the channel it came from.  | read-only: true 
     - name: editedDate | type: string | description: Date and time the message was last edited on the channel it came from. Omitted if it was never edited.  | read-only: true | validation: format date-time
  - name: pagingMetadata | type: PagingMetadataV2 | description: Details on the paged set of results returned.  
     - name: count | type: integer | description: Number of items returned in the response.  | validation: format int32
     - name: offset | type: integer | description: Offset that was requested.  | validation: format int32
     - name: total | type: integer | description: Total number of items that match the query. Returned if offset paging is used and the `tooManyToCount` flag is not set.  | validation: format int32
     - name: tooManyToCount | type: boolean | description: Flag that indicates the server failed to calculate the `total` field.  
     - name: cursors | type: Cursors | description: Cursors to navigate through the result pages using `next` and `prev`. Returned if cursor paging is used.  
        - name: next | type: string | description: Cursor string pointing to the next page in the list of results.  | validation: maxLength 16000
        - name: prev | type: string | description: Cursor pointing to the previous page in the list of results.  | validation: maxLength 16000

 Possible Errors:
   HTTP Code: 401 | Status Code: UNAUTHENTICATED | Application Code: NOT_JOINED_CHATROOM | Description: Not joined to chatroom.
   HTTP Code: 401 | Status Code: UNAUTHENTICATED | Application Code: NO_INBOX_INSTANCE | Description: No inbox instance available.
   HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: INBOX_INSTANCE_NOT_FOUND | Description: Inbox instance not found.
   HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: CONVERSATION_NOT_FOUND | Description: Conversation not found.


```

### Examples

### ListMessages
```curl
~~~cURL
curl -X GET \
'https://www.wixapis.com/inbox/v2/messages?conversationId=6202c3bb-f263-3c16-8c90-d6387d9ed420&visibility=BUSINESS_AND_PARTICIPANT' \
-H 'Authorization: <AUTH>'
~~~
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.inbox.messages.listMessages(conversationId, visibility, options)
 Description: Retrieves messages between the business and participant.  Up to 30 messages are returned per request. If the number of messages in a conversation is larger than 30, `pagingMetadata.cursors` is returned in the response, indicating that another page of results is available. To retrieve the next page of messages, specify the `next` cursor value in the next request's `paging.cursor` parameter.  To ensure you'll always retrieve the next record, use the same visibility and sorting in the first request and all subsequent requests.  By default, 30 messages are retrieved and sorted by `sequence` in descending order (the most recent messages are first in the list).
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  conversationId, visibility
 Method parameters: 
   param name: conversationId | type: string | description: GUID of the conversation that contains the intended messages. | required: true | validation: format GUID
   param name: visibility | type: MessageVisibility   | required: true 
      - enum:
           UNKNOWN_VISIBILITY - Unknown message visibility.
           BUSINESS_AND_PARTICIPANT - Visible to the participant and site collaborators.
           BUSINESS - Visible to site collaborators only.
   param name: options | type: ListMessagesOptions  none  
        - name: paging | type: CursorPaging | description:   
           - name: limit | type: integer | description: Maximum number of items to return in the results.  | validation: minimum 0, maximum 100, format int32
           - name: cursor | type: string | description: Pointer to the next or previous page in the list of results.  Pass the relevant cursor token from the `pagingMetadata` object in the previous call's response. Not relevant for the first request.  | validation: maxLength 16000
        - name: sorting | type: Sorting | description: only message_sequence is supported for field name  
           - name: fieldName | type: string | description: Name of the field to sort by.  | validation: maxLength 512
           - name: order | type: SortOrder | description: Sort order.  
                 - enum: ASC, DESC
           - name: origin | type: AddressLocation | description: Origin point for geo-distance sorting on a GEO field results are ordered by distance from this point (ASC = nearest first, DESC = farthest first).  
              - name: latitude | type: number | description: Address latitude.  
              - name: longitude | type: number | description: Address longitude.  
 Return type: PROMISE<ListMessagesResponse>
  - name: messages | type: array<Message> | description: List of messages between the specified visitor and the site.  
     - name: _id | type: string | description: Message GUID.  | read-only: true 
     - name: content | type: MessageContent | description: Structured message content.  
        - ONE-OF: 
           - name: basic | type: BasicMessagePayload | description: Plain text, file, or image message.  
              - name: items | type: array<BasicMessageData> | description: List of plain text messages, images, and/or files. List items are displayed as separate messages in Inbox and the site's chat widget.  | validation: minItems 1
                 - ONE-OF: 
                    - name: text | type: string | description: Text message.  | validation: minLength 1, maxLength 16384
                    - name: image | type: ImageMessage | description: Image message. Can contain an image from Wix Media or from an external provider.  
                       - name: _id | type: string | description: Wix Media GUID.  | validation: maxLength 2000
                       - name: url | type: string | description: URL where the image is hosted. This URL is valid for 10 hours from the time the message is sent.  | validation: maxLength 2000
                       - name: filename | type: string | description: File name of the original file.  | validation: maxLength 255
                       - name: width | type: integer | description: Original image width, in pixels.  | validation: minimum 0
                       - name: height | type: integer | description: Original image height, in pixels.  | validation: minimum 0
                       - name: urlExpiration | type: Date | description: Expiration date and time of the URL in `YYYY-MM-DDThh:mm:ss.sssZ` format.  | read-only: true 
                    - name: file | type: FileMessage | description: File attachment. Can contain a file from Wix Media or an external provider.  
                       - name: _id | type: string | description: Wix Media GUID.  | validation: maxLength 2000
                       - name: url | type: string | description: URL where the image is hosted. This URL is valid for 10 hours from the time the message is sent.  | validation: maxLength 2000
                       - name: filename | type: string | description: File name of the original file.  | validation: maxLength 255
                       - name: mimeType | type: string | description: File [MIME type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types).  | validation: maxLength 100
                       - name: urlExpiration | type: Date | description: Expiration date and time of the URL in `YYYY-MM-DDThh:mm:ss.sssZ` format.  | read-only: true 
           - name: template | type: TemplateMessagePayload | description: Template containing an image, title, text, and/or up to 10 call-to-action buttons.  
              - name: title | type: string | description: Title displayed in the message.  
              - name: buttons | type: array<Button> | description: List of buttons to display with the message. Buttons can either open a URL or pass interaction details to the Button Interacted event.  Maximum: 10 buttons.  | validation: maxItems 10
                 - name: label | type: string | description: Button label text.  | validation: minLength 1, maxLength 16384
                 - name: launchUrl | type: string | description: If included, the button launches the specified URL.  | validation: maxLength 16384, format WEB_URL
                 - name: postbackProperties | type: PostbackProperties | description: Properties to pass to the Button Interacted event when the button is clicked.  
                    - name: appId | type: string | description: App GUID.  | read-only: true | validation: format GUID
                    - name: interactionId | type: string | description: GUID you define for the interaction, to be handled by your server.  | validation: minLength 1, maxLength 256
              - name: orientation | type: Orientation | description: Controls whether the message is displayed in portrait or landscape layout.  Default: `PORTRAIT`.  
                     - enum:
                     -     UNKNOWN_ORIENTATION: Unknown orientation.
                     -     PORTRAIT: Portrait layout.
                     -     LANDSCAPE: Landscape layout.
              - name: textLines | type: array<string> | description: List of lines of text. Each item in the array is displayed on a new line.  Max: 10 lines (up to 512 characters per line).  | validation: maxItems 10
              - name: imageUrl | type: string | description: URL where the icon is hosted.  | validation: maxLength 2000, format WEB_URL
           - name: minimal | type: MinimalMessagePayload | description: Minimal message containing a single line of text and an optional icon. Often reports an activity that took place.  
              - name: text | type: string | description: Message text.  | validation: minLength 1, maxLength 16384
              - name: iconUrl | type: string | description: URL where the icon is hosted.  | validation: maxLength 2000, format WEB_URL
              - name: url | type: string | description: If included, URL the user is redirected to when clicking the message.  | validation: maxLength 2000, format WEB_URL
           - name: form | type: FormMessagePayload | description: Message containing submitted form data. Typically sent with a `direction` of `PARTICIPANT_TO_BUSINESS` and message `visibility` of `BUSINESS`.  
              - name: title | type: string | description: Form title displayed in the message.  | validation: minLength 1, maxLength 256
              - name: description | type: string | description: Form description displayed below the title.  | validation: minLength 1, maxLength 16384
              - name: fields | type: array<FormField> | description: List of form fields and values.  | validation: minItems 1, maxItems 30
                 - name: name | type: string | description: Form field display name.  | validation: maxLength 8192
                 - name: value | type: string | description: Submitted value.  | validation: maxLength 8192
              - name: media | type: array<MediaItem> | description: List of files and/or images attached to the form.  List items are displayed as separate messages in Inbox and the site's chat widget.  | validation: maxItems 15
                 - ONE-OF: 
                    - name: image | type: ImageMessage | description: Image message. Can contain an image from Wix Media or from an external provider.  
                    - name: file | type: FileMessage | description: File attachment. Can contain a file from Wix Media or an external provider.  
           - name: system | type: SystemMessagePayload | description: System message. For internal use.  
              - name: text | type: string | description: Text message. `\n` renders as a line break.  | validation: maxLength 16384
              - name: buttons | type: array<Button> | description: List of buttons to display with the message. Buttons can either open a URL or pass interaction details to the Button Interacted event.  Maximum: 10 buttons.  | validation: maxItems 10
              - name: imageUrl | type: string | description: URL where the icon is hosted.  | validation: maxLength 2000, format WEB_URL
        - name: previewText | type: string | description: Summary of message contents. Displayed in Inbox in the [Message List](https://support.wix.com/en/article/wix-inbox-an-overview).  | validation: maxLength 256
        - name: title | type: string | description: Message title.  
     - name: sender | type: IdentificationData | description: GUID of the message sender.  Defaults to the caller's GUID using the property that matches their identity type. For 3rd-party apps, defaults to using the app's `appId`.  You can override the default behavior when calling the Send Message method by using the `sendAs` parameter.  | read-only: true 
        - ONE-OF: 
           - name: anonymousVisitorId | type: string | description: Anonymous site visitor GUID.  | validation: format GUID
           - name: memberId | type: string | description: Member GUID. See the Members API for more information.  | validation: format GUID
           - name: wixUserId | type: string | description: GUID of the Wix user.  | validation: format GUID
           - name: appId | type: string | description: App GUID.  | validation: format GUID
        - name: contactId | type: string | description: Contact GUID. See the Contacts API for more information.  | read-only: true | validation: format GUID
     - name: badges | type: array<Badge> | description: Optional icon and short text providing additional details about the message, such as the app from which the message was sent, or whether the message was an automated response.  Currently only 1 badge is supported.  | validation: maxItems 1
        - name: text | type: string | description: Display text.  
        - name: iconUrl | type: string | description: URL where the icon is hosted.  | validation: format WEB_URL
        - name: badgeVisibility | type: BadgeVisibility | description: Controls whether the badge is visible to the participant. Currently not supported in the Chat widget.  
             - enum:
             -     UNKNOWN_BADGE_VISIBILITY: Unkown visibility.
             -     BUSINESS_AND_PARTICIPANT: Visible to the participant and site collaborators.
             -     BUSINESS: Visible to site collaborators only.
     - name: appId | type: string | description: GUID of the app that sent the message.  Omitted if the message was sent with the Chat widget.  | read-only: true | validation: format GUID
     - name: visibility | type: MessageVisibility | description: __Required.__ Controls who can see the message.  
         - enum:
         -     UNKNOWN_VISIBILITY: Unknown message visibility.
         -     BUSINESS_AND_PARTICIPANT: Visible to the participant and site collaborators.
         -     BUSINESS: Visible to site collaborators only.
     - name: sequence | type: string | description: Sequential ordering of the message.  Ensures more accurate sorting than `createdDate` if two messages are sent at the same time.  | read-only: true | validation: format int64
     - name: direction | type: MessageDirection | description: __Required.__ Message direction.  
         - enum:
         -     UNKNOWN_DIRECTION: Unknown message direction.
         -     BUSINESS_TO_PARTICIPANT: The message was sent from the business to the participant.
         -     PARTICIPANT_TO_BUSINESS: The message was sent from the participant to the business.
     - name: _createdDate | type: Date | description: Date and time the message was sent.  
     - name: targetChannelIds | type: array<string> | description: Target channel GUIDs to send the message to.  | validation: maxItems 100, maxLength 100
     - name: sourceChannelId | type: string | description: The channel GUID from which the message was sent.  | validation: maxLength 100
     - name: silent | type: boolean | description: Controls whether the unread count and conversation summary are updated in the [Message List](https://support.wix.com/en/article/wix-inbox-an-overview).  If `true`, unread count and conversation summary are not updated.  Default: `false`  
     - name: edited | type: boolean | description: Whether the message was edited on the channel it came from.  | read-only: true 
     - name: editedDate | type: Date | description: Date and time the message was last edited on the channel it came from. Omitted if it was never edited.  | read-only: true 
  - name: pagingMetadata | type: PagingMetadataV2 | description: Details on the paged set of results returned.  
     - name: count | type: integer | description: Number of items returned in the response.  | validation: format int32
     - name: offset | type: integer | description: Offset that was requested.  | validation: format int32
     - name: total | type: integer | description: Total number of items that match the query. Returned if offset paging is used and the `tooManyToCount` flag is not set.  | validation: format int32
     - name: tooManyToCount | type: boolean | description: Flag that indicates the server failed to calculate the `total` field.  
     - name: cursors | type: Cursors | description: Cursors to navigate through the result pages using `next` and `prev`. Returned if cursor paging is used.  
        - name: next | type: string | description: Cursor string pointing to the next page in the list of results.  | validation: maxLength 16000
        - name: prev | type: string | description: Cursor pointing to the previous page in the list of results.  | validation: maxLength 16000

 Possible Errors:
   HTTP Code: 401 | Status Code: UNAUTHENTICATED | Application Code: NOT_JOINED_CHATROOM | Description: Not joined to chatroom.
   HTTP Code: 401 | Status Code: UNAUTHENTICATED | Application Code: NO_INBOX_INSTANCE | Description: No inbox instance available.
   HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: INBOX_INSTANCE_NOT_FOUND | Description: Inbox instance not found.
   HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: CONVERSATION_NOT_FOUND | Description: Conversation not found.


```

### Examples

### View a list of sent messages (with elevated permissions)
```javascript
import { messages } from '@wix/inbox';
import { auth } from '@wix/essentials';

/* Sample conversationId value: '9ac410b1-17f8-3b10-a3f4-0dd5c295d510'
 * 
 * Sample visibility value: 'BUSINESS_AND_PARTICIPANT'
 */

const elevatedListMessages = auth.elevate(messages.listMessages);

export async function myListMessagesFunction(conversationId, visibility) {
  
  try {
    const messageList = await elevatedListMessages(conversationId, visibility);
    const firstSender = messageList.messages[0].sender;
    
    return messageList;
  } catch(error) {
    console.error(error);
    // Handle the error
  }
}

/* Promise resolves to:
 * {
 *   "messages": [
 *     {
 *       "_createdDate": "2023-12-28T09:41:06.660Z",
 *       "_id": "1703756466660667",
 *       "appId": "14517e1a-3ff0-af98-408e-2bd6953c36a2",
 *       "badges": [],
 *       "content": {
 *         "previewText": "thanks for the content",
 *         "basic": {
 *           "items": [
 *             {
 *               "text": "thanks for the content"
 *             }
 *           ]
 *         },
 *       },
 *       "direction": "PARTICIPANT_TO_BUSINESS",
 *       "sender": {
 *         "anonymousVisitorId": "3c06d38d-1433-4889-b303-1ff1779176e6"
 *       },
 *       "sequence": "1703756466660667",
 *       "sourceChannel": "UNKNOWN_CHANNEL_TYPE",
 *       "targetChannels": [],
 *       "visibility": "BUSINESS_AND_PARTICIPANT",
 *     },
 *     {
 *       "_createdDate": "2023-12-27T16:16:07.816Z",
 *       "_id": "1703693767816923",
 *       "badges": [],
 *       "content": {
 *         "previewText": "Thanks for the like :)",
 *         "basic": {
 *           "items": [
 *             {
 *               "text": "Thanks for the like :)"
 *             }
 *           ]
 *         },
 *       },
 *       "direction": "BUSINESS_TO_PARTICIPANT",
 *       "sender": {
 *         "wixUserId": "b17c523c-6ec9-4b56-9d9d-123cc6978bdf"
 *       },
 *       "sequence": "1703693767816923",
 *       "sourceChannel": "UNKNOWN_CHANNEL_TYPE",
 *       "targetChannels": [
 *         "CHAT"
 *       ],
 *       "visibility": "BUSINESS_AND_PARTICIPANT",
 *     }
 *   ],
 *   "pagingMetadata": {
 *     "tooManyToCount": true
 *   }
 * }
 */

```

### View a list of sent messages
```javascript
import { messages } from '@wix/inbox';

/* Sample conversationId value: '9ac410b1-17f8-3b10-a3f4-0dd5c295d510'
 * 
 * Sample visibility value: 'BUSINESS_AND_PARTICIPANT'
 */

export async function myListMessagesFunction(conversationId, visibility) {
  
  try {
    const messageList = await messages.listMessages(conversationId, visibility);
    const firstSender = messageList.messages[0].sender;
    
    return messageList;
  } catch(error) {
    console.error(error);
    // Handle the error
  }
}

/* Promise resolves to:
 * {
 *   "messages": [
 *     {
 *       "_createdDate": "2023-12-28T09:41:06.660Z",
 *       "_id": "1703756466660667",
 *       "appId": "14517e1a-3ff0-af98-408e-2bd6953c36a2",
 *       "badges": [],
 *       "content": {
 *         "previewText": "thanks for the content",
 *         "basic": {
 *           "items": [
 *             {
 *               "text": "thanks for the content"
 *             }
 *           ]
 *         },
 *       },
 *       "direction": "PARTICIPANT_TO_BUSINESS",
 *       "sender": {
 *         "anonymousVisitorId": "3c06d38d-1433-4889-b303-1ff1779176e6"
 *       },
 *       "sequence": "1703756466660667",
 *       "sourceChannel": "UNKNOWN_CHANNEL_TYPE",
 *       "targetChannels": [],
 *       "visibility": "BUSINESS_AND_PARTICIPANT",
 *     },
 *     {
 *       "_createdDate": "2023-12-27T16:16:07.816Z",
 *       "_id": "1703693767816923",
 *       "badges": [],
 *       "content": {
 *         "previewText": "Thanks for the like :)",
 *         "basic": {
 *           "items": [
 *             {
 *               "text": "Thanks for the like :)"
 *             }
 *           ]
 *         },
 *       },
 *       "direction": "BUSINESS_TO_PARTICIPANT",
 *       "sender": {
 *         "wixUserId": "b17c523c-6ec9-4b56-9d9d-123cc6978bdf"
 *       },
 *       "sequence": "1703693767816923",
 *       "sourceChannel": "UNKNOWN_CHANNEL_TYPE",
 *       "targetChannels": [
 *         "CHAT"
 *       ],
 *       "visibility": "BUSINESS_AND_PARTICIPANT",
 *     }
 *   ],
 *   "pagingMetadata": {
 *     "tooManyToCount": true
 *   }
 * }
 */
```

### listMessages (self-managed)
Self-managed SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).

```javascript
import { createClient } from '@wix/sdk';
import { messages } from '@wix/inbox';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { messages },
  // Include the auth strategy and host as relevant
});


async function listMessages(conversationId,visibility,options) {
  const response = await myWixClient.messages.listMessages(conversationId,visibility,options);
};
```

---