LINE 1対1チャット送信
curl --request POST \
--url https://api.utage-system.com/v1/accounts/{account_id}/line/friends/{friend_id}/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"sender_id": "<string>",
"reply_token": "<string>",
"text": "<string>",
"original_content_url": "<string>",
"preview_image_url": "<string>",
"duration": 2,
"package_id": "<string>",
"sticker_id": "<string>",
"template_id": "<string>"
}
'import requests
url = "https://api.utage-system.com/v1/accounts/{account_id}/line/friends/{friend_id}/messages"
payload = {
"sender_id": "<string>",
"reply_token": "<string>",
"text": "<string>",
"original_content_url": "<string>",
"preview_image_url": "<string>",
"duration": 2,
"package_id": "<string>",
"sticker_id": "<string>",
"template_id": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
sender_id: '<string>',
reply_token: '<string>',
text: '<string>',
original_content_url: '<string>',
preview_image_url: '<string>',
duration: 2,
package_id: '<string>',
sticker_id: '<string>',
template_id: '<string>'
})
};
fetch('https://api.utage-system.com/v1/accounts/{account_id}/line/friends/{friend_id}/messages', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.utage-system.com/v1/accounts/{account_id}/line/friends/{friend_id}/messages",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'sender_id' => '<string>',
'reply_token' => '<string>',
'text' => '<string>',
'original_content_url' => '<string>',
'preview_image_url' => '<string>',
'duration' => 2,
'package_id' => '<string>',
'sticker_id' => '<string>',
'template_id' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.utage-system.com/v1/accounts/{account_id}/line/friends/{friend_id}/messages"
payload := strings.NewReader("{\n \"sender_id\": \"<string>\",\n \"reply_token\": \"<string>\",\n \"text\": \"<string>\",\n \"original_content_url\": \"<string>\",\n \"preview_image_url\": \"<string>\",\n \"duration\": 2,\n \"package_id\": \"<string>\",\n \"sticker_id\": \"<string>\",\n \"template_id\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.utage-system.com/v1/accounts/{account_id}/line/friends/{friend_id}/messages")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"sender_id\": \"<string>\",\n \"reply_token\": \"<string>\",\n \"text\": \"<string>\",\n \"original_content_url\": \"<string>\",\n \"preview_image_url\": \"<string>\",\n \"duration\": 2,\n \"package_id\": \"<string>\",\n \"sticker_id\": \"<string>\",\n \"template_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.utage-system.com/v1/accounts/{account_id}/line/friends/{friend_id}/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"sender_id\": \"<string>\",\n \"reply_token\": \"<string>\",\n \"text\": \"<string>\",\n \"original_content_url\": \"<string>\",\n \"preview_image_url\": \"<string>\",\n \"duration\": 2,\n \"package_id\": \"<string>\",\n \"sticker_id\": \"<string>\",\n \"template_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"type": "<string>",
"sent_at": "<string>",
"template_id": "<string>"
}
}{
"error": {
"code": "friend_blocked",
"message": "ブロックされている友だちには送信できません"
}
}{
"error": {
"code": "unauthorized",
"message": "認証に失敗しました"
}
}{
"error": {
"code": "not_found",
"message": "リソースが見つかりません"
}
}{
"error": {
"code": "validation_error",
"message": "バリデーションエラーが発生しました"
}
}{
"error": {
"code": "rate_limit_exceeded",
"message": "リクエスト上限を超えました。しばらく時間を空けて再試行してください"
}
}{
"error": {
"code": "external_service_error",
"message": "LINEへの送信に失敗しました"
}
}LINE
LINE 1対1チャット送信
プレビュー機能。仕様は今後変更される可能性があります。
LINE友だちに1対1チャットでメッセージを送信します。type で送信種別を指定し、種別ごとに必須フィールドが異なります。
text:text必須image:original_content_url必須(HTTPS)。preview_image_urlはプレビューが自動設定されるため指定不可video:original_content_url・preview_image_url必須(いずれもHTTPS)audio:original_content_url・duration必須sticker:package_id・sticker_id必須button:template_id必須
reply_token を指定するとReply APIで送信を試み、失敗した場合はPush APIにフォールバックします。sender_id は type=button のときは無視されます。
ブロック済み(is_blocked=true)の友だちには送信できず400を返します。
LINE 1対1チャット送信
curl --request POST \
--url https://api.utage-system.com/v1/accounts/{account_id}/line/friends/{friend_id}/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"sender_id": "<string>",
"reply_token": "<string>",
"text": "<string>",
"original_content_url": "<string>",
"preview_image_url": "<string>",
"duration": 2,
"package_id": "<string>",
"sticker_id": "<string>",
"template_id": "<string>"
}
'import requests
url = "https://api.utage-system.com/v1/accounts/{account_id}/line/friends/{friend_id}/messages"
payload = {
"sender_id": "<string>",
"reply_token": "<string>",
"text": "<string>",
"original_content_url": "<string>",
"preview_image_url": "<string>",
"duration": 2,
"package_id": "<string>",
"sticker_id": "<string>",
"template_id": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
sender_id: '<string>',
reply_token: '<string>',
text: '<string>',
original_content_url: '<string>',
preview_image_url: '<string>',
duration: 2,
package_id: '<string>',
sticker_id: '<string>',
template_id: '<string>'
})
};
fetch('https://api.utage-system.com/v1/accounts/{account_id}/line/friends/{friend_id}/messages', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.utage-system.com/v1/accounts/{account_id}/line/friends/{friend_id}/messages",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'sender_id' => '<string>',
'reply_token' => '<string>',
'text' => '<string>',
'original_content_url' => '<string>',
'preview_image_url' => '<string>',
'duration' => 2,
'package_id' => '<string>',
'sticker_id' => '<string>',
'template_id' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.utage-system.com/v1/accounts/{account_id}/line/friends/{friend_id}/messages"
payload := strings.NewReader("{\n \"sender_id\": \"<string>\",\n \"reply_token\": \"<string>\",\n \"text\": \"<string>\",\n \"original_content_url\": \"<string>\",\n \"preview_image_url\": \"<string>\",\n \"duration\": 2,\n \"package_id\": \"<string>\",\n \"sticker_id\": \"<string>\",\n \"template_id\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.utage-system.com/v1/accounts/{account_id}/line/friends/{friend_id}/messages")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"sender_id\": \"<string>\",\n \"reply_token\": \"<string>\",\n \"text\": \"<string>\",\n \"original_content_url\": \"<string>\",\n \"preview_image_url\": \"<string>\",\n \"duration\": 2,\n \"package_id\": \"<string>\",\n \"sticker_id\": \"<string>\",\n \"template_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.utage-system.com/v1/accounts/{account_id}/line/friends/{friend_id}/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"sender_id\": \"<string>\",\n \"reply_token\": \"<string>\",\n \"text\": \"<string>\",\n \"original_content_url\": \"<string>\",\n \"preview_image_url\": \"<string>\",\n \"duration\": 2,\n \"package_id\": \"<string>\",\n \"sticker_id\": \"<string>\",\n \"template_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"type": "<string>",
"sent_at": "<string>",
"template_id": "<string>"
}
}{
"error": {
"code": "friend_blocked",
"message": "ブロックされている友だちには送信できません"
}
}{
"error": {
"code": "unauthorized",
"message": "認証に失敗しました"
}
}{
"error": {
"code": "not_found",
"message": "リソースが見つかりません"
}
}{
"error": {
"code": "validation_error",
"message": "バリデーションエラーが発生しました"
}
}{
"error": {
"code": "rate_limit_exceeded",
"message": "リクエスト上限を超えました。しばらく時間を空けて再試行してください"
}
}{
"error": {
"code": "external_service_error",
"message": "LINEへの送信に失敗しました"
}
}POST
https://api.utage-system.com/v1/accounts/{account_id}/line/friends/{friend_id}/messages
この機能はプレビュー版です。仕様が変更される場合があります。
Authorizations
APIキーをBearerトークンとして指定
Body
application/json
メッセージタイプ
Available options:
text, image, video, audio, sticker, button カスタム送信者ID。type=text/image/video/audio/sticker のときのみ有効(type=button では無視)
LINEリプライトークン。指定時はReply APIで送信を試み、失敗時はPush APIにフォールバック
メッセージ本文(type=textで必須)
Maximum string length:
5000コンテンツURL(HTTPS必須)。type=image/video/audioで必須
プレビュー画像URL(HTTPS必須)。type=videoで必須。type=imageでは指定不可
再生時間(ミリ秒)。type=audioで必須
Required range:
x >= 1LINEスタンプパッケージID(type=stickerで必須)
LINEスタンプID(type=stickerで必須)
テンプレートID(type=buttonで必須)
Response
送信結果
Show child attributes
Show child attributes
⌘I