R/post_ip_comments.R

Defines functions post_ip_comments

Documented in post_ip_comments

#' Add a comment to an IP address
#'
#' @param ip IP address. Required.
#' @param comment Comment. Required.
#' @param \dots Additional arguments passed to \code{\link{virustotal_POST}}.
#'
#' @return named list
#' @export
#'
#' @references \url{https://docs.virustotal.com/reference}
#'
#' @seealso \code{\link{set_key}} for setting the API key
#'
#' @examples \dontrun{
#'
#' # Before calling the function, set the API key using set_key('api_key_here')
#'
#' post_ip_comments(ip = "64.233.160.0", comment = "test")
#' }
post_ip_comments <- function(ip = NULL, comment = NULL, ...) {
  assert_character(ip, len = 1, any.missing = FALSE, min.chars = 1)
  assert_character(comment, len = 1, any.missing = FALSE, min.chars = 1)

  comment_body <- list(
    data = list(
      type = "comment",
      attributes = list(text = comment)
    )
  )

  res <- virustotal_POST(
    path = paste0("ip_addresses/", ip, "/comments"),
    body = comment_body, ...
  )

  res
}

Try the virustotal package in your browser

Any scripts or data that you put into this service are public.

virustotal documentation built on Aug. 20, 2026, 5:07 p.m.