# LINE MINI App API reference

# Service Messages

The Service Message API enables you to send service messages from your service to your LINE MINI App users.

Sending service messages requires a service notification token and a template.

# Issuing a service notification token

Issues a service notification token. Service notification tokens are used to send a service message to the associated user.

Service notification tokens have the following features:

  • A service notification token expires 1 year (31,536,000 seconds) after being issued. While it is still valid, up to 5 service messages can be sent.
  • Every time you use the service notification token, the token value is renewed unless it expired or no longer has remaining message counts. If you are planning to send successive service messages to a user, keep the renewed service notification token.
Don't issue more than one service notification token with a single access token

Issuing multiple service notification tokens reusing an access token obtained by liff.getAccessToken() (LIFF access token) is not allowed.

Only one service notification token can be issued per LIFF access token.

Note

Each service notification token is associated with one user. You cannot use a service notification token associated with one user to send a service message to other users.

Example request

# HTTP request

POST https://api.line.me/message/v3/notifier/token

# Request headers

Content-Type

Required

application/json

Authorization

Required

Bearer {channel access token}
For more information, see Channel access token in the LINE Platform basics.

Use of stateless channel access tokens is recommended

Long-lived channel access tokens and channel access token with a user-specified expiration (Channel Access Token v2.1) cannot be used for LINE MINI App channels.

When developing LINE MINI Apps, either stateless channel access tokens or short-lived channel access tokens can be used. Stateless channel access tokens are recommended among those two. Stateless channel access tokens have an unlimited number of issuances, so there is no need for the application to manage the token lifecycle.

# Request body

liffAccessToken

String

Required

User access token obtained by liff.getAccessToken() (LIFF access token).

# Response

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

notificationToken

String

Service notification token

expiresIn

Number

The amount of time remaining in seconds before the service notification token expires. A service notification token expires 1 year (31,536,000 seconds) after being issued.

remainingCount

Number

The number of times you can send a service message with the issued service notification token

sessionId

String

The session ID. For more information, see Sending service messages.

Example response

# Error response

Returns one of the following status codes and error messages.

Status code Description
400 Bad request This status code means one of the following:
  • There is a problem with the request body.
  • The LIFF access token specified in the liffAccessToken property was used multiple times in a short span of time to request the issuing of service notification tokens.
401 Unauthorized This status code means one or both of the following:
  • A valid channel access token hasn't been specified.
  • A valid LIFF access token hasn't been specified.
    • When the user closes the LINE MINI App, the LIFF access token will be revoked even if it hasn't expired.
403 Forbidden This channel isn't authorized to issue service messages.
500 Internal Server Error Error on the internal server

Example error response

# Sending service messages

Sends a service message to a user specified in the service notification token.

Once a service message is sent, the token's value is renewed unless the token expired or no longer has remaining message counts. If you are planning to send successive service messages to a user, keep the renewed service notification token.

Example request

# HTTP request

POST https://api.line.me/message/v3/notifier/send

# Request headers

Content-Type

Required

application/json

Authorization

Required

Bearer {channel access token}
For more information, see Channel access token in the LINE Platform basics.

Use of stateless channel access tokens is recommended

Long-lived channel access tokens and channel access token with a user-specified expiration (Channel Access Token v2.1) cannot be used for LINE MINI App channels.

When developing LINE MINI Apps, either stateless channel access tokens or short-lived channel access tokens can be used. Stateless channel access tokens are recommended among those two. Stateless channel access tokens have an unlimited number of issuances, so there is no need for the application to manage the token lifecycle.

# Query parameters

target

Required

service

# Request body

templateName

String

Required

The name of a pre-registered template to use for the service message, with a BCP 47 language tag suffix.

  • Format: {template name}_{BCP 47 language tag}
  • Maximum length: 30 characters
Note

The languages and language tags supported by the service message are as follows.

  • Arabic: ar
  • Chinese (Simplified): zh-CN
  • Chinese (Traditional): zh-TW
  • English: en
  • French: fr
  • German: de
  • Indonesian: id
  • Italian: it
  • Japanese: ja
  • Korean: ko
  • Malay: ms
  • Portuguese (Brazil): pt-BR
  • Portuguese (Portugal): pt-PT
  • Russian: ru
  • Spanish (Spain): es-ES
  • Thai: th
  • Turkish: tr
  • Vietnamese: vi

params

object

Required

JSON Object to specify each template variable-value pair.
If the template has no template variable, specify an empty JSON object ({ }).
The template variables are defined for each template. If a template variable is part of the required elements, be sure to specify a template variable-value pair.
For more information, see Adding service message templates.

notificationToken

String

Required

Service notification token

# Response

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

notificationToken

String

A renewed service notification token. Use this service notification token to send successive service messages.

expiresIn

Number

The remaning amount of time in seconds until renewed service notification token expires

remainingCount

Number

The number of times you can send successive service messages with the renewed service notification token.

sessionId

String

The session ID. For more information, see Sending service messages.

Note

If the values of expiresIn and remainingCount are 0, it means that the service message was sent, but the service notification token couldn't be renewed.

Example response

# Error response

Returns one of the following status codes and error messages.

Status code Description
400 Bad request This status code means one of the following:
  • There is a problem with the request body.
  • The target recipient of the service message doesn't exist.
401 Unauthorized This status code means one or both of the following:
  • A valid channel access token hasn't been specified.
  • A valid service notification token hasn't been specified.
403 Forbidden This status code means one of the following:
  • This channel is not authorized to send service messages.
  • The specified template cannot be found.

Example error response