Skip to main content
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
}
'
{
  "success": true,
  "message": "<string>",
  "fileId": "<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 CodeCauseSolution
NOT_FOUNDFile doesn’t existVerify file ID
DELETE_FAILEDStorage errorRetry or contact support

Authorizations

Authorization
string
header
required

API key obtained from FlexPortal dashboard

Headers

Tenant-ID
string
required

Your tenant identifier

Path Parameters

fileId
string
required

The file ID

Body

application/json
deleteFromStorage
boolean

Also delete from storage (default: true)

Response

File deleted

success
enum<boolean>
required
Available options:
true,
false
message
string
required
fileId
string
required