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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d39d274baa3fb8db5441f2a5ce5e5aa1a82662da9038fa0592279083d83d6ce9
|
|
| MD5 |
ccbc3c273d689e75962d9de4572a7d6c
|
|
| BLAKE2b-256 |
3cd4718d52aac3e3728e74cc2a90439df2c113c47b1dff98fc0fddc9774cc5ce
|
Provenance
The following attestation bundles were made for spctre_sdk-0.1.0.tar.gz:
Publisher:
release-python.yml on getspctre/spctre
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spctre_sdk-0.1.0.tar.gz -
Subject digest:
d39d274baa3fb8db5441f2a5ce5e5aa1a82662da9038fa0592279083d83d6ce9 - Sigstore transparency entry: 2412305770
- Sigstore integration time:
-
Permalink:
getspctre/spctre@0964146e3ac5820784df78887b8f0c5ee19fa6e5 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/getspctre
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@0964146e3ac5820784df78887b8f0c5ee19fa6e5 -
Trigger Event:
workflow_dispatch
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04c6179633e09ff50ba27bb9783002bb25bfbd602b9887f9297027391b12e36f
|
|
| MD5 |
e29c4ff10cebe6df76f7e7338084908b
|
|
| BLAKE2b-256 |
10d5c95d99d16a2ba25a0c31e256055557eb244c96b7af747f06155bc278d345
|
Provenance
The following attestation bundles were made for spctre_sdk-0.1.0-py3-none-any.whl:
Publisher:
release-python.yml on getspctre/spctre
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spctre_sdk-0.1.0-py3-none-any.whl -
Subject digest:
04c6179633e09ff50ba27bb9783002bb25bfbd602b9887f9297027391b12e36f - Sigstore transparency entry: 2412305777
- Sigstore integration time:
-
Permalink:
getspctre/spctre@0964146e3ac5820784df78887b8f0c5ee19fa6e5 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/getspctre
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@0964146e3ac5820784df78887b8f0c5ee19fa6e5 -
Trigger Event:
workflow_dispatch
-
Statement type: