Skip to content

Commit 960fb23

Browse files
github-actions[bot]github-actions
andauthored
Add Coupon API Support to Messaging API (#1361)
line/line-openapi#111 # Add Coupon API Support to Messaging API We've supported a set of new APIs that make it possible to create, manage, and deliver coupons via the Messaging API. These features provide functionality similar to what's available through the LINE Official Account Manager interface ([see here](https://www.lycbiz.com/jp/manual/OfficialAccountManager/coupons-create/)), allowing developers to integrate coupon-related workflows into their bots more flexibly. For more details, see the official announcement: [LINE Developers News — Coupon API Released (2025/08/06)](https://developers.line.biz/en/news/2025/08/06/coupon-api/) ## New API Endpoints - `POST /v2/bot/coupon` Create a new coupon. The request includes metadata such as the coupon title, description, image URLs, validity period, reward details(e.g. 1000yen discount), acquisition requirements, time zone, etc. - `GET /v2/bot/coupon` Retrieve a list of coupons associated with the bot. - `GET /v2/bot/coupon/{couponId}` Fetch detailed information about a specific coupon. - `PUT /v2/bot/coupon/{couponId}` Mark a coupon as expired. ## Messaging API Update Message Object now supports a new type: `type=coupon` This allows developers to send coupons directly to users via the Messaging API, similar to sending text, image, or template messages. ## Example Requests ### Create a Coupon ``` POST /v2/bot/coupon Content-Type: application/json ``` #### Request body ```json { "title": "1000 yen off coupon", "acquisitionCondition": { "type": "normal" }, "visibility": "PUBLIC", "startTimestamp": 1672537600, "endTimestamp": 1672624000, "maxUseCountPerTicket": 1, "reward": { "type": "discount", "priceInfo": { "priceInfoType": "fixed", "fixedAmount": 1000 } }, "imageUrl": "https://example.com/coupon_image.png", "barcodeImageUrl": "https://example.com/coupon_barcode.png", "timezone": "ASIA_TOKYO" } ``` #### Response ```json { "couponId": "abc1234" } ``` ### Send a Coupon Message ```json { "to": "<userId>", "messages": [ { "type": "coupon", "couponId": "abc1234" } ] } ``` Co-authored-by: github-actions <[email protected]>
1 parent d0e91cf commit 960fb23

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1761
-1
lines changed

lib/messaging-api/.openapi-generator/FILES

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ api.ts
33
api/apis.ts
44
api/messagingApiBlobClient.ts
55
api/messagingApiClient.ts
6+
model/acquisitionConditionRequest.ts
7+
model/acquisitionConditionResponse.ts
68
model/action.ts
79
model/ageDemographic.ts
810
model/ageDemographicFilter.ts
@@ -21,13 +23,44 @@ model/cameraAction.ts
2123
model/cameraRollAction.ts
2224
model/carouselColumn.ts
2325
model/carouselTemplate.ts
26+
model/cashBackFixedPriceInfoRequest.ts
27+
model/cashBackFixedPriceInfoResponse.ts
28+
model/cashBackPercentagePriceInfoRequest.ts
29+
model/cashBackPercentagePriceInfoResponse.ts
30+
model/cashBackPriceInfoRequest.ts
31+
model/cashBackPriceInfoResponse.ts
2432
model/chatReference.ts
2533
model/clipboardAction.ts
2634
model/clipboardImagemapAction.ts
2735
model/confirmTemplate.ts
36+
model/couponCashBackRewardRequest.ts
37+
model/couponCashBackRewardResponse.ts
38+
model/couponCreateRequest.ts
39+
model/couponCreateResponse.ts
40+
model/couponDiscountRewardRequest.ts
41+
model/couponDiscountRewardResponse.ts
42+
model/couponFreeRewardRequest.ts
43+
model/couponFreeRewardResponse.ts
44+
model/couponGiftRewardRequest.ts
45+
model/couponGiftRewardResponse.ts
46+
model/couponListResponse.ts
47+
model/couponMessage.ts
48+
model/couponOthersRewardRequest.ts
49+
model/couponOthersRewardResponse.ts
50+
model/couponResponse.ts
51+
model/couponRewardRequest.ts
52+
model/couponRewardResponse.ts
2853
model/createRichMenuAliasRequest.ts
2954
model/datetimePickerAction.ts
3055
model/demographicFilter.ts
56+
model/discountExplicitPriceInfoRequest.ts
57+
model/discountExplicitPriceInfoResponse.ts
58+
model/discountFixedPriceInfoRequest.ts
59+
model/discountFixedPriceInfoResponse.ts
60+
model/discountPercentagePriceInfoRequest.ts
61+
model/discountPercentagePriceInfoResponse.ts
62+
model/discountPriceInfoRequest.ts
63+
model/discountPriceInfoResponse.ts
3164
model/emoji.ts
3265
model/emojiSubstitutionObject.ts
3366
model/errorDetail.ts
@@ -86,6 +119,8 @@ model/issueLinkTokenResponse.ts
86119
model/limit.ts
87120
model/locationAction.ts
88121
model/locationMessage.ts
122+
model/lotteryAcquisitionConditionRequest.ts
123+
model/lotteryAcquisitionConditionResponse.ts
89124
model/markMessagesAsReadRequest.ts
90125
model/membersIdsResponse.ts
91126
model/membership.ts
@@ -96,10 +131,13 @@ model/message.ts
96131
model/messageAction.ts
97132
model/messageImagemapAction.ts
98133
model/messageQuotaResponse.ts
134+
model/messagingApiPagerCouponListResponse.ts
99135
model/models.ts
100136
model/multicastRequest.ts
101137
model/narrowcastProgressResponse.ts
102138
model/narrowcastRequest.ts
139+
model/normalAcquisitionConditionRequest.ts
140+
model/normalAcquisitionConditionResponse.ts
103141
model/numberOfMessagesResponse.ts
104142
model/operatorDemographicFilter.ts
105143
model/operatorRecipient.ts
@@ -113,6 +151,7 @@ model/quotaConsumptionResponse.ts
113151
model/quotaType.ts
114152
model/recipient.ts
115153
model/redeliveryRecipient.ts
154+
model/referralAcquisitionConditionResponse.ts
116155
model/replyMessageRequest.ts
117156
model/replyMessageResponse.ts
118157
model/richMenuAliasListResponse.ts

lib/messaging-api/api/messagingApiClient.ts

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
/* tslint:disable:no-unused-locals */
1414
import { BotInfoResponse } from "../model/botInfoResponse.js";
1515
import { BroadcastRequest } from "../model/broadcastRequest.js";
16+
import { CouponCreateRequest } from "../model/couponCreateRequest.js";
17+
import { CouponCreateResponse } from "../model/couponCreateResponse.js";
18+
import { CouponResponse } from "../model/couponResponse.js";
1619
import { CreateRichMenuAliasRequest } from "../model/createRichMenuAliasRequest.js";
1720
import { ErrorResponse } from "../model/errorResponse.js";
1821
import { GetAggregationUnitNameListResponse } from "../model/getAggregationUnitNameListResponse.js";
@@ -29,6 +32,7 @@ import { MarkMessagesAsReadRequest } from "../model/markMessagesAsReadRequest.js
2932
import { MembersIdsResponse } from "../model/membersIdsResponse.js";
3033
import { MembershipListResponse } from "../model/membershipListResponse.js";
3134
import { MessageQuotaResponse } from "../model/messageQuotaResponse.js";
35+
import { MessagingApiPagerCouponListResponse } from "../model/messagingApiPagerCouponListResponse.js";
3236
import { MulticastRequest } from "../model/multicastRequest.js";
3337
import { NarrowcastProgressResponse } from "../model/narrowcastProgressResponse.js";
3438
import { NarrowcastRequest } from "../model/narrowcastRequest.js";
@@ -158,6 +162,64 @@ export class MessagingApiClient {
158162
const parsedBody = text ? JSON.parse(text) : null;
159163
return { httpResponse: res, body: parsedBody };
160164
}
165+
/**
166+
* Close coupon
167+
* @param couponId
168+
*
169+
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#discontinue-coupon"> Documentation</a>
170+
*/
171+
public async closeCoupon(
172+
couponId: string,
173+
): Promise<Types.MessageAPIResponseBase> {
174+
return (await this.closeCouponWithHttpInfo(couponId)).body;
175+
}
176+
177+
/**
178+
* Close coupon.
179+
* This method includes HttpInfo object to return additional information.
180+
* @param couponId
181+
*
182+
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#discontinue-coupon"> Documentation</a>
183+
*/
184+
public async closeCouponWithHttpInfo(
185+
couponId: string,
186+
): Promise<Types.ApiResponseType<Types.MessageAPIResponseBase>> {
187+
const res = await this.httpClient.put(
188+
"/v2/bot/coupon/{couponId}/close".replace("{couponId}", String(couponId)),
189+
);
190+
const text = await res.text();
191+
const parsedBody = text ? JSON.parse(text) : null;
192+
return { httpResponse: res, body: parsedBody };
193+
}
194+
/**
195+
* Create a new coupon. Define coupon details such as type, title, and validity period.
196+
* @param couponCreateRequest
197+
*
198+
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#create-coupon"> Documentation</a>
199+
*/
200+
public async createCoupon(
201+
couponCreateRequest?: CouponCreateRequest,
202+
): Promise<CouponCreateResponse> {
203+
return (await this.createCouponWithHttpInfo(couponCreateRequest)).body;
204+
}
205+
206+
/**
207+
* Create a new coupon. Define coupon details such as type, title, and validity period..
208+
* This method includes HttpInfo object to return additional information.
209+
* @param couponCreateRequest
210+
*
211+
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#create-coupon"> Documentation</a>
212+
*/
213+
public async createCouponWithHttpInfo(
214+
couponCreateRequest?: CouponCreateRequest,
215+
): Promise<Types.ApiResponseType<CouponCreateResponse>> {
216+
const params = couponCreateRequest;
217+
218+
const res = await this.httpClient.post("/v2/bot/coupon", params);
219+
const text = await res.text();
220+
const parsedBody = text ? JSON.parse(text) : null;
221+
return { httpResponse: res, body: parsedBody };
222+
}
161223
/**
162224
* Create rich menu
163225
* @param richMenuRequest
@@ -373,6 +435,33 @@ export class MessagingApiClient {
373435
const parsedBody = text ? JSON.parse(text) : null;
374436
return { httpResponse: res, body: parsedBody };
375437
}
438+
/**
439+
* Get coupon detail
440+
* @param couponId
441+
*
442+
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-coupon"> Documentation</a>
443+
*/
444+
public async getCouponDetail(couponId: string): Promise<CouponResponse> {
445+
return (await this.getCouponDetailWithHttpInfo(couponId)).body;
446+
}
447+
448+
/**
449+
* Get coupon detail.
450+
* This method includes HttpInfo object to return additional information.
451+
* @param couponId
452+
*
453+
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-coupon"> Documentation</a>
454+
*/
455+
public async getCouponDetailWithHttpInfo(
456+
couponId: string,
457+
): Promise<Types.ApiResponseType<CouponResponse>> {
458+
const res = await this.httpClient.get(
459+
"/v2/bot/coupon/{couponId}".replace("{couponId}", String(couponId)),
460+
);
461+
const text = await res.text();
462+
const parsedBody = text ? JSON.parse(text) : null;
463+
return { httpResponse: res, body: parsedBody };
464+
}
376465
/**
377466
* Gets the ID of the default rich menu set with the Messaging API.
378467
*
@@ -1463,6 +1552,52 @@ export class MessagingApiClient {
14631552
const parsedBody = text ? JSON.parse(text) : null;
14641553
return { httpResponse: res, body: parsedBody };
14651554
}
1555+
/**
1556+
* Get a paginated list of coupons.
1557+
* @param status Filter coupons by their status.
1558+
* @param start Pagination token to retrieve the next page of results.
1559+
* @param limit Maximum number of coupons to return per request.
1560+
*
1561+
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-coupons-list"> Documentation</a>
1562+
*/
1563+
public async listCoupon(
1564+
status?: Set<"DRAFT" | "RUNNING" | "CLOSED">,
1565+
start?: string,
1566+
limit?: number,
1567+
): Promise<MessagingApiPagerCouponListResponse> {
1568+
return (await this.listCouponWithHttpInfo(status, start, limit)).body;
1569+
}
1570+
1571+
/**
1572+
* Get a paginated list of coupons..
1573+
* This method includes HttpInfo object to return additional information.
1574+
* @param status Filter coupons by their status.
1575+
* @param start Pagination token to retrieve the next page of results.
1576+
* @param limit Maximum number of coupons to return per request.
1577+
*
1578+
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#get-coupons-list"> Documentation</a>
1579+
*/
1580+
public async listCouponWithHttpInfo(
1581+
status?: Set<"DRAFT" | "RUNNING" | "CLOSED">,
1582+
start?: string,
1583+
limit?: number,
1584+
): Promise<Types.ApiResponseType<MessagingApiPagerCouponListResponse>> {
1585+
const queryParams = {
1586+
status: status,
1587+
start: start,
1588+
limit: limit,
1589+
};
1590+
Object.keys(queryParams).forEach((key: keyof typeof queryParams) => {
1591+
if (queryParams[key] === undefined) {
1592+
delete queryParams[key];
1593+
}
1594+
});
1595+
1596+
const res = await this.httpClient.get("/v2/bot/coupon", queryParams);
1597+
const text = await res.text();
1598+
const parsedBody = text ? JSON.parse(text) : null;
1599+
return { httpResponse: res, body: parsedBody };
1600+
}
14661601
/**
14671602
* Mark messages from users as read
14681603
* @param markMessagesAsReadRequest
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
import { LotteryAcquisitionConditionRequest } from "./models.js";
14+
import { NormalAcquisitionConditionRequest } from "./models.js";
15+
16+
export type AcquisitionConditionRequest =
17+
| LotteryAcquisitionConditionRequest // lottery
18+
| NormalAcquisitionConditionRequest; // normal
19+
20+
export type AcquisitionConditionRequestBase = {
21+
/**
22+
* Determines how the coupon is distributed or used.
23+
*/
24+
type: string /**/;
25+
};
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
import { LotteryAcquisitionConditionResponse } from "./models.js";
14+
import { NormalAcquisitionConditionResponse } from "./models.js";
15+
import { ReferralAcquisitionConditionResponse } from "./models.js";
16+
17+
export type AcquisitionConditionResponse =
18+
| LotteryAcquisitionConditionResponse // lottery
19+
| NormalAcquisitionConditionResponse // normal
20+
| ReferralAcquisitionConditionResponse; // referral
21+
22+
export type AcquisitionConditionResponseBase = {
23+
/**
24+
* Determines how the coupon is distributed or used.
25+
*/
26+
type: string /**/;
27+
};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
import { CashBackPriceInfoRequest } from "./cashBackPriceInfoRequest.js";
14+
15+
import { CashBackPriceInfoRequestBase } from "./models.js";
16+
17+
export type CashBackFixedPriceInfoRequest = CashBackPriceInfoRequestBase & {
18+
type: "fixed";
19+
/**
20+
*/
21+
fixedAmount?: number /**/;
22+
};
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
import { CashBackPriceInfoResponse } from "./cashBackPriceInfoResponse.js";
14+
15+
import { CashBackPriceInfoResponseBase } from "./models.js";
16+
17+
export type CashBackFixedPriceInfoResponse = CashBackPriceInfoResponseBase & {
18+
type: "fixed";
19+
/**
20+
* Currency code (e.g., JPY, THB, TWD).
21+
*/
22+
currency?: CashBackFixedPriceInfoResponse.CurrencyEnum /**/;
23+
/**
24+
*/
25+
fixedAmount?: number /**/;
26+
};
27+
28+
export namespace CashBackFixedPriceInfoResponse {
29+
export type CurrencyEnum = "JPY" | "THB" | "TWD";
30+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
import { CashBackPriceInfoRequest } from "./cashBackPriceInfoRequest.js";
14+
15+
import { CashBackPriceInfoRequestBase } from "./models.js";
16+
17+
export type CashBackPercentagePriceInfoRequest =
18+
CashBackPriceInfoRequestBase & {
19+
type: "percentage";
20+
/**
21+
* Specifies the cashback rate as a percentage. Must be an integer between 1 and 99.
22+
*/
23+
percentage?: number /**/;
24+
};

0 commit comments

Comments
 (0)