X

Upload a file

Upload a file to your secure file transfer area.


[POST] https://api-eu1.stannp.com/v1/files/upload

Parameters

file string This value can be either a binary file or a URL to a file.
folder int A folder ID for placing the file in a folder.

Request

                <?php
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://api-eu1.stannp.com/v1/files/upload?api_key={API_KEY}",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_POSTFIELDS => array(
        'file' => "https://www.stannp.com/assets/samples/letter-heading.webp",
        'folder' => "0"
    ),
    
));

$response = curl_exec($curl);

curl_close($curl);
print_r($response);
?>
            

Response

{
    "success": true,
    "data": {
        "id": "342"
    }
}

Create a folder

Create a folder in your secure file transfer area.


[POST] https://api-eu1.stannp.com/v1/files/createFolder

Parameters

name string The name of the folder you wish to create.

Request

                <?php
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://api-eu1.stannp.com/v1/files/createFolder?api_key={API_KEY}",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_POSTFIELDS => array(
        'name' => "Test Folder"
    ),
    
));

$response = curl_exec($curl);

curl_close($curl);
print_r($response);
?>
            

Response

{
    "success": true,
    "data": "342"
}

List folders

Get a list of the folders in your secure file transfer area.


[GET] https://api-eu1.stannp.com/v1/files/folders

Request

                <?php
define("API_KEY", "YOUR API KEY");
$opts = array(
    'http' => array(
        'method'  => 'GET',
        'header'  => 'Content-type: application/x-www-form-urlencoded'
    )
);
$context  = stream_context_create($opts);
$result = file_get_contents("https://api-eu1.stannp.com/v1/files/folders?api_key=" . API_KEY, false, $context);
$response = json_decode($result, true);

print_r($response);
?>
            

Response

{
    "success": true,
    "data": [
        {
            "id": "2",
            "name": "test folder",
            "created": "2017-06-27 14:24:07"
        },
        {
            "id": "15",
            "name": "test folder 2",
            "created": "2017-06-27 14:26:23"
        }
    ]
}