SendSafely Python Client API

1.0.9.6 · active · verified Thu Apr 16

The SendSafely Client API allows programmatic access to SendSafely, providing a layer of abstraction over the complex REST API for secure data transfer capabilities within Python applications. It handles cryptographic details, file segmentation, and server authentication. The current version is 1.0.9.6, and the library appears to be actively maintained with frequent point releases.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the SendSafely client, create a new secure package, add an encrypted message, specify a recipient, and finalize the package to obtain a secure download link. Ensure your `BASE_URL`, `API_KEY`, and `API_SECRET` are obtained from your SendSafely profile.

import os
from sendsafely import SendSafely, Package

# Retrieve credentials from environment variables for security
BASE_URL = os.environ.get('SENDSAFELY_BASE_URL', 'https://your-company.sendsafely.com')
API_KEY = os.environ.get('SENDSAFELY_API_KEY', 'YOUR_API_KEY')
API_SECRET = os.environ.get('SENDSAFELY_API_SECRET', 'YOUR_API_SECRET')
RECIPIENT_EMAIL = os.environ.get('SENDSAFELY_RECIPIENT_EMAIL', 'user@example.com')

if not all([BASE_URL, API_KEY, API_SECRET, RECIPIENT_EMAIL]):
    print("Please set SENDSAFELY_BASE_URL, SENDSAFELY_API_KEY, SENDSAFELY_API_SECRET, and SENDSAFELY_RECIPIENT_EMAIL environment variables.")
    exit(1)

try:
    # Create a SendSafely instance object for authentication
    sendsafely_client = SendSafely(BASE_URL, API_KEY, API_SECRET)

    # Create a new package
    package = Package(sendsafely_client)

    # Add a secure message to the package
    package.encrypt_and_upload_message("Hello this is a secure message from Python.")

    # Add a recipient to the package
    package.add_recipient(RECIPIENT_EMAIL)

    # Finalize the package to generate the secure link
    response = package.finalize()

    if response and response.get('secureLink'):
        print(f"Secure Package Link: {response['secureLink']}")
    else:
        print("Failed to finalize package or retrieve secure link.")
        print(response)

except Exception as e:
    print(f"An error occurred: {e}")

view raw JSON →