Skip to main content
PUT
/
files
/
overwrite
/
{path}
Overwrite file content completely
curl --request PUT \
  --url https://api.openfiles.ai/functions/v1/api/files/overwrite/{path} \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '
{
  "content": "<string>",
  "isBase64": false
}
'
{
  "success": true,
  "data": {
    "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "path": "<string>",
    "version": 2,
    "mimeType": "<string>",
    "size": 1,
    "createdAt": "2023-11-07T05:31:56Z",
    "updatedAt": "2023-11-07T05:31:56Z"
  },
  "operation": "write_file",
  "message": "File created successfully, version 1"
}

Documentation Index

Fetch the complete documentation index at: https://docs.openfiles.ai/llms.txt

Use this file to discover all available pages before exploring further.

Overwrite File Content Completely

Replaces the entire content of an existing file with new content. The file must exist first - this operation cannot create new files.

Use Cases

  • Document revisions - Replace entire documents with new versions
  • Configuration updates - Update entire config files
  • Template replacement - Replace template files with generated content
  • Data refresh - Replace data files with updated datasets

Example Usage

const response = await fetch('https://api.openfiles.ai/functions/v1/api/files/overwrite/config/settings.json', {
  method: 'PUT',
  headers: {
    'x-api-key': API_KEY,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    content: JSON.stringify({
      "version": "2.0",
      "theme": "dark",
      "notifications": true
    }, null, 2)
  })
})

Authorizations

x-api-key
string
header
required

API key for authentication. Get your API key from the console.

Path Parameters

path
string
required

File path (S3-style, no leading slash)

Body

application/json
content
string
required
Maximum string length: 10485760
isBase64
boolean
default:false

Response

Success

success
boolean
required
Example:

true

data
object
required
operation
string
required
Example:

"write_file"

message
string
required
Example:

"File created successfully, version 1"