Delete a file
curl --request DELETE \
--url https://api-eu.flexportal.io/v1/files/{fileId} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Tenant-ID: <tenant-id>' \
--data '
{
"deleteFromStorage": true
}
'import requests
url = "https://api-eu.flexportal.io/v1/files/{fileId}"
payload = { "deleteFromStorage": True }
headers = {
"Tenant-ID": "<tenant-id>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.delete(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'DELETE',
headers: {
'Tenant-ID': '<tenant-id>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({deleteFromStorage: true})
};
fetch('https://api-eu.flexportal.io/v1/files/{fileId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-eu.flexportal.io/v1/files/{fileId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_POSTFIELDS => json_encode([
'deleteFromStorage' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"Tenant-ID: <tenant-id>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-eu.flexportal.io/v1/files/{fileId}"
payload := strings.NewReader("{\n \"deleteFromStorage\": true\n}")
req, _ := http.NewRequest("DELETE", url, payload)
req.Header.Add("Tenant-ID", "<tenant-id>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.delete("https://api-eu.flexportal.io/v1/files/{fileId}")
.header("Tenant-ID", "<tenant-id>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"deleteFromStorage\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-eu.flexportal.io/v1/files/{fileId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Tenant-ID"] = '<tenant-id>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"deleteFromStorage\": true\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "<string>",
"fileId": "<string>"
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}Files
Delete File
Deletes a file record and optionally removes from storage.
DELETE
/
v1
/
files
/
{fileId}
Delete a file
curl --request DELETE \
--url https://api-eu.flexportal.io/v1/files/{fileId} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Tenant-ID: <tenant-id>' \
--data '
{
"deleteFromStorage": true
}
'import requests
url = "https://api-eu.flexportal.io/v1/files/{fileId}"
payload = { "deleteFromStorage": True }
headers = {
"Tenant-ID": "<tenant-id>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.delete(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'DELETE',
headers: {
'Tenant-ID': '<tenant-id>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({deleteFromStorage: true})
};
fetch('https://api-eu.flexportal.io/v1/files/{fileId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-eu.flexportal.io/v1/files/{fileId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_POSTFIELDS => json_encode([
'deleteFromStorage' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"Tenant-ID: <tenant-id>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-eu.flexportal.io/v1/files/{fileId}"
payload := strings.NewReader("{\n \"deleteFromStorage\": true\n}")
req, _ := http.NewRequest("DELETE", url, payload)
req.Header.Add("Tenant-ID", "<tenant-id>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.delete("https://api-eu.flexportal.io/v1/files/{fileId}")
.header("Tenant-ID", "<tenant-id>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"deleteFromStorage\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-eu.flexportal.io/v1/files/{fileId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Tenant-ID"] = '<tenant-id>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"deleteFromStorage\": true\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "<string>",
"fileId": "<string>"
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}Overview
Delete a file from storage. This permanently removes the file—it cannot be recovered.File deletion is permanent. Ensure you have backups if the file may be needed later.
Common Use Cases
- Cleanup: Remove outdated or superseded documents
- Corrections: Delete incorrectly uploaded files
- Compliance: Remove files per data retention policies
- Storage Management: Free up storage space
What Gets Deleted
- File content is permanently removed from storage
- File metadata is removed from the database
- References in orders/subscriptions are cleared
Example: Delete Obsolete Document
async function deleteObsoleteFile(fileId) {
// Verify file exists first
const file = await getFile(fileId);
console.log(`Deleting: ${file.fileName}`);
// Delete the file
await deleteFile(fileId);
return { deleted: true, fileName: file.fileName };
}
Example: Cleanup Old Files
async function cleanupOldFiles(orderId, keepTypes) {
const { files } = await listFiles({ orderId });
const toDelete = files.filter(f => !keepTypes.includes(f.fileType));
for (const file of toDelete) {
await deleteFile(file.fileId);
}
return {
deleted: toDelete.length,
kept: files.length - toDelete.length
};
}
// Usage: Keep only contracts, delete other files
await cleanupOldFiles('ord_abc123', ['contract']);
Error Handling
| Error Code | Cause | Solution |
|---|---|---|
NOT_FOUND | File doesn’t exist | Verify file ID |
DELETE_FAILED | Storage error | Retry or contact support |
Related Endpoints
- Get File - Verify file before deletion
- List Files - Find files to delete
Authorizations
API key obtained from FlexPortal dashboard
Headers
Your tenant identifier
Path Parameters
The file ID
Body
application/json
Also delete from storage (default: true)
Was this page helpful?