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
}
'import requests
url = "https://api-eu.flexportal.io/v1/files/url"
payload = {
"fileId": "<string>",
"action": "view",
"expiresInMinutes": 60
}
headers = {
"Tenant-ID": "<tenant-id>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Tenant-ID': '<tenant-id>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({fileId: '<string>', action: 'view', expiresInMinutes: 60})
};
fetch('https://api-eu.flexportal.io/v1/files/url', 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/url",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'fileId' => '<string>',
'action' => 'view',
'expiresInMinutes' => 60
]),
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/url"
payload := strings.NewReader("{\n \"fileId\": \"<string>\",\n \"action\": \"view\",\n \"expiresInMinutes\": 60\n}")
req, _ := http.NewRequest("POST", 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.post("https://api-eu.flexportal.io/v1/files/url")
.header("Tenant-ID", "<tenant-id>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"fileId\": \"<string>\",\n \"action\": \"view\",\n \"expiresInMinutes\": 60\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-eu.flexportal.io/v1/files/url")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Tenant-ID"] = '<tenant-id>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"fileId\": \"<string>\",\n \"action\": \"view\",\n \"expiresInMinutes\": 60\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"url": "<string>",
"filename": "<string>",
"contentType": "<string>",
"fileSize": 1,
"expiresAt": 1
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}Files
Get File URL
Generates a signed URL for viewing or downloading a file. URLs expire after the specified time.
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
}
'import requests
url = "https://api-eu.flexportal.io/v1/files/url"
payload = {
"fileId": "<string>",
"action": "view",
"expiresInMinutes": 60
}
headers = {
"Tenant-ID": "<tenant-id>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Tenant-ID': '<tenant-id>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({fileId: '<string>', action: 'view', expiresInMinutes: 60})
};
fetch('https://api-eu.flexportal.io/v1/files/url', 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/url",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'fileId' => '<string>',
'action' => 'view',
'expiresInMinutes' => 60
]),
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/url"
payload := strings.NewReader("{\n \"fileId\": \"<string>\",\n \"action\": \"view\",\n \"expiresInMinutes\": 60\n}")
req, _ := http.NewRequest("POST", 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.post("https://api-eu.flexportal.io/v1/files/url")
.header("Tenant-ID", "<tenant-id>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"fileId\": \"<string>\",\n \"action\": \"view\",\n \"expiresInMinutes\": 60\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-eu.flexportal.io/v1/files/url")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Tenant-ID"] = '<tenant-id>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"fileId\": \"<string>\",\n \"action\": \"view\",\n \"expiresInMinutes\": 60\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"url": "<string>",
"filename": "<string>",
"contentType": "<string>",
"fileSize": 1,
"expiresAt": 1
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}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
| Action | Use Case |
|---|---|
download | Get URL to download existing file |
upload | Get URL to upload new file |
Request Fields
| Field | Required | Description |
|---|---|---|
action | Yes | download or upload |
fileId | For download | ID of file to download |
fileName | For upload | Name of file to upload |
contentType | For upload | MIME type of file |
Download Example
Get a URL to download an existing file:{
"action": "download",
"fileId": "file_abc123"
}
{
"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"
}
{
"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;
}
Related Endpoints
- Get File - Get file metadata
- List Files - Browse files
- Delete File - Remove uploaded file
Authorizations
API key obtained from FlexPortal dashboard
Headers
Your tenant identifier
Body
application/json
Was this page helpful?