R/archivePage.R

Defines functions archivePage

Documented in archivePage

#' Archive a Page
#'
#' Archive's a notion page.
#'
#'
#' @author Eduardo Flores
#' @return list of response
#'
#' @param secret Notion API token
#' @param id page id
#' @return list
#'
#'
#' @importFrom httr PATCH
#' @importFrom httr content
#' @importFrom httr content_type
#' @export
archivePage <- function(secret, id){

  value <- "true"

  payload  <- sprintf(
    "{\"archived\":%s}",
    value
  )

  auth_secret <- paste0("Bearer ", secret)

  headers = c(
    `Authorization` = auth_secret,
    `Notion-Version` = '2021-05-13',
    `Content-Type` = 'application/json' )

  res <- httr::PATCH(url = paste0('https://api.notion.com/v1/pages/', id),
                     httr::add_headers(.headers = headers),
                     body = payload,
                     encode = "json")
  d <- httr::content(res)
  return(d)
}

Try the notionR package in your browser

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

notionR documentation built on June 25, 2025, 1:08 a.m.