Skip to main content
GET
/
file
/
{id}
/
download
Get file download URL
curl --request GET \
  --url https://api.royalti.io/file/{id}/download \
  --header 'Authorization: Bearer <token>'
import requests

url = "https://api.royalti.io/file/{id}/download"

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers)

print(response.text)
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

fetch('https://api.royalti.io/file/{id}/download', 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.royalti.io/file/{id}/download",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"net/http"
"io"
)

func main() {

url := "https://api.royalti.io/file/{id}/download"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("Authorization", "Bearer <token>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.get("https://api.royalti.io/file/{id}/download")
.header("Authorization", "Bearer <token>")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.royalti.io/file/{id}/download")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
{
  "status": "success",
  "message": "Download URL generated successfully",
  "data": {
    "downloadUrl": "https://storage.googleapis.com/royalty_files/dataset123/spotify_2024-01.csv?X-Goog-Algorithm=...",
    "fileName": "spotify_2024-01.csv",
    "fileType": "text/csv",
    "fileSize": 1048576,
    "expiresAt": "2024-01-15T11:30:00.000Z"
  }
}
{
"success": false,
"error": {
"code": "400",
"message": "Bad Request",
"details": [
"File has no associated cloud storage path"
]
}
}
{
"status": "error",
"message": "Unauthorized"
}
{
"success": false,
"error": {
"code": "404",
"message": "Not Found",
"details": [
"File not found"
]
}
}
{
"success": false,
"error": {
"code": "500",
"message": "Internal Server Error",
"details": [
"Failed to generate download URL"
]
}
}
This endpoint requires authentication. Include your Bearer token in the Authorization header.

Description

Get a signed download URL for a file Generates a time-limited signed URL that can be used to download the file directly from cloud storage. URL Expiration:
  • Default: 1 hour
  • Configurable via expirationHours query parameter (1-24 hours)
  • After expiration, request a new URL
Usage Flow:
  1. Call this endpoint with the file ID
  2. Receive a signed download URL
  3. Use the URL to download the file directly (no auth required for the URL itself)
  4. URL expires after the specified time
Authorization:
  • Required role: user or higher

Code Examples

const response = await fetch('https://api.royalti.io/file/example-id/download', {
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${token}`,
  },
});

const data = await response.json();
console.log(data);
import requests

response = requests.get(
  'https://api.royalti.io/file/example-id/download',
  headers={
    'Authorization': f'Bearer {token}'
  },
)

data = response.json()
print(data)
curl -X GET https://api.royalti.io/file/example-id/download \
  -H "Authorization: Bearer YOUR_TOKEN" \

Authorizations

Authorization
string
header
required

JWT Authorization header using the Bearer scheme. Format: "Bearer {token}"

Path Parameters

id
string<uuid>
required

The UUID of the file to download

Query Parameters

expirationHours
integer
default:1

URL expiration time in hours (1-24, default 1)

Required range: 1 <= x <= 24

Response

Download URL generated successfully

status
enum<string>
Available options:
success
message
string
data
object