Skip to content

A SharePoint site and document library. Remote paths are relative to the library root, e.g. 'Reports/2026/summary.xlsx'; local paths are relative to the project.

How to get one

  1. Sharepoint .connect()
  2. SharepointSite
local sharepointSite = Sharepoint.connect(siteUrl)

Functions

  • useLibrary self Switches to another document library of the site.
  • upload self Uploads a project file to the library, replacing the remote file if it exists.
  • download self Downloads a library file into the project, creating missing local folders and overwriting an existing local file.
  • list SharepointItem[] Lists the files and subfolders directly in a folder (not recursive); "" is the library root.
  • exists boolean Returns true when a file or folder exists at the path, false when SharePoint answers 404.
  • createFolder self Creates a folder and any missing parent folders.
  • move self Moves and/or renames a file or folder within the library.
  • delete self Deletes a file or a folder with everything in it; SharePoint moves it to the site recycle bin, so it can be restored there.
sharepointSite.useLibrary(name: string)→self

Switches to another document library of the site. The name is matched without regard to case against the library's display name and the name in its URL ("Documents" or "Shared Documents"). Raises an error listing the available libraries when none matches. All later calls on this site use that library.

Parameters

name string
Library name

Returns

self chainable The sharepointSite itself, so calls can be chained.

Example

site.useLibrary("Contracts")
print(#site.list(""))
sharepointSite.upload(localFile: string, remoteFile: string)→self

Uploads a project file to the library, replacing the remote file if it exists. Files are sent in a single request, which SharePoint limits to 250 MB; larger files fail with an HTTP error. The local path must be a file inside the project (otherwise "Local path must be a file inside the project"); it is fetched from the Reflex server first when it is not in the workspace. Create missing folders yourself with createFolder.

Parameters

localFile string
Local file, relative to the project
remoteFile string
Remote file path in the library

Returns

self chainable The sharepointSite itself, so calls can be chained.

Example

site.createFolder("Reports/2026")
site.upload("output/summary.xlsx", "Reports/2026/summary.xlsx")
sharepointSite.download(remoteFile: string, localFile: string)→self

Downloads a library file into the project, creating missing local folders and overwriting an existing local file. The local path must be inside the project. Raises an error ("HTTP 404 itemNotFound") when the remote file does not exist.

Parameters

remoteFile string
Remote file path in the library
localFile string
Local file, relative to the project

Returns

self chainable The sharepointSite itself, so calls can be chained.

Example

site.download("Inbox/orders.csv", "input/orders.csv")
sharepointSite.list(folder: string)→SharepointItem[]

Lists the files and subfolders directly in a folder (not recursive); "" is the library root. Every page of results is read, so large folders are complete. Each item's path can be passed to download, move, exists and delete. Raises an error when the folder does not exist.

Parameters

folder string
Remote folder path

Returns

SharepointItem[] A file or folder in a SharePoint document library.
Fields of SharepointItem
name string
file or folder name
path string
path relative to the library root; pass it to download, move or delete
folder boolean
true for a folder, false for a file
size number
size in bytes
webUrl string
browser URL of the item
lastModified string
last modified date in ISO 8601
All table shapes

Example

for _, item in ipairs(site.list("Inbox")) do
if not item.folder and item.name:match("%.csv$") then
print(item.path, item.size, item.lastModified)
end
end
sharepointSite.exists(path: string)→boolean

Returns true when a file or folder exists at the path, false when SharePoint answers 404. Other errors (no access, sign-in problems) are raised.

Parameters

path string
Remote path

Returns

boolean

Example

if not site.exists("Reports/2026") then
site.createFolder("Reports/2026")
end
sharepointSite.createFolder(path: string)→self

Creates a folder and any missing parent folders. Folders that already exist are left alone, so it is safe to call repeatedly.

Parameters

path string
Remote folder path

Returns

self chainable The sharepointSite itself, so calls can be chained.

Example

site.createFolder("Archive/2026/Q1")
sharepointSite.move(from: string, to: string)→self

Moves and/or renames a file or folder within the library. The destination path includes the new name, and its parent folder must already exist (createFolder). Raises an error when the destination already exists or the source is missing.

Parameters

from string
Remote source path
to string
Remote destination path, including the new name

Returns

self chainable The sharepointSite itself, so calls can be chained.

Example

site.move("Inbox/orders.csv", "Processed/orders-2026-05.csv")
sharepointSite.delete(path: string)→self

Deletes a file or a folder with everything in it; SharePoint moves it to the site recycle bin, so it can be restored there. Refuses to delete the library root (""). Raises an error when the path does not exist.

Parameters

path string
Remote path

Returns

self chainable The sharepointSite itself, so calls can be chained.

Example

site.delete("Inbox/orders.csv")