Files.com Python Client
The Files.com Python Client provides a direct, high performance integration to Files.com from applications written in Python.
Files.com is the cloud-native, next-gen MFT, SFTP, and secure file-sharing platform that replaces brittle legacy servers with one always-on, secure fabric. Automate mission-critical file flows—across any cloud, protocol, or partner—while supporting human collaboration and eliminating manual work.
With universal SFTP, AS2, HTTPS, and 50+ native connectors backed by military-grade encryption, Files.com unifies governance, visibility, and compliance in a single pane of glass.
The content included here should be enough to get started, but please visit our
Developer Documentation Website for the complete documentation.
examples/getting_started.py
is a short, runnable tour of the SDK.
Introduction
For integration choices and credential scope, start with SDKs & APIs. Scripts, APIs & Application Workflows explains how to coordinate Files.com operations with the work your application owns.
The Files.com Python SDK manages files, folders, users, permissions and other API resources. Start by installing the package, then choose Authentication and a Client. For file transfers, begin with Uploads or Downloads.
The SDK communicates over HTTPS on port 443. Your environment needs outbound access to Files.com and the storage hosts used for transfers.
Installation
Install the package into the Python environment that runs your application:
python -m pip install Files.com
Python 3.11 or newer is required. The package is tested on CPython 3.11–3.14 and supported on Python versions receiving vendor security updates. On older Python versions, pip installs the last 1.x release, which no longer receives updates.
Version 2 changes retry behavior and transfer return values. Review UPGRADING.md when moving an existing integration from 1.x.
Files.com is Committed to Python
The package supports custom integrations across the Files.com API. Use the resource reference for operation parameters, and the overview guides for pagination, retries and cancellation.
Explore the files-sdk-python code on GitHub.
Getting Support
The Files.com Support team provides official support for all of our official Files.com integration tools.
To initiate a support conversation, you can send an Authenticated Support Request or simply send an E-Mail to support@files.com.
Authentication
There are two ways to authenticate: API Key authentication and Session-based authentication.
Authenticate with an API Key
Authenticating with an API key is the recommended authentication method for most scenarios, and is
the method used in the examples on this site.
To use an API Key, first generate an API key from the web
interface or via the API or an
SDK.
A user key follows its account's permissions, narrowed by the key's permission scope, Workspace, and any path restriction on file operations. It can perform administrative operations only when both the account and key permit them. API Keys explains credential scope and lifecycle; Workspaces explains request context and delegated administration.
import files_sdk
files_sdk.set_api_key("YOUR_API_KEY")
## Alternatively, you can specify the API key on a per-request basis in the final parameter to any method or initializer.
try:
files_sdk.user.list(params, {"api_key": "YOUR_API_KEY"})
except files_sdk.error.NotAuthenticatedError as err:
print(f"Authentication Error Occurred ({type(err).__name__}):", err)
except files_sdk.error.Error as err:
print(f"Unknown Error Occurred ({type(err).__name__}):", err)
Don't forget to replace the placeholder, YOUR_API_KEY, with your actual API key.
Authenticate with a Session
Create a session with the username and password of an active user. The session uses that user's permissions, including any delegated administrative access. Workspaces describes account scope and administrative access.
Sessions use the exact same session timeout settings as web interface sessions. When a
session times out, simply create a new session and resume where you left off. This process is not
automatically handled by our SDKs because we do not want to store password information in memory without
your explicit consent.
Logging In
To create a session, call files_sdk.session.create(), or a client's client.session.create(), with
the user's username and password.
This returns a session object that can be used to authenticate SDK method calls, including as a
client's session setting. Closing a client does not log out its session.
import files_sdk
try:
session = files_sdk.session.create({ "username": "motor", "password": "vroom" })
except files_sdk.error.NotAuthenticatedError as err:
print(f"Authentication Error Occurred ({type(err).__name__}):", err)
except files_sdk.error.Error as err:
print(f"Unknown Error Occurred ({type(err).__name__}):", err)
Using a Session
Once a session has been created, you can store the session globally, use the session per object, or use the session per request to authenticate SDK operations.
import files_sdk
## You may set the returned session to be used by default for subsequent requests.
files_sdk.set_session(session)
try:
# Alternatively, you can specify the session ID on a per-object basis in the second parameter to a model constructor.
user = files_sdk.user.User(params, {"session_id": session.id})
# You may also specify the session ID on a per-request basis in the final parameter to static methods.
files_sdk.user.find(id, params, {"session_id": session.id})
except files_sdk.error.NotAuthenticatedError as err:
print(f"Authentication Error Occurred ({type(err).__name__}):", err)
except files_sdk.error.Error as err:
print(f"Unknown Error Occurred ({type(err).__name__}):", err)
Logging Out
User sessions can be ended calling the destroy method on the session object.
session.destroy()
Configuration
Create a files_sdk.Client with the settings it needs. A client never reads the module-level
settings, and its objects keep using it. See Clients for per-call
options, clients with your own Requests session, and closing.
The module-level functions, such as files_sdk.user.find(), use the settings on the files_sdk
module instead, as they are when each call starts.
import files_sdk
client = files_sdk.Client(
api_key="YOUR_API_KEY",
base_url="https://SUBDOMAIN.files.com",
workspace_id=5,
open_timeout=30,
read_timeout=80,
max_network_retries=3,
request_timeout=None,
)
Client Settings
| Setting |
Default |
Meaning |
api_key, session_id, session |
|
The credential. With both, the API key is used. |
workspace_id, language, headers |
|
Sent with every API request. |
base_url |
https://app.files.com |
Where the API is. See Base URL below. |
open_timeout, read_timeout |
30, 80 |
Seconds to wait for a connection to each resolved address, and for each read. |
max_network_retries |
3 |
Retries of a failed request; 0 sends it once. |
initial_network_retry_delay, max_network_retry_delay |
0.1, 2 |
Seconds API retries wait, doubling. |
request_timeout |
None |
Seconds each operation may take in all. |
max_redirects |
30 |
Redirects each request may follow. |
source_ip |
|
The local address to send from. |
verify, cert, proxies, trust_env |
True, None, None, True |
As for requests.Session. |
http_session |
|
Your own requests.Session to send through. |
transfer_limiter, upload_tuning |
A limiter of its own, adaptive |
See Uploads. |
region_policy, region_handler, region_development_origins |
"automatic" |
See Regional Relocation. |
Retries and Timeouts and
Cancellation and Deadlines describe the timing settings.
Module Settings
Base URL
Set this to the full https:// URL of your Files.com subdomain (e.g. https://MY-SUBDOMAIN.files.com).
This is not required in most cases, but one benefit of setting it is that it ensures that authentication failures will be logged to your site's API logs. Without setting this, we won't know which site to associate the authentication failure with, and it won't be logged to your site's API logs.
This is always required if your site is configured to disable global acceleration.
This can also be set to use a mock server in development or CI.
A client takes the same value as its base_url setting.
import files_sdk
files_sdk.base_url = "https://SUBDOMAIN.files.com"
Log Level
This SDK uses the standard Python logging framework, through the files_sdk logger. The SDK
logs nothing until your application configures logging. At INFO it logs each request, response
and retry without credentials or signed URLs; at DEBUG it logs complete requests and responses,
including credentials, signed URLs and file content, so enable DEBUG only where those can be
kept safe.
import logging
logging.basicConfig()
logging.getLogger("files_sdk").setLevel(logging.INFO)
Console Log Level
Also prints the SDK's messages at or above this level to stderr, however logging is configured.
Allowed values are:
- "none" (the default)
- "error"
- "warning"
- "info"
- "debug"
import files_sdk
files_sdk.console_log_level = "info"
Open Timeout
Seconds to wait for a connection to each address the host name resolves to. The default
value is 30.
import files_sdk
files_sdk.open_timeout = 60
Read Timeout
Read timeout in seconds, for each read of a response. The default value is 80.
import files_sdk
files_sdk.read_timeout = 90
Initial Network Retry Delay
Seconds before the first retry of an API request, doubling for each later retry. The default
value is 0.1.
import files_sdk
files_sdk.initial_network_retry_delay = 1
Maximum Retry Delay
Maximum network retry delay in seconds. The default value is 2.
import files_sdk
files_sdk.max_network_retry_delay = 5
Maximum Network Retries
Maximum number of retries after the first attempt. The default value is 3; 0 sends each request
once.
import files_sdk
files_sdk.max_network_retries = 5
Source IP
Configure the local IP address from which to send requests.
import files_sdk
files_sdk.source_ip = '10.1.2.3'
Clients
A files_sdk.Client has its own credentials, settings and connections. Each of its resources,
such as client.user or client.file, has the operations of the module of the same name, and
every object and list they return keeps using that client. A client never reads the module-level
settings, such as files_sdk.set_api_key(), so several clients, for different sites or users,
can work side by side.
Use a client as a context manager, or call close() when you are done with it. Closing stops its
operations in progress and closes its connections. The objects it returned keep their data, but
can no longer send requests. Closing a client never logs out a session.
client.user.new(attributes) makes an unsaved object whose save() uses the client.
A record's update() and save() change that object in place and return None. Read the updated attributes from the same object. The client's resource methods, such as client.user.update(id, params), return the updated record.
import files_sdk
try:
with files_sdk.Client(api_key="YOUR_API_KEY") as client:
user = client.user.find(1234)
user.update({"name": "Pat"}) # Also through this client.
for item in client.folder.list_for("reports").auto_paging_iter():
print(item.path)
except files_sdk.error.NotAuthenticatedError as err:
print(f"Authentication Error Occurred ({type(err).__name__}):", err)
except files_sdk.error.Error as err:
print(f"Unknown Error Occurred ({type(err).__name__}):", err)
Options for One Call
Every operation takes an options dictionary after its parameters, described by
files_sdk.RequestOptions. Options apply to that call and to the objects it returns. An option
that is left out, or set to None, is inherited from the client. Set it to files_sdk.CLEAR to
remove the inherited value instead, such as a client's workspace. 0 and False are real
values. An unknown option raises InvalidParameterError before anything is sent.