Box files: get file info (with fields and representation hints),
update, rename, move, copy, trash, restore, and versions (list,
promote). Content lives in ::box::content and ::box::upload.
Every function has an options arity taking an opts Map: Box query
parameters by their Box names (fields, limit, offset, ...),
if-match (an etag) for safe writes, and the credential keys handled
by ::box::auth.
Values
LOCAL_KEYS
LOCAL_KEYS: Vec [
"if-match",
"if-none-match",
"boxapi",
"rep-hints",
"name",
"parent-id",
"version"
]
MAX_LIMIT
MAX_LIMIT: Int 1000
Functions
copy-body
fn (parent-id: Str, opts: Map): Map
The copy body (pure): parent: {id}, an optional new name, and an
optional version (a file version id to copy).
Example
::box::files/copy-body("67890", {name: "Copy.pdf"}) // {parent: {id: "67890"}, name: "Copy.pdf"}
copy-file
fn (file-id: Str, parent-id: Str): Map
fn (file-id: Str, parent-id: Str, opts: Map): Map
POST /files/{id}/copy - copy a file into parent-id. opts.name
renames the copy; opts.version copies an older version.
Example
copy ::box::files/copy-file("12345", "67890", {name: "Q4 copy.pdf"})
copy.id
file-headers
fn (opts: Map): Map
The headers get-file sends (pure): if-match / if-none-match /
boxapi from opts, plus x-rep-hints from opts.rep-hints (e.g.
"[extracted_text]", "[jpg?dimensions=320x320]").
Example
::box::files/file-headers({rep-hints: "[extracted_text]", if-match: "3"}) // {if-match: "3", x-rep-hints: "[extracted_text]"}
get-doc-file
fn (file-id: Str): ::box/DocFile
fn (file-id: Str, opts: Map): ::box/DocFile
get-file normalised to a ::box/DocFile.
Example
file ::box::files/get-doc-file("12345")
file.sha1
// Fewer fields, on behalf of a managed user
named ::box::files/get-doc-file("12345", {fields: "id,type,name", as-user: "123"})
named.name
get-file
fn (file-id: Str): Map
fn (file-id: Str, opts: Map): Map
GET /files/{id} - file information. fields defaults to
::box/FILE_FIELDS (a Str or Vec; Box returns only a mini
representation for fields you do not name). opts.rep-hints with a
representations field asks for representations.
file ::box::files/get-file("12345")
file.sha1
file.file_version.id
get-trashed-file
fn (file-id: Str): Map
fn (file-id: Str, opts: Map): Map
GET /files/{id}/trash - a trashed file's information (404 when it is not in the trash).
Example
file ::box::files/get-trashed-file("12345")
file.trashed_at
list-all-versions
fn (file-id: Str): Vec
fn (file-id: Str, opts: Map): Vec
Every previous version of a file (all offset pages).
Example
versions ::box::files/list-all-versions("12345")
map(versions, %.id)
list-versions
fn (file-id: Str): Map
fn (file-id: Str, opts: Map): Map
GET /files/{id}/versions - one page of a file's previous versions
({entries, total_count, offset, limit}; the current version is the
file's file_version). Offset paging (offset, limit up to 1000).
Version history needs a paid plan with versioning; the free developer
plan keeps one version.
Example
page ::box::files/list-versions("12345", {limit: 100})
page.total_count
page.entries
move-file
fn (file-id: Str, parent-id: Str): Map
fn (file-id: Str, parent-id: Str, opts: Map): Map
Move a file into parent-id (a Box item has exactly one parent).
Example
file ::box::files/move-file("12345", "67890")
file.parent.id
promote-body
fn (version-id: Str): Map
The promote body (pure): {type: "file_version", id}.
Example
::box::files/promote-body("99") // {type: "file_version", id: "99"}
promote-version
fn (file-id: Str, version-id: Str): Map
fn (file-id: Str, version-id: Str, opts: Map): Map
POST /files/{id}/versions/current - make an older version current (Box
copies it to a new version; history is kept). Returns the new current
file_version.
Example
version ::box::files/promote-version("12345", "99")
version.id
rename-file
fn (file-id: Str, name: Str): Map
fn (file-id: Str, name: Str, opts: Map): Map
Rename a file. Box fails with 409 item_name_in_use when the folder
already has that name.
Example
file ::box::files/rename-file("12345", "Q4 report.pdf")
file.name
restore-body
fn (opts: Map): Map
The restore body (pure): an optional new name and parent: {id}.
Example
::box::files/restore-body({name: "Restored.pdf", parent-id: "67890"}) // {name: "Restored.pdf", parent: {id: "67890"}}
::box::files/restore-body({}) // {}
restore-file
fn (file-id: Str): Map
fn (file-id: Str, opts: Map): Map
POST /files/{id} - restore a trashed file. opts.name /
opts.parent-id restore it under a new name or into another folder when
the original is taken or gone.
Example
file ::box::files/restore-file("12345", {name: "Restored.pdf", parent-id: "67890"})
file.item_status
trash-file
fn (file-id: Str): Bool
fn (file-id: Str, opts: Map): Bool
DELETE /files/{id} - move a file to the trash (recoverable until the
enterprise's trash retention, 30 days by default). opts.if-match
guards against concurrent changes. Returns true.
Example
::box::files/trash-file("12345")
// Only if nobody changed it
::box::files/trash-file("67890", {if-match: "3"})
update-file
fn (file-id: Str, changes: Map): Map
fn (file-id: Str, changes: Map, opts: Map): Map
PUT /files/{id} - update file information: name, description,
parent ({id}, to move), tags, lock, shared_link,
disposition_at, ... Null values in changes are dropped.
opts.if-match (an etag) makes the write fail with 412 when the file
changed. Content updates go through ::box::upload/upload-version.
Example
file ::box::files/update-file("12345", {description: "Q4 numbers"})
file.description
// Fails with 412 if the file changed
safe ::box::files/update-file("12345", {tags: ["q4"]}, {if-match: file.etag})
safe.etag