# 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 user access token

Issuing multiple service notification tokens using a single user access token obtained with liff.getAccessToken() is not allowed.

Only one service notification token can be issued per user 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

application/json

Authorization

Bearer {channel access token}
For more information, see Channel access tokens in the Messaging API documentation.

# Request body

liffAccessToken

String

Required

User access token obtained with liff.getAccessToken().

# 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 given user access token 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 user access token hasn't been specified.
403 Forbidden This channel is not 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

application/json

Authorization

Bearer {channel access token}
For more information, see Channel access tokens in the Messaging API documentation.

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

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