telebot-ts API Documentation - v1.0.0
    Preparing search index...

    Function buildRequestBody

    • Builds either a JSON string body or a FormData multipart body for Telegram Bot API requests.

      Automatically inspects the payload properties for binary InputFile or Blob instances:

      • If binary data is present, serializes as multipart FormData.
      • If only primitive/JSON data is present, serializes as JSON with application/json header.

      Parameters

      • payload: Record<string, unknown>

        Key-value map of parameters to send with the Telegram API request.

      Returns { body: BodyInit; headers?: Record<string, string> }

      Object containing the serialized body and optional request headers.

      const { body, headers } = buildRequestBody({ chat_id: 12345, text: "Hello!" });