Downloads

We'll assume you've already got the API authentication settled and you have our API token with you.

 

Use inbox mail download #

Inbox mail includes already created download resource. For example, by making GET request to the /api/inbox/cfd4d439-8cc6-4e6d-a78a-72528c21cdcd?include=download endpoint you can get all email information including download information.

curl https://privasfer.com/api/inbox/2ef14b84-87d0-4abb-813f-2351a4251345?include=download \
    -H 'Authorization: Bearer 7xcB5XlinBWGzajPdSW7bHr12erWZICIJN4jk0RpasoLYLpoiD6ErYnVSzld' \
    -H 'Accept: application/json' \
    -H 'Content-Type: application/json'

As a result, you get the details for email in your inbox with download object.

{
    "data": {
            "id": "2ef14b84-87d0-4abb-813f-2351a4251345",
            "identifier": "1Kh2",
            "subject": "Secure files",
            "body": "<p>Mail body</p>",
            "sender": {
                "name": "Sender Name",
                "email": "sender@email.address"
            },
            "download": {
                "id": "15c00595-6474-4ea9-aac2-bb3729d0aa79",
                "created_at": "2019-05-15 14:11:00"
            },
            "received_at": "2019-05-15 14:11:00",
            "opened": true
        }
}

 

Create download #

You can create download for multiple or single file. To create download you can make POST request to the /api/downloads endpoint.

Manually created downloads are only for a single use and lives only for one minute. Right after download is performed, download record will be deleted.
curl -X POST https://privasfer.com/api/downloads \
    -H 'Authorization: Bearer 7xcB5XlinBWGzajPdSW7bHr12erWZICIJN4jk0RpasoLYLpoiD6ErYnVSzld' \
    -H 'Accept: application/json' \
    -H 'Content-Type: application/json' \
    -d '{"files":["811f216d-eb8f-46fc-a263-08387c70a4a4"]}'

Form fields #

name description type
files List of files ID’s you have uploaded. More about files uploading you can read here. array

If the API call succeeded, you'll be given output like this.

{
    "data": {
            "id": "6d3bf21d-0e10-4484-af02-81e94ff9606b",
            "files": [
                {
                    "id": "fad2027a-ac89-4ef4-baab-95b2fb316cf1",
                    "filename": "invoice",
                    "type": "application/pdf",
                    "extension": "pdf",
                    "full_filename": "invoice.pdf",
                    "size": 43389,
                    "formatted_size": "42.37 KB",
                    "encrypted_size": 78508,
                    "formatted_encrypted_size": "76.67 KB",
                    "created_by": {
                        "name": "Author Name",
                        "initials": "Author N.",
                        "email": "author@email.address",
                        "photo_url": "https://www.privasfer.com/storage/profiles/Qj1lOxYuBE23taYibnRE3N0MnvwM5mreEQ1Q6Zaq.png",
                        "timezone": "Europe/Vilnius"
                    },
                    "created_at": "2019-05-08 00:18:03",
                    "disk": "local-spaces",
                    "trashed": false
                }
            ],
            "created_at": "2019-05-20 14:39:29"
      }
}

Return properties #

  • id: an internal identifier.
  • files: list of files related to this download object.
  • created_at: date ant time when download was created.

 

Error handling #

If an error occurred, you'll be given a non-HTTP/200 response code. The resulting payload might look like this.

{
    "message": "The given data was invalid.",
    "errors": {
        "files": [
            "The files field is required."
        ]
    }
}