Python client for the SentinelOne Management Console API, for security automation scripts.
A thin wrapper around the SentinelOne REST API (/web/api/v2.1) that handles login and cursor pagination. It is a library imported by other scripts. It is not a service and has no CLI.
Note
This repo is a Glovo fork of fragtastic/sentinelone-api-python. Glovo's own additions are the isolate, scan and quarantine calls (see Overview).
- Overview
- Build & local development
- Security & data handling
- Repository layout
- Contributing & conventions
- Ownership & support
sentineloneapi.Client logs in to a SentinelOne console with an API token and exposes one method per API call (about 43 methods in client.py). Every call returns a (data, errors) tuple. Pagination is automatic: api_call follows pagination.nextCursor until the console stops returning one, and merges all pages into data.
| Language / build | Python >=3.5, setuptools (setup.py) |
| Dependency | requests (requirements.txt), unpinned |
| Package name | sentinelone-api-python-fragtastic 0.0.2 (upstream name, kept in setup.py) |
| API | SentinelOne Management Console REST API v2.1 |
| Area | Examples |
|---|---|
| Agents | GetAgents, CountAgents, DecommissionAgent, MoveToSite, MoveToGroup |
| Agent actions (Glovo) | disconnect_agent (isolate), reconnect_agent (un-isolate), initiate_scan, abort_scan |
| Threats | GetThreats, mitigate_threat (Glovo, quarantine) |
| Policies | GlobalPolicy, AccountPolicy, GroupPolicy |
| Sites, groups, roles | GetSites, GetSiteById, GetGroups, GetAllRoles, GetSpecificRoleDefinition |
| Users and tokens | ListUsers, GenerateApiToken, RevokeApiToken, ChangePassword, SendVerificationEmail |
| Vulnerabilities, alerts | GetCves, GetAlerts |
| System | SystemInfo, SystemStatus, CacheStatus, DatabaseStatus, GetSystemConfig, SetSystemConfig |
The disconnect_agent, reconnect_agent and mitigate_threat calls act on live endpoints. disconnect_agent and reconnect_agent read the agent ID from the first entry of filter.ids in the payload and use only that one.
Note
Needs Python >=3.5 and a SentinelOne API token for a console URL. There are no tests, linters or CI in this repo.
pip install -r requirements.txt # installs requests
python setup.py install # installs the sentineloneapi package
./build.sh # builds the Docker image sentineloneapi:latest (python:3-alpine + setup.py install)All API calls automatically handle pagination.
import sentineloneapi
client = sentineloneapi.Client(
username='username@domain.tld',
password='<your-password>',
url='example.sentinelone.net'
)
# One or the other.
# Username/password and apitoken are mutually exclusive.
client = sentineloneapi.Client(
apitoken='<your-api-token>',
url='example.sentinelone.net'
)
client.authenticate()
data, errors = client.CountAgents(payload={'computerName__like': 'test'})
data, errors = client.ListUsers(payload={
'skipCount': True,
'query': 'Test'
})Warning
These points from reading the code differ from the example above:
authenticate()only supportsapitoken. With username and password it raisesAuthenticationError('Unhandled authentication method.').urlis joined directly with/web/api/v2.1/..., so pass the full base URL with scheme (for examplehttps://example.sentinelone.net), orrequestsrejects it.- The client needs either
apitoken, orusernameandpassword; otherwise it raisesInvalidParameters. A missingurlraisesMissingURL.
Client(..., verify='/path/ca-bundle.pem') passes a certificate bundle to requests for TLS verification.
Errors are returned in the errors list of the tuple. Exception classes (exceptions.py): AuthenticationError, Unauthenticated, InvalidParameters, UnhandledRequestType, MissingURL, AuthenticationTokenExpired, APITokenExpired, Unimplemented.
- Credentials: pass the API token or password at run time from your secret store. Never commit them.
- The token is sent as
Authorization: Token <token>on every call. verifydefaults toNone, whichrequeststreats as its default (TLS verification on). Use it only to point at a CA bundle.- Debug logging (
loggingat DEBUG) prints full API responses, which can include agent and user data.
sentinelone-api-python/
├── sentineloneapi/ ⭐ the package
│ ├── __init__.py exports Client
│ ├── client.py Client: auth, pagination, one method per API call
│ ├── exceptions.py exception classes
│ └── util.py datetime parsing helper
├── setup.py packaging (setuptools)
├── requirements.txt runtime dependency (requests)
├── Dockerfile python:3-alpine, runs setup.py install
├── build.sh builds the Docker image sentineloneapi:latest
└── LICENSE
- Add a new API call as a
Clientmethod inclient.pythat setsendpointand returnsself.api_call(requests.get|post|put, endpoint, payload). OnlyGET,POSTandPUTare supported; anything else raisesUnhandledRequestType. - Keep the
(data, errors)return shape. - Open a PR against
main. There is no CI, so run your change against a console before asking for review. - Upstream:
fragtastic/sentinelone-api-python. Glovo commits are ahead of upstream onmain.
- No
CODEOWNERSfile or catalog entry exists in this repo. The last Glovo change is theSEC-6487PR (2025-07-07, #1).