Skip to main content
POST
/
v1
/
files
/
url
Get secure file URL
curl --request POST \
  --url https://api-eu.flexportal.io/v1/files/url \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --header 'Tenant-ID: <tenant-id>' \
  --data '
{
  "fileId": "<string>",
  "action": "view",
  "expiresInMinutes": 60
}
'
{
  "success": true,
  "url": "<string>",
  "filename": "<string>",
  "contentType": "<string>",
  "fileSize": 1,
  "expiresAt": 1
}

Overview

Generate a signed URL for uploading or downloading files. Signed URLs provide secure, time-limited access to file storage without exposing credentials.

URL Types

ActionUse Case
downloadGet URL to download existing file
uploadGet URL to upload new file

Request Fields

FieldRequiredDescription
actionYesdownload or upload
fileIdFor downloadID of file to download
fileNameFor uploadName of file to upload
contentTypeFor uploadMIME type of file

Download Example

Get a URL to download an existing file:
{
  "action": "download",
  "fileId": "file_abc123"
}
Response:
{
  "url": "https://storage.example.com/files/abc123?signature=...",
  "expiresAt": "2025-01-15T11:30:00Z"
}

Upload Example

Get a URL to upload a new file:
{
  "action": "upload",
  "fileName": "contract-order-123.pdf",
  "contentType": "application/pdf"
}
Response:
{
  "url": "https://storage.example.com/upload?signature=...",
  "fileId": "file_xyz789",
  "expiresAt": "2025-01-15T11:30:00Z"
}

URL Expiration

Signed URLs expire after a short period (typically 15-60 minutes). Use them promptly after generation.

Example: Download File

async function downloadFile(fileId) {
  // Get signed download URL
  const { url } = await getFileUrl({
    action: 'download',
    fileId
  });

  // Download using the signed URL
  const response = await fetch(url);
  return await response.blob();
}

Example: Upload File

async function uploadFile(file) {
  // Get signed upload URL
  const { url, fileId } = await getFileUrl({
    action: 'upload',
    fileName: file.name,
    contentType: file.type
  });

  // Upload to signed URL
  await fetch(url, {
    method: 'PUT',
    body: file,
    headers: {
      'Content-Type': file.type
    }
  });

  return fileId;
}

Authorizations

Authorization
string
header
required

API key obtained from FlexPortal dashboard

Headers

Tenant-ID
string
required

Your tenant identifier

Body

application/json
fileId
string
required
Minimum string length: 1
action
enum<string>
default:view
Available options:
view,
download
expiresInMinutes
number
default:60
Required range: 1 <= x <= 1440

Response

Signed URL generated

success
enum<boolean>
required
Available options:
true,
false
url
string<uri>
required
filename
string
required
Minimum string length: 1
contentType
string
required
Minimum string length: 1
fileSize
number
required
Required range: x >= 0
expiresAt
number
required
Required range: x >= 0