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.
You may provide the key to the API one of two ways. The simplest way is to set the X-FilesAPI-Key
header with the value of the key.
Alternatively, you may use HTTP Basic Authentication. You should pass in the API Key as the Username
field in HTTP Basic Authentication. The password field may be left blank, or you may use a placeholder
value, such as x.
Noteworthy
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, a POST request is made to /sessions with the user's username and
password.
The id field in the response is the session ID that must be provided to subsequent requests in
order to use this session.
Endpoint
POST/sessions
Using a Session
Once a session has been created, you authenticate to the REST API by sending a header called
X-FilesAPI-Auth set to the value of the session ID.
Logging Out
User sessions can be ended by sending a DELETE request to /sessions. If a valid user session
ID is passed in via the X-FilesAPI-Auth header, then that user session will be deleted, which is
similar to the user logging out. Note that sending a DELETE request at this endpoint will always
result in a response of an empty array, even if an invalid user session was passed in.
Endpoint
DELETE/sessions
Reauthentication
When authenticating to the API with a session ID, certain requests require confirmation of the
session user's identity in an X-Files-Reauthentication header. This process is called
reauthentication.
See the Security Reference's Re-authentication page for the operations and fields that require confirmation, supported verification methods, and authentication exceptions.