Skip to content

Send files

POST /upload accepts a file from the authenticated user. You can send the file as multipart/form-data or as the binary request body; the optional metadata is the same in both formats.

Choose the format

FormatWhen to useMetadata
multipart/form-dataForms and most HTTP libraries.Form fields
application/octet-streamStreaming uploads or clients that do not build multipart requests.X-STCPDIRECTLINK-* headers

Optional metadata

Whether you can use each metadata item depends on the operations enabled in the environment.

MultipartBinary body (header)Description
file (required)X-STCPDIRECTLINK-FILENAME (required)File sent (multipart) or file name (binary body).
dX-STCPDIRECTLINK-DESTINATIONRecipient or destination user.
mX-STCPDIRECTLINK-EMAILEmail associated with the transfer notification.
cX-STCPDIRECTLINK-MOBILEMobile phone associated with the transfer notification.
hX-STCPDIRECTLINK-HASHExpected SHA-256 hash of the file, in hexadecimal. The value is returned in the X-STCPDIRECTLINK-HASH header of the download.
nX-STCPDIRECTLINK-EMAIL-FROMSender identification or email.
iX-STCPDIRECTLINK-INFOAdditional information or tags for the transfer.

Send the file

Minimal upload:

curl -i \
  -H "Authorization: Bearer ${ACCESS_TOKEN}" \
  -F 'file=@./document.pdf' \
  "$API_BASE/upload"

With recipient and notification:

curl -i \
  -H "Authorization: Bearer ${ACCESS_TOKEN}" \
  -F 'file=@./document.pdf' \
  -F 'd=RECIPIENT' \
  -F 'm=recipient@example.com' \
  -F 'c=5511999999999' \
  -F "h=$(sha256sum ./document.pdf | cut -d' ' -f1)" \
  -F 'i=external-reference' \
  "$API_BASE/upload"

Read the response

The 200 response returns the transfer data:

{
  "status": 0,
  "description": "<description returned by the API>",
  "apiver": "v2 (9.0.1)",
  "user": "USER",
  "id": "<file identifier>",
  "destination": "RECIPIENT",
  "length": 12345,
  "linkURL": [],
  "time": "<date and time>"
}
FieldDescription
idName or identifier of the received file.
destinationTransfer destination.
lengthSize received, in bytes.
linkURLNotification links generated for the transfer, if any.

The actual values depend on the environment; use the response you receive as the reference.

Tip

Compare length with the size of the local file and provide the hash in the upload to detect incomplete transfers.

Full contract in Reference: Transfers.