Metadata-Version: 2.5
Name: countersig
Version: 1.0.3
Summary: Python SDK for the Countersig NHI governance API
Project-URL: Homepage, https://countersig.com
Project-URL: Documentation, https://github.com/RunTimeAdmin/Countersig-Public/tree/main/docs
License: MIT
Requires-Python: >=3.11
Requires-Dist: h11>=0.16
Requires-Dist: httpx>=0.28
Description-Content-Type: text/markdown

# countersig

Python client for the [Countersig](https://countersig.com) API: agent identity, A2A tokens, policy checks and the org audit log.

```bash
pip install countersig
```

Python 3.11 or later.

## Configuration

The client reads these environment variables when it is imported:

| Variable | Default | |
|---|---|---|
| `COUNTERSIG_API_URL` | `https://api.countersig.com` | Base URL of the API |
| `COUNTERSIG_API_KEY` | none | API key, sent as a bearer token |
| `COUNTERSIG_ORG_ID` | none | Organization ID, needed by the org-scoped calls |
| `COUNTERSIG_TIMEOUT` | `10` | HTTP timeout in seconds |

## Use

```python
import countersig

# Verify an A2A token another agent presented. No API key needed.
try:
    result = countersig.verify_a2a_token(token)  # {"valid": True, "payload": {...}}
except countersig.CountersigError as e:
    print(e.status_code, e)  # 401 "Invalid or expired token"

# Calls that need an API key go through a session.
cs = countersig.init_session()  # uses COUNTERSIG_API_KEY and COUNTERSIG_ORG_ID
agents = cs.list_agents()
decision, reason = cs.evaluate_policy(agent_id, "send_email")  # "allow", "hold" or "deny"
chain = cs.verify_chain()
```

Every call raises `CountersigError` (with `status_code`) when the API answers 400 or above.

`append_audit` posts to `/orgs/{org_id}/audit`, which the API does not serve yet, so it raises a 404 for now. Reading, exporting and verifying the audit log work.

## Documentation

The API reference and developer guide are in [Countersig-Public](https://github.com/RunTimeAdmin/Countersig-Public/tree/main/docs).

## License

MIT
