# List messages by channel identity Retrieves the last message sent to specified channel identities. In CONVERSATION_SOURCE mode, you can query either by channel_identities or by contact_ids. Note: Use either contact_ids OR channel_identities per request, not both. DISPATCH_SOURCE mode does not support contact_ids. Endpoint: POST /v1/projects/{project_id}/messages:fetch-last-message Version: 1.0 Security: Basic, oAuth2 ## Path parameters: - `project_id` (string, required) The unique ID of the project. You can find this on the Sinch Dashboard. ## Request fields (application/json): - `channel_identities` (array) Optional. Filter messages by channel_identity. - `contact_ids` (array) Optional. Resource name (id) of the contact. In case the messages source is set to CONVERSATION_SOURCE: Can list last messages by contact_id. In case the messages source is set to DISPATCH_SOURCE: The field is unsupported and cannot be set. - `app_id` (string) Optional. Resource name (id) of the app. - `messages_source` (string) Specifies the message source for which the request will be processed. Used for operations on messages in Dispatch Mode. For more information, see [Processing Modes](https://developers.sinch.com/docs/conversation/processing-modes/). Enum: "CONVERSATION_SOURCE", "DISPATCH_SOURCE" - `page_size` (integer) Optional. Maximum number of messages to fetch. Defaults to 10 and the maximum is 1000. - `page_token` (string) Optional. Next page token previously returned if any. - `view` (string) Optional. Specifies the representation in which messages should be returned. Default to WITH_METADATA. Enum: "WITH_METADATA", "WITHOUT_METADATA" - `start_time` (string) Optional. Only fetch messages with accept_time after this date. - `end_time` (string) Optional. Only fetch messages with accept_time before this date. - `channel` (string) Optional. Only fetch messages from the channel. Enum: "WHATSAPP", "RCS", "SMS", "MESSENGER", "VIBERBM", "MMS", "INSTAGRAM", "TELEGRAM", "KAKAOTALK", "KAKAOTALKCHAT", "LINE", "WECHAT", "APPLEBC" - `direction` (string) Optional. Only fetch messages with the specified direction. If direction is not specified, it will list both TO_APP and TO_CONTACT messages. Enum: "TO_APP", "TO_CONTACT" ## Response 200 fields (application/json): - `messages` (array) List of messages associated to the referenced conversation. - `messages.accept_time` (string) The time Conversation API processed the message. - `messages.channel_identity` (object) A unique identity of message recipient on a particular channel. For example, the channel identity on SMS, WHATSAPP or VIBERBM is a MSISDN phone number. - `messages.channel_identity.identity` (string, required) The channel identity. This will differ from channel to channel. For example, a phone number for SMS, WhatsApp, and Viber Business. - `messages.channel_identity.channel` (string, required) The identifier of the channel you want to include. Must be one of the enum values. Enum: "WHATSAPP", "RCS", "SMS", "MESSENGER", "VIBERBM", "MMS", "INSTAGRAM", "TELEGRAM", "KAKAOTALK", "KAKAOTALKCHAT", "LINE", "WECHAT", "APPLEBC" - `messages.channel_identity.app_id` (string) Required if using a channel that uses app-scoped channel identities. Currently, FB Messenger, Instagram, LINE, and WeChat use app-scoped channel identities, which means contacts will have different channel identities on different Conversation API apps. These can be thought of as virtual identities that are app-specific and, therefore, the app_id must be included in the API call. - `messages.contact_id` (string) The ID of the contact. - `messages.conversation_id` (string) The ID of the conversation. - `messages.direction` (string) The direction of the message flow, indicating whether the message was sent to or from the Conversation API app. Enum: "TO_APP", "TO_CONTACT" - `messages.id` (string) The ID of the message. - `messages.metadata` (string) Optional. Metadata associated with the contact. Up to 1024 characters long. - `messages.injected` (boolean) Flag for whether this message was injected. - `messages.sender_id` (string) For Contact Messages (MO messages), the sender ID represents the recipient to which the message was sent. This may be a phone number (in the case of SMS and MMS) or a unique ID (in the case of WhatsApp). This is field is not supported on all channels, nor is it supported for MT messages. - `messages.processing_mode` (string) Whether or not Conversation API should store contacts and conversations for the app. For more information, see [Processing Modes](https://developers.sinch.com/docs/conversation/processing-modes/). Enum: "CONVERSATION", "DISPATCH" - `next_page_token` (string) Token that should be included in the next request to fetch the next page. ## Response 400 fields (application/json): - `error` (object) - `error.code` (integer) - `error.details` (array) - `error.details.type_url` (string) - `error.details.value` (string) - `error.message` (string) - `error.status` (string) ## Response 403 fields (application/json): - `error` (object) - `error.code` (integer) - `error.details` (array) - `error.details.type_url` (string) - `error.details.value` (string) - `error.message` (string) - `error.status` (string) ## Response 500 fields (application/json): - `error` (object) - `error.code` (integer) - `error.details` (array) - `error.details.type_url` (string) - `error.details.value` (string) - `error.message` (string) - `error.status` (string) ## Response 501 fields (application/json): - `error` (object) - `error.code` (integer) - `error.details` (array) - `error.details.type_url` (string) - `error.details.value` (string) - `error.message` (string) - `error.status` (string)