API reference

Common specifications

Rate limits

The limit for the number of requests you can make for each API are shown below. Rate limits vary depending on your plan.

Plan Limit
Developer Trial 1,000/min
Other plans 10,000/min

Status codes

The following status codes are returned by the API.

Status code Description
200 OK Request successful
400 Bad Request Problem with the request
401 Unauthorized Valid Channel access token is not specified
403 Forbidden Not authorized to use the API. Confirm that your account or plan is authorized to used the API.
429 Too Many Requests Exceeded the rate limit for API calls
500 Internal Server Error Error on the internal server

Response headers

The following HTTP headers are included in Messaging API responses.

Response header Description
X-Line-Request-Id ID generated for each request

Example JSON error response

{
  "message":"The request body has 2 error(s)",
  "details":[
    {"message":"May not be empty","property":"messages[0].text"},
    {"message":"Must be one of the following values: [text, image, video, audio, location, sticker, template, imagemap]","property":"messages[1].type"}
  ]
}


{
  "message":"Invalid reply token"
}

Error responses

The following JSON data is returned in the response body when an error occurs.

Field Type Description
message String Summary of the error
details[].message String Details of the error
details[].property String Location of where the error occurred

OR

Field Type Description
message String Details of the error

Error messages

The main error messages that are found in the message field of the JSON error responses are shown below.

Message Description
The request body has X error(s) An error was found in the JSON data of the request body. The number of errors is displayed for "X". Further details are shown in the details[].message and details[].property fields.
Invalid reply token An invalid reply token was used in the reply message
The property, XXX, in the request body is invalid (line: XXX, column: XXX) An invalid property was specified in the request body. The specific property is displayed for "XXX".
The request body could not be parsed as JSON (line: XXX, column: XXX) The JSON in the request body could not be parsed. The specific line and column are displayed.
The content type, XXX, is not supported A content type not supported by the API is requested.
Authentication failed due to the following reason: XXX Authentication failed when the API was called. The reason is displayed for "XXX".
Access to this API is not available for your account Appears when calling an API that you do not have permission to use.
Failed to send messages Appears when the message fails to be sent. One reason this may appear is if the user ID specified does not exist.

Example webhook request body

{
  "events": [
      {
        "replyToken": "nHuyWiB7yP5Zw52FIkcQobQuGDXCTA",
        "type": "message",
        "timestamp": 1462629479859,
        "source": {
             "type": "user",
             "userId": "U206d25c2ea6bd87c17655609a1c37cb8"
         },
         "message": {
             "id": "325708",
             "type": "text",
             "text": "Hello, world"
          }
      }
  ]
}

Webhooks

When an event, such as when a user adds your account or sends a message, is triggered, an HTTPS POST request is sent to the webhook URL that is configured for your channel on the console.

Your bot application server then receives and handles the requests.

Request headers

Request header Description
X-Line-Signature Used for signature validation

Request body

The request body contains a JSON object with an array of webhook event objects

Field Type Description
events Array of webhook event objects Information about the event

Response

Your server should return the status code 200 for a HTTP POST request sent by a webhook.

Example of signature validation

# Click on the language tabs for examples of signature validation
Example of signature validation
String channelSecret = ...; // Channel secret string
String httpRequestBody = ...; // Request body string
SecretKeySpec key = new SecretKeySpec(channelSecret.getBytes(), "HmacSHA256");
Mac mac = Mac.getInstance("HmacSHA256");
mac.init(key);
byte[] source = httpRequestBody.getBytes("UTF-8");
String signature = Base64.encodeBase64String(mac.doFinal(source));
// Compare X-Line-Signature request header string and the signature
Example of signature validation
CHANNEL_SECRET = ... # Channel secret string
http_request_body = request.raw_post # Request body string
hash = OpenSSL::HMAC::digest(OpenSSL::Digest::SHA256.new, CHANNEL_SECRET, http_request_body)
signature = Base64.strict_encode64(hash)
# Compare X-Line-Signature request header string and the signature
Example of signature validation
defer req.Body.Close()
body, err := ioutil.ReadAll(req.Body)
if err != nil {
    // ...
}
decoded, err := base64.StdEncoding.DecodeString(req.Header.Get("X-Line-Signature"))
if err != nil {
    // ...
}
hash := hmac.New(sha256.New, []byte("<channel secret>"))
hash.Write(body)
// Compare decoded signature and `hash.Sum(nil)` by using `hmac.Equal`
Example of signature validation
$channelSecret = ...; // Channel secret string
$httpRequestBody = ...; // Request body string
$hash = hash_hmac('sha256', $httpRequestBody, $channelSecret, true);
$signature = base64_encode($hash);
// Compare X-Line-Signature request header string and the signature
Example of signature validation
use Digest::SHA 'hmac_sha256';
use MIME::Base64 'decode_base64';

my $channel_secret= ... # Channel secret string
my $http_body = ... # Request body string
my $signature = decode_base64(hmac_sha256($http_body, $channel_secret));
# Compare X-Line-Signature request header string and the signature
Example of signature validation
import base64
import hashlib
import hmac

channel_secret = ... # Channel secret string
body = ... # Request body string
hash = hmac.new(channel_secret.encode('utf-8'),
    body.encode('utf-8'), hashlib.sha256).digest()
signature = base64.b64encode(hash)
# Compare X-Line-Signature request header and the signature
Example of signature validation
const crypto = require('crypto');

const channelSecret = ...; // Channel secret string
const body = ...; // Request body string
const signature =
  createHmac('SHA256', channelSecret)
  .update(body).digest('base64');
// Compare X-Line-Signature request header and the signature

Signature validation

The signature in the X-Line-Signature request header must be verified to confirm that the request was sent from the LINE Platform.

Authentication is performed as follows.

  1. With the channel secret as the secret key, your application retrieves the digest value in the request body created using the HMAC-SHA256 algorithm.
  2. The server confirms that the signature in the request header matches the digest value which is Base64 encoded.

Example webhook event object

{
  "events": [
    {
      "replyToken": "nHuyWiB7yP5Zw52FIkcQobQuGDXCTA",
      "type": "message",
      "timestamp": 1462629479859,
      "source": {
        "type": "user",
        "userId": "U206d25c2ea6bd87c17655609a1c37cb8"
      },
      "message": {
        "id": "325708",
        "type": "text",
        "text": "Hello, world"
      }
    },
    {
      "replyToken": "nHuyWiB7yP5Zw52FIkcQobQuGDXCTA",
      "type": "follow",
      "timestamp": 1462629479859,
      "source": {
        "type": "user",
        "userId": "U206d25c2ea6bd87c17655609a1c37cb8"
      }
    }
  ]
}

Common fields

The following are the fields found in the webhook event object

Field Type Description
type String Identifier for the type of event
timestamp Number Time of the event in milliseconds
source User
Group
Room
JSON object which contains the source of the event

Source user example

  "source": {
    "type": "user",
    "userId": "U206d25c2ea6bd87c17655609a1c37cb8"
  }

Source user

JSON object which contains the source user of the event.

Field Type Description
type String user
userId String ID of the source user

Source group example

  "source": {
    "type": "group",
    "groupId": "Ca56f94637cc4347f90a25382909b24b9",
    "userId": "U206d25c2ea6bd87c17655609a1c37cb8"
  }

Source group

JSON object which contains the source group of the event.

Field Type Description
type String group
groupId String ID of the source group
userId String ID of the source user

Note: User IDs of individual group members are only included in message events. The user ID is not included if the user has not agreed to the Official Accounts Terms of Use.

Source room example

  "source": {
    "type": "room",
    "roomId": "Ra8dbf4673c4c812cd491258042226c99",
    "userId": "U206d25c2ea6bd87c17655609a1c37cb8"
  }

Source room

JSON object which contains the source room of the event.

Field Type Description
type String room
roomId String ID of the source room
userId String ID of the source user

Note: User IDs of individual group members are only included in message events. The user ID is not included if the user has not agreed to the Official Accounts Terms of Use.

Message event

Event object which contains the sent message. The message field contains a message object which corresponds with the message type. You can reply to message events.

Field Type Description
type String message
replyToken String Token for replying to this event
message Text
Image
Video
Audio
File
Location
Sticker
Contents of the message

Text message example

{
  "replyToken": "nHuyWiB7yP5Zw52FIkcQobQuGDXCTA",
  "type": "message",
  "timestamp": 1462629479859,
  "source": {
    "type": "user",
    "userId": "U206d25c2ea6bd87c17655609a1c37cb8"
  },
  "message": {
    "id": "325708",
    "type": "text",
    "text": "Hello, world"
  }
}

Text message

Message object which contains the text sent from the source.

Field Type Description
id String Message ID
type String text
text String Message text

Image message example

{
  "replyToken": "nHuyWiB7yP5Zw52FIkcQobQuGDXCTA",
  "type": "message",
  "timestamp": 1462629479859,
  "source": {
    "type": "user",
    "userId": "U206d25c2ea6bd87c17655609a1c37cb8"
  },
  "message": {
    "id": "325708",
    "type": "image"
  }
}

Image message

Message object which contains the image content sent from the source. The binary image data can be retrieved from the content endpoint.

Field Type Description
id String Message ID
type String image

Video message example

{
  "replyToken": "nHuyWiB7yP5Zw52FIkcQobQuGDXCTA",
  "type": "message",
  "timestamp": 1462629479859,
  "source": {
    "type": "user",
    "userId": "U206d25c2ea6bd87c17655609a1c37cb8"
  },
  "message": {
    "id": "325708",
    "type": "video"
  }
}

Video message

Message object which contains the video content sent from the source. The binary video data can be retrieved from the content endpoint.

Field Type Description
id String Message ID
type String video

Audio message example

{
  "replyToken": "nHuyWiB7yP5Zw52FIkcQobQuGDXCTA",
  "type": "message",
  "timestamp": 1462629479859,
  "source": {
    "type": "user",
    "userId": "U206d25c2ea6bd87c17655609a1c37cb8"
  },
  "message": {
    "id": "325708",
    "type": "audio"
  }
}

Audio message

Message object which contains the audio content sent from the source. The binary audio data can be retrieved from the content endpoint.

Field Type Description
id String Message ID
type String audio

File message example

{
  "replyToken": "nHuyWiB7yP5Zw52FIkcQobQuGDXCTA",
  "type": "message",
  "timestamp": 1462629479859,
  "source": {
    "type": "user",
    "userId": "U206d25c2ea6bd87c17655609a1c37cb8"
  },
  "message": {
    "id": "325708",
    "type": "file",
    "fileName": "file.txt",
    "fileSize": 2138
  }
}

File message

Message object which contains the file sent from the source. The binary data can be retrieved from the content endpoint.

Field Type Description
id String Message ID
type String file
fileName String file name
fileSize String File size in bytes

Location message example

{
  "replyToken": "nHuyWiB7yP5Zw52FIkcQobQuGDXCTA",
  "type": "message",
  "timestamp": 1462629479859,
  "source": {
    "type": "user",
    "userId": "U206d25c2ea6bd87c17655609a1c37cb8"
  },
  "message": {
    "id": "325708",
    "type": "location",
    "title": "my location",
    "address": "〒150-0002 東京都渋谷区渋谷2丁目21−1",
    "latitude": 35.65910807942215,
    "longitude": 139.70372892916203
  }
}

Location message

Message object which contains the location data sent from the source.

Field Type Description
id String Message ID
type String location
title String Title
address String Address
latitude Decimal Latitude
longitude Decimal Longitude

Sticker message example

{
  "replyToken": "nHuyWiB7yP5Zw52FIkcQobQuGDXCTA",
  "type": "message",
  "timestamp": 1462629479859,
  "source": {
    "type": "user",
    "userId": "U206d25c2ea6bd87c17655609a1c37cb8"
  },
  "message": {
    "id": "325708",
    "type": "sticker",
    "packageId": "1",
    "stickerId": "1"
  }
}

Sticker message

Message object which contains the sticker data sent from the source. For a list of basic LINE stickers and sticker IDs, see sticker list.

Field Type Description
id String Message ID
type String sticker
packageId String Package ID
stickerId String Sticker ID

Follow event example

{
  "replyToken": "nHuyWiB7yP5Zw52FIkcQobQuGDXCTA",
  "type": "follow",
  "timestamp": 1462629479859,
  "source": {
    "type": "user",
    "userId": "U206d25c2ea6bd87c17655609a1c37cb8"
  }
}

Follow event

Event object for when your account is added as a friend (or unblocked). You can reply to follow events.

Field Type Description
type String follow
replyToken String Token for replying to this event

Unfollow event example

{
  "type": "unfollow",
  "timestamp": 1462629479859,
  "source": {
    "type": "user",
    "userId": "U206d25c2ea6bd87c17655609a1c37cb8"
  }
}

Unfollow event

Event object for when your account is blocked.

Field Type Description
type String unfollow

Join event example

{
  "replyToken": "nHuyWiB7yP5Zw52FIkcQobQuGDXCTA",
  "type": "join",
  "timestamp": 1462629479859,
  "source": {
    "type": "group",
    "groupId": "cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  }
}

Join event

Event object for when your account joins a group or talk room. You can reply to join events.

Field Type Description
type String join
replyToken String Token for replying to this event

Leave event example

{
  "type": "leave",
  "timestamp": 1462629479859,
  "source": {
    "type": "group",
    "groupId": "cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  }
}

Leave event

Event object for when your account leaves a group.

Field Type Description
type String leave

No event is generated when your account leaves a room.

Leave events are not generated if you leave a group or room using leave group or leave room.

Postback event example

{
  "replyToken": "nHuyWiB7yP5Zw52FIkcQobQuGDXCTA",
  "type": "postback",
  "timestamp": 1462629479859,
  "source": {
    "type": "user",
    "userId": "U206d25c2ea6bd87c17655609a1c37cb8"
  },
  "postback": {
    "data": "action=buyItem&itemId=123123&color=red"
  }
}

Postback event

Event object for when a user performs an action on a template message which initiates a postback. You can reply to postback events.

Field Type Description
type String postback
replyToken String Token for replying to this event
postback.data String Postback data
postback.params Object JSON object with the date and time selected by a user through a datetime picker action.
Only returned for postback actions via the datetime picker.

postback.params object

Object with the date and time selected by a user through a datetime picker action. The full-date, time-hour, and time-minute formats follow the RFC3339 protocol.

Field Format Description
date full-date Date selected by user. Only included in the date mode.
time time-hour ":" time-minute Time selected by the user. Only included in the time mode.
datetime full-date "T" time-hour ":" time-minute Date and time selected by the user. Only included in the datetime mode.

Beacon event example

{
  "replyToken": "nHuyWiB7yP5Zw52FIkcQobQuGDXCTA",
  "type": "beacon",
  "timestamp": 1462629479859,
  "source": {
    "type": "user",
    "userId": "U206d25c2ea6bd87c17655609a1c37cb8"
  },
  "beacon": {
    "hwid": "d41d8cd98f",
    "type": "enter"
  }
}

Beacon event

Event object for when a user enters or leaves the range of a LINE Beacon. You can reply to beacon events.

Field Type Description
type String beacon
replyToken String Token for replying to this event
beacon.hwid String Hardware ID of the beacon that was detected
beacon.type String Type of beacon event
beacon.dm String Optional. Device message of beacon that was detected

The "device message" consists of data generated by the beacon to send notifications to bots. The beacon.dm property is only included in webhooks from devices that support the "device message" property. You can use beacon.dm with the LINE Simple Beacon specification. For more information, see the LINE Simple Beacon specification.

Depending on the type of event, the beacon.type field contains the following strings.

beacon.type Description
enter Entered beacon's reception range
leave Left beacon's reception range
banner Tapped beacon banner

OAuth

Example request

curl -X POST  \
-H "Content-Type:application/x-www-form-urlencoded" \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'client_id={CLIENT_ID}' \
--data-urlencode 'client_secret={CLIENT_SECRET}' \
https://api.line.me/v2/oauth/accessToken
Example request
// No sample code available
Example request
# No sample code available
Example request
// No sample code available
Example request
// No sample code available
Example request
# No sample code available
Example request
# No sample code available
Example request
// No sample code available

Issue channel access token

Note: This method issues a short-lived channel access token that is valid for 30 days. To issue a long-lived channel access token, use the "Issue" button found on the console. (Long-lived access tokens may not be available to users using official accounts or certain LINE@ plans.)

Issues a short-lived channel access token.

Up to 30 tokens can be issued. If the maximum is exceeded, existing channel access tokens will be revoked in the order of when they were first issued.

HTTP request

POST https://api.line.me/v2/oauth/accessToken

Request header

Request header Description
Content-Type application/x-www-form-urlencoded

Request body

Name Type Description
grant_type String client_credentials
client_id String Channel ID. Found on the console.
client_secret String Channel secret. Found on the console.

Example response

{
"access_token":"W1TeHCgfH2Liwa.....",
"expires_in":2592000,
"token_type":"Bearer"
}

Response

Returns a 200 HTTP status code and a JSON object with the following fields.

Property Type Description
access_token String Short-lived channel access token. Valid for 30 days.
Note: Channel access tokens cannot be refreshed.
expires_in Number Time until channel access token expires in seconds from time the token is issued
token_type String Bearer

Example error response

{
"error":"invalid_request",
"error_description":"some parameters missed or invalid"
}

Error response

Returns a 400 HTTP status code and a JSON object with the following fields.

Property Type Description
error String Error summary
error_description String Details of the error. In some cases, this field is not included in the response.

Example request

curl -X POST \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode 'access_token={ACCESS_TOKEN}' \
https://api.line.me/v2/oauth/revoke
Example request
// No sample code available
Example request
# No sample code available
Example request
// No sample code available
Example request
// No sample code available
Example request
# No sample code available
Example request
# No sample code available
Example request
// No sample code available

Revoke channel access token

Revokes a channel access token.

HTTP request

POST https://api.line.me/v2/oauth/revoke

Request header

Request header Description
Content-Type application/x-www-form-urlencoded

Request body

Property Type Description
access_token String Channel access token

Example response

{}

Response

Returns the status code 200 and an empty JSON object. No error occurs if an invalid channel access token is specified.

Example error response

{
"error":"invalid_request",
"error_description":"some parameters missed or invalid"
}

Error response

Returns a 400 HTTP status code and a JSON object with the following fields.

Property Type Description
error String Error summary
error_description String Details of the error. In some cases, this field is not included in the response.

Message

Example send reply message request

curl -X POST \
-H 'Content-Type:application/json' \
-H 'Authorization: Bearer {ENTER_ACCESS_TOKEN}' \
-d '{
    "replyToken":"nHuyWiB7yP5Zw52FIkcQobQuGDXCTA",
    "messages":[
        {
            "type":"text",
            "text":"Hello, user"
        },
        {
            "type":"text",
            "text":"May I help you?"
        }
    ]
}' https://api.line.me/v2/bot/message/reply
Example send reply message request
TextMessage textMessage = new TextMessage("hello");
ReplyMessage replyMessage = new ReplyMessage(
        "<replyToken>",
        textMessage
);
Response<BotApiResponse> response =
        LineMessagingServiceBuilder
                .create("<channel access token>")
                .build()
                .replyMessage(replyMessage)
                .execute();
System.out.println(response.code() + " " + response.message());
Example send reply message request
bot, err := linebot.New(<channel secret>, <channel token>)
if err != nil {
    ...
}
if _, err := bot.ReplyMessage(<replyToken>, linebot.NewTextMessage("hello")).Do(); err != nil {
    ...
}
Example send reply message request
message = {
  type: 'text',
  text: 'hello'
}
client = Line::Bot::Client.new { |config|
    config.channel_secret = "<channel secret>"
    config.channel_token = "<channel access token>"
}
response = client.reply_message("<replyToken>", message)
p response
Example send reply message request
$httpClient = new \LINE\LINEBot\HTTPClient\CurlHTTPClient('<channel access token>');
$bot = new \LINE\LINEBot($httpClient, ['channelSecret' => '<channel secret>']);

$textMessageBuilder = new \LINE\LINEBot\MessageBuilder\TextMessageBuilder('hello');
$response = $bot->replyMessage('<replyToken>', $textMessageBuilder);

echo $response->getHTTPStatus() . ' ' . $response->getRawBody();
Example send reply message request
use LINE::Bot::API;
use LINE::Bot::API::Builder::SendMessage;

my $bot = LINE::Bot::API->new(
    channel_secret       => "<channel secret>",
    channel_access_token => "<channel access token>",
);

my $messages = LINE::Bot::API::Builder::SendMessage->new(
)->add_text(
    text => 'hello',
);
my $res = $bot->reply_message("<replyToken>", $messages->build);
unless ($res->is_success) {
    # error handling
    ....
}
Example send reply message request
from linebot import LineBotApi
from linebot.models import TextSendMessage
from linebot.exceptions import LineBotApiError

line_bot_api = LineBotApi('<channel access token>')

try:
    line_bot_api.reply_message('<reply_token>', TextSendMessage(text='Hello World!'))
except LineBotApiError as e:
    # error handle
    ...
Example send reply message request
const line = require('@line/bot-sdk');

const client = new line.Client({
  channelAccessToken: '<channel access token>'
});

const message = {
  type: 'text',
  text: 'Hello World!'
};

client.replyMessage('<replyToken>', message)
  .then(() => {
    ...
  })
  .catch((err) => {
    // error handling
  });

Send reply message

Respond to events from users, groups, and rooms.

Webhooks are used to notify you when an event occurs. For events that you can respond to, a replyToken is issued for replying to messages.

Because the replyToken becomes invalid after a certain period of time, responses should be sent as soon as a message is received. Reply tokens can only be used once.

HTTP request

POST https://api.line.me/v2/bot/message/reply

Request headers

Request header Description
Content-Type application/json
Authorization Bearer {Channel Access Token}

Request body

Include an array of message objects for your message.

Field Type Required Description
replyToken String Yes replyToken received via webhook
messages Array of message objects Yes Messages
Max: 5

Example JSON response

{}

Response

Returns the status code 200 and an empty JSON object.

Push message request example

curl -X POST \
-H 'Content-Type:application/json' \
-H 'Authorization: Bearer {ENTER_ACCESS_TOKEN}' \
-d '{
    "to": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "messages":[
        {
            "type":"text",
            "text":"Hello, world1"
        },
        {
            "type":"text",
            "text":"Hello, world2"
        }
    ]
}' https://api.line.me/v2/bot/message/push
Push message request example
TextMessage textMessage = new TextMessage("hello");
PushMessage pushMessage = new PushMessage(
        "<to>",
        textMessage
);

Response<BotApiResponse> response =
        LineMessagingServiceBuilder
                .create("<channel access token>")
                .build()
                .pushMessage(pushMessage)
                .execute();
System.out.println(response.code() + " " + response.message());
Push message request example
bot, err := linebot.New(<channel secret>, <channel token>)
if err != nil {
    ...
}
if _, err := bot.PushMessage(<to>, linebot.NewTextMessage("hello")).Do(); err != nil {
    ...
}
Push message request example
message = {
  type: 'text',
  text: 'hello'
}
client = Line::Bot::Client.new { |config|
    config.channel_secret = "<channel secret>"
    config.channel_token = "<channel access token>"
}
response = client.push_message("<to>", message)
p response
Push message request example
$httpClient = new \LINE\LINEBot\HTTPClient\CurlHTTPClient('<channel access token>');
$bot = new \LINE\LINEBot($httpClient, ['channelSecret' => '<channel secret>']);

$textMessageBuilder = new \LINE\LINEBot\MessageBuilder\TextMessageBuilder('hello');
$response = $bot->pushMessage('<to>', $textMessageBuilder);

echo $response->getHTTPStatus() . ' ' . $response->getRawBody();
Push message request example
use LINE::Bot::API;
use LINE::Bot::API::Builder::SendMessage;

my $bot = LINE::Bot::API->new(
    channel_secret       => "<channel secret>",
    channel_access_token => "<channel access token>",
);

my $messages = LINE::Bot::API::Builder::SendMessage->new(
)->add_text(
    text => 'hello',
);
my $res = $bot->push_message("<to>", $messages->build);
unless ($res->is_success) {
    # error handling
    ....
}
Push message request example
from linebot import LineBotApi
from linebot.models import TextSendMessage
from linebot.exceptions import LineBotApiError

line_bot_api = LineBotApi('<channel access token>')

try:
    line_bot_api.push_message('<to>', TextSendMessage(text='Hello World!'))
except LineBotApiError as e:
    # error handle
    ...
Push message request example
const line = require('@line/bot-sdk');

const client = new line.Client({
  channelAccessToken: '<channel access token>'
});

const message = {
  type: 'text',
  text: 'Hello World!'
};

client.pushMessage('<to>', message)
  .then(() => {
    ...
  })
  .catch((err) => {
    // error handling
  });

Send push message

Send messages to a user, group, or room at any time.

Note: Use of push messages are limited to certain plans.

HTTP request

POST https://api.line.me/v2/bot/message/push

Request headers

Request header Description
Content-Type application/json
Authorization Bearer {Channel Access Token}

Request body

Include an array of message objects for your message.

Field Type Required Description
to String Yes ID of the receiver
messages Array of message objects Yes Messages
Max: 5

Example JSON response

{}

Response

Returns the status code 200 and an empty JSON object.

Multicast request example

curl -X POST \
-H 'Content-Type:application/json' \
-H 'Authorization: Bearer {ENTER_ACCESS_TOKEN}' \
-d '{
    "to": ["xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"],
    "messages":[
        {
            "type":"text",
            "text":"Hello, world1"
        },
        {
            "type":"text",
            "text":"Hello, world2"
        }
    ]
}' https://api.line.me/v2/bot/message/multicast
Multicast request example
// No sample code available
Multicast request example
# No sample code available
Multicast request example
// No sample code available
Multicast request example
// No sample code available
Multicast request example
# No sample code available
Multicast request example
# No sample code available
Multicast request example
// No sample code available

Send multicast messages

Send push messages to multiple users at any time.

HTTP request

POST https://api.line.me/v2/bot/message/multicast

Request headers

Request header Description
Content-Type application/json
Authorization Bearer {Channel Access Token}

Request body

Include an array of message objects with the messages to be sent.

Field Type Required Description
to Array of strings Yes IDs of the receivers
Max: 150 users
messages Array of message objects Yes Messages
Max: 5

Example JSON response

{}

Response

Returns the status code 200 and an empty JSON object.

Example request

curl -X GET \
-H 'Authorization: Bearer {ENTER_ACCESS_TOKEN}' \
https://api.line.me/v2/bot/message/{messageId}/content
Example request
Response<ResponseBody> response =
        LineMessagingServiceBuilder
                .create("<channel access token>")
                .build()
                .getMessageContent("<messageId>")
                .execute();
if (response.isSuccessful()) {
    ResponseBody content = response.body();
    Files.copy(content.byteStream(),
               Files.createTempFile("foo", "bar"));
} else {
    System.out.println(response.code() + " " + response.message());
}
Example request
bot, err := linebot.New(<channel secret>, <channel token>)
if err != nil {
    ...
}
content, err := bot.GetMessageContent(<messageID>).Do()
if err != nil {
    ...
}
defer content.Content.Close()

...
Example request
client = Line::Bot::Client.new { |config|
    config.channel_secret = "<channel secret>"
    config.channel_token = "<channel access token>"
}
response = client.get_message_content("<messageId>")
case response
when Net::HTTPSuccess then
  tf = Tempfile.open("content")
  tf.write(response.body)
else
  p "#{response.code} #{response.body}"
end
Example request
$httpClient = new \LINE\LINEBot\HTTPClient\CurlHTTPClient('<channel access token>');
$bot = new \LINE\LINEBot($httpClient, ['channelSecret' => '<channel secret>']);
$response = $bot->getMessageContent('<messageId>');
if ($response->isSucceeded()) {
    $tempfile = tmpfile();
    fwrite($tempfile, $response->getRawBody());
} else {
    error_log($response->getHTTPStatus() . ' ' . $response->getRawBody());
}
Example request
use LINE::Bot::API;

my $bot = LINE::Bot::API->new(
    channel_secret       => "<channel secret>",
    channel_access_token => "<channel access token>",
);

my $res = $bot->get_message_content("<messageId>");
unless ($res->is_success) {
    # error handling
    ....
}
my $filename = $ret->fh->filename;
open my $fh, '<', $file or die "$!: $file";
Example request
from linebot import LineBotApi

line_bot_api = LineBotApi('<channel access token>')

message_content = line_bot_api.get_message_content('<message_id>')
with open(file_path, 'wb') as fd:
    for chunk in message_content.iter_content():
        fd.write(chunk)
Example request
const line = require('@line/bot-sdk');

const client = new line.Client({
  channelAccessToken: '<channel access token>'
});

const stream = client.getMessageContent('<messageId>');
stream.on('data', (chunk) => {
  ...
});
stream.on('error', (err) => {
  // error handling
});

Get content

Retrieve image, video, and audio data sent by users.

HTTP request

GET https://api.line.me/v2/bot/message/{messageId}/content

Request headers

Request header Description
Authorization Bearer {Channel Access Token}

URL parameters

Parameter Description
messageId Message ID

Response

Returns status code 200 and the content in binary.

Note: Content is automatically deleted after a certain period from when the message was sent. There is no guarantee for how long content is stored.

Profile

Profile request example

curl -X GET \
-H 'Authorization: Bearer {ENTER_ACCESS_TOKEN}' \
https://api.line.me/v2/bot/profile/{userId}
Profile request example
Response<UserProfileResponse> response =
        LineMessagingServiceBuilder
                .create("<channel access token>")
                .build()
                .getProfile("<userId>")
                .execute();
if (response.isSuccessful()) {
    UserProfileResponse profile = response.body();
    System.out.println(profile.getDisplayName());
    System.out.println(profile.getPictureUrl());
    System.out.println(profile.getStatusMessage());
} else {
    System.out.println(response.code() + " " + response.message());
}
Profile request example
bot, err := linebot.New(<channel secret>, <channel token>)
if err != nil {
    ...
}
res, err := bot.GetUserProfile(<userId>).Do();
if err != nil {
    ...
}
println(res.Displayname)
println(res.PicutureURL)
println(res.StatusMessage)
Profile request example
client = Line::Bot::Client.new { |config|
    config.channel_secret = "<channel secret>"
    config.channel_token = "<channel access token>"
}
response = client.get_profile("<userId>")
case response
when Net::HTTPSuccess then
  contact = JSON.parse(response.body)
  p contact['displayName']
  p contact['pictureUrl']
  p contact['statusMessage']
else
  p "#{response.code} #{response.body}"
end
Profile request example
$httpClient = new \LINE\LINEBot\HTTPClient\CurlHTTPClient('<channel access token>');
$bot = new \LINE\LINEBot($httpClient, ['channelSecret' => '<channel secret>']);
$response = $bot->getProfile('<userId>');
if ($response->isSucceeded()) {
    $profile = $response->getJSONDecodedBody();
    echo $profile['displayName'];
    echo $profile['pictureUrl'];
    echo $profile['statusMessage'];
}
Profile request example
use LINE::Bot::API;

my $bot = LINE::Bot::API->new(
    channel_secret       => "<channel secret>",
    channel_access_token => "<channel access token>",
);

my $res = $bot->get_profile("<userId>");
unless ($res->is_success) {
    # error handling
    ....
}

say $ret->display_name;
say $ret->user_id;
say $ret->picture_url;
say $ret->status_message;
Profile request example
from linebot import LineBotApi
from linebot.exceptions import LineBotApiError

line_bot_api = LineBotApi('<channel access token>')

try:
    profile = line_bot_api.get_profile('<user_id>')
    print(profile.display_name)
    print(profile.user_id)
    print(profile.picture_url)
    print(profile.status_message)
except LineBotApiError as e:
    # error handle
    ...
Profile request example
const line = require('@line/bot-sdk');

const client = new line.Client({
  channelAccessToken: '<channel access token>'
});

client.getProfile('<userId>')
  .then((profile) => {
    console.log(profile.displayName);
    console.log(profile.userId);
    console.log(profile.pictureUrl);
    console.log(profile.statusMessage);
  })
  .catch((err) => {
    // error handling
  });

Get profile

Get user profile information.

HTTP request

GET https://api.line.me/v2/bot/profile/{userId}

Request headers

Request header Description
Authorization Bearer {Channel Access Token}

URL parameters

Parameter Description
userId User ID

Response body example

{
    "displayName":"LINE taro",
    "userId":"Uxxxxxxxxxxxxxx...",
    "pictureUrl":"http://obs.line-apps.com/...",
    "statusMessage":"Hello, LINE!"
}

Response

Returns the status code 200 and a JSON object with the following parameters.

Field Type Description
displayName String Display name
userId String User ID
pictureUrl String Image URL
statusMessage String Status message

Group

Get group member profiles example request

curl -X GET \
-H 'Authorization: Bearer {ENTER_ACCESS_TOKEN}' \
https://api.line.me/v2/bot/group/{groupId}/member/{userId}
Get group member profiles example request
// No sample code available
Get group member profiles example request
# No sample code available
Get group member profiles example request
// No sample code available
Get group member profiles example request
// No sample code available
Get group member profiles example request
# No sample code available
Get group member profiles example request
# No sample code available
Get group member profiles example request
const line = require('@line/bot-sdk');

const client = new line.Client({
  channelAccessToken: '<channel access token>'
});

client.getGroupMemberProfile('<groupId>', '<userId>')
  .then((profile) => {
    console.log(profile.displayName);
    console.log(profile.userId);
    console.log(profile.pictureUrl);
    console.log(profile.statusMessage);
  })
  .catch((err) => {
    // error handling
  });

Get group member profile

Gets the user profile of a member of a group that the bot is in. This includes user profiles of users who have not added the bot as a friend or have blocked the bot.

HTTP request

GET https://api.line.me/v2/bot/group/{groupId}/member/{userId}

Request headers

Request header Description
Authorization Bearer {Channel Access Token}

URL parameters

Group
Parameter Description
groupId Identifier of the group
userId Identifier of the user

Example response

{
    "displayName":"LINE taro",
    "userId":"Uxxxxxxxxxxxxxx...",
    "pictureUrl":"http://obs.line-apps.com/..."
}

Response

Returns the status code 200 and a JSON object with the following properties.

Field Type Description
displayName String Display name
userId String User ID
pictureUrl String Profile image URL

Example request

curl -X GET \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
https://api.line.me/v2/bot/group/{groupId}/members/ids?start={continuationToken}
Example request
// No sample code available
Example request
# No sample code available
Example request
// No sample code available
Example request
// No sample code available
Example request
# No sample code available
Example request
# No sample code available
Example request
const line = require('@line/bot-sdk');

const client = new line.Client({
  channelAccessToken: '<channel access token>'
});

client.getGroupMemberIds('<groupId>')
  .then((ids) => {
    ids.forEach((id) => console.log(id));
  })
  .catch((err) => {
    // error handling
  });

Get group member user IDs

Gets the user IDs of the members of a group that the bot is in. This includes the user IDs of users who have not added the bot as a friend or has blocked the bot.

HTTP request

GET https://api.line.me/v2/bot/group/{groupId}/members/ids?start={continuationToken}

Request headers

Request header Description
Authorization Bearer {Channel Access Token}

URL parameters

Group
Parameter Required Description
groupId Yes Identifier of the group
start No continuationToken

Example response body

{"memberIds":["Uxxxxxxxxxxxxxx...","Uxxxxxxxxxxxxxx...","Uxxxxxxxxxxxxxx..."]}

{"memberIds":["Uxxxxxxxxxxxxxx...","Uxxxxxxxxxxxxxx...","Uxxxxxxxxxxxxxx..."],"next":"jxEWCEEP..."}

Response

Returns the status code 200 and a JSON object with the following properties.

Property Type Required Description
memberIds Array of strings Yes List of user IDs of the members in the group.
Max: 100 user IDs
next String No continuationToken
Only returned when there are more user IDs remaining in memberIds.

Leave request example

curl -X POST \
-H 'Authorization: Bearer {ENTER_ACCESS_TOKEN}' \
https://api.line.me/v2/bot/group/{groupId}/leave
Leave request example
Response<BotApiResponse> response =
        LineMessagingServiceBuilder
                .create("<channel access token>")
                .build()
                .leaveGroup("<groupId>")
                .execute();
System.out.println(response.code() + " " + response.message());
Leave request example
bot, err := linebot.New(<channel secret>, <channel token>)
if err != nil {
    ...
}
if _, err := bot.LeaveGroup(<groupId>).Do(); err != nil {
    ...
}
Leave request example
client = Line::Bot::Client.new { |config|
    config.channel_secret = "<channel secret>"
    config.channel_token = "<channel access token>"
}
response = client.leave_group("<groupId>")
p response.body
Leave request example
$httpClient = new \LINE\LINEBot\HTTPClient\CurlHTTPClient('<channel access token>');
$bot = new \LINE\LINEBot($httpClient, ['channelSecret' => '<channel secret>']);
$response = $bot->leaveGroup('<groupId>');
echo $response->getHTTPStatus() . ' ' . $response->getRawBody();
Leave request example
use LINE::Bot::API;

my $bot = LINE::Bot::API->new(
    channel_secret       => "<channel secret>",
    channel_access_token => "<channel access token>",
);

my $res = $bot->leave_group("<groupId>");
unless ($res->is_success) {
    # error handling
    ....
}
Leave request example
from linebot import LineBotApi
from linebot.exceptions import LineBotApiError

line_bot_api = LineBotApi('<channel access token>')

try:
    line_bot_api.leave_group('<group_id>')
except LineBotApiError as e:
    # error handle
    ...
Leave request example
const line = require('@line/bot-sdk');

const client = new line.Client({
  channelAccessToken: '<channel access token>'
});

client.leaveGroup('<groupId>')
  .then(() => {
    ...
  })
  .catch((err) => {
    // error handling
  });

Leave group

Leave a group.

HTTP request

POST https://api.line.me/v2/bot/group/{groupId}/leave

Request headers

Request header Description
Authorization Bearer {Channel Access Token}

URL parameters

Parameter Description
groupId Group ID

JSON response example

{}

Response

Returns the status code 200 and an empty JSON object.

Room

Get room member profiles example request

curl -X GET \
-H 'Authorization: Bearer {ENTER_ACCESS_TOKEN}' \
https://api.line.me/v2/bot/room/{roomId}/member/{userId}
Get room member profiles example request
// No sample code available
Get room member profiles example request
# No sample code available
Get room member profiles example request
// No sample code available
Get room member profiles example request
// No sample code available
Get room member profiles example request
# No sample code available
Get room member profiles example request
# No sample code available
Get room member profiles example request
const line = require('@line/bot-sdk');

const client = new line.Client({
  channelAccessToken: '<channel access token>'
});

client.getRoomMemberProfile('<roomId>', '<userId>')
  .then((profile) => {
    console.log(profile.displayName);
    console.log(profile.userId);
    console.log(profile.pictureUrl);
    console.log(profile.statusMessage);
  })
  .catch((err) => {
    // error handling
  });

Get room member profile

Gets the user profile of a member of a room that the bot is in. This includes user profiles of users who have not added the bot as a friend or have blocked the bot.

HTTP request

GET https://api.line.me/v2/bot/room/{roomId}/member/{userId}

Request headers

Request header Description
Authorization Bearer {Channel Access Token}

URL parameters

Room
Parameter Description
roomId Identifier of the room
userId Identifier of the user

Example response

{
    "displayName":"LINE taro",
    "userId":"Uxxxxxxxxxxxxxx...",
    "pictureUrl":"http://obs.line-apps.com/..."
}

Response

Returns the status code 200 and a JSON object with the following properties.

Field Type Description
displayName String Display name
userId String User ID
pictureUrl String Profile image URL

Example request

curl -X GET \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
https://api.line.me/v2/bot/room/{roomId}/members/ids?start={continuationToken}
Example request
// No sample code available
Example request
# No sample code available
Example request
// No sample code available
Example request
// No sample code available
Example request
# No sample code available
Example request
# No sample code available
Example request
const line = require('@line/bot-sdk');

const client = new line.Client({
  channelAccessToken: '<channel access token>'
});

client.getRoomMemberIds('<roomId>')
  .then((ids) => {
    ids.forEach((id) => console.log(id));
  })
  .catch((err) => {
    // error handling
  });

Get room member user IDs

Gets the user IDs of the members of a room that the bot is in. This includes the user IDs of users who have not added the bot as a friend or has blocked the bot.

HTTP request

GET https://api.line.me/v2/bot/room/{roomId}/members/ids?start={continuationToken}

Request headers

Request header Description
Authorization Bearer {Channel Access Token}

URL parameters

Room
Parameter Required Description
roomId Yes Identifier of the room
start No continuationToken

Example response body

{"memberIds":["Uxxxxxxxxxxxxxx...","Uxxxxxxxxxxxxxx...","Uxxxxxxxxxxxxxx..."]}

{"memberIds":["Uxxxxxxxxxxxxxx...","Uxxxxxxxxxxxxxx...","Uxxxxxxxxxxxxxx..."],"next":"jxEWCEEP..."}

Response

Returns the status code 200 and a JSON object with the following properties.

Property Type Required Description
memberIds Array of strings Yes List of user IDs of the members in the room.
Max: 100 user IDs
next String No continuationToken
Only returned when there are more user IDs remaining in memberIds.

Leave request example

curl -X POST \
-H 'Authorization: Bearer {ENTER_ACCESS_TOKEN}' \
https://api.line.me/v2/bot/room/{roomId}/leave
Leave request example
Response<BotApiResponse> response =
        LineMessagingServiceBuilder
                .create("<channel access token>")
                .build()
                .leaveRoom("<roomId>")
                .execute();
System.out.println(response.code() + " " + response.message());
Leave request example
bot, err := linebot.New(<channel secret>, <channel token>)
if err != nil {
    ...
}
if _, err := bot.LeaveRoom(<roomId>).Do(); err != nil {
    ...
}
Leave request example
client = Line::Bot::Client.new { |config|
    config.channel_secret = "<channel secret>"
    config.channel_token = "<channel access token>"
}
response = client.leave_room("<roomId>")
p response.body
Leave request example
$httpClient = new \LINE\LINEBot\HTTPClient\CurlHTTPClient('<channel access token>');
$bot = new \LINE\LINEBot($httpClient, ['channelSecret' => '<channel secret>']);
$response = $bot->leaveRoom('<roomId>');
echo $response->getHTTPStatus() . ' ' . $response->getRawBody();
Leave request example
use LINE::Bot::API;

my $bot = LINE::Bot::API->new(
    channel_secret       => "<channel secret>",
    channel_access_token => "<channel access token>",
);

my $res = $bot->leave_room("<roomId>");
unless ($res->is_success) {
    # error handling
    ....
}
Leave request example
from linebot import LineBotApi
from linebot.exceptions import LineBotApiError

line_bot_api = LineBotApi('<channel access token>')

try:
    line_bot_api.leave_room('<room_id>')
except LineBotApiError as e:
    # error handle
    ...
Leave request example
const line = require('@line/bot-sdk');

const client = new line.Client({
  channelAccessToken: '<channel access token>'
});

client.leaveRoom('<roomId>')
  .then(() => {
    ...
  })
  .catch((err) => {
    // error handling
  });

Leave room

Leave a room.

HTTP request

POST https://api.line.me/v2/bot/room/{roomId}/leave

Request headers

Request header Description
Authorization Bearer {Channel Access Token}

URL parameters

Parameter Description
roomId Room ID

JSON response example

{}

Response

Returns the status code 200 and an empty JSON object.

Message objects

JSON object which contains the contents of the message you send.

Text example

{
    "type": "text",
    "text": "Hello, world"
}

Text

Field Type Required Description
type String Yes text
text String Yes Message text
Max: 2000 characters

Text example with emoji


{
    "type": "text",
    "text": "\uDBC0\uDC84 LINE emoji"
}

You can send text messages containing the following emoji.

Sticker example

{
  "type": "sticker",
  "packageId": "1",
  "stickerId": "1"
}

Sticker

For a list of the sticker IDs for stickers that can be sent with the Messaging API, see Sticker list.

Field Type Required Description
type String Yes sticker
packageId String Yes Package ID
stickerId String Yes Sticker ID

Image example

{
    "type": "image",
    "originalContentUrl": "https://example.com/original.jpg",
    "previewImageUrl": "https://example.com/preview.jpg"
}

Image

Field Type Required Description
type String Yes image
originalContentUrl String Yes Image URL (Max: 1000 characters)
HTTPS
JPEG
Max: 1024 x 1024
Max: 1 MB
previewImageUrl String Yes Preview image URL (Max: 1000 characters)
HTTPS
JPEG
Max: 240 x 240
Max: 1 MB

Video example

{
    "type": "video",
    "originalContentUrl": "https://example.com/original.mp4",
    "previewImageUrl": "https://example.com/preview.jpg"
}

Video

Field Type Required Description
type String Yes video
originalContentUrl String Yes URL of video file (Max: 1000 characters)
HTTPS
mp4
Less than 1 minute
Max: 10 MB
previewImageUrl String Yes URL of preview image (Max: 1000 characters)
HTTPS
JPEG
Max: 240 x 240
Max: 1 MB

Audio example

{
    "type": "audio",
    "originalContentUrl": "https://example.com/original.m4a",
    "duration": 240000
}

Audio

Field Type Required Description
type String Yes audio
originalContentUrl String Yes URL of audio file (Max: 1000 characters)
HTTPS
m4a
Less than 1 minute
Max 10 MB
duration Number Yes Length of audio file (milliseconds)

Location example

{
    "type": "location",
    "title": "my location",
    "address": "〒150-0002 東京都渋谷区渋谷2丁目21−1",
    "latitude": 35.65910807942215,
    "longitude": 139.70372892916203
}

Location

Field Type Required Description
type String Yes location
title String Yes Title
Max: 100 characters
address String Yes Address
Max: 100 characters
latitude Decimal Yes Latitude
longitude Decimal Yes Longitude

Imagemap with two tappable regions on the left and the right

{
  "type": "imagemap",
  "baseUrl": "https://example.com/bot/images/rm001",
  "altText": "this is an imagemap",
  "baseSize": {
      "height": 1040,
      "width": 1040
  },
  "actions": [
      {
          "type": "uri",
          "linkUri": "https://example.com/",
          "area": {
              "x": 0,
              "y": 0,
              "width": 520,
              "height": 1040
          }
      },
      {
          "type": "message",
          "text": "hello",
          "area": {
              "x": 520,
              "y": 0,
              "width": 520,
              "height": 1040
          }
      }
  ]
}

Imagemap message

Imagemaps are images with one or more links. You can assign one link for the entire image or multiple links which correspond to different regions of the image.

Field Type Required Description
type String Yes imagemap
baseUrl String Yes Base URL of image (Max: 1000 characters)
HTTPS
altText String Yes Alternative text
Max: 400 characters
baseSize.width Number Yes Width of base image (set to 1040px)
baseSize.height Number Yes Height of base image(set to the height that corresponds to a width of 1040px)
actions Array of Imagemap action object Yes Action when tapped
Max: 50

Base URL

To use an imagemap, you must include URLs with the image width (px) at the end of the base URL so that the client can download the image at the required resolution.

For example, if the base URL is,

https://example.com/images/cats

the URL for a client device to download a 700px image would be

https://example.com/images/cats/700

Below are the image resolutions required by client devices.

  • Width: 240px, 300px, 460px, 700px, 1040px

The image used for the imagemap must meet the following specifications:

  • Image format: JPEG or PNG
  • File size: Up to 1 MB

Imagemap action object

Object which specifies the actions and tappable regions of an imagemap.

When a region is tapped, the user is redirected to the URI specified in uri and the message specified in message is sent.

URI action
Field Type Required Description
type String Yes uri
linkUri String Yes Webpage URL
Max: 1000 characters
area Imagemap area object Yes Defined tappable area
Message action
Field Type Required Description
type String Yes message
text String Yes Message to send
Max: 400 characters
area Imagemap area object Yes Defined tappable area

Imagemap area object

Defines the size of the full imagemap with the width as 1040px. The top left is used as the origin of the area.

Field Type Required Description
x Number Yes Horizontal position of the tappable area
y Number Yes Vertical position of the tappable area
width Number Yes Width of the tappable area
height Number Yes Height of the tappable area

Template messages

Template messages are messages with predefined layouts which you can customize. There are four types of templates available that can be used to interact with users through your bot.

Field Type Required Description
type String Yes template
altText String Yes Alternative text.
Max: 400 characters
template Buttons
Confirm
Carousel
Image Carousel
Yes Object with the contents of the template.

Buttons template message example

{
  "type": "template",
  "altText": "this is a buttons template",
  "template": {
      "type": "buttons",
      "thumbnailImageUrl": "https://example.com/bot/images/image.jpg",
      "title": "Menu",
      "text": "Please select",
      "actions": [
          {
            "type": "postback",
            "label": "Buy",
            "data": "action=buy&itemid=123"
          },
          {
            "type": "postback",
            "label": "Add to cart",
            "data": "action=add&itemid=123"
          },
          {
            "type": "uri",
            "label": "View detail",
            "uri": "http://example.com/page/123"
          }
      ]
  }
}

Buttons

Template message with an image, title, text, and multiple action buttons.

Field Type Required Description
type String Yes buttons
thumbnailImageUrl String No Image URL (Max: 1000 characters)
HTTPS
JPEG or PNG
Aspect ratio: 1:1.51
Max width: 1024px
Max: 1 MB
title String No Title
Max: 40 characters
text String Yes Message text
Max: 160 characters (no image or title)
Max: 60 characters (message with an image or title)
actions Array of template actions Yes Action when tapped
Max: 4

Confirm template message example

{
  "type": "template",
  "altText": "this is a confirm template",
  "template": {
      "type": "confirm",
      "text": "Are you sure?",
      "actions": [
          {
            "type": "message",
            "label": "Yes",
            "text": "yes"
          },
          {
            "type": "message",
            "label": "No",
            "text": "no"
          }
      ]
  }
}

Confirm

Template message with two action buttons.

Field Type Required Description
type String Yes confirm
text String Yes Message text
Max: 240 characters
actions Array of template actions Yes Action when tapped
Set 2 actions for the 2 buttons

Carousel template message example

{
  "type": "template",
  "altText": "this is a carousel template",
  "template": {
      "type": "carousel",
      "columns": [
          {
            "thumbnailImageUrl": "https://example.com/bot/images/item1.jpg",
            "title": "this is menu",
            "text": "description",
            "actions": [
                {
                    "type": "postback",
                    "label": "Buy",
                    "data": "action=buy&itemid=111"
                },
                {
                    "type": "postback",
                    "label": "Add to cart",
                    "data": "action=add&itemid=111"
                },
                {
                    "type": "uri",
                    "label": "View detail",
                    "uri": "http://example.com/page/111"
                }
            ]
          },
          {
            "thumbnailImageUrl": "https://example.com/bot/images/item2.jpg",
            "title": "this is menu",
            "text": "description",
            "actions": [
                {
                    "type": "postback",
                    "label": "Buy",
                    "data": "action=buy&itemid=222"
                },
                {
                    "type": "postback",
                    "label": "Add to cart",
                    "data": "action=add&itemid=222"
                },
                {
                    "type": "uri",
                    "label": "View detail",
                    "uri": "http://example.com/page/222"
                }
            ]
          }
      ]
  }
}

Template message with multiple columns which can be cycled like a carousel.

Field Type Required Description
type String Yes carousel
columns Array of column objects Yes Array of columns
Max: 5

Field Type Required Description
thumbnailImageUrl String No Image URL (Max: 1000 characters)
HTTPS
JPEG or PNG
Aspect ratio: 1:1.51
Max width: 1024px
Max: 1 MB
title String No Title
Max: 40 characters
text String Yes Message text
Max: 120 characters (no image or title)
Max: 60 characters (message with an image or title)
actions Array of template actions Yes Action when tapped
Max: 3

Image carousel example

{
  "type": "template",
  "altText": "this is a image carousel template",
  "template": {
      "type": "image_carousel",
      "columns": [
          {
            "imageUrl": "https://example.com/bot/images/item1.jpg",
            "action": {
              "type": "postback",
              "label": "Buy",
              "data": "action=buy&itemid=111"
            }
          },
          {
            "imageUrl": "https://example.com/bot/images/item2.jpg",
            "action": {
              "type": "message",
              "label": "Yes",
              "text": "yes"
            }
          },
          {
            "imageUrl": "https://example.com/bot/images/item3.jpg",
            "action": {
              "type": "uri",
              "label": "View detail",
              "uri": "http://example.com/page/222"
            }
          }
      ]
  }
}

Template with multiple images which can be cycled like a carousel.

Field Type Required Description
type String Yes image_carousel
columns Array of column object Yes Array of columns
Max: 5

Field Type Required Description
imageUrl String Yes Image URL (Max: 1000 characters)
HTTPS
JPEG or PNG
Aspect ratio: 1:1
Max width: 1024px
Max: 1 MB
action template action Yes Action when image is tapped

Template action

Action to include in your template message.

Postback action

When this action is tapped, a postback event is returned via webhook with the specified string in the data field.

If you have included the text field, the string in the text field is sent as a message from the user.

Field Type Required Description
type String Yes postback
label String Yes/No Label for the action
Required for templates other than image carousel. Max: 20 characters
Optional for image carousel templates. Max: 12 characters.
data String Yes String returned via webhook in the postback.data property of the postback event
Max: 300 characters
text String No Text sent when the action is performed
Max: 300 characters
Message action

When this action is tapped, the string in the text field is sent as a message from the user.

Field Type Required Description
type String Yes message
label String Yes/No Label for the action
Required for templates other than image carousel. Max: 20 characters
Optional for image carousel templates. Max: 12 characters.
text String Yes Text sent when the action is performed
Max: 300 characters
URI action

When this action is tapped, the URI specified in the uri field is opened.

Field Type Required Description
type String Yes uri
label String Yes/No Label for the action
Required for templates other than image carousel. Max: 20 characters
Optional for image carousel templates. Max: 12 characters.
uri String Yes URI opened when the action is performed (Max: 1000 characters)
http, https, tel
Datetime picker action

When this action is tapped, a postback event is returned via webhook with the date and time selected by the user from the date and time selection dialog.

Field Type Required Description
type String Yes datetimepicker
label String Yes/No Label for the action
Required for templates other than image carousel. Max: 20 characters
Optional for image carousel templates. Max: 12 characters.
data String Yes String returned via webhook in the postback.data property of the postback event
Max: 300 characters
mode String Yes Action mode
date: Pick date
time: Pick time
datetime: Pick date and time
initial String No Initial value of date or time
max String No Largest date or time value that can be selected.
Must be greater than the min value.
min String No Smallest date or time value that can be selected.
Must be less than the max value.
Date and time format

The date and time formats for the initial, max, and min values are shown below.
The full-date, time-hour, and time-minute formats below follow the RFC3339 protocol.

Mode Format Example
date full-date
Max: 2100-12-31
Min: 1900-01-01
2017-06-18
time time-hour ":" time-minute
Max: 23:59
Min: 00:00
00:00
06:15
23:59
datetime full-date ("T"/"t") time-hour ":" time-minute
Max: 2100-12-31T23:59
Min: 1900-01-01T00:00
2017-06-18T06:15
2017-06-18t06:15