Python SDK

Install and start using the Python SDK.

Intro

The Decionis Policy Evaluation API SDK provides access to the Decionis Policy Evaluation API REST APIs.

Decionis evaluates captured execution intent against versioned policies before the caller performs the action. SDKs delegate policy judgment to this service and locally enforce the signed decision. New SDK API keys can be associated with an industry so Decionis provisions a starter encoded policy binding server-side; applications do not receive or implement policy logic.

Installation

Add the SDK to your project from its folder, with whichever package manager your project uses. Give each tool a path containing a slash, such as ../decionis-policy-evaluation-api — a bare folder name is looked up on PyPI instead, and resolves to whatever project holds that name there:

Terminal
pip install <path-to-sdk>
Terminal
uv add <path-to-sdk>
Terminal
poetry add <path-to-sdk>

Quick Start

Synchronous client

Construct DecionisPolicyEvaluationApiClient with keyword arguments, and call close() when you are done. Every argument is optional.

Python
from decionis_policy_evaluation_api import DecionisPolicyEvaluationApiClient

client = DecionisPolicyEvaluationApiClient(
    api_key_auth="YOUR_BEARER_TOKEN",
    operator_entra_auth="YOUR_BEARER_TOKEN",
    account_session_cookie="YOUR_API_KEY",
    hosted_gateway_tcp_route_credential="YOUR_BEARER_TOKEN",
    hosted_gateway_tcp_broker_auth="YOUR_BEARER_TOKEN",
    hosted_gateway_worker_auth="YOUR_BEARER_TOKEN",
    protocol_service_auth="YOUR_BEARER_TOKEN",
    commerce_accounts_o_auth="YOUR_BEARER_TOKEN",
    commerce_connected_transport="YOUR_BEARER_TOKEN",
    accounts_workspace_credential_service="YOUR_BEARER_TOKEN",
    accounts_native_enrollment_service="YOUR_BEARER_TOKEN",
    drupal_site_key="YOUR_BEARER_TOKEN",
)

client.close()

Alternatively, scope it — with DecionisPolicyEvaluationApiClient(...) as client: closes the pool on exit.

Asynchronous client

AsyncDecionisPolicyEvaluationApiClient mirrors DecionisPolicyEvaluationApiClient with identical method names, and every endpoint method is a coroutine. It takes the same arguments, with some differences — for example, the transport argument is custom_async_http_client.

Python
from asyncio import run

from decionis_policy_evaluation_api import AsyncDecionisPolicyEvaluationApiClient


async def main() -> None:
    client = AsyncDecionisPolicyEvaluationApiClient(
        api_key_auth="YOUR_BEARER_TOKEN",
        operator_entra_auth="YOUR_BEARER_TOKEN",
        account_session_cookie="YOUR_API_KEY",
        hosted_gateway_tcp_route_credential="YOUR_BEARER_TOKEN",
        hosted_gateway_tcp_broker_auth="YOUR_BEARER_TOKEN",
        hosted_gateway_worker_auth="YOUR_BEARER_TOKEN",
        protocol_service_auth="YOUR_BEARER_TOKEN",
        commerce_accounts_o_auth="YOUR_BEARER_TOKEN",
        commerce_connected_transport="YOUR_BEARER_TOKEN",
        accounts_workspace_credential_service="YOUR_BEARER_TOKEN",
        accounts_native_enrollment_service="YOUR_BEARER_TOKEN",
        drupal_site_key="YOUR_BEARER_TOKEN",
    )
    await client.aclose()


run(main())

Alternatively, scope it — async with AsyncDecionisPolicyEvaluationApiClient(...) as client: closes the pool on exit.

On this page