To get a file via the API, send a GET HTTP request with the Files module and the file_id you want to obtain. We will respond with the complete file object, including a temporary download URL that you can use to download the file. The URL will expire in 15 minutes.

<?php

// Snapforce API token
$api_token = 'your api token goes here';

// Snapforce username
$api_user = 'your username goes here';

// Module name
$module = 'Files';

// File id number
$file_id = 12345;

// URL for adding a file
$url = 'https://app.snapforce.com/prodigy/api/v1/request.php?module='.$module.'&file_id='.$file_id.'&api_username='.$api_user.'&api_token=' . $api_token;


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

echo 'Sending request...' . PHP_EOL;

$output = curl_exec($ch);
curl_close($ch);

// Create a file object from the json data
$result = json_decode($output, true);

// save the file if call successful
if (isset($result[0]['download_url']) && $result[0]['download_url'] != "") {
    $url1 = $result[0]['download_url'];
    file_put_contents('mynewfile.pdf', file_get_contents($url1));
}