LiquidFiles Documentation
LiquidFiles Documentation

FileLink API

With the FileLink API, you can automate creating FileLinks from other applications using the API.

New in v4.3: a single FileLink can now contain multiple files. The attachment parameter on Create accepts either a single attachment id or an array of attachment ids, and files can be added to or removed from a live FileLink without changing its URL (see Managing Files). v4.3 also adds endpoints for the new FileLink capabilities: custom URLs, display mode (gallery / inline preview), view-only mode, direct (hot-link) URLs, recipient limitations, and a customisable page header and footer. Each capability is governed by a per-group permission; an attempt to set one the user's group doesn't allow returns 422 Unprocessable Entity.

Create FileLink

Same as with the Filedrop and the standard messages based sending of files, you need to upload the files to the LiquidFiles server first and retrieve the attachment id before calling this File Request API, please see the Attachments API for instructions how to upload the files.

Request Info
Info Value
Request URL /link
Request VERB POST
Request Parameters
Parameter Type Description
attachment String or Array The attachment ID of the uploaded file to create the FileLink for. To create a multi-file FileLink, pass an array of attachment IDs (e.g. ["fHbI…","a8Rs…"]); the files are ordered as listed. The number of files may not exceed the group setting Maximum Files per FileLink (filelink_max_files, default 100).
expires_at Date (Optional) The date when the FileLink will expire. Format: YYYY-MM-DD. Defaults to the number of days in the future as configured in the Groups config.
password String (Optional) Set a password before downloading of the FileLink.
send_download_confirmation Boolean (Optional) Default: true. If set to false, the LiquidFiles system will not send download receipts when someone downloads a file using this FileLink.
require_authentication Boolean (Optional) If the FileLink requires authentication when downloading or not. The Default value is configured in the Users Group settings.

The http response codes are 200 OK if the File Request was successful, and 422 Unprocessable Entity if anything went wrong. In case of an error, there's also an error message with what went wrong.

Response Parameters
Parameter Type Description
id String The FileLink ID.
filename String The file name of the first (primary) file in the FileLink. Retained for single-file API clients; use filenames / attachments for the full list.
size Integer The size of the first (primary) file, in bytes.
size_human String The size of the first (primary) file in a human readable form (using KB, MB, GB, ...).
file_count Integer The number of files in the FileLink.
total_size Integer The combined size of all files in the FileLink, in bytes.
total_size_human String The combined size of all files in a human readable form.
filenames Array The file names of all files in the FileLink, in display order.
attachments Array One object per file, in display order. Each contains id (the attachment id used by the file-management endpoints), filename, size, size_human, content_type and caption.
expires_at Date The date when the FileLink will expire. Format: YYYY-MM-DD.
send_download_confirmation Boolean If the LiquidFiles system will send download receipts when someone downloads a file using this FileLink or not.
require_authentication Boolean If the FileLink requires authentication when downloading or not.
password Boolean True if a password has been set on this FileLink.
url String The URL to this FileLink (reflects the custom URL slug when one is set).
slug String The custom URL slug, or null when the default id-based URL is used.
display_mode String How the files are presented: icons, inline or gallery.
allow_download Boolean False when the FileLink is in view-only mode (recipients can view but not download).
allow_direct_links Boolean True if direct (hot-link) URLs are enabled for this FileLink.
recipient_limitations Array Allowlisted email addresses and/or domains. Only enforced when require_authentication is true.
header_html String The custom page header HTML, or null when none is set.
footer_html String The custom page footer HTML, or null when none is set.
created_at DateTime When this FileLink was created.
updated_at DateTime When this FileLink was last updated.
The filename, size and size_human fields describe the first (primary) file and are retained for single-file API clients. For multi-file FileLinks, use file_count, total_size, filenames and the per-file attachments array. The same response shape is returned by Create, List (GET /link), Show (GET /link/<id>) and the file-management and update endpoints.

Example Request in JSON

cat <<EOF | \
  curl -X POST -H "Authorization: Bearer Y9fdTmZdv0THButt5ZONIY" \
       -H "Accept: application/json" \
       -H "Content-Type: application/json" \
       -d @- https://liquidfiles.company.com/link
{"link":
  {
    "attachment":"fHbIuSIou38Txc0jVrobEp",
    "expires_at":"2017-01-01",
    "download_receipt":true,
    "require_authentication":true
  }
}
EOF

Example Response in JSON

{"link":
  {
    "id":"ZLa8RSQF2XDyrcVVMbrsNY",
    "filename":"screenshot.png",
    "send_download_confirmation":true,
    "require_authentication":true,
    "size":147874,
    "size_human":"144 KB",
    "file_count":2,
    "total_size":295748,
    "total_size_human":"289 KB",
    "filenames":["screenshot.png","diagram.png"],
    "attachments":[
      {
        "id":"fHbIuSIou38Txc0jVrobEp",
        "filename":"screenshot.png",
        "size":147874,
        "size_human":"144 KB",
        "content_type":"image/png",
        "caption":null
      },
      {
        "id":"a8RsQF2XDyrcVVMbrsNYZL",
        "filename":"diagram.png",
        "size":147874,
        "size_human":"144 KB",
        "content_type":"image/png",
        "caption":"System overview"
      }
    ],
    "expires_at":"2017-01-03",
    "url":"https://liquidfiles.company.com/link/ZLa8RSQF2XDyrcVVMbrsNY",
    "slug":null,
    "display_mode":"icons",
    "allow_download":true,
    "allow_direct_links":false,
    "recipient_limitations":[],
    "header_html":null,
    "footer_html":null,
    "created_at":"2016-12-19T21:56:08.719Z",
    "updated_at":"2016-12-19T21:56:08.719Z"
  }
}

Uploading Files

Uploading files to create a FileLink is very similar to the sending messages API, with the only change is the URL for the file upload. For detailed instructions how to upload the file(s), please see the Attachments API.

Request Info
Info Value
Request URL /link/attachments/upload
Request VERB POST
Authentication Required
Headers
Info Value
username the Users API key
password not used (use 'x' if your programming API requires a value)
Content-Type (Optional) LiquidFiles first use the Content-Type HTTP header if that's set. If the Content-Type header is not set it will use this optional parameter. If neither are set, the Content-Type will be detected using the Linux `file` command.
Request Parameters
Parameter Type Description
filename String The filename of the uploaded file.
chunks Integer (optional) When uploading files in chunks (in pieces), these are the total number of pieces there is.
chunk Integer (optional and required when chunks is set) When uploading files in chunks, this is the current chunk number, with the first chunk being chunk number 0 (zero).
Please note that with this binary upload, it's not possible to submit parameters using POST style embedded within the post. Instead, these parameters are submitted using GET style parameters following a question mark (?) on the URL.

Response

As a response to a successful File Upload you will receive an attachment response with the attributes outlined in the Attachment Attributes documentation.

Example: Create FileLink using bash and curl

#!/bin/bash

# Some nice variables
api_key="Y9fdTmZdv0THButt5ZONIY"
server="https://liquidfiles.example.com"

# Uploading the actual file and get attachment id for the file
attachment_id=`curl -X POST -H "Authorization: Bearer $api_key" \
  -H "Accept: application/json" \
  --data-binary @bigfile.zip $server/link/attachments/upload | \
  jq .attachment.id`

# Create the FileLink
cat <<EOF | curl -s -X POST -H "Authorization: Bearer $api_key" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d @- $server/link

{"link":
  {"attachment":"$attachment_id"}
}
EOF

List FileLinks

You can list the available FileLinks using a GET request to /link like this:

Request Info
Info Value
Request URL /link
Request VERB GET
Request Parameters
Parameter Type Description
limit Integer (Optional) Limit the output of number of FileLinks to this value.

Response

The response will be a JSON Array with all available FileLinks.

Example: List FileLinks using bash and curl

#!/bin/bash

# Some nice variables
api_key="Y9fdTmZdv0THButt5ZONIY"
server="https://liquidfiles.example.com"

curl -X GET -H "Authorization: Bearer $api_key" \
     -H "Accept: application/json" \
     -H "Content-Type: application/json" \
     $server/link?limit=2

Example Response

{"links":
  [
    {
      "id":"pOIcoQ1NbJ8Lmp19hd9Vo3",
      "filename":"screenshot.png",
      "send_download_confirmation":true,
      "require_authentication":true,
      "size":147874,
      "size_human":"144 KB",
      "expires_at":"2017-01-03",
      "url":"https://test.host/link/pOIcoQ1NbJ8Lmp19hd9Vo3",
      "created_at":"2016-12-19T21:54:54.000Z",
      "updated_at":"2016-12-19T21:54:54.000Z"
    },
    {
      "id":"ZLa8RSQF2XDyrcVVMbrsNY",
      "filename":"another screenshot.png",
      "send_download_confirmation":true,
      "require_authentication":true,
      "size":147874,
      "size_human":"144 KB",
      "expires_at":"2017-01-03",
      "url":"https://lfapp.dev/link/ZLa8RSQF2XDyrcVVMbrsNY",
      "created_at":"2016-12-19T21:56:08.000Z",
      "updated_at":"2016-12-19T21:56:08.000Z"
    }
  ]
}

Deleting a FileLink

Request Info
Info Value
Request URL /link/link_id
Request VERB DELETE

Example Delete FileLink using bash and curl

#!/bin/bash

# Some nice variables
api_key="Y9fdTmZdv0THButt5ZONIY"
server="https://liquidfiles.example.com"

curl -X DELETE -H "Authorization: Bearer $api_key" \
     -H "Accept: application/json" \
     -H "Content-Type: application/json" \
     $server/link/tzMNVK0sbpXFFlld65s4Ly

Response Code

There are three possible response codes as a result of the request:

Response Code
Code Description
200 Success - The FileLink was deleted.
404 Not Found - The FileLink ID wasn't found.
422 Not Permitted - The Request wasn't permitted.

Managing Files on a FileLink

A FileLink can hold multiple files (up to the group's filelink_max_files limit). You can add and remove files on a live FileLink without changing its URL or losing the download log. All of the endpoints below are owner-only and, when called with Accept: application/json, return the updated FileLink in the same shape as Create FileLink.

Add a File

First upload the file using the Upload File endpoint to obtain an attachment id, then attach it to the FileLink. Adding a file that is already attached is a no-op (no duplicate is created).

Request Info
Info Value
Request URL /link/link_id/attachments
Request VERB POST
Request Parameters
Parameter Type Description
secure_id String The attachment id of an already-uploaded file owned by the requesting user.

Example Add a File using bash and curl

#!/bin/bash

# Some nice variables
api_key="Y9fdTmZdv0THButt5ZONIY"
server="https://liquidfiles.example.com"

curl -X POST -H "Authorization: Bearer $api_key" \
     -H "Accept: application/json" \
     -H "Content-Type: application/json" \
     -d '{"secure_id":"a8RsQF2XDyrcVVMbrsNYZL"}' \
     $server/link/tzMNVK0sbpXFFlld65s4Ly/attachments

Remove a File

Removes a file from the FileLink. If no other FileLink or message references the underlying file, the file itself is also deleted.

Request Info
Info Value
Request URL /link/link_id/attachments/attachment_secure_id
Request VERB DELETE

Example Remove a File using bash and curl

#!/bin/bash

# Some nice variables
api_key="Y9fdTmZdv0THButt5ZONIY"
server="https://liquidfiles.example.com"

curl -X DELETE -H "Authorization: Bearer $api_key" \
     -H "Accept: application/json" \
     $server/link/tzMNVK0sbpXFFlld65s4Ly/attachments/a8RsQF2XDyrcVVMbrsNYZL

Reorder Files

Sets the order of the files in the FileLink (the order they are presented in to recipients). Submit the complete list of attachment ids in the desired order.

Request Info
Info Value
Request URL /link/link_id/attachments/reorder
Request VERB POST
Request Parameters
Parameter Type Description
ordered_secure_ids Array The attachment ids of the files in the order they should appear.

Example Reorder Files using bash and curl

#!/bin/bash

# Some nice variables
api_key="Y9fdTmZdv0THButt5ZONIY"
server="https://liquidfiles.example.com"

curl -X POST -H "Authorization: Bearer $api_key" \
     -H "Accept: application/json" \
     -H "Content-Type: application/json" \
     -d '{"ordered_secure_ids":["a8RsQF2XDyrcVVMbrsNYZL","fHbIuSIou38Txc0jVrobEp"]}' \
     $server/link/tzMNVK0sbpXFFlld65s4Ly/attachments/reorder

Set a File Caption

Sets (or clears, when blank) the caption shown beneath a file in the gallery and single-file views. The caption is stored per FileLink, so the same file can have different captions in different FileLinks.

Request Info
Info Value
Request URL /link/link_id/attachments/attachment_secure_id
Request VERB PUT
Request Parameters
Parameter Type Description
caption String The caption text. Submit an empty string to clear an existing caption.

Example Set a Caption using bash and curl

#!/bin/bash

# Some nice variables
api_key="Y9fdTmZdv0THButt5ZONIY"
server="https://liquidfiles.example.com"

curl -X PUT -H "Authorization: Bearer $api_key" \
     -H "Accept: application/json" \
     -H "Content-Type: application/json" \
     -d '{"caption":"Front elevation, revision B"}' \
     $server/link/tzMNVK0sbpXFFlld65s4Ly/attachments/a8RsQF2XDyrcVVMbrsNYZL

Updating Parameters

When you have added a FileLink and you want to change some parameters such as expiration date, authentication and download notifications.

Updating Require Authentication

Request Info
Info Value
Request URL /link/link_id/update_authentication
Request VERB PUT
Request Parameters
Parameter Type Description
require_authentication Boolean True if users should be required to authenticate to download.

Example Update Require Authentication using bash and curl

#!/bin/bash

# Some nice variables
api_key="Y9fdTmZdv0THButt5ZONIY"
server="https://liquidfiles.example.com"

curl -X PUT -H "Authorization: Bearer $api_key" \
     -H "Accept: application/json" \
     -H "Content-Type: application/json" \
     -d '{"require_authentication":false}' \
     $server/link/tzMNVK0sbpXFFlld65s4Ly/update_authentication

Response Code

There are three possible response codes as a result of the request:

Response Code
Code Description
200 Success - The request change was carried out successfully.
404 Not Found - The FileLink ID wasn't found.
422 Not Permitted - The Request wasn't permitted, i.e. the user is not allowed to change if the download should be authenticated or not.

Updating Download Notification

Request Info
Info Value
Request URL /link/link_id/update_download_confirmation
Request VERB PUT
Request Parameters
Parameter Type Description
send_download_confirmation Boolean True if download notifications should be sent.

Example Update Download Notification using bash and curl

#!/bin/bash

# Some nice variables
api_key="Y9fdTmZdv0THButt5ZONIY"
server="https://liquidfiles.example.com"

curl -X PUT -H "Authorization: Bearer $api_key" \
     -H "Accept: application/json" \
     -H "Content-Type: application/json" \
     -d '{"send_download_confirmation":false}' \
     $server/link/tzMNVK0sbpXFFlld65s4Ly/update_download_confirmation

Response Code

There are three possible response codes as a result of the request:

Response Code
Code Description
200 Success - The request change was carried out successfully.
404 Not Found - The FileLink ID wasn't found.
422 Not Permitted - The Request wasn't permitted.

Updating Expires At

Request Info
Info Value
Request URL /link/link_id/update_expires_at
Request VERB PUT
Request Parameters
Parameter Type Description
expires_at Date Expiration date in YYYY-MM-DD.

Example Update Expires At using bash and curl

#!/bin/bash

# Some nice variables
api_key="Y9fdTmZdv0THButt5ZONIY"
server="https://liquidfiles.example.com"

curl -X PUT -H "Authorization: Bearer $api_key" \
     -H "Accept: application/json" \
     -H "Content-Type: application/json" \
     -d '{"expires_at":"2015-04-18"}' \
     $server/link/tzMNVK0sbpXFFlld65s4Ly/update_expires_at

Response Code

There are three possible response codes as a result of the request:

Response Code
Code Description
200 Success - The request change was carried out successfully.
404 Not Found - The FileLink ID wasn't found.
422 Not Permitted - The Request wasn't permitted.

The endpoints below were added in v4.3. They all use the PUT verb against /link/link_id/<action> and share the same response codes: 200 on success, 404 if the FileLink id wasn't found, and 422 if the change wasn't permitted (typically because the user's group doesn't allow that capability, or the change conflicts with another setting — see Updating Direct Links). On success, a request with Accept: application/json returns the updated FileLink.

Updating Password

Sets or clears the password required before downloading. Requires the group permission filelink_can_use_password.

Request Info
Info Value
Request URL /link/link_id/update_password
Request VERB PUT
Request Parameters
Parameter Type Description
password String The password to set. Submit an empty string to remove the password.

Example Update Password using bash and curl

curl -X PUT -H "Authorization: Bearer $api_key" \
     -H "Accept: application/json" \
     -H "Content-Type: application/json" \
     -d '{"password":"correct horse battery staple"}' \
     $server/link/tzMNVK0sbpXFFlld65s4Ly/update_password

Updating Custom URL

Sets a memorable custom URL slug for the FileLink (e.g. /link/support_documents) instead of the default 22-character id. The original id-based URL continues to work. Submit a blank value to remove the custom URL. Requires the group permission filelink_can_change_url. If the group setting filelink_custom_url_prefix_email is on, the slug is automatically prefixed with the owner's email user-part. A 422 is returned if the slug is already in use, reserved, or otherwise invalid.

Request Info
Info Value
Request URL /link/link_id/update_slug
Request VERB PUT
Request Parameters
Parameter Type Description
slug_input String The desired custom URL slug. Letters, numbers, dashes and underscores. Submit a blank value to revert to the default id-based URL.

Example Update Custom URL using bash and curl

curl -X PUT -H "Authorization: Bearer $api_key" \
     -H "Accept: application/json" \
     -H "Content-Type: application/json" \
     -d '{"slug_input":"support_documents"}' \
     $server/link/tzMNVK0sbpXFFlld65s4Ly/update_slug

Updating Display Mode

Sets how the files are presented on the FileLink page. Requires the matching group permission for the chosen mode. gallery additionally requires the FileLink to contain at least one image or video.

Request Info
Info Value
Request URL /link/link_id/update_display_mode
Request VERB PUT
Request Parameters
Parameter Type Description
display_mode String One of icons (always available), inline (requires filelink_can_use_inline), or gallery (requires filelink_can_use_gallery).

Example Update Display Mode using bash and curl

curl -X PUT -H "Authorization: Bearer $api_key" \
     -H "Accept: application/json" \
     -H "Content-Type: application/json" \
     -d '{"display_mode":"gallery"}' \
     $server/link/tzMNVK0sbpXFFlld65s4Ly/update_display_mode

Enabling / Disabling Downloads

Controls whether recipients can download the files (allow_download = true) or can only view them in the browser (allow_download = false, "view-only" mode). Requires the group permission filelink_can_disable_downloads. Disabling downloads is not compatible with direct links being enabled — see Updating Direct Links.

Request Info
Info Value
Request URL /link/link_id/update_allow_download
Request VERB PUT
Request Parameters
Parameter Type Description
allow_download Boolean True to allow downloads, false for view-only mode.

Example Disable Downloads using bash and curl

curl -X PUT -H "Authorization: Bearer $api_key" \
     -H "Accept: application/json" \
     -H "Content-Type: application/json" \
     -d '{"allow_download":false}' \
     $server/link/tzMNVK0sbpXFFlld65s4Ly/update_allow_download

Enables or disables direct (hot-link) URLs, which let a file's bytes be embedded directly on a third-party page (e.g. in an <img> or <video> tag). Requires the group permission filelink_can_use_direct_links. Because direct links bypass the FileLink page, they cannot be enabled while the FileLink requires authentication, has a password, or has downloads disabled — attempting to do so returns 422 with an explanation. Turning direct links off is always allowed.

Request Info
Info Value
Request URL /link/link_id/update_direct_links
Request VERB PUT
Request Parameters
Parameter Type Description
allow_direct_links Boolean True to enable direct (hot-link) URLs, false to disable them.

Example Enable Direct Links using bash and curl

curl -X PUT -H "Authorization: Bearer $api_key" \
     -H "Accept: application/json" \
     -H "Content-Type: application/json" \
     -d '{"allow_direct_links":true}' \
     $server/link/tzMNVK0sbpXFFlld65s4Ly/update_direct_links

When direct links are enabled, each file's direct URL has the form /link/link_id/raw/filename.

Recipient Limitations

Sets an allowlist of email addresses and/or bare domains that may pass the authentication gate. Only enforced when the FileLink has require_authentication on. Requires the same group permission as authentication (filelink_can_change_require_authentication). Submit a blank value to clear the list.

Request Info
Info Value
Request URL /link/link_id/update_recipient_limitations
Request VERB PUT
Request Parameters
Parameter Type Description
recipient_limitations String A comma- or whitespace-separated list of email addresses and/or domains (e.g. jane@example.com, partner.com). Invalid entries are rejected with 422.

Example Set Recipient Limitations using bash and curl

curl -X PUT -H "Authorization: Bearer $api_key" \
     -H "Accept: application/json" \
     -H "Content-Type: application/json" \
     -d '{"recipient_limitations":"jane@example.com, partner.com"}' \
     $server/link/tzMNVK0sbpXFFlld65s4Ly/update_recipient_limitations

Sets the custom HTML header (shown above the file list) and footer (shown below it) on the FileLink page. Requires the group permission filelink_can_customise_header_footer. The HTML is rendered through Liquid and then sanitised, and may use FileLink variables such as , and . Submit a blank value to clear the header or footer.

Request Info
Info Value
Request URL /link/link_id/update_header  or  /link/link_id/update_footer
Request VERB PUT
Request Parameters
Parameter Type Description
header_html String (update_header) The header HTML. Submit a blank value to clear it.
footer_html String (update_footer) The footer HTML. Submit a blank value to clear it.

Example Update Header using bash and curl

curl -X PUT -H "Authorization: Bearer $api_key" \
     -H "Accept: application/json" \
     -H "Content-Type: application/json" \
     -d '{"header_html":"<h2>Documents for </h2>"}' \
     $server/link/tzMNVK0sbpXFFlld65s4Ly/update_header