Skip to content

Replace a file's contents

overwriteFile

PUT /api/v1/shares/{share_id}/content

Scope: files.overwriteRate cost: 5

Replace a file’s contents: the request body is the new contents, streamed to the share as it arrives, at any size (Content-Length required)

Send If-Match with the file’s ETag as you last read it (GET …/item, a listing, or a write’s answer): without it 428, with a stale one 412, so nothing is replaced that you did not look at. A body that ends before its Content-Length leaves the file exactly as it was. Needs files.overwrite, allowed for your app on this share. Refused for a file someone else has checked out (423), one under a legal hold (403), the document of a signing still out (409), and, for a person who may only read the approved version of a published file, that file (403). Where the share’s storage keeps no earlier versions an administrator may refuse apps this change (409 not-recoverable-here). Answers the file with its new ETag. Not offered to an app whose administrator requires approval for its changes (403 needs-approval-not-available): new contents cannot be held for approval.

Terminal window
curl -X PUT "$FOLDR/api/v1/shares/$SHARE_ID/content?path=%2FReports%2Fq3.pdf" \
-H "Authorization: Bearer $TOKEN" \
-H "If-Match: $ETAG" \
-H "Content-Type: application/octet-stream" \
--data-binary @./file

$FOLDR is your site’s address (for example https://files.example.com) and $TOKEN is an access token. See Getting access.

NameInTypeRequiredDescription
share_idpathstringYesThe share’s id.
pathquerystringYesThe path of the file to replace.
If-MatchheaderstringYesThe file’s ETag as you last read it (any form this API gave you for it; a list matches if any member does). ”*” is refused.

The file’s new contents, exactly Content-Length bytes.

application/octet-stream, required: string (binary)

StatusMeaningBody
200The file, with its new ETag.application/json: Item
HeaderDescription
ETagThe entity tag of what was answered. Send it back as If-None-Match for a 304 while it is unchanged, or as If-Match to change it only while it is unchanged.

Item:

FieldTypeDescription
share_idstring (uuid)Required. The id of the share the item is in.
pathstringRequired. The canonical path: as the storage holds it (its case), Unicode NFC, always starting with ”/”. ”/” is the top of the share. Send this form back in later calls.
namestringRequired. The item’s name (the last segment of its path; the share’s name for the top).
kindstring, one of file, folderRequired. file or folder.
sizeinteger or nullRequired. Size in bytes; null for a folder, and null when the item has no fixed byte size (a native Google document, exported on download: see export).
modifiedstring or null (date-time)Required. Last modified (RFC 3339, UTC), where the storage reports it.
mime_typestring or nullRequired. The item’s own media type, as the storage reports it or guessed from the name; null for a folder. A native Google document has Google’s own type here (application/vnd.google-apps.document for a Doc); export says what it downloads as.
exportExport or nullRequired. For a native Google document that can be downloaded, what content delivers: its media type and the extension the download is named with. Null for everything else, including a native Google type that cannot be downloaded (a Form: content answers 409 not-downloadable).
etagstring or nullRequired. The item’s entity tag: the storage’s own where it has one, else a weak tag over size and modified time (over modified time alone for a native Google document, whose export is made afresh each time). Null on a search hit, which comes from the index; GET …/item for the live one.
read_onlybooleanRequired. True when the person cannot change things in this share.
checked_outCheckout or nullRequired. Who has the item checked out, or null. Null on a search hit.

Example:

{
"share_id": "0191f2c4-8a1e-7b52-9d3a-5c1e0b7a4d21",
"path": "string",
"name": "string",
"kind": "file",
"size": 1,
"modified": "2026-11-04T09:30:00Z",
"mime_type": "string",
"export": {
"mime_type": "string",
"extension": "string"
},
"etag": "string",
"read_only": false,
"checked_out": {
"by": {},
"since": "2026-11-04T09:30:00Z"
}
}

Every error is an application/problem+json document (ProblemDetails); branch on its type or code. See Errors.

StatusProblem typesWhen
400invalid-path
invalid-request
One of: Invalid path (invalid-path); Invalid request (invalid-request).
401invalid-tokenInvalid token (invalid-token).
403insufficient-scope
legal-hold
needs-approval-not-available
write-not-allowed
One of: Insufficient scope (insufficient-scope); Legal hold (legal-hold); Not offered in approval mode (needs-approval-not-available); Not allowed for this app (write-not-allowed).
404not-foundNot found (not-found).
409ambiguous-path
envelope-source
not-a-file
not-recoverable-here
storage-account-not-connected
One of: Ambiguous path (ambiguous-path); Out for signature (envelope-source); Not a file (not-a-file); Not recoverable here (not-recoverable-here); Storage account not connected (storage-account-not-connected).
412precondition-failedPrecondition failed (precondition-failed).
413too-largeToo large (too-large).
423checked-outChecked out (checked-out).
428precondition-requiredPrecondition required (precondition-required).
429destructive-budget
rate-limited
One of: Daily limit of removals reached (destructive-budget); Too many requests (rate-limited).
500internal-errorInternal error (internal-error).
503share-unavailable
share-unreachable
write-failed
One of: Share unavailable (share-unavailable); Share unreachable (share-unreachable); Write failed (write-failed).