driveItems: get by id or path, list children, search, recent and shared-with-me, create folders, update, rename, move, copy (async, with a monitor URL), delete to the recycle bin, permanently delete, and restore.
Every function takes opts: drive (see ::microsoft::onedrive),
OData options (select, expand, top, orderby, filter) and
microsoft-graph credentials.
Permissions. Reads: Files.Read (own drive) or Files.Read.All
(shared and other users' files); SharePoint libraries also accept
Sites.Read.All, or Sites.Selected / Files.SelectedOperations.Selected
for app-only access granted per site or file. Writes: the
ReadWrite variants.
Values
DEFAULT_PAGE_SIZE
DEFAULT_PAGE_SIZE: Int 200
Functions
build-copy
fn (dest-parent-id: Str, opts: Map): Map
The copy body (pure): parentReference {driveId?, id}, name,
childrenOnly, includeAllVersionHistory; unset options are omitted.
Example
::microsoft::onedrive::items/build-copy("01FOLDER", {drive-id: "b!xyz", name: "Copy.xlsx"}) // {parentReference: {driveId: "b!xyz", id: "01FOLDER"}, name: "Copy.xlsx"}
build-folder
fn (name: Str, conflict: Str): Map
The body for creating a folder (pure): {name, folder: {}, @microsoft.graph.conflictBehavior}.
Example
::microsoft::onedrive::items/build-folder("Reports", "fail") // {name: "Reports", folder: {}, "@microsoft.graph.conflictBehavior": "fail"}
build-move
fn (new-parent-id: Str, opts: Map): Map
The PATCH body for a move (pure): {parentReference: {id, driveId?}, name?}.
Example
::microsoft::onedrive::items/build-move("01FOLDER", {name: "Q3.xlsx"}) // {parentReference: {id: "01FOLDER"}, name: "Q3.xlsx"}
classify-copy-status
fn (response: Result): CopyStatus
Interpret a monitor-URL response (pure). 200 and 202 carry an
AsyncOperationStatus body. Personal OneDrive answers a finished copy
with 303 See Other. ::hot::http/request follows a 303 that has a
Location (as a GET, with no Authorization), so the answer is then
the new item's URL: a 401 or 403 (its API URL needs a token) or a
driveItem both mean completed. A 303 without Location arrives as
itself and also means completed.
Example
status ::microsoft::onedrive::items/classify-copy-status({status: 202, headers: {}, body: {status: "inProgress", percentageComplete: 40}})
status.done // false
status.percent // 40
copy-item
fn (item: Any, dest-parent-id: Str): Map
fn (item: Any, dest-parent-id: Str, opts: Map): Map
POST {item}/copy - start an asynchronous copy into the folder
dest-parent-id (opts.drive-id for another drive, name,
conflict (fail default, replace, rename; not on personal
OneDrive), children-only, include-all-versions). Returns
{monitor-url, status: "accepted"} at once: check progress later with
copy-status(monitor-url) from a schedule or a follow-up event, never
in a loop.
job ::microsoft::onedrive::items/copy-item("/Reports/Q3.xlsx", "01ARCHIVE", {name: "Q3 (archive).xlsx"})
send("copy:started", {monitor-url: job.monitor-url})
copy-status
fn (monitor-url: Str): CopyStatus
fn (monitor-url: Str, opts: Map): CopyStatus
GET a copy's monitor URL (no Authorization header: the URL is
pre-authenticated) and return a CopyStatus. Call it from a
schedule or event, not in a loop; the monitor URL is short-lived.
job ::microsoft::onedrive::items/copy-item("/Reports/Q3.xlsx", "01ARCHIVE")
status ::microsoft::onedrive::items/copy-status(job.monitor-url)
cond {
not(status.done) => { send("copy:pending", {monitor-url: job.monitor-url}) }
eq(status.status, "failed") => { println(`copy failed: ${to-json(status.error)}`) }
=> { println(`copied: ${status.resource-id}`) }
}
create-folder
fn (parent: Any, name: Str): Map
fn (parent: Any, name: Str, opts: Map): Map
POST {parent}/children - create a folder. opts.conflict is
"fail" (default), "rename" or "replace". Returns the folder.
folder ::microsoft::onedrive::items/create-folder("root", "Reports", {conflict: "rename"})
delete-item
fn (item: Any): Bool
fn (item: Any, opts: Map): Bool
DELETE an item: it moves to the recycle bin (restorable for 93 days on
work/school, 30 days on personal). opts.if-match (eTag) makes it
conditional. Returns true.
Example
::microsoft::onedrive::items/delete-item("/Reports/Old.xlsx")
// Only if nobody changed it since it was read
item ::microsoft::onedrive::items/get-item("/Reports/Draft.xlsx")
::microsoft::onedrive::items/delete-item(item, {if-match: item.eTag})
ensure-folder
fn (path: Str): Map
fn (path: Str, opts: Map): Map
Return the folder at /path (from the drive root), creating it and any
missing parents. Returns the folder driveItem.
Example
folder ::microsoft::onedrive::items/ensure-folder("/Reports/2026/Q3")
folder.id
get-doc-file
fn (item: Any): ::microsoft::onedrive/DocFile
fn (item: Any, opts: Map): ::microsoft::onedrive/DocFile
get-item normalised to a ::microsoft::onedrive/DocFile.
Example
f ::microsoft::onedrive::items/get-doc-file("/Reports/Q3.xlsx")
f.version
f.web-url
get-item
fn (item: Any): Map
fn (item: Any, opts: Map): Map
GET an item by id, /path, "root" or Map. opts takes select,
expand (e.g. "thumbnails", "permissions") and drive.
item ::microsoft::onedrive::items/get-item("/Reports/Q3.xlsx")
item.id
item.file.hashes.quickXorHash
is-copy-done
fn (status: Map): Bool
True when a CopyStatus is completed or failed.
Example
::microsoft::onedrive::items/is-copy-done({done: true}) // true
::microsoft::onedrive::items/is-copy-done({done: false}) // false
list-all-children
fn (folder: Any): Vec
fn (folder: Any, opts: Map): Vec
fn (folder: Any, opts: Map, limit: Int?): Vec
Follow @odata.nextLink and return every child of folder (a Vec of
driveItems), or at most limit. Uses top: 200 unless set.
files filter(::microsoft::onedrive::items/list-all-children("root", {}, 1000), (i) { is-map(i.file) })
list-children
fn (folder: Any): Map
fn (folder: Any, opts: Map): Map
GET {folder}/children - one page of a folder's children: Graph's
{value, @odata.nextLink?}. Follow @odata.nextLink with
::microsoft::graph::api/fetch-page or use list-all-children.
opts takes select, expand, top (page size), orderby (e.g.
"name", "lastModifiedDateTime desc"; not on every drive type) and
drive.
Example
page ::microsoft::onedrive::items/list-children("/Reports", {top: 50, select: "id,name,file"})
map(page.value, %.name)
get(page, "@odata.nextLink")
move-item
fn (item: Any, new-parent-id: Str): Map
fn (item: Any, new-parent-id: Str, opts: Map): Map
Move an item to another folder (by id) in the same drive, optionally
renaming it (opts.name). Moving across drives is not supported by
PATCH: use copy-item then delete-item. Returns the item.
Example
moved ::microsoft::onedrive::items/move-item("/Reports/Q3.xlsx", "01ARCHIVE", {name: "Q3 (archive).xlsx"})
moved.parentReference.id
permanent-delete
fn (item: Any): Bool
fn (item: Any, opts: Map): Bool
POST {item}/permanentDelete - delete without the recycle bin (OneDrive for work or school and SharePoint only). Cannot be undone. Returns true.
Example
::microsoft::onedrive::items/permanent-delete("/Reports/Old.xlsx")
recent
fn (): Vec
fn (opts: Map): Vec
GET /me/drive/recent - items the signed-in user used recently
(delegated only; entries from other drives carry remoteItem).
Deprecated by Microsoft: degraded until November 2026, after
which it returns no data. Prefer delta sync or search.
Example
items ::microsoft::onedrive::items/recent()
map(items, %.name)
rename-item
fn (item: Any, new-name: Str): Map
fn (item: Any, new-name: Str, opts: Map): Map
Rename an item. Returns the item.
Example
renamed ::microsoft::onedrive::items/rename-item("/Reports/Q3.xlsx", "Q3 final.xlsx")
renamed.name
resolve-remote
fn (item: Map): Map
fn (item: Map, opts: Map): Map
For a shared item (remoteItem), fetch the target item from its own
drive; otherwise return item. One hop.
Example
hits ::microsoft::onedrive::items/search("budget", {scope: "drive"}, 1)
target ::microsoft::onedrive::items/resolve-remote(first(hits))
target.id
restore-item
fn (item: Any): Map
fn (item: Any, opts: Map): Map
POST {item}/restore - restore a deleted item from the recycle bin
(personal OneDrive only). opts.parent-id restores into another folder
and opts.name renames. Returns the restored item.
Example
::microsoft::onedrive::items/restore-item("01ABC", {parent-id: "01FOLDER", name: "Recovered.xlsx"})
search
fn (query: Str): Vec
fn (query: Str, opts: Map): Vec
fn (query: Str, opts: Map, limit: Int?): Vec
Search a drive for query (file names, metadata and content), all
pages or at most limit. Defaults to {drive}/root/search(...);
opts.folder searches under one folder, and opts.scope: "drive"
uses {drive}/search(...), which on /me/drive also includes items
shared with the user. opts also takes select, top.
hits ::microsoft::onedrive::items/search("quarterly report", {}, 25)
search-function
fn (query: Str): Str
The OData function segment for a search (pure): search(q='...') with
' doubled and the text percent-encoded.
Example
::microsoft::onedrive::items/search-function("q3 report") // "search(q='q3%20report')"
shared-with-me
fn (): Vec
fn (opts: Map): Vec
GET /me/drive/sharedWithMe - items shared with the signed-in user
(delegated only; each has a remoteItem pointing at the owner's
drive). opts.allow-external: true includes other tenants' items.
Deprecated by Microsoft: degraded until November 2026, after
which it returns no data.
Example
items ::microsoft::onedrive::items/shared-with-me({allow-external: true})
map(items, %.remoteItem.id)
update-item
fn (item: Any, fields: Map): Map
fn (item: Any, fields: Map, opts: Map): Map
PATCH an item's metadata (name, description, parentReference,
fileSystemInfo, ...). opts.if-match (an eTag) makes it conditional
(412 when changed). Returns the item.
Example
item ::microsoft::onedrive::items/get-item("/Reports/Q3.xlsx")
// Fails with 412 if someone changed the file first
::microsoft::onedrive::items/update-item(item, {description: "Final numbers"}, {if-match: item.eTag})
Types
CopyStatus
CopyStatus type {
status: Str,
percent: Any?,
resource-id: Str?,
error: Map?,
done: Bool
}
A copy job's status from its monitor URL.
status-notStarted,inProgress,completed,failed,waiting,deletePending,cancelPending,cancelled, orunknownpercent-percentageComplete(0..100), when reportedresource-id- the new item's id once completed (null when Graph redirected to it instead; then list the destination folder)error- Graph's error object forfaileddone- true forcompletedandfailed