Dashboard

Python SDK

sentriq is a server-only SDK — it holds a secret key and must never run in browser-facing code. For browser-side tracking, see the Browser SDK. Not yet published to PyPI — install from source (see below).

Install

pip install sentriq

Not yet published — locally, pip install -e sdks/python from within this repository.

Initialize

import os
from sentriq import Sentriq

sentriq = Sentriq(
    secret_key=os.environ["SENTRIQ_SECRET_KEY"],
    # Optional. Defaults to the hosted Sentriq API.
    api_url=os.environ.get("SENTRIQ_API_URL"),
    # Optional. Defaults to 10 seconds.
    timeout=10.0,
    # Optional. Automatic retries for idempotent GET requests only. Default 2.
    max_retries=2,
)

Resources

sentriq.events.retrieve(event_id)
sentriq.events.list(environment_id, params=None)
sentriq.events.submit_outcome(event_id, {"label": "legitimate"})
sentriq.events.list_outcomes(event_id)

sentriq.devices.retrieve(device_id)
sentriq.devices.list(environment_id)
sentriq.devices.list_events(device_id)
sentriq.devices.list_accounts(device_id)
sentriq.devices.list_signals(device_id)
sentriq.devices.list_resolutions(device_id)
sentriq.devices.trust(environment_id, external_account_id, device_id)
sentriq.devices.revoke_trust(environment_id, external_account_id, device_id)

sentriq.accounts.list_devices(environment_id, external_account_id)

sentriq.risk.list(environment_id, params=None)

sentriq.network.list(environment_id)

sentriq.webhooks.verify_signature(raw_body, timestamp, signature, secret)
No policies, webhook management, or event ingestion here
Same boundary as every server SDK — there is no sentriq.policies, no sentriq.webhooks.create()/list()/update()/delete(), and no event ingestion method: POST /v1/events only accepts a public key, which this server SDK never holds. See the Node.js SDK docs for the full explanation.

Sync and async

Both Sentriq and AsyncSentriq share the same resource surface, error hierarchy, and retry policy:

from sentriq import AsyncSentriq

async with AsyncSentriq(secret_key=os.environ["SENTRIQ_SECRET_KEY"]) as sentriq:
    event = await sentriq.events.retrieve(event_id)

Errors

sentriq.exceptions.SentriqError                  (base)
sentriq.exceptions.SentriqConfigurationError
sentriq.exceptions.SentriqNetworkError
sentriq.exceptions.SentriqTimeoutError
sentriq.exceptions.SentriqApiError
sentriq.exceptions.SentriqAuthenticationError     401
sentriq.exceptions.SentriqPermissionError         403
sentriq.exceptions.SentriqNotFoundError           404
sentriq.exceptions.SentriqValidationError         422 — .fields
sentriq.exceptions.SentriqRateLimitError          429 — .retry_after_seconds
from sentriq import SentriqError, SentriqNotFoundError

try:
    sentriq.events.retrieve(event_id)
except SentriqNotFoundError as exc:
    ...  # exc.request_id — include this when contacting support
except SentriqError as exc:
    ...  # catches everything else this SDK raises

Security notes

repr()/str() of a Sentriq client never contain the secret key. Like PHP's var_dump(), Python has no language mechanism to make an attribute truly unreadable to code holding a reference to the object — never vars() or log a Sentriq instance directly.

Version compatibility

Python >=3.10 (tested on 3.12; CI additionally covers 3.10–3.13). httpx >=0.27,<1.0.