> ## Documentation Index
> Fetch the complete documentation index at: https://docs.utage-system.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 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を返します。


`POST`

```
https://api.utage-system.com/v1/accounts/{account_id}/line/friends/{friend_id}/messages
```

<Note>この機能はプレビュー版です。仕様が変更される場合があります。</Note>


## OpenAPI

````yaml POST /accounts/{account_id}/line/friends/{friend_id}/messages
openapi: 3.0.3
info:
  title: UTAGE API
  description: |
    UTAGEのパブリックAPIです。ファネル、配信アカウント、シナリオ、メディアなどのリソースをプログラムから操作できます。

    ## 認証
    すべてのリクエストにAPIキーによるBearer認証が必要です（要素タイプエンドポイントを除く）。

    ```
    Authorization: Bearer {api_key}
    ```

    APIキーはUTAGE管理画面から発行できます。

    ## レート制限
    リクエスト数には以下の制限があります。

    | 分間上限 | 日間上限 |
    |----------|----------|
    | 60リクエスト/分 | 10,000リクエスト/日 |

    レスポンスヘッダーで現在の使用状況を確認できます。

    | ヘッダー | 説明 |
    |----------|------|
    | X-RateLimit-Limit | 分間の上限値 |
    | X-RateLimit-Remaining | 分間の残りリクエスト数 |
    | X-RateLimit-Reset | 制限がリセットされるUNIXタイムスタンプ |

    上限を超えた場合は `429 Too Many Requests` が返されます。

    ## エラーレスポンス
    エラー時は以下の形式で返されます。

    ```json
    {
      "error": {
        "code": "error_code",
        "message": "エラーメッセージ"
      }
    }
    ```
  version: '1.0'
  contact:
    name: UTAGE サポート
servers:
  - url: https://api.utage-system.com/v1
    description: UTAGE API
security:
  - BearerAuth: []
tags:
  - name: ファネル
    description: ファネルの作成・更新・一覧取得
  - name: ステップ
    description: ファネル内のステップの作成・更新・並び替え
  - name: ページ
    description: ステップ内のページの作成・更新・取得・削除
  - name: 配信アカウント
    description: 配信アカウントの作成・一覧取得
  - name: シナリオ
    description: シナリオの作成・一覧取得
  - name: メディア
    description: 動画・音声・通常メディアの一覧取得とアップロード
  - name: 要素タイプ
    description: ファネルページ・HTMLメールの要素タイプ定義、LINEメッセージタイプ・配信条件タイプの取得（認証不要）
  - name: ファネル統計
    description: ファネルの集計データ・登録者・登録経路の取得（プレビュー）
  - name: 配信メッセージ
    description: 配信メッセージの作成・更新・テスト送信・配信統計、置き換え文字の取得（プレビュー）
  - name: 読者
    description: 読者の作成・更新・取得、ラベル・配信履歴・開封/クリック履歴の取得（プレビュー）
  - name: LINE
    description: LINE友だち・カスタム送信者・1対1チャット・テンプレートの操作（プレビュー）
  - name: ラベル・共通読者・登録経路
    description: ラベル・共通読者・アクション・登録経路の操作（プレビュー）
paths:
  /accounts/{account_id}/line/friends/{friend_id}/messages:
    post:
      tags:
        - LINE
      summary: LINE 1対1チャット送信
      description: >
        **プレビュー機能。仕様は今後変更される可能性があります。**


        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を返します。
      operationId: sendLineChatMessage
      parameters:
        - $ref: '#/components/parameters/AccountId'
        - name: friend_id
          in: path
          required: true
          description: LINE友だちID
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - type
              properties:
                type:
                  type: string
                  enum:
                    - text
                    - image
                    - video
                    - audio
                    - sticker
                    - button
                  description: メッセージタイプ
                sender_id:
                  type: string
                  description: >-
                    カスタム送信者ID。type=text/image/video/audio/sticker
                    のときのみ有効（type=button では無視）
                reply_token:
                  type: string
                  description: LINEリプライトークン。指定時はReply APIで送信を試み、失敗時はPush APIにフォールバック
                text:
                  type: string
                  maxLength: 5000
                  description: メッセージ本文（type=textで必須）
                original_content_url:
                  type: string
                  format: uri
                  description: コンテンツURL（HTTPS必須）。type=image/video/audioで必須
                preview_image_url:
                  type: string
                  format: uri
                  description: プレビュー画像URL（HTTPS必須）。type=videoで必須。type=imageでは指定不可
                duration:
                  type: integer
                  minimum: 1
                  description: 再生時間（ミリ秒）。type=audioで必須
                package_id:
                  type: string
                  description: LINEスタンプパッケージID（type=stickerで必須）
                sticker_id:
                  type: string
                  description: LINEスタンプID（type=stickerで必須）
                template_id:
                  type: string
                  description: テンプレートID（type=buttonで必須）
      responses:
        '201':
          description: 送信結果
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      type:
                        type: string
                        description: 送信したメッセージタイプ
                      sent_at:
                        type: string
                        description: 送信日時
                      sent_via:
                        type: string
                        enum:
                          - push
                          - reply
                        description: 送信に使用したAPI
                      template_id:
                        type: string
                        description: テンプレートID（type=buttonのみ）
        '400':
          description: ブロック済みの友だちへの送信（friend_blocked）など不正なリクエスト
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: friend_blocked
                  message: ブロックされている友だちには送信できません
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/ValidationError'
        '429':
          $ref: '#/components/responses/RateLimitExceeded'
        '502':
          description: LINEへの送信に失敗しました（details.http_status / line_error を含む）。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: external_service_error
                  message: LINEへの送信に失敗しました
components:
  parameters:
    AccountId:
      name: account_id
      in: path
      required: true
      description: アカウントID
      schema:
        type: string
  schemas:
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: エラーコード
            message:
              type: string
              description: エラーメッセージ
            details:
              type: object
              nullable: true
              description: エラーの補足情報（retry_afterやフィールド別エラー等）。エラー種別により含まれる場合があります。
  responses:
    Unauthorized:
      description: 認証エラー。APIキーが無効または未指定。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: unauthorized
              message: 認証に失敗しました
    NotFound:
      description: 指定されたリソースが見つかりません。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: not_found
              message: リソースが見つかりません
    ValidationError:
      description: バリデーションエラー。リクエストパラメータが不正。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: validation_error
              message: バリデーションエラーが発生しました
    RateLimitExceeded:
      description: レート制限超過。時間を空けて再試行してください。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: rate_limit_exceeded
              message: リクエスト上限を超えました。しばらく時間を空けて再試行してください
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: APIキーをBearerトークンとして指定

````