API reference

Common specifications

Rate limits

The limit for the number of API calls that you can make to each endpoint and the number of recipients that you can send messages to per minute are shown below. Rate limits vary depending on your plan. For more information on the plans available in your region, see the LINE@ website.

Plan API calls Number of recipients
Developer Trial 1,000/min per API call 20,000/min per bot
Other plans 10,000/min per API call 200,000/min per bot

Status codes

The following status codes are returned by the Messaging 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 access the resource. Confirm that your account or plan is authorized to access the resource.
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 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"
      }
   ]
}

Error responses

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

Property Type Description
message String Message containing information about the error. For more details, see Error messages.
details[].message String Details of the error. Not returned in certain situations.
details[].property String Location of where the error occurred. Not returned in certain situations.

Error messages

The main error messages that are found in the message property 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 properties.
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.

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.

Property 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 'encode_base64';

my $channel_secret= ... # Channel secret string
my $http_body = ... # Request body string
my $signature = encode_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 = crypto
  .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": "0f3779fba3b349968c5d07db31eab56f",
      "type": "message",
      "timestamp": 1462629479859,
      "source": {
        "type": "user",
        "userId": "U4af4980629..."
      },
      "message": {
        "id": "325708",
        "type": "text",
        "text": "Hello, world"
      }
    },
    {
      "replyToken": "8cf9239d56244f4197887e939187e19e",
      "type": "follow",
      "timestamp": 1462629479859,
      "source": {
        "type": "user",
        "userId": "U4af4980629..."
      }
    }
  ]
}

Common properties

The following properties are found in webhook event objects.

Property Type Description
type String Identifier for the type of event
timestamp Number Time of the event in milliseconds
source Object Source user, group, or room object with information about the source of the event.

Source user example

  "source": {
    "type": "user",
    "userId": "U4af4980629..."
  }

Source user

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

Source group example

  "source": {
    "type": "group",
    "groupId": "Ca56f94637c...",
    "userId": "U4af4980629..."
  }

Source group

Property Type Description
type String group
groupId String ID of the source group
userId String ID of the source user. Only included in message events. Not included if the user has not agreed to the Official Accounts Terms of Use.

Source room example

  "source": {
    "type": "room",
    "roomId": "Ra8dbf4673c...",
    "userId": "U4af4980629..."
  }

Source room

Property Type Description
type String room
roomId String ID of the source room
userId String ID of the source user. Only included in message events. Not included if the user has not agreed to the Official Accounts Terms of Use.

Message event

Webhook event object which contains the sent message. The message property contains a message object which corresponds with the message type. You can reply to message events.

Property Type Description
type String message
replyToken String Token for replying to the event
message Object Object containing the contents of the message. Message types include:

Text message example

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

Text

Message object which contains the text sent from the source.

Property 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": "U4af4980629..."
  },
  "message": {
    "id": "325708",
    "type": "image"
  }
}

Image

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

Property Type Description
id String Message ID
type String image

Video message example

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

Video

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

Property Type Description
id String Message ID
type String video

Audio message example

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

Audio

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

Property Type Description
id String Message ID
type String audio

File message example

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

File

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

Property 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": "U4af4980629..."
  },
  "message": {
    "id": "325708",
    "type": "location",
    "title": "my location",
    "address": "〒150-0002 東京都渋谷区渋谷2丁目21−1",
    "latitude": 35.65910807942215,
    "longitude": 139.70372892916203
  }
}

Location

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

Property 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": "U4af4980629..."
  },
  "message": {
    "id": "325708",
    "type": "sticker",
    "packageId": "1",
    "stickerId": "1"
  }
}

Sticker

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

Property 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": "U4af4980629..."
  }
}

Follow event

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

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

Unfollow event example

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

Unfollow event

Event object for when your account is blocked.

Property Type Description
type String unfollow

Join event example

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

Join event

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

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

Leave event example

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

Leave event

Event object for when a user removes your bot from a group or when your bot leaves a group or room.

Property Type Description
type String leave

Postback event example

{  
   "type":"postback",
   "replyToken":"b60d432864f44d079f6d8efe86cf404b",
   "source":{  
      "userId":"U91eeaf62d...",
      "type":"user"
   },
   "timestamp":1513669370317,
   "postback":{  
      "data":"storeId=12345",
      "params":{  
         "datetime":"2017-12-25T01:00"
      }
   }
}

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.

Property 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 a datetime picker action.

postback.params object example

{  
   "datetime":"2017-12-25T01:00"
}

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.

Property 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": "U4af4980629..."
  },
  "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.

Property 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. See Beacon event types.
beacon.dm String Device message of beacon that was detected. This message consists of data generated by the beacon to send notifications to bots. Only included in webhooks from devices that support the "device message" property.
For more information, see the LINE Simple Beacon specification.

Beacon event types

beacon.type Description
enter Entered beacon's reception range
leave (Deprecated.) Left beacon's reception range.
Note: The leave event cannot be used by enterprise users. If you are interested in using this feature, contact your LINE representative.
banner Tapped beacon banner

Account link event example

{
  "type": "accountLink",
  "replyToken": "b60d432864f44d079f6d8efe86cf404b",
  "source": {
    "userId": "U91eeaf62d...",
    "type": "user"
  },
  "timestamp": 1513669370317,
  "link": {
    "result": "ok",
    "nonce": "xxxxxxxxxxxxxxx"
  }
}

Event object for when a user has linked his/her LINE account with a provider's service account. You can reply to account link events.

If the link token has expired or has already been used, no webhook event will be sent and the user will be shown an error.

Property Type Description
type String accountLink
replyToken String Token for replying to this event. This value will not be included if the link has failed.
link Object link object. This will include whether the account link was successful or not and a nonce generated from the user ID on the provider's service.

Example link object

"link": {
  "result": "ok",
  "nonce": "xxxxxxxxxxxxxxx"
}

Property Type Description
result String One of the following values to indicate whether the link was successful or not.
  • ok: Indicates the link was successful.
  • failed: Indicates the link failed for any reason, such as due to a user impersonation.
nonce String Specified nonce when verifying the user ID

OAuth

Example request

curl -v -X POST https://api.line.me/v2/oauth/accessToken \
-H "Content-Type:application/x-www-form-urlencoded" \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'client_id={channel ID}' \
--data-urlencode 'client_secret={channel secret}'
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 are 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

Field 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 information.

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 information.

Property Type Description
error String Error summary
error_description String Details of the error. Not returned in certain situations.

Example request

curl -v -X POST https://api.line.me/v2/oauth/revoke \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode 'access_token={channel access token}'
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

Field Type Description
access_token String Channel access token

Response

Returns the status code 200 and an empty response body. 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 information.

Property Type Description
error String Error summary
error_description String Details of the error. Not returned in certain situations.

Message

Example request

curl -v -X POST https://api.line.me/v2/bot/message/reply \
-H 'Content-Type:application/json' \
-H 'Authorization: Bearer {channel access token}' \
-d '{
    "replyToken":"nHuyWiB7yP5Zw52FIkcQobQuGDXCTA",
    "messages":[
        {
            "type":"text",
            "text":"Hello, user"
        },
        {
            "type":"text",
            "text":"May I help you?"
        }
    ]
}'
Example request
final LineMessagingClient client = LineMessagingClient
        .builder("<channel access token>")
        .build();

final TextMessage textMessage = new TextMessage("hello");
final ReplyMessage replyMessage = new ReplyMessage(
        "<replyToken>",
        textMessage);

final BotApiResponse botApiResponse;
try {
    botApiResponse = client.replyMessage(replyMessage).get();
} catch (InterruptedException | ExecutionException e) {
    e.printStackTrace();
    return;
}

System.out.println(botApiResponse);
Example request
bot, err := linebot.New(<channel secret>, <channel token>)
if err != nil {
    ...
}
if _, err := bot.ReplyMessage(<replyToken>, linebot.NewTextMessage("hello")).Do(); err != nil {
    ...
}
Example 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 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 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 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 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

Sends a reply message in response to an event from a user, group, or room.

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

Because the reply token 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

Property Type Required Description
replyToken String Required Reply token received via webhook
messages Array of message objects Required Messages
Max: 5

Example response

{}

Response

Returns the status code 200 and an empty JSON object.

Example request

curl -v -X POST https://api.line.me/v2/bot/message/push \
-H 'Content-Type:application/json' \
-H 'Authorization: Bearer {channel access token}' \
-d '{
    "to": "U4af4980629...",
    "messages":[
        {
            "type":"text",
            "text":"Hello, world1"
        },
        {
            "type":"text",
            "text":"Hello, world2"
        }
    ]
}'
Example request
final LineMessagingClient client = LineMessagingClient
        .builder("<channel access token>")
        .build();

final TextMessage textMessage = new TextMessage("hello");
final PushMessage pushMessage = new PushMessage(
        "<to>",
        textMessage);

final BotApiResponse botApiResponse;
try {
    botApiResponse = client.pushMessage(pushMessage).get();
} catch (InterruptedException | ExecutionException e) {
    e.printStackTrace();
    return;
}

System.out.println(botApiResponse);
Example request
bot, err := linebot.New(<channel secret>, <channel token>)
if err != nil {
    ...
}
if _, err := bot.PushMessage(<to>, linebot.NewTextMessage("hello")).Do(); err != nil {
    ...
}
Example 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.push_message("<to>", message)
p response
Example 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->pushMessage('<to>', $textMessageBuilder);

echo $response->getHTTPStatus() . ' ' . $response->getRawBody();
Example 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->push_message("<to>", $messages->build);
unless ($res->is_success) {
    # error handling
    ....
}
Example 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.push_message('<to>', TextSendMessage(text='Hello World!'))
except LineBotApiError as e:
    # error handle
    ...
Example request
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

Note: Use of push messages are limited to certain plans. For more information, see the LINE@ website.

Sends a push message to a user, group, or room at any time.

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

Property Type Required Description
to String Required ID of the target recipient. Use a userId, groupId, or roomId value returned in a webhook event object. Do not use the LINE ID found on the LINE app.
messages Array of message objects Required Messages
Max: 5

Example response

{}

Response

Returns the status code 200 and an empty JSON object.

Example request

curl -v -X POST https://api.line.me/v2/bot/message/multicast \
-H 'Content-Type:application/json' \
-H 'Authorization: Bearer {channel access token}' \
-d '{
    "to": ["U4af4980629...","U0c229f96c4..."],
    "messages":[
        {
            "type":"text",
            "text":"Hello, world1"
        },
        {
            "type":"text",
            "text":"Hello, world2"
        }
    ]
}'
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

Send multicast messages

Note: Only available for plans which support push messages. For more information, see the LINE@ website.

Sends push messages to multiple users at any time. Messages cannot be sent to groups or rooms.

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

Property Type Required Description
to Array of strings Required Array of user IDs. Use userId values which are returned in webhook event objects. Do not use LINE IDs found on the LINE app.
Max: 150 user IDs
messages Array of message objects Required Messages
Max: 5
You cannot send Flex Messages.

Example response

{}

Response

Returns the status code 200 and an empty JSON object.

Example request

curl -v -X GET https://api.line.me/v2/bot/message/{messageId}/content \
-H 'Authorization: Bearer {channel access token}'
Example request
final LineMessagingClient client = LineMessagingClient
        .builder("<channel access token>")
        .build();

final MessageContentResponse messageContentResponse;
try {
    messageContentResponse = client.getMessageContent("<messageId>").get();
} catch (InterruptedException | ExecutionException e) {
    e.printStackTrace();
    return;
}

Files.copy(messageContentResponse.getStream(),
           Files.createTempFile("foo", "bar"));
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>'
});

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

Get content

Gets 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}

Path parameters

Parameter Description
messageId Message ID

Response

Returns status code 200 and the content in binary.

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

Example request

curl -v -X GET https://api.line.me/v2/bot/profile/{userId} \
-H 'Authorization: Bearer {channel access token}'
Example request
final LineMessagingClient client = LineMessagingClient
        .builder("<channel access token>")
        .build();

final UserProfileResponse userProfileResponse;
try {
    userProfileResponse = client.getProfile("<userId>").get();
} catch (InterruptedException | ExecutionException e) {
    e.printStackTrace();
    return;
}

System.out.println(userProfileResponse.getUserId());
System.out.println(userProfileResponse.getDisplayName());
System.out.println(userProfileResponse.getPictureUrl());
Example request
bot, err := linebot.New(<channel secret>, <channel token>)
if err != nil {
    ...
}
res, err := bot.GetProfile(<userId>).Do();
if err != nil {
    ...
}
println(res.Displayname)
println(res.PicutureURL)
println(res.StatusMessage)
Example request
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
Example request
$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'];
}
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_profile("<userId>");
unless ($res->is_success) {
    # error handling
    ....
}

say $ret->display_name;
say $ret->user_id;
say $ret->picture_url;
say $ret->status_message;
Example request
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
    ...
Example request
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

Gets user profile information.

HTTP request

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

Request headers

Request header Description
Authorization Bearer {channel access token}

Path parameters

Parameter Description
userId User ID that is returned in a webhook event object. Do not use the LINE ID found on the LINE app.

Example response

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

Response

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

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

Group

Example request

curl -v -X GET https://api.line.me/v2/bot/group/{groupId}/member/{userId} \
-H 'Authorization: Bearer {channel access token}'
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.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}

Path parameters

Parameter Description
groupId Group ID. Found in the source object of webhook event objects.
userId User ID. Found in the source object of webhook event objects. Do not use the LINE ID used in the LINE app.

Example response

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

Response

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

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

Example request

curl -v -X GET https://api.line.me/v2/bot/group/{groupId}/members/ids?start={continuationToken} \
-H 'Authorization: Bearer {channel access token}'
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

Note: Only available for LINE@ Approved accounts or official accounts. For more information, see Create a LINE@ Account or LINE Partner.

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

Request headers

Request header Description
Authorization Bearer {channel access token}

Path parameters

Parameter Required Description
groupId Required Group ID. Found in the source object of webhook event objects.

Query parameters

Parameter Required Description
start Optional Value of the continuation token found in the next property of the JSON object returned in the response. Include this parameter to get the next array of user IDs for the members of the group.

Example response

{  
   "memberIds":[  
      "U4af4980629...",
      "U0c229f96c4...",
      "U95afb1d4df..."
   ],
   "next":"jxEWCEEP..."
}

Response

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

Property Type Description
memberIds Array of strings List of user IDs of the members in the group. The number of user IDs returned in memberIds is not fixed. Users who have not agreed to the Official Accounts Terms of Use are not included in memberIds.
Max: 100 user IDs
next String A continuation token to get the next array of user IDs of the members in the group. Returned only when there are remaining user IDs that were not returned in memberIds in the original request.

Example request

curl -v -X POST https://api.line.me/v2/bot/group/{groupId}/leave \
-H 'Authorization: Bearer {channel access token}'
Example request
final LineMessagingClient client = LineMessagingClient
        .builder("<channel access token>")
        .build();

final BotApiResponse botApiResponse;
try {
    botApiResponse = client.leaveGroup("<roomId>").get();
} catch (InterruptedException | ExecutionException e) {
    e.printStackTrace();
    return;
}

System.out.println(botApiResponse);
Example request
bot, err := linebot.New(<channel secret>, <channel token>)
if err != nil {
    ...
}
if _, err := bot.LeaveGroup(<groupId>).Do(); err != nil {
    ...
}
Example request
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
Example request
$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();
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->leave_group("<groupId>");
unless ($res->is_success) {
    # error handling
    ....
}
Example request
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
    ...
Example request
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

Leaves a group.

HTTP request

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

Request headers

Request header Description
Authorization Bearer {channel access token}

Path parameters

Parameter Description
groupId Group ID. Found in the source object of webhook event objects.

Example response

{}

Response

Returns the status code 200 and an empty JSON object.

Room

Example request

curl -v -X GET https://api.line.me/v2/bot/room/{roomId}/member/{userId} \
-H 'Authorization: Bearer {channel access token}'
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.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}

Path parameters

Parameter Description
roomId Room ID. Found in the source object of webhook event objects.
userId User ID. Found in the source object of webhook event objects. Do not use the LINE ID used in the LINE app.

Example response

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

Response

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

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

Example request

curl -v -X GET https://api.line.me/v2/bot/room/{roomId}/members/ids?start={continuationToken} \
-H 'Authorization: Bearer {channel access token}'
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

Note: Only available for LINE@ Approved accounts or official accounts. For more information, see Create a LINE@ Account or LINE Partner.

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

Request headers

Request header Description
Authorization Bearer {channel access token}

Path parameters

Parameter Required Description
roomId Required Room ID. Found in the source object of webhook event objects.

Query parameters

Parameter Required Description
start Optional Value of the continuation token found in the next property of the JSON object returned in the response. Include this parameter to get the next array of user IDs for the members of the group.

Example response

{  
   "memberIds":[  
      "U4af4980629...",
      "U0c229f96c4...",
      "U95afb1d4df..."
   ],
   "next":"jxEWCEEP..."
}

Response

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

Property Type Description
memberIds Array of strings List of user IDs of the members in the room. The number of user IDs returned in memberIds is not fixed. Users who have not agreed to the Official Accounts Terms of Use are not included in memberIds.
Max: 100 user IDs
next String A continuation token to get the next array of user IDs of the members in the room. Returned only when there are remaining user IDs that were not returned in memberIds in the original request.

Example request

curl -v -X POST https://api.line.me/v2/bot/room/{roomId}/leave \
-H 'Authorization: Bearer {channel access token}'
Example request
final LineMessagingClient client = LineMessagingClient
        .builder("<channel access token>")
        .build();

final BotApiResponse botApiResponse;
try {
    botApiResponse = client.leaveRoom("<roomId>").get();
} catch (InterruptedException | ExecutionException e) {
    e.printStackTrace();
    return;
}

System.out.println(botApiResponse);
Example request
bot, err := linebot.New(<channel secret>, <channel token>)
if err != nil {
    ...
}
if _, err := bot.LeaveRoom(<roomId>).Do(); err != nil {
    ...
}
Example request
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
Example request
$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();
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->leave_room("<roomId>");
unless ($res->is_success) {
    # error handling
    ....
}
Example request
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
    ...
Example request
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

Leaves a room.

HTTP request

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

Request headers

Request header Description
Authorization Bearer {channel access token}

Path parameters

Parameter Description
roomId Room ID. Found in the source object of webhook event objects.

Example response

{}

Response

Returns the status code 200 and an empty JSON object.

Rich menu

Note: Rich menus created using the Messaging API are only supported on LINE Android and iOS versions 7.14.0 and above.

Customizable menu that is displayed on your bot's chat screen. For more information, see Using rich menus.

Example request

curl -v -X GET https://api.line.me/v2/bot/richmenu/{richMenuId} \
-H 'Authorization: Bearer {channel access token}'
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

Get rich menu

Gets a rich menu via a rich menu ID.

HTTP request

GET https://api.line.me/v2/bot/richmenu/{richMenuId}

Request headers

Request header Description
Authorization Bearer {channel access token}

Path parameters

Parameter Required Description
richMenuId Required ID of an uploaded rich menu

Example response

{
  "richMenuId": "{richMenuId}",
  "size": {
     "width": 2500,
     "height": 1686
   },
   "selected": false,
   "areas": [
     {
       "bounds": {
         "x": 0,
         "y": 0,
         "width": 2500,
         "height": 1686
       },
       "action": {
         "type": "postback"
         "data": "action=buy&itemid=123"
       }
     }
   ]
}

Response

Returns the status code 200 and a rich menu response object.

Example request

curl -v -X POST https://api.line.me/v2/bot/richmenu \
-H 'Authorization: Bearer {channel access token}' \
-H 'Content-Type: application/json' \
-d \
'{
    "size": {
      "width": 2500,
      "height": 1686
    },
    "selected": false,
    "name": "Nice richmenu",
    "chatBarText": "Tap here",
    "areas": [
      {
        "bounds": {
          "x": 0,
          "y": 0,
          "width": 2500,
          "height": 1686
        },
        "action": {
          "type": "postback",
          "data": "action=buy&itemid=123"
        }
      }
   ]
}'
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

Create rich menu

Creates a rich menu.

You must upload a rich menu image and link the rich menu to a user for the rich menu to be displayed. You can create up to 1000 rich menus for one bot.

HTTP request

POST https://api.line.me/v2/bot/richmenu

Request headers

Request header Description
Authorization Bearer {channel access token}
Content-Type application/json

Request body

The rich menu represented as a rich menu object.

Example response

{
  "richMenuId": "{richMenuId}"
}

Response

Returns the status code 200 and the ID of the rich menu.

Example request

curl -v -X DELETE https://api.line.me/v2/bot/richmenu/{richMenuId} \
-H 'Authorization: Bearer {channel access token}'
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

Delete rich menu

Deletes a rich menu.

HTTP request

DELETE https://api.line.me/v2/bot/richmenu/{richMenuId}

Request headers

Request header Description
Authorization Bearer {channel access token}

Path parameters

Parameter Required Description
richMenuId Required ID of an uploaded rich menu

Example response

{}

Response

Returns the status code 200 and an empty JSON object.

Example request

curl -v -X GET https://api.line.me/v2/bot/user/{userId}/richmenu \
-H 'Authorization: Bearer {channel access token}'
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

Get rich menu ID of user

Gets the ID of the rich menu linked to a user.

HTTP request

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

Request headers

Request header Description
Authorization Bearer {channel access token}

Path parameters

Parameter Required Description
userId Required User ID. Found in the source object of webhook event objects. Do not use the LINE ID used in the LINE app.

Example response

{
    "richMenuId": "{richMenuId}"
}

Response

Returns the status code 200 and a JSON object with the rich menu ID.

Example request

curl -v -X POST https://api.line.me/v2/bot/user/{userId}/richmenu/{richMenuId} \
-H "Authorization: Bearer {channel access token}" -d ""
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

Links a rich menu to a user. Only one rich menu can be linked to a user at one time.

HTTP request

POST https://api.line.me/v2/bot/user/{userId}/richmenu/{richMenuId}

Request headers

Request header Description
Authorization Bearer {channel access token}

Path parameters

Parameter Required Description
richMenuId Required ID of an uploaded rich menu
userId Required User ID. Found in the source object of webhook event objects. Do not use the LINE ID used in the LINE app.

Example response

{}

Response

Returns the status code 200 and an empty JSON object.

Example request

curl -v -X DELETE https://api.line.me/v2/bot/user/{userId}/richmenu \
-H 'Authorization: Bearer {channel access token}'
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

Unlinks a rich menu from a user.

HTTP request

DELETE https://api.line.me/v2/bot/user/{userId}/richmenu

Request headers

Request header Description
Authorization Bearer {channel access token}

Path parameters

Parameter Required Description
userId Required User ID. Found in the source object of webhook event objects. Do not use the LINE ID used in the LINE app.

Example response

{}

Response

Returns the status code 200 and an empty JSON object.

Example request

curl -v -X GET "https://api.line.me/v2/bot/richmenu/{richMenuId}/content" \
-H 'Authorization: Bearer {channel access token}' \
-o picture.jpg
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

Download rich menu image

Downloads an image associated with a rich menu.

HTTP request

GET https://api.line.me/v2/bot/richmenu/{richMenuId}/content

Request headers

Request header Description
Authorization Bearer {channel access token}

Path parameters

Parameter Required Description
richMenuId Required ID of the rich menu with the image to be downloaded

Response

Returns the status code 200 and the binary data of the rich menu image. The image can be downloaded as shown in the example request.

Example request

curl -v -X POST https://api.line.me/v2/bot/richmenu/{richMenuId}/content \
-H "Authorization: Bearer {channel access token}" \
-H "Content-Type: image/jpeg" \
-T image.jpg
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

Upload rich menu image

Uploads and attaches an image to a rich menu.

You can use rich menu images with the following specifications:

  • Image format: JPEG or PNG
  • Image size: 2500x1686 or 2500x843 pixels
  • Maximum file size: 1 MB

Note: You cannot replace an image attached to a rich menu. To update your rich menu image, create a new rich menu object and upload another image.

HTTP request

POST https://api.line.me/v2/bot/richmenu/{richMenuId}/content

Request headers

Request header Description
Authorization Bearer {channel access token}
Content-Type image/jpeg or image/png
Content-Length The length of the request body in octets (8-bit bytes). Must be a non-negative value.

Path parameters

Parameter Required Description
richMenuId Required The ID of the rich menu to attach the image to

Example response

{}

Response

Returns the status code 200 and an empty JSON object.

Example request

curl -v -X GET https://api.line.me/v2/bot/richmenu/list \
-H 'Authorization: Bearer {channel access token}'
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

Get rich menu list

Gets a list of all uploaded rich menus.

HTTP request

GET https://api.line.me/v2/bot/richmenu/list

Request headers

Request header Description
Authorization Bearer {channel access token}

Example response

{
  "richmenus": [
    {
      "richMenuId": "{richMenuId}",
      "size": {
        "width": 2500,
        "height": 1686
      },
      "selected": false,
      "areas": [
        {
          "bounds": {
            "x": 0,
            "y": 0,
            "width": 2500,
            "height": 1686
          },
          "action": {
            "type": "postback"
            "data": "action=buy&itemid=123"
          }
        }
      ]
    }
  ]
}

Response

Returns the status code 200 and a list of rich menu response objects.

Property Type Description
richmenus Array Array of rich menu response objects

Message objects

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

Text message example

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

Text message

Property Type Required Description
type String Required text
text String Required Message text. You can include the following emoji: Max: 2000 characters

Text message example with emoji


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

Sticker message example

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

Sticker message

Property Type Required Description
type String Required sticker
packageId String Required Package ID for a set of stickers. For information on package IDs, see the Sticker list.
stickerId String Required Sticker ID. For a list of sticker IDs for stickers that can be sent with the Messaging API, see the Sticker list.

Image message example

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

Image message

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

Video message example

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

Video message

Property Type Required Description
type String Required video
originalContentUrl String Required URL of video file (Max: 1000 characters)
HTTPS
mp4
Max: 1 minute
Max: 10 MB

A very wide or tall video may be cropped when played in some environments.
previewImageUrl String Required URL of preview image (Max: 1000 characters)
HTTPS
JPEG
Max: 240 x 240
Max: 1 MB

Audio message example

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

Audio message

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

Location message example

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

Location message

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

Imagemap message example with two tappable regions

{
  "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

Note: Imagemap messages are supported on the following versions of the LINE app: Version 3.9.1 or later for iOS, version 3.9.2 or later for Android, version 3.6.0 for Windows Phone, and version 4.4.1 for Windows and Mac.

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.

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

How to configure an image

You can use images with the following specifications for imagemap messages.

  • Image format: JPEG or PNG
  • Image width: 240px, 300px, 460px, 700px, 1040px
  • Size: Up to 1 MB

Make it possible to access images of 5 different sizes using the baseUrl/{image width} URL format. The LINE application will then download an image at the appropriate resolution based on the device.

For example, if we had a base URL of https://example.com/images/cats, the URL for the image with a width of 700px would be https://example.com/images/cats/700.

Imagemap action objects

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.

Example imagemap URI action object

{  
   "type":"uri",
   "label":"https://example.com/",
   "linkUri":"https://example.com/",
   "area":{  
      "x":0,
      "y":0,
      "width":520,
      "height":1040
   }
}
Imagemap URI action object
Property Type Required Description
type String Required uri
label String Optional Label for the action. Spoken when the accessibility feature is enabled on the client device.
Max: 50 characters
Supported on LINE iOS version 8.2.0 and later.
linkUri String Required Webpage URL
Max: 1000 characters
area Imagemap area object Required Defined tappable area

Example imagemap message action object

{  
   "type":"message",
   "label":"hello",
   "text":"hello",
   "area":{  
      "x":520,
      "y":0,
      "width":520,
      "height":1040
   }
}
Imagemap message action object
Property Type Required Description
type String Required message
label String Optional Label for the action. Spoken when the accessibility feature is enabled on the client device.
Max: 50 characters
Supported on LINE iOS version 8.2.0 and later.
text String Required Message to send
Max: 400 characters
Supported on the LINE app for iOS and Android only.
area Imagemap area object Required Defined tappable area

Example imagemap area object

{
   "x":520,
   "y":0,
   "width":520,
   "height":1040
}

Imagemap area object

Defines the size of a tappable area. The top left is used as the origin of the area. Set these properties based on the baseSize.width property and the baseSize.height property.

Property Type Required Description
x Number Required Horizontal position relative to the top-left corner of the area
y Number Required Vertical position relative to the top-left corner of the area
width Number Required Width of the tappable area
height Number Required Height of the tappable area

Template messages

Note: Template messages are only supported on LINE iOS/Android versions 6.7.0 and later.

Template messages are messages with predefined layouts which you can customize. For more information, see template messages.

The following template types are available:

Common properties of template message objects

The following properties are common to all template message objects.

Property Type Required Description
type String Required template
altText String Required Alternative text.
Max: 400 characters
template Object Required A Buttons, Confirm, Carousel, or Image Carousel object.

Buttons template message example

{
  "type": "template",
  "altText": "This is a buttons template",
  "template": {
      "type": "buttons",
      "thumbnailImageUrl": "https://example.com/bot/images/image.jpg",
      "imageAspectRatio": "rectangle",
      "imageSize": "cover",
      "imageBackgroundColor": "#FFFFFF",
      "title": "Menu",
      "text": "Please select",
      "defaultAction": {
          "type": "uri",
          "label": "View detail",
          "uri": "http://example.com/page/123"
      },
      "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

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

Property Type Required Description
type String Required buttons
thumbnailImageUrl String Optional Image URL (Max: 1000 characters)
HTTPS
JPEG or PNG
Max width: 1024px
Max: 1 MB
imageAspectRatio String Optional Aspect ratio of the image. Specify one of the following values:
  • rectangle: 1.51:1
  • square: 1:1
The default value is rectangle.
imageSize String Optional Size of the image. Specify one of the following values:
  • cover: The image fills the entire image area. Parts of the image that do not fit in the area are not displayed.
  • contain: The entire image is displayed in the image area. A background is displayed in the unused areas to the left and right of vertical images and in the areas above and below horizontal images.
The default value is cover.
imageBackgroundColor String Optional Background color of image. Specify a RGB color value. The default value is #FFFFFF (white).
title String Optional Title
Max: 40 characters
text String Required Message text
Max: 160 characters (no image or title)
Max: 60 characters (message with an image or title)
defaultAction Action object Optional Action when image is tapped; set for the entire image, title, and text area
actions Array of action objects Required 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

Template with two action buttons.

Property Type Required Description
type String Required confirm
text String Required Message text
Max: 240 characters
actions Array of action objects Required 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",
            "imageBackgroundColor": "#FFFFFF",
            "title": "this is menu",
            "text": "description",
            "defaultAction": {
                "type": "uri",
                "label": "View detail",
                "uri": "http://example.com/page/123"
            },
            "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",
            "imageBackgroundColor": "#000000",
            "title": "this is menu",
            "text": "description",
            "defaultAction": {
                "type": "uri",
                "label": "View detail",
                "uri": "http://example.com/page/222"
            },
            "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"
                }
            ]
          }
      ],
      "imageAspectRatio": "rectangle",
      "imageSize": "cover"
  }
}

Template with multiple columns which can be cycled like a carousel. The columns will be shown in order by scrolling horizontally.

Property Type Required Description
type String Required carousel
columns Array of column objects Required Array of columns
Max: 10
imageAspectRatio String Optional Aspect ratio of the image. Specify one of the following values:
  • rectangle: 1.51:1
  • square: 1:1
Applies to all columns. The default value is rectangle.
imageSize String Optional Size of the image. Specify one of the following values:
  • cover: The image fills the entire image area. Parts of the image that do not fit in the area are not displayed.
  • contain: The entire image is displayed in the image area. A background is displayed in the unused areas to the left and right of vertical images and in the areas above and below horizontal images.
Applies to all columns. The default value is cover.

Property Type Required Description
thumbnailImageUrl String Optional Image URL (Max: 1000 characters)
HTTPS
JPEG or PNG
Aspect ratio: 1:1.51
Max width: 1024px
Max: 1 MB
imageBackgroundColor String Optional Background color of image. Specify a RGB color value. The default value is #FFFFFF (white).
title String Optional Title
Max: 40 characters
text String Required Message text
Max: 120 characters (no image or title)
Max: 60 characters (message with an image or title)
defaultAction Action object Optional Action when image is tapped; set for the entire image, title, and text area
actions Array of action objects Required Action when tapped
Max: 3

Image carousel template message 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. The images will be shown in order by scrolling horizontally.

Property Type Required Description
type String Required image_carousel
columns Array of column objects Required Array of columns
Max: 10

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

Flex Message example

{  
  "type": "flex",
  "altText": "this is a flex message",
  "contents": {
    "type": "bubble",
    "body": {
      "type": "box",
      "layout": "vertical",
      "contents": [
        {
          "type": "text",
          "text": "hello"
        },
        {
          "type": "text",
          "text": "world"
        }
      ]
    }
  }
}

Flex Message

Note: Flex Messages are only supported on LINE iOS/Android versions 6.7.0 and later.

Flex Messages are messages with a customizable layout. You can customize the layout freely by combining multiple elements. For more information, see Using Flex Messages.

Property Type Required Description
type String Required flex
altText String Required Alternative text
Max: 400 characters
contents Object Required Flex Message container object

Container

A container is the top-level structure of a Flex Message. Here are the types of containers available.

See Flex Message elements for the containers' JSON data samples and usage.

Bubble container example

{
  "type": "bubble",
  "header": {
    "type": "box",
    "layout": "vertical",
    "contents": [
      {
        "type": "text",
        "text": "Header text"
      }
    ]
  },
  "hero": {
    "type": "image",
    "url": "https://example.com/flex/images/image.jpg",
  },
  "body": {
    "type": "box",
    "layout": "vertical",
    "contents": [
      {
        "type": "text",
        "text": "Body text",
      }
    ]
  },
  "footer": {
    "type": "box",
    "layout": "vertical",
    "contents": [
      {
        "type": "text",
        "text": "Footer text",
      }
    ]
  },
  "styles": {
    "comment": "See the example of a bubble style object"
  }
}

Bubble container

This is a container that contains one message bubble. It can contain four blocks: header, hero, body, and footer. For more information about using each block, see Block.

Property Type Required Description
direction String Optional Text directionality and the order of components in horizontal boxes in the container. Specify one of the following values:
  • ltr: Left to right
  • rtl: Right to left
The default value is ltr.
header Object Optional Header block. Specify a box component.
hero Object Optional Hero block. Specify an image component.
body Object Optional Body block. Specify a box component.
footer Object Optional Footer block. Specify a box component.
styles Object Optional Style of each block. Specify a bubble style object. For more information, see Objects for the block style.

Example of a bubble style object with block style objects

  "styles": {
    "header": {
      "backgroundColor": "#00ffff"
    },
    "hero": {
      "separator": true,
      "separatorColor": "#000000"
    },
    "footer": {
      "backgroundColor": "#00ffff",
      "separator": true,
      "separatorColor": "#000000"
    }
  }

Objects for the block style

Use the following two objects to define the style of blocks in a bubble.

Bubble style

Property Type Required Description
header Block style object Optional Style of the header block
hero Block style object Optional Style of the hero block
body Block style object Optional Style of the body block
footer Block style object Optional Style of the footer block

Block style

Property Type Required Description
backgroundColor String Optional Background color of the block. Use a hexadecimal color code.
separator Boolean Optional true to place a separator above the block. true will be ignored for the first block in a container because you cannot place a separator above the first block. The default value is false.
separatorColor String Optional Color of the separator. Use a hexadecimal color code.

Carousel container example

{
  "type": "carousel",
  "contents": [
    {
      "type": "bubble",
      "body": {
        "type": "box",
        "layout": "vertical",
        "contents": [
          {
            "type": "text",
            "text": "First bubble"
          }
        ]
      }
    },
    {
      "type": "bubble",
      "body": {
        "type": "box",
        "layout": "vertical",
        "contents": [
          {
            "type": "text",
            "text": "Second bubble"
          }
        ]
      }
    }
  ]
}

This is a container that contains multiple bubble containers, or message bubbles. The bubbles will be shown in order by scrolling horizontally.

Property Type Required Description
contents Array of bubble containers Required Max: 10 bubbles

If any of the bubbles in a carousel container has a body block, the body block extends so that the bubble has the same height as the highest bubble in the carousel container.

Component

Components are objects that compose a Flex Message container. Here are the types of components available:

See Flex Message elements and Flex Message layout for the components' JSON data samples and usage.

Box component example

{
  "type": "box",
  "layout": "vertical",
  "contents": [
    {
      "type": "image",
      "url": "https://example.com/flex/images/image.jpg",
    },
    {
      "type": "separator",
    },
    {
      "type": "text",
      "text": "Text in the box"
    }
  ]
}

Box component

This is a component that defines the layout of child components. You can also include a box in a box.

Property Type Required Description
type String Required box
layout String Required The placement style of components in this box. Specify one of the following values:
  • horizontal: Components are placed horizontally. The direction property of the bubble container specifies the order.
  • vertical: Components are placed vertically from top to bottom.
  • baseline: Components are placed in the same way as horizontal is specified except the baselines of the components are aligned.
For more information, see Types of box layouts.
contents Array of objects Required Components in this box. Here are the types of components available:
flex Number Optional The ratio of the width or height of this box within the parent box. The default value for the horizontal parent box is 1, and the default value for the vertical parent box is 0. For more information, see Width and height of components.
spacing String Optional Minimum space between components in this box. You can specify one of the following values: none, xs, sm, md, lg, xl, or xxl. none does not set a space while the other values set a space whose size increases in the order of listing. The default value is none.
To override this setting for a specific component, set the margin property of that component.
margin String Optional Minimum space between this box and the previous component in the parent box. You can specify one of the following values: none, xs, sm, md, lg, xl, or xxl. none does not set a space while the other values set a space whose size increases in the order of listing. The default value is the value of the spacing property of the parent box.
If this box is the first component in the parent box, the margin property will be ignored.

Button component example

{
  "type": "button",
  "action": {
    "type": "uri",
    "label": "Tap me",
    "uri": "https://example.com"
  }
  "style": "primary",
  "color": "#0000ff"
}

Button component

This component draws a button. When the user taps a button, a specified action is performed.

Property Type Required Description
type String Required button
action Object Required Action performed when this button is tapped. Specify an action object.
flex Number Optional The ratio of the width or height of this component within the parent box. The default value for the horizontal parent box is 1, and the default value for the vertical parent box is 0. For more information, see Width and height of components.
margin String Optional Minimum space between this component and the previous component in the parent box. You can specify one of the following values: none, xs, sm, md, lg, xl, or xxl. none does not set a space while the other values set a space whose size increases in the order of listing. The default value is the value of the spacing property of the parent box.
If this component is the first component in the parent box, the margin property will be ignored.
height String Optional Height of the button. You can specify sm or md. The default value is md.
style String Optional Style of the button. Specify one of the following values:
  • link: HTML link style
  • primary: Style for dark color buttons
  • secondary: Style for light color buttons
The default value is link.
color String Optional Character color when the style property is link. Background color when the style property is primary or secondary. Use a hexadecimal color code.
gravity String Optional Vertical alignment style. Specify one of the following values:
  • top: Top-aligned
  • bottom: Bottom-aligned
  • center: Center-aligned
The default value is top.
If the layout property of the parent box is baseline, the gravity property will be ignored.

Filler component example

{
  "type": "filler"
}

Filler component

This is an invisible component to fill extra space between components.

Property Type Required Description
type String Required filler
  • The filler's flex property is fixed to 1.
  • The spacing property of the parent box will be ignored for fillers.

Icon component example

{
  "type": "icon",
  "url": "https://example.com/icon/png/caution.png",
  "size": "lg"
}

Icon component

This component draws an icon.

Property Type Required Description
type String Required icon
url String Required Image URL
Protocol: HTTPS
Image format: JPEG or PNG
Maximum image size: 240×240 pixels
Maximum data size: 1 MB
margin String Optional Minimum space between this component and the previous component in the parent box. You can specify one of the following values: none, xs, sm, md, lg, xl, or xxl. none does not set a space while the other values set a space whose size increases in the order of listing. The default value is the value of the spacing property of the parent box.
If this component is the first component in the parent box, the margin property will be ignored.
size String Optional Maximum size of the icon width. You can specify one of the following values: xxs, xs, sm, md, lg, xl, xxl, 3xl, 4xl, or 5xl. The size increases in the order of listing. The default value is md.
aspectRatio String Optional Aspect ratio of the icon. You can specify one of the following values: 1:1, 2:1, or 3:1. The default value is 1:1.

The icon's flex property is fixed to 0.

Image component example

{
  "type": "image",
  "url": "https://example.com/flex/images/image.jpg",
  "size": "full"
}

Image component

This component draws an image.

Property Type Required Description
type String Required image
url String Required Image URL
Protocol: HTTPS
Image format: JPEG or PNG
Maximum image size: 1024×1024 pixels
Maximum data size: 1 MB
flex Number Optional The ratio of the width or height of this component within the parent box. The default value for the horizontal parent box is 1, and the default value for the vertical parent box is 0. For more information, see Width and height of components.
margin String Optional Minimum space between this component and the previous component in the parent box. You can specify one of the following values: none, xs, sm, md, lg, xl, or xxl. none does not set a space while the other values set a space whose size increases in the order of listing. The default value is the value of the spacing property of the parent box.
If this component is the first component in the parent box, the margin property will be ignored.
align String Optional Horizontal alignment style. Specify one of the following values:
  • start: Left-aligned
  • end: Right-aligned
  • center: Center-aligned
The default value is center.
gravity String Optional Vertical alignment style. Specify one of the following values:
  • top: Top-aligned
  • bottom: Bottom-aligned
  • center: Center-aligned
The default value is top.
If the layout property of the parent box is baseline, the gravity property will be ignored.
size String Optional Maximum size of the image width. You can specify one of the following values: xxs, xs, sm, md, lg, xl, xxl, 3xl, 4xl, 5xl, or full. The size increases in the order of listing. The default value is md.
aspectRatio String Optional Aspect ratio of the image. You can specify one of the following values: 1:1, 1.51:1, 1.91:1, 4:3, 16:9, 20:13, 2:1, 3:1, 3:4, 9:16, 1:2, or 1:3. The default value is 1:1.
aspectMode String Optional Style of the image. Specify one of the following values:
  • cover: The image fills the entire drawing area. Parts of the image that do not fit in the drawing area are not displayed.
  • fit: The entire image is displayed in the drawing area. The background is displayed in the unused areas to the left and right of vertical images and in the areas above and below horizontal images.
  • The default value is fit.
backgroundColor String Optional Background color of the image. Use a hexadecimal color code.
action Object Optional Action performed when this image is tapped. Specify an action object.

Separator component example

{
  "type": "separator",
  "color": "#000000"
}

Separator component

This component draws a separator between components in the parent box.

Property Type Required Description
type String Required separator
margin String Optional Minimum space between this component and the previous component in the parent box. You can specify one of the following values: none, xs, sm, md, lg, xl, or xxl. none does not set a space while the other values set a space whose size increases in the order of listing. The default value is the value of the spacing property of the parent box.
If this component is the first component in the parent box, the margin property will be ignored.
color String Optional Color of the separator. Use a hexadecimal color code.

Spacer component example

{
  "type": "spacer",
  "size": "md"
}

Spacer component

This is an invisible component that places a fixed-size space at the beginning or end of the box.

Property Type Required Description
type String Required spacer
size String Required Size of the space. You can specify one of the following values: xs, sm, md, lg, xl, or xxl. The size increases in the order of listing. The default value is md.

The spacing property of the parent box will be ignored for spacers.

Text component example

{
  "type": "text",
  "text": "Hello, World!",
  "size": "xl",
  "weight": "bold",
  "color": "#0000ff"
}

Text component

This component draws text. You can format the text.

Property Type Required Description
type String Required text
text String Required Text
flex Number Optional The ratio of the width or height of this component within the parent box. The default value for the horizontal parent box is 1, and the default value for the vertical parent box is 0. For more information, see Width and height of components.
margin String Optional Minimum space between this component and the previous component in the parent box. You can specify one of the following values: none, xs, sm, md, lg, xl, or xxl. none does not set a space while the other values set a space whose size increases in the order of listing. The default value is the value of the spacing property of the parent box.
If this component is the first component in the parent box, the margin property will be ignored.
size String Optional Font size. You can specify one of the following values: xxs, xs, sm, md, lg, xl, xxl, 3xl, 4xl, or 5xl. The size increases in the order of listing. The default value is md.
align String Optional Horizontal alignment style. Specify one of the following values:
  • start: Left-aligned
  • end: Right-aligned
  • center: Center-aligned
The default value is start.
gravity String Optional Vertical alignment style. Specify one of the following values:
  • top: Top-aligned
  • bottom: Bottom-aligned
  • center: Center-aligned
The default value is top.
If the layout property of the parent box is baseline, the gravity property will be ignored.
wrap Boolean Optional true to wrap text. The default value is false. If set to true, you can use a new line character (\n) to begin on a new line.
weight String Optional Font weight. You can specify one of the following values: regular, or bold. Specifying bold makes the font bold. The default value is regular.
color String Optional Font color. Use a hexadecimal color code.
action Object Optional Action performed when this text is tapped. Specify an action object.

Example request

curl -X POST https://api.line.me/v2/bot/user/{userId}/linkToken \
-H 'Authorization: Bearer {channel access token}'
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

Issues a link token used for the account link feature.

HTTP request

POST https://api.line.me/v2/bot/user/{userId}/linkToken

Request headers

Request header Description
Authorization Bearer {channel access token}

Path parameters

Parameter Required Description
userId Required User ID for the LINE account to be linked. Found in the source object of account link event objects. Do not use the LINE ID used in the LINE app.

Example response

{
  "linkToken": "NMZTNuVrPTqlr2IF8Bnymkb7rXfYv5EY"
}

Response

Returns the status code 200 and a link token. Link tokens are valid for 10 minutes and can only be used once.

Note: The validity period may change without notice.

Action objects

Example postback action object

{  
   "type":"postback",
   "label":"Buy",
   "data":"action=buy&itemid=111",
   "text":"Buy"
}

Postback action

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

Property Type Required Description
type String Required postback
label String See description Label for the action
  • Required for templates other than image carousel. Max: 20 characters.
  • Optional for image carousel templates. Max: 12 characters.
  • Optional for rich menus. Spoken when the accessibility feature is enabled on the client device. Max: 20 characters. Supported on LINE iOS version 8.2.0 and later.
data String Required String returned via webhook in the postback.data property of the postback event
Max: 300 characters
displayText String Optional Text displayed in the chat as a message sent by the user when the action is performed.
Max: 300 characters
The displayText and text fields cannot both be used at the same time.
text String Optional Deprecated. Text displayed in the chat as a message sent by the user when the action is performed. Returned from the server through a webhook.
Max: 300 characters
The displayText and text fields cannot both be used at the same time.

Example message action object

{  
   "type":"message",
   "label":"Yes",
   "text":"Yes"
}

Message action

When a control associated with this action is tapped, the string in the text property is sent as a message from the user.

Property Type Required Description
type String Required message
label String See description Label for the action
  • Required for templates other than image carousel. Max: 20 characters.
  • Optional for image carousel templates. Max: 12 characters.
  • Optional for rich menus. Spoken when the accessibility feature is enabled on the client device. Max: 20 characters. Supported on LINE iOS version 8.2.0 and later.
text String Required Text sent when the action is performed
Max: 300 characters

Example URI action object

{  
   "type":"uri",
   "label":"View details",
   "uri":"http://example.com/page/222"
}

URI action

When a control associated with this action is tapped, the URI specified in the uri property is opened.

Property Type Required Description
type String Required uri
label String See description Label for the action
  • Required for templates other than image carousel. Max: 20 characters.
  • Optional for image carousel templates. Max: 12 characters.
  • Optional for rich menus. Spoken when the accessibility feature is enabled on the client device. Max: 20 characters. Supported on LINE iOS version 8.2.0 and later.
uri String Required URI opened when the action is performed (Max: 1000 characters)
Must start with http, https, or tel.

Example datetime picker action object

{  
   "type":"datetimepicker",
   "label":"Select date",
   "data":"storeId=12345",
   "mode":"datetime",
   "initial":"2017-12-25t00:00",
   "max":"2018-01-24t23:59",
   "min":"2017-12-25t00:00"
}

Datetime picker action

Note: The datetime picker action is only supported on versions equal to or later than LINE 7.9.0 for iOS and LINE 7.12.0 for Android.

When a control associated with 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. The datetime picker action does not support time zones.

Property Type Required Description
type String Required datetimepicker
label String See description Label for the action
  • Required for templates other than image carousel. Max: 20 characters.
  • Optional for image carousel templates. Max: 12 characters.
  • Optional for rich menus. Spoken when the accessibility feature is enabled on the client device. Max: 20 characters. Supported on LINE iOS version 8.2.0 and later.
data String Required String returned via webhook in the postback.data property of the postback event
Max: 300 characters
mode String Required Action mode
date: Pick date
time: Pick time
datetime: Pick date and time
initial String Optional Initial value of date or time
max String Optional Largest date or time value that can be selected. Must be greater than the min value.
min String Optional 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 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-dateTtime-hour:time-minute or full-datettime-hour:time-minute
Max: 2100-12-31T23:59
Min: 1900-01-01T00:00
2017-06-18T06:15
2017-06-18t06:15

Rich menu structure

Rich menus consist of either of these objects.

Area objects and action objects are included in these objects.

Example rich menu object

{
  "size": {
    "width": 2500,
    "height": 1686
  },
  "selected": false,
  "name": "Nice richmenu",
  "chatBarText": "Tap to open",
  "areas": [
    {
      "bounds": {
        "x": 0,
        "y": 0,
        "width": 2500,
        "height": 1686
      },
      "action": {
        "type": "postback",
        "data": "action=buy&itemid=123"
      }
    }
  ]
}

Rich menu object

Property Type Required Description
size Object Required size object which contains the width and height of the rich menu displayed in the chat. Rich menu images must be one of the following sizes: 2500x1686px or 2500x843px.
selected Boolean Required true to display the rich menu by default. Otherwise, false.
name String Required Name of the rich menu. This value can be used to help manage your rich menus and is not displayed to users.
Max: 300 characters
chatBarText String Required Text displayed in the chat bar
Max: 14 characters
areas Array Required Array of area objects which define the coordinates and size of tappable areas
Max: 20 area objects

Example rich menu response object

{
  "richMenuId": "{richMenuId}",
  "size": {
    "width": 2500,
    "height": 1686
  },
  "selected": false,
  "name": "Nice richmenu",
  "chatBarText": "Tap to open",
  "areas": [
    {
      "bounds": {
        "x": 0,
        "y": 0,
        "width": 2500,
        "height": 1686
      },
      "action": {
        "type": "postback",
        "label":"Buy",
        "data": "action=buy&itemid=123"
      }
    }
  ]
}

Rich menu response object

Property Type Description
richMenuId  String Rich menu ID
size Object size object which contains the width and height of the rich menu displayed in the chat. Rich menu images must be one of the following sizes: 2500x1686px or 2500x843px.
selected Boolean true to display the rich menu by default. Otherwise, false.
name String Name of the rich menu. This value can be used to help manage your rich menus and is not displayed to users.
Max: 300 characters
chatBarText String Text displayed in the chat bar
Max: 14 characters
areas Array Array of area objects which define the coordinates and size of tappable areas
Max: 20 area objects

Example size object

{
   "width":520,
   "height":1040
}

size object

Property Type Required Description
width Number Required Width of the rich menu. Must be 2500.
height Number Required Height of the rich menu. Possible values: 1686, 843.

Example area object

{
  "bounds": {
    "x": 0,
    "y": 0,
    "width": 2500,
    "height": 1686
  },
  "action": {
    "type": "postback",
    "label":"Buy",
    "data": "action=buy&itemid=123"
  }
}

Area object

Property Type Required Description
bounds Object Required Object describing the boundaries of the area in pixels. See bounds object.
action Object Required Action performed when the area is tapped. See action objects.

Example bounds object

{
   "x":0,
   "y":0,
   "width":2500,
   "height":1686
}

bounds object
Property Type Required Description
x Number Required Horizontal position relative to the top-left corner of the area.
y Number Required Vertical position relative to the top-left corner of the area.
width Number Required Width of the area.
height Number Required Height of the area.