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

# メッセージの投稿

> チャンネルに新しいメッセージを投稿します（JSON形式）。
テキストメッセージやURL指定の添付ファイルを送信できます。 チャンネルに新しいメッセージを投稿します（ファイルアップロード）。
バイナリファイルをアップロードできます。



## OpenAPI

````yaml post /channels/{channel_id}/messages
openapi: 3.0.0
info:
  title: Rheel Chat Client API
  version: 1.0.0
  license:
    name: MIT
    url: https://opensource.org/licenses/MIT
  description: |-
    RheelのChat API (Client版) 仕様です。

    このAPIはJWT認証（UserSessionAuth）を使用するクライアント向けのエンドポイントを提供します。
    すべてのエンドポイントは `/client` プレフィックスを持ち、セッショントークンによる認証が必要です。

    ## 認証方式
    - **JWT認証（Bearer Token）**: セッショントークン発行のエンドポイントを介して取得したセッショントークンを
    Authorizationヘッダーに `Bearer {token}` 形式で指定します。

    ## WebSocketについて
    このサービスでは、メッセージや通知をリアルタイムに受信するために WebSocket通信を提供しています。
    接続先は以下のURLです: `wss://<application_id>.chat.rheel.net/v1/ws`
servers:
  - url: https://<application_id>.chat.rheel.net/client/v1
    description: 本番サーバー
    variables:
      application_id:
        default: YOUR_APP_ID（RheelチャットインスタンスのアプリケーションID）
security: []
tags:
  - name: Client Channels
  - name: Client Messages
  - name: Client Users
paths:
  /channels/{channel_id}/messages:
    post:
      tags:
        - Client Messages
      summary: メッセージの投稿 メッセージの投稿（ファイル付き）
      description: |-
        チャンネルに新しいメッセージを投稿します（JSON形式）。
        テキストメッセージやURL指定の添付ファイルを送信できます。 チャンネルに新しいメッセージを投稿します（ファイルアップロード）。
        バイナリファイルをアップロードできます。
      operationId: ClientMessages_createMessage_ClientMessages_createMessageWithFiles
      parameters:
        - name: channel_id
          in: path
          required: true
          description: メッセージを投稿するチャンネルID
          schema:
            $ref: '#/components/schemas/ChannelId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Messages.CreateMessageJsonRequest'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/Messages.CreateMessageMultipartRequest'
            encoding:
              data:
                contentType: application/json
      responses:
        '200':
          description: メッセージの作成完了
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Messages.Message'
        '400':
          description: 入力内容が不正です
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error.BadRequestError'
        '401':
          description: 認証に失敗しました
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error.UnauthorizedError'
        '403':
          description: アクセス権がありません
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error.ForbiddenError'
        '404':
          description: リソースが存在しません
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error.NotFoundError'
        '500':
          description: サーバーでエラーが発生しました。時間をおいて再度お試しください。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error.InternalServerError'
      security:
        - UserSessionAuth: []
components:
  schemas:
    ChannelId:
      type: string
      minLength: 1
      maxLength: 100
      pattern: ^[a-zA-Z0-9_-]+$
    Messages.CreateMessageJsonRequest:
      type: object
      properties:
        message:
          $ref: '#/components/schemas/Messages.CreateMessageRequest'
        attachments:
          type: array
          items:
            $ref: '#/components/schemas/Messages.AttachmentInput'
      description: メッセージ送信リクエスト（JSON）
    Messages.CreateMessageMultipartRequest:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/Messages.BaseMessageFields'
        files:
          type: array
          items:
            type: string
            format: binary
      required:
        - data
    Messages.Message:
      type: object
      required:
        - id
        - channel_id
        - sent_by
        - created_at
        - updated_at
      properties:
        id:
          type: string
          format: uuid
          description: メッセージID
          readOnly: true
        content:
          type: string
          maxLength: 32000
          description: メッセージ本文
        channel_id:
          allOf:
            - $ref: '#/components/schemas/ChannelId'
          description: メッセージが属するチャンネルのID
          readOnly: true
        thread_id:
          type: string
          nullable: true
          format: uuid
          description: スレッドメッセージとして返信する場合の親メッセージID
        sent_by:
          allOf:
            - $ref: '#/components/schemas/Users.UserBasic'
          description: メッセージを送信したユーザー
          readOnly: true
        read_by:
          type: array
          items:
            $ref: '#/components/schemas/Users.UserBasic'
          description: 既読したユーザーの一覧
          readOnly: true
        reactions:
          type: array
          items:
            $ref: '#/components/schemas/Messages.Reaction'
          description: メッセージに付与されたリアクション一覧
          readOnly: true
        attachments:
          type: array
          items:
            $ref: '#/components/schemas/Messages.Attachment'
          description: 添付ファイル一覧
          readOnly: true
        mentions:
          type: array
          items:
            $ref: '#/components/schemas/Messages.Mention'
          description: メンション一覧
          readOnly: true
        thread_reply_info:
          type: object
          allOf:
            - $ref: '#/components/schemas/Messages.ThreadReplyInfo'
          nullable: true
          description: このメッセージへの返信に関する情報
          readOnly: true
        edited_at:
          type: string
          format: date-time
          nullable: true
          description: 編集日時
          readOnly: true
        created_at:
          type: string
          format: date-time
          description: 作成日時
          readOnly: true
        updated_at:
          type: string
          format: date-time
          nullable: true
          description: 更新日時
          readOnly: true
        deleted_at:
          type: string
          format: date-time
          nullable: true
          description: 削除日時
          readOnly: true
        metadata:
          type: object
          additionalProperties: {}
          nullable: true
          description: 任意の追加メタデータ
    Error.BadRequestError:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            code:
              type: string
              enum:
                - BAD_REQUEST
            errors:
              type: array
              items:
                $ref: '#/components/schemas/Error.ValidationError'
          required:
            - message
            - code
      allOf:
        - $ref: '#/components/schemas/TypeSpec.Http.BadRequestResponse'
      description: 入力内容が不正です
    Error.UnauthorizedError:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            code:
              type: string
              enum:
                - UNAUTHORIZED
          required:
            - message
            - code
      allOf:
        - $ref: '#/components/schemas/TypeSpec.Http.UnauthorizedResponse'
      description: 認証に失敗しました
    Error.ForbiddenError:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            code:
              type: string
              enum:
                - FORBIDDEN
          required:
            - message
            - code
      allOf:
        - $ref: '#/components/schemas/TypeSpec.Http.ForbiddenResponse'
      description: アクセス権がありません
    Error.NotFoundError:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            code:
              type: string
              enum:
                - NOT_FOUND
          required:
            - message
            - code
      allOf:
        - $ref: '#/components/schemas/TypeSpec.Http.NotFoundResponse'
      description: リソースが存在しません
    Error.InternalServerError:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            code:
              type: string
              enum:
                - INTERNAL_SERVER_ERROR
          required:
            - message
            - code
      allOf:
        - type: object
          description: ''
      description: サーバーでエラーが発生しました。時間をおいて再度お試しください。
    Messages.CreateMessageRequest:
      type: object
      properties:
        content:
          type: string
          maxLength: 32000
          description: メッセージ本文
        thread_id:
          type: string
          nullable: true
          format: uuid
          description: スレッドメッセージとして返信する場合の親メッセージID
        metadata:
          type: object
          additionalProperties: {}
          nullable: true
          description: 任意の追加メタデータ
        mentions:
          type: array
          items:
            $ref: '#/components/schemas/Messages.MentionInput'
          description: メンション一覧（送信時）
    Messages.AttachmentInput:
      type: object
      required:
        - url
        - name
        - mime_type
      properties:
        url:
          type: string
        name:
          type: string
        mime_type:
          type: string
        size:
          type: integer
          format: int64
      description: 添付ファイル情報（URL指定）
    Messages.BaseMessageFields:
      type: object
      properties:
        message:
          $ref: '#/components/schemas/Messages.CreateMessageRequest'
      description: メッセージ送信の共通フィールド
    Users.UserBasic:
      type: object
      required:
        - id
        - display_name
        - role
      properties:
        id:
          allOf:
            - $ref: '#/components/schemas/UserId'
          description: ユーザーの一意な識別子
        display_name:
          type: string
          minLength: 1
          maxLength: 200
          description: ユーザーの表示名
        icon_url:
          type: string
          nullable: true
          description: ユーザーアイコンのURL
        role:
          allOf:
            - $ref: '#/components/schemas/Users.UserRole'
          description: ユーザーの権限・役割(Admin:管理者, Member:一般ユーザー)
        metadata:
          type: object
          additionalProperties: {}
          nullable: true
          description: 任意の追加メタデータ
      description: 簡易ユーザー情報（IDと基本情報のみ）
    Messages.Reaction:
      type: object
      required:
        - id
        - message_id
        - emoji_code
        - user
        - created_at
      properties:
        id:
          type: string
          format: uuid
          description: リアクションID
          readOnly: true
        message_id:
          type: string
          format: uuid
          description: リアクションを付与するメッセージID
          readOnly: true
        emoji_code:
          type: string
          description: リアクションに用いる絵文字のコード
        user:
          allOf:
            - $ref: '#/components/schemas/Users.UserBasic'
          description: リアクションを付与したユーザー
          readOnly: true
        created_at:
          type: string
          format: date-time
          nullable: true
          description: リアクションが付与された日時
          readOnly: true
    Messages.Attachment:
      type: object
      required:
        - url
        - name
        - mime_type
        - size
        - source
        - channel_id
      properties:
        id:
          type: string
          format: uuid
          description: 添付ファイルID
          readOnly: true
        message_id:
          type: string
          format: uuid
          description: 添付対象のメッセージID
          readOnly: true
        url:
          type: string
          description: ファイルのURL（バイナリアップロードの場合は認証付きURL）
          readOnly: true
        name:
          type: string
          description: ファイル名
        mime_type:
          type: string
          description: MIMEタイプ
        size:
          type: integer
          format: int64
          description: ファイルサイズ（バイト）
        source:
          allOf:
            - $ref: '#/components/schemas/Messages.FileSource'
          description: ファイルのソース
        metadata:
          type: object
          additionalProperties: {}
          nullable: true
          description: 任意の追加メタデータ
        channel_id:
          allOf:
            - $ref: '#/components/schemas/ChannelId'
          description: 添付を行うチャンネルID
          readOnly: true
    Messages.Mention:
      type: object
      required:
        - type
      properties:
        type:
          allOf:
            - $ref: '#/components/schemas/Messages.MentionType'
          description: メンションタイプ
        user:
          allOf:
            - $ref: '#/components/schemas/Users.UserBasic'
          description: メンション対象のユーザー情報（userタイプの場合のみ）
      description: メンション情報（取得時）
    Messages.ThreadReplyInfo:
      type: object
      required:
        - count
        - last_replied_at
      properties:
        count:
          type: integer
          description: 返信数
          readOnly: true
        last_replied_at:
          type: string
          format: date-time
          description: 最終返信日時
          readOnly: true
      description: スレッド返信情報
    Error.ValidationError:
      type: object
      required:
        - field
        - message
        - code
      properties:
        field:
          type: string
        message:
          type: string
        code:
          type: string
      description: バリデーションエラー詳細
    TypeSpec.Http.BadRequestResponse:
      type: object
      description: The server could not understand the request due to invalid syntax.
    TypeSpec.Http.UnauthorizedResponse:
      type: object
      description: Access is unauthorized.
    TypeSpec.Http.ForbiddenResponse:
      type: object
      description: Access is forbidden.
    TypeSpec.Http.NotFoundResponse:
      type: object
      description: The server cannot find the requested resource.
    Messages.MentionInput:
      type: object
      required:
        - type
      properties:
        type:
          allOf:
            - $ref: '#/components/schemas/Messages.MentionType'
          description: メンションタイプ
        user_id:
          type: string
          description: メンション対象のユーザーID（userタイプの場合のみ必須）
      description: メンション情報（送信時）
    UserId:
      type: string
      minLength: 1
      maxLength: 100
      pattern: ^[a-zA-Z0-9_-]+$
    Users.UserRole:
      type: string
      enum:
        - Admin
        - Member
    Messages.FileSource:
      type: string
      enum:
        - Binary
        - Url
      description: ファイルのソース種別
    Messages.MentionType:
      type: string
      enum:
        - User
        - Channel
      description: メンションタイプ
  securitySchemes:
    UserSessionAuth:
      type: http
      scheme: bearer
      description: ユーザーがログインすると発行されるsession_idをBearerトークンとして指定します

````