Skip to main content
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

Authorization
string
header
required

APIキーをBearerトークンとして指定

Path Parameters

account_id
string
required

アカウントID

friend_id
string
required

LINE友だちID

Body

application/json
type
enum<string>
required

メッセージタイプ

Available options:
text,
image,
video,
audio,
sticker,
button
sender_id
string

カスタム送信者ID。type=text/image/video/audio/sticker のときのみ有効(type=button では無視)

reply_token
string

LINEリプライトークン。指定時はReply APIで送信を試み、失敗時はPush APIにフォールバック

text
string

メッセージ本文(type=textで必須)

Maximum string length: 5000
original_content_url
string<uri>

コンテンツURL(HTTPS必須)。type=image/video/audioで必須

preview_image_url
string<uri>

プレビュー画像URL(HTTPS必須)。type=videoで必須。type=imageでは指定不可

duration
integer

再生時間(ミリ秒)。type=audioで必須

Required range: x >= 1
package_id
string

LINEスタンプパッケージID(type=stickerで必須)

sticker_id
string

LINEスタンプID(type=stickerで必須)

template_id
string

テンプレートID(type=buttonで必須)

Response

送信結果

data
object