Skip to content

Commit 4e10c73

Browse files
authored
Support new Membership API and Webhook (#86)
# Support new Membership API and Webhook We have implemented and supported new API and Webhook about Membership. ## API to get a list of users who joined the membership You can obtain a list of user IDs for users who have joined the membership of your LINE Official Account by calling `client.getJoinedMembershipUsers(...)`. Documents: https://developers.line.biz/en/reference/messaging-api/#get-membership-user-ids ## Membership Webhook We have introduced new Webhook events `MembershipEvent` that indicates that a user has joined, left or renewed a membership of your LINE Official Account. Documents: https://developers.line.biz/en/reference/messaging-api/#membership-event ## For more details For more details, check out the announcement: https://developers.line.biz/en/news/2025/02/13/membership-api/
1 parent 04b9b63 commit 4e10c73

File tree

2 files changed

+149
-0
lines changed

2 files changed

+149
-0
lines changed

messaging-api.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1869,6 +1869,69 @@ paths:
18691869
schema:
18701870
"$ref": "#/components/schemas/ErrorResponse"
18711871

1872+
"/v2/bot/membership/{membershipId}/users/ids":
1873+
get:
1874+
externalDocs:
1875+
url: https://developers.line.biz/en/reference/messaging-api/#get-membership-user-ids
1876+
tags:
1877+
- messaging-api
1878+
operationId: getJoinedMembershipUsers
1879+
description: "Get a list of user IDs who joined the membership."
1880+
parameters:
1881+
- name: start
1882+
in: query
1883+
required: false
1884+
description: |+
1885+
A continuation token to get next remaining membership user IDs.
1886+
Returned only when there are remaining user IDs that weren't returned in the userIds property in the previous request.
1887+
The continuation token expires in 24 hours (86,400 seconds).
1888+
schema:
1889+
type: string
1890+
- name: limit
1891+
in: query
1892+
required: false
1893+
description: |+
1894+
The max number of items to return for this API call.
1895+
The value is set to 300 by default, but the max acceptable value is 1000.
1896+
schema:
1897+
type: integer
1898+
format: int32
1899+
default: 300
1900+
maximum: 1000
1901+
minimum: 1
1902+
- name: membershipId
1903+
in: path
1904+
required: true
1905+
schema:
1906+
type: integer
1907+
description: "Membership plan ID."
1908+
responses:
1909+
"200":
1910+
description: "OK"
1911+
content:
1912+
application/json:
1913+
schema:
1914+
"$ref": "#/components/schemas/GetJoinedMembershipUsersResponse"
1915+
example:
1916+
userIds:
1917+
- U4af4980629...
1918+
- U0c229f96c4...
1919+
- U95afb1d4df...
1920+
next: jxEWCEEP...
1921+
1922+
"400":
1923+
description: "`start` is incorrect or expired, or `limit` is under 1 or over 1000."
1924+
content:
1925+
application/json:
1926+
schema:
1927+
"$ref": "#/components/schemas/ErrorResponse"
1928+
"404":
1929+
description: "Membership ID is not owned by the bot or does not exist."
1930+
content:
1931+
application/json:
1932+
schema:
1933+
"$ref": "#/components/schemas/ErrorResponse"
1934+
18721935
"/v2/bot/chat/loading/start":
18731936
post:
18741937
externalDocs:
@@ -4836,6 +4899,30 @@ components:
48364899
items:
48374900
"$ref": "#/components/schemas/Membership"
48384901

4902+
GetJoinedMembershipUsersResponse:
4903+
externalDocs:
4904+
url: https://developers.line.biz/en/reference/messaging-api/#get-membership-user-ids
4905+
description: "List of users who have joined the membership"
4906+
required:
4907+
- userIds
4908+
type: object
4909+
properties:
4910+
userIds:
4911+
type: array
4912+
maxItems: 1000
4913+
description: |+
4914+
A list of user IDs who joined the membership.
4915+
Users who have not agreed to the bot user agreement, are not following the bot, or are not active will be excluded.
4916+
If there are no users in the membership, an empty list will be returned.
4917+
items:
4918+
type: string
4919+
next:
4920+
type: string
4921+
description: |+
4922+
A continuation token to get next remaining membership user IDs.
4923+
Returned only when there are remaining user IDs that weren't returned in the userIds property in the previous request.
4924+
The continuation token expires in 24 hours (86,400 seconds).
4925+
48394926
Subscription:
48404927
description: "An array of memberships."
48414928
required:

webhook.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ components:
108108
beacon: "#/components/schemas/BeaconEvent"
109109
accountLink: "#/components/schemas/AccountLinkEvent"
110110
things: "#/components/schemas/ThingsEvent"
111+
membership: "#/components/schemas/MembershipEvent"
111112
module: "#/components/schemas/ModuleEvent"
112113
activated: "#/components/schemas/ActivatedEvent"
113114
deactivated: "#/components/schemas/DeactivatedEvent"
@@ -860,6 +861,67 @@ components:
860861
description: "Base64-encoded binary data"
861862
type: string
862863

864+
# https://developers.line.biz/en/reference/messaging-api/#membership-event
865+
MembershipEvent:
866+
description: "This event indicates that a user has subscribed (joined), unsubscribed (left), or renewed the bot's membership."
867+
allOf:
868+
- $ref: "#/components/schemas/Event"
869+
- type: object
870+
required:
871+
- replyToken
872+
- membership
873+
properties:
874+
replyToken:
875+
type: string
876+
description: "Reply token used to send reply message to this event"
877+
membership:
878+
$ref: "#/components/schemas/MembershipContent"
879+
MembershipContent:
880+
description: "Content of the membership event."
881+
required:
882+
- type
883+
- membershipId
884+
type: object
885+
properties:
886+
type:
887+
type: string
888+
description: "Type of membership event."
889+
discriminator:
890+
propertyName: type
891+
mapping:
892+
joined: "#/components/schemas/JoinedMembershipContent"
893+
left: "#/components/schemas/LeftMembershipContent"
894+
renewed: "#/components/schemas/RenewedMembershipContent"
895+
JoinedMembershipContent:
896+
allOf:
897+
- $ref: "#/components/schemas/MembershipContent"
898+
- type: object
899+
required:
900+
- membershipId
901+
properties:
902+
membershipId:
903+
type: integer
904+
description: "The ID of the membership that the user joined. This is defined for each membership."
905+
LeftMembershipContent:
906+
allOf:
907+
- $ref: "#/components/schemas/MembershipContent"
908+
- type: object
909+
required:
910+
- membershipId
911+
properties:
912+
membershipId:
913+
type: integer
914+
description: "The ID of the membership that the user left. This is defined for each membership."
915+
RenewedMembershipContent:
916+
allOf:
917+
- $ref: "#/components/schemas/MembershipContent"
918+
- type: object
919+
required:
920+
- membershipId
921+
properties:
922+
membershipId:
923+
type: integer
924+
description: "The ID of the membership that the user renewed. This is defined for each membership."
863925

864926
# https://developers.line.biz/en/reference/partner-docs/#module-webhook-event-object
865927
ModuleEvent:

0 commit comments

Comments
 (0)