Skip to content

Commit f14ee40

Browse files
github-actions[bot]github-actions
andauthored
Support mark as read by token API (#637)
line/line-openapi#115 ## Support for "Mark as Read" by Token API We have released a new **Mark as Read API** that allows developers to mark a user’s messages as read. Previously, this functionality was available only to partners, but it is now publicly available. When your server receives a user message via Webhook, the `MessageEvent` will include a new field: `markAsReadToken`. By calling the Mark as Read API with this token, all messages in the chat room **up to and including** that message will be marked as read. > **Note:** This feature assumes that your service uses the chat feature through Official Account Manager. > If chat is not enabled, messages from users are automatically marked as read, making this API unnecessary. For more details, please refer to the release note: https://developers.line.biz/en/news/2025/11/05/mark-as-read/ Co-authored-by: github-actions <[email protected]>
1 parent 75c602b commit f14ee40

11 files changed

+135
-1
lines changed

line-openapi

linebot/messaging_api/.openapi-generator/FILES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ model_location_action.go
118118
model_location_message.go
119119
model_lottery_acquisition_condition_request.go
120120
model_lottery_acquisition_condition_response.go
121+
model_mark_messages_as_read_by_token_request.go
121122
model_mark_messages_as_read_request.go
122123
model_members_ids_response.go
123124
model_membership.go

linebot/messaging_api/api_messaging_api.go

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3306,6 +3306,73 @@ func (client *MessagingApiAPI) MarkMessagesAsReadWithHttpInfo(
33063306

33073307
}
33083308

3309+
// MarkMessagesAsReadByToken
3310+
//
3311+
// Mark messages from users as read by token
3312+
// Parameters:
3313+
// markMessagesAsReadByTokenRequest
3314+
3315+
// https://developers.line.biz/en/reference/messaging-api/#mark-as-read
3316+
func (client *MessagingApiAPI) MarkMessagesAsReadByToken(
3317+
3318+
markMessagesAsReadByTokenRequest *MarkMessagesAsReadByTokenRequest,
3319+
3320+
) (struct{}, error) {
3321+
_, body, error := client.MarkMessagesAsReadByTokenWithHttpInfo(
3322+
3323+
markMessagesAsReadByTokenRequest,
3324+
)
3325+
return body, error
3326+
}
3327+
3328+
// MarkMessagesAsReadByToken
3329+
// If you want to take advantage of the HTTPResponse object for status codes and headers, use this signature.
3330+
//
3331+
// Mark messages from users as read by token
3332+
// Parameters:
3333+
// markMessagesAsReadByTokenRequest
3334+
3335+
// https://developers.line.biz/en/reference/messaging-api/#mark-as-read
3336+
func (client *MessagingApiAPI) MarkMessagesAsReadByTokenWithHttpInfo(
3337+
3338+
markMessagesAsReadByTokenRequest *MarkMessagesAsReadByTokenRequest,
3339+
3340+
) (*http.Response, struct{}, error) {
3341+
path := "/v2/bot/chat/markAsRead"
3342+
3343+
var buf bytes.Buffer
3344+
enc := json.NewEncoder(&buf)
3345+
if err := enc.Encode(markMessagesAsReadByTokenRequest); err != nil {
3346+
return nil, struct{}{}, err
3347+
}
3348+
req, err := http.NewRequest(http.MethodPost, client.Url(path), &buf)
3349+
if err != nil {
3350+
return nil, struct{}{}, err
3351+
}
3352+
req.Header.Set("Content-Type", "application/json; charset=UTF-8")
3353+
3354+
res, err := client.Do(req)
3355+
3356+
if err != nil {
3357+
return res, struct{}{}, err
3358+
}
3359+
3360+
if res.StatusCode/100 != 2 {
3361+
bodyBytes, err := io.ReadAll(res.Body)
3362+
bodyReader := bytes.NewReader(bodyBytes)
3363+
if err != nil {
3364+
return res, struct{}{}, fmt.Errorf("failed to read response body: %w", err)
3365+
}
3366+
res.Body = io.NopCloser(bodyReader)
3367+
return res, struct{}{}, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, string(bodyBytes))
3368+
}
3369+
3370+
defer res.Body.Close()
3371+
3372+
return res, struct{}{}, nil
3373+
3374+
}
3375+
33093376
// Multicast
33103377
//
33113378
// An API that efficiently sends the same message to multiple user IDs. You can't send messages to group chats or multi-person chats.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* LINE Messaging API
3+
* This document describes LINE Messaging API.
4+
*
5+
* The version of the OpenAPI document: 0.0.1
6+
*
7+
*
8+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9+
* https://openapi-generator.tech
10+
* Do not edit the class manually.
11+
*/
12+
13+
/**
14+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
15+
* https://openapi-generator.tech
16+
* Do not edit the class manually.
17+
*/
18+
19+
//go:generate python3 ../../generate-code.py
20+
package messaging_api
21+
22+
// MarkMessagesAsReadByTokenRequest
23+
// MarkMessagesAsReadByTokenRequest
24+
// https://developers.line.biz/en/reference/messaging-api/#mark-as-read-request-body
25+
type MarkMessagesAsReadByTokenRequest struct {
26+
27+
/**
28+
* Token used to mark messages as read. (Required)
29+
*/
30+
MarkAsReadToken string `json:"markAsReadToken"`
31+
}

linebot/webhook/model_audio_message_content.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ type AudioMessageContent struct {
4343
* Length of audio file (milliseconds)
4444
*/
4545
Duration int64 `json:"duration"`
46+
47+
/**
48+
* Token used to mark the message as read.
49+
*/
50+
MarkAsReadToken string `json:"markAsReadToken,omitempty"`
4651
}
4752

4853
// MarshalJSON customizes the JSON serialization of the AudioMessageContent struct.

linebot/webhook/model_file_message_content.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ type FileMessageContent struct {
4343
* File size in bytes (Required)
4444
*/
4545
FileSize int32 `json:"fileSize"`
46+
47+
/**
48+
* Token used to mark the message as read.
49+
*/
50+
MarkAsReadToken string `json:"markAsReadToken,omitempty"`
4651
}
4752

4853
// MarshalJSON customizes the JSON serialization of the FileMessageContent struct.

linebot/webhook/model_image_message_content.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ type ImageMessageContent struct {
4848
* Quote token to quote this message. (Required)
4949
*/
5050
QuoteToken string `json:"quoteToken"`
51+
52+
/**
53+
* Token used to mark the message as read.
54+
*/
55+
MarkAsReadToken string `json:"markAsReadToken,omitempty"`
5156
}
5257

5358
// MarshalJSON customizes the JSON serialization of the ImageMessageContent struct.

linebot/webhook/model_location_message_content.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ type LocationMessageContent struct {
5353
* Longitude (Required)
5454
*/
5555
Longitude float64 `json:"longitude"`
56+
57+
/**
58+
* Token used to mark the message as read.
59+
*/
60+
MarkAsReadToken string `json:"markAsReadToken,omitempty"`
5661
}
5762

5863
// MarshalJSON customizes the JSON serialization of the LocationMessageContent struct.

linebot/webhook/model_sticker_message_content.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ type StickerMessageContent struct {
6868
* Message ID of a quoted message. Only included when the received message quotes a past message.
6969
*/
7070
QuotedMessageId string `json:"quotedMessageId,omitempty"`
71+
72+
/**
73+
* Token used to mark the message as read.
74+
*/
75+
MarkAsReadToken string `json:"markAsReadToken,omitempty"`
7176
}
7277

7378
// MarshalJSON customizes the JSON serialization of the StickerMessageContent struct.

linebot/webhook/model_text_message_content.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ type TextMessageContent struct {
5858
* Message ID of a quoted message. Only included when the received message quotes a past message.
5959
*/
6060
QuotedMessageId string `json:"quotedMessageId,omitempty"`
61+
62+
/**
63+
* Token used to mark the message as read.
64+
*/
65+
MarkAsReadToken string `json:"markAsReadToken,omitempty"`
6166
}
6267

6368
// MarshalJSON customizes the JSON serialization of the TextMessageContent struct.

0 commit comments

Comments
 (0)