Replace file in folder
Replaces an existing file in a document folder. The new file is stored and the existing one removed in one step: if the upload fails or is refused (for example 413, a storage limit, checked on the size after the replace), the original stays in place. A file that is not in this folder returns 404. Max 50 MB.
PUT
https://api.deutschlandgpt.de/v2/document-folders/{id}/files/{fileId}Example request
curl https://api.deutschlandgpt.de/v2/document-folders/{id}/files/{fileId} \
-X PUT \
-H "Authorization: Bearer $DGPT_API_KEY"curl https://api.deutschlandgpt.de/v2/document-folders/{id}/files/{fileId} \
-X PUT \
-H "Authorization: Bearer $DGPT_API_KEY"import os, requests
response = requests.put(
"https://api.deutschlandgpt.de/v2/document-folders/{id}/files/{fileId}",
headers={"Authorization": f"Bearer {os.environ['DGPT_API_KEY']}"},
)
print(response.json())import os, requests
response = requests.put(
"https://api.deutschlandgpt.de/v2/document-folders/{id}/files/{fileId}",
headers={"Authorization": f"Bearer {os.environ['DGPT_API_KEY']}"},
)
print(response.json())const response = await fetch('https://api.deutschlandgpt.de/v2/document-folders/{id}/files/{fileId}', {
method: 'PUT',
headers: {
Authorization: `Bearer ${process.env.DGPT_API_KEY}`,
},
});
console.log(await response.json());const response = await fetch('https://api.deutschlandgpt.de/v2/document-folders/{id}/files/{fileId}', {
method: 'PUT',
headers: {
Authorization: `Bearer ${process.env.DGPT_API_KEY}`,
},
});
console.log(await response.json());Parameters
idstring<uuid>requiredDocument folder ID
fileIdstringrequiredFile ID to replace
Response
200application/json
{
"file_id": "string"
}{
"file_id": "string"
}File replaced
file_idstringResponse codes
200
File replaced
object400
Invalid file type or size
401
Unauthorized
402
Insufficient credits or spending limit exceeded
Error403
Requires enterprise workspace
404
Folder or file not found
413
Storage limit reached: the document folder, the uploading person or the organisation would exceed its storage limit. Nothing was stored.
objectWas this page helpful?