Public API client
Access this client through sandbox.api. It uses the API token from SandboxKey.
Methods inherited from the storage, analysis, scanning, and maintenance mixins
are listed below.
ptsandbox.sandbox.api.SandboxApi
Bases: StorageMixin, AnalysisMixin, ScanMixin, MaintenanceMixin
Using raw queries to sandbox API
get_images
async
Get a list of available images in the sandbox
Raises:
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
-
ValidationError–if the response body does not match the expected model
get_health_status
async
Checking the API status
Raises:
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
-
ValidationError–if the response body does not match the expected model
get_version
async
Get information about the product
Raises:
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
-
ValidationError–if the response body does not match the expected model
source_check_file
async
source_check_file(file: str | Path | bytes | BinaryIO, data: SandboxScanWithSourceFileRequest, read_timeout: int = 240) -> SandboxBaseTaskResponse
Send a file to the sandbox with source settings
Parameters:
-
file(str | Path | bytes | BinaryIO) –The file to be sent for analysis
-
data(SandboxScanWithSourceFileRequest) –Request parameters in model
-
read_timeout(int, default:240) –Response waiting time in seconds
Raises:
-
SandboxException–if incorrect arguments are passed (usually when ignoring type hints)
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
-
ValidationError–if the response body does not match the expected model
source_check_url
async
source_check_url(data: SandboxScanWithSourceURLRequest, read_timeout: int = 240) -> SandboxBaseTaskResponse
Send the URL to the sandbox with source settings
Parameters:
-
data(SandboxScanWithSourceURLRequest) –Request parameters in model
-
read_timeout(int, default:240) –Response waiting time in seconds
Raises:
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
-
ValidationError–if the response body does not match the expected model
source_get_status
async
Check the status of a scan started via the source API (source_check_file / source_check_url).
Returns only the status without the full report. For the full report, use source_get_report.
Parameters:
-
data(SandboxCheckTaskRequest) –request parameters (scan_id and allow_preflight)
Returns:
-
SandboxCheckTaskResponse–Information about the analysis status
Raises:
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
-
ValidationError–if the response body does not match the expected model
source_get_report
async
Get the full scan report created using the source settings
Parameters:
-
scan_id(UUID) –task id
Returns:
-
SandboxBaseTaskResponse–The response from the sandbox is either with partial information (when using async_result), or with full information.
Raises:
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
-
ValidationError–if the response body does not match the expected model
create_scan
async
Send the specified file to the sandbox for analysis
Parameters:
-
data(SandboxScanTaskRequest) –sandbox parameters in model
-
read_timeout(int, default:0) –response waiting time in seconds
Returns:
-
SandboxBaseTaskResponse–The response from the sandbox is either with partial information (when using async_result), or with full information.
Raises:
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
-
ValidationError–if the response body does not match the expected model
create_advanced_scan
async
create_advanced_scan(data: SandboxAdvancedScanTaskRequest, read_timeout: int = 0) -> SandboxBaseTaskResponse
Send the specified file to the sandbox for analysis using advanced API
Parameters:
-
data(SandboxAdvancedScanTaskRequest) –sandbox parameters in model
-
read_timeout(int, default:0) –response waiting time in seconds
Returns:
-
SandboxBaseTaskResponse–The response from the sandbox is either with partial information (when using async_result), or with full information.
Raises:
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
-
ValidationError–if the response body does not match the expected model
create_url_scan
async
Send the URL to the sandbox
Parameters:
-
data(SandboxScanURLTaskRequest) –sandbox parameters in model
-
read_timeout(int, default:0) –response waiting time in seconds
Returns:
-
SandboxBaseTaskResponse–The response from the sandbox is either with partial information (when using async_result), or with full information.
Raises:
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
-
ValidationError–if the response body does not match the expected model
check_task
async
Checking the result of a scan running with the async_result flag
Parameters:
-
data(SandboxCheckTaskRequest) –request parameters (scan_id, allow_preflight)
Returns:
-
SandboxCheckTaskResponse–Information about the analysis status
Raises:
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
-
ValidationError–if the response body does not match the expected model
get_report
async
Getting the full task scan report
Parameters:
-
scan_id(UUID) –ID of the task to get the report for
Returns:
-
SandboxBaseTaskResponse–The response from the sandbox is either with partial information (when using async_result), or with full information.
Raises:
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
-
ValidationError–if the response body does not match the expected model
create_rescan
async
Run a retro scan to check for detects without running a behavioral analysis.
Parameters:
-
data(SandboxRescanTaskRequest) –sandbox parameters in model
-
read_timeout(int, default:300) –response waiting time in seconds
Returns:
-
SandboxBaseTaskResponse–The response from the sandbox is either with partial information (when using async_result), or with full information.
Raises:
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
-
ValidationError–if the response body does not match the expected model
get_email_headers
async
Upload an email to receive headers
Parameters:
-
data(str | Path | bytes | BinaryIO) –path to .eml file, its content or a binary stream
Returns:
-
AsyncIterator[bytes]–The header file
Raises:
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
get_tasks
async
Get tasks listing
Raises:
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
-
ValidationError–if the response body does not match the expected model
upload_file
async
upload_file(file: str | Path | bytes | BinaryIO, upload_timeout: float = 300) -> SandboxUploadScanFileResponse
Uploads the file to the sandbox
Parameters:
-
file(str | Path | bytes | BinaryIO) –a path in the form of a string, either a Path object or binary data
-
upload_timeout(float, default:300) –if a large enough file is being uploaded, increase timeout (in seconds).
Returns:
-
SandboxUploadScanFileResponse–The link to the file in the temporary storage and the lifetime of this file are returned, or an exception is thrown.
Raises:
-
SandboxException–if incorrect arguments are passed (usually when ignoring type hints)
-
ClientResponseError–if the server returns an error status
-
ClientError–on connection or transport errors
-
ValidationError–if the response body does not match the expected model
download_artifact
async
Download file from the sandbox by hash
Parameters:
-
file_uri(str) –Permanent file identifier in the
sha256:<sha256_hex>format.This is not the same as the temporary
file_urireturned by :meth:upload_file(sfm:stream_v1...), which is only valid for use with scan creation endpoints. -
read_timeout(int, default:120) –response waiting time in seconds
Returns:
-
bytes–File data
Raises:
-
ClientResponseError–if the server returns an error status (404 if the file is not found)
-
ClientError–on connection or transport errors
download_artifact_stream
async
Download file from the sandbox by hash
Parameters:
-
file_uri(str) –Permanent file identifier in the
sha256:<sha256_hex>format.This is not the same as the temporary
file_urireturned by :meth:upload_file(sfm:stream_v1...), which is only valid for use with scan creation endpoints. -
read_timeout(int, default:120) –response waiting time in seconds
Returns:
-
AsyncIterator[bytes]–streaming file data
Raises:
-
ClientResponseError–if the server returns an error status (404 if the file is not found)
-
ClientError–on connection or transport errors