# stapel-integrations-core

> Shared base of Stapel integrations: stored connections with encrypted secrets, per-workspace access, guarded outbound HTTP and a provider registry.

## Rules
- Get a connection only through `services.get_connection(user, id, action, provider=...)`; never query the model in a view.
- Actions: MANAGE (see settings, change), SET_ACCESS (choose who may use), USE (act through it).
- Secrets are write-only: no API, log or error text may carry them.
- A write that raises `UnknownOutcome` must not be retried blindly.
- In views use `IntegrationAPIView`, `@maps_errors`, `provider_slug`.

## Add an integration
1. New package `stapel-<name>`; modules named `stpl_<name>_*.py`.
2. A client subclassing `stpl_integrations_net.ApiClient` (pass secrets in `secrets=` so they are redacted).
3. An `IntegrationProvider` with `fields`, `clean`, `build`, `check`; `register_provider()` in `AppConfig.ready()`.
4. Test with `stpl_integrations_testing.FakeTransport`.
Text goes in as Markdown: parse it with `stpl_integrations_markdown.parse` and escape for the target.
