Skip to main content

spctre-sdk

Python client for the Spctre policy operations control plane.

pip install spctre-sdk

Requires Python 3.11+.

Usage

from spctre import SpctreClient
from spctre.models import GatewayDecisionRequest

client = SpctreClient(
    base_url="https://app-staging.spctre.dev",
    token=token,
)

decision = client.gateway.decide(
    GatewayDecisionRequest(
        decision_id="d-1",
        artifact_hash="sha256:...",
        policy_context=[...],
    )
)

if decision.decision.outcome.value == "PROCEED":
    ...  # act
    client.evidence.ingest(record)

base_url is the deployment origin, not the API root — the client owns the /api/v1 path segment. Staging, production and self-hosted deployments differ only in this value:

Given Requests go to
https://app-staging.spctre.dev https://app-staging.spctre.dev/api/v1/...
http://localhost:3000 http://localhost:3000/api/v1/...
https://internal.example.com/spctre https://internal.example.com/spctre/api/v1/...

A URL that already ends in /api/v1 is accepted as-is rather than doubled.

Domains

The client is organized by product domain, following the control-plane loop: policy changes become published controls, controls produce enforced decisions, decisions produce evidence, evidence supports assurance.

Domain Operations
client.gateway decide, resolve, escalation_status, list_escalations, register_agt_escalation
client.evidence ingest, ingest_git_checkpoint, forensic_query
client.policy import_policy
client.trust ingest_score, evaluate, ingest_context_budget
client.verification ingest, list
client.bundle latest, retain_latest
client.compliance export
client.approvals get

Models come from spctre.models. Field names are snake_case in Python and are serialized to the API's camelCase automatically.

Operations outside these domains — SCIM, auth token rotation, blueprint import, simulation — are reachable through spctre._generated, which is regenerated wholesale from the OpenAPI spec and carries no stability promise. Anything you find yourself needing there is a reasonable thing to request as a facade addition.

Errors

Every failure is raised as a SpctreError subclass. Generated exceptions never escape:

Raised When
SpctreAuthError 401: token missing, expired, or revoked
SpctrePermissionError 403: token lacks the required scope
SpctreRequestError other 4xx
SpctreServerError 5xx
SpctreTransportError no HTTP response at all (DNS, TLS, timeout)
SpctreResponseError answered, but the response did not parse

Each carries status, body, and trace_id lifted from the response envelope's meta.traceId — quote it when reporting a problem.

SpctreResponseError is deliberately distinct from SpctreTransportError: it means the client and the deployment disagree about the API contract, usually an SDK too old or too new for the server. Reporting that as an unreachable host would send debugging in the wrong direction.

Testing

transport= accepts any httpx.BaseTransport, so tests need no network:

import httpx
from spctre import SpctreClient


def handler(request: httpx.Request) -> httpx.Response:
    assert request.url.path == "/api/v1/gateway/decide"
    return httpx.Response(200, json={...})


client = SpctreClient(
    base_url="https://app.example.com",
    token="test-token",
    transport=httpx.MockTransport(handler),
)

How this package is built

spctre._generated is produced by openapi-python-client from the control plane's OpenAPI spec, at a pinned generator version. Unlike most generated code in this repository it is checked in, so installing or building the package needs no code generator, and CI can assert the committed client still matches the spec.

License

Apache-2.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spctre_sdk-0.1.0.tar.gz (59.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spctre_sdk-0.1.0-py3-none-any.whl (170.1 kB view details)

Uploaded Python 3

File details

Details for the file spctre_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: spctre_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 59.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for spctre_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d39d274baa3fb8db5441f2a5ce5e5aa1a82662da9038fa0592279083d83d6ce9
MD5 ccbc3c273d689e75962d9de4572a7d6c
BLAKE2b-256 3cd4718d52aac3e3728e74cc2a90439df2c113c47b1dff98fc0fddc9774cc5ce

See more details on using hashes here.

Provenance

The following attestation bundles were made for spctre_sdk-0.1.0.tar.gz:

Publisher: release-python.yml on getspctre/spctre

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file spctre_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: spctre_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 170.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for spctre_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 04c6179633e09ff50ba27bb9783002bb25bfbd602b9887f9297027391b12e36f
MD5 e29c4ff10cebe6df76f7e7338084908b
BLAKE2b-256 10d5c95d99d16a2ba25a0c31e256055557eb244c96b7af747f06155bc278d345

See more details on using hashes here.

Provenance

The following attestation bundles were made for spctre_sdk-0.1.0-py3-none-any.whl:

Publisher: release-python.yml on getspctre/spctre

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page