SDK Guide
Use the official SDKs to call Sammati from your backend or browser. HTTP shapes follow the API Reference.
Packages
| Package | Role | Availability |
|---|---|---|
@sammati/server-sdk | Backend HTTP client (recommended) | npm |
@sammati/widget-sdk | Browser iframe + postMessage — Widget Guide | npm |
@sammati/webhook-utils | Webhook HMAC verification — Webhooks | npm |
@sammati/cli | Terminal client — CLI | Available on request |
sammati (Python) | Minimal Python client | Available on request |
@sammati/shared-core is a shared dependency. You normally get it transitively with the Node packages.
For production integrations, use the three npm packages below. CLI and Python are provided on request until they are published to public registries.
Installation
Install the server SDK:
npm install @sammati/server-sdk
For the hosted widget and webhook verification:
npm install @sammati/widget-sdk @sammati/webhook-utils
You can also copy the install command from Developer → SDK in the Company Portal.
Create a client
import { SammatiClient } from "@sammati/server-sdk";
const client = new SammatiClient({
apiKey: process.env.SAMMATI_API_KEY!,
environment: "test", // must match smm_test_ vs smm_live_ prefix
baseUrl: process.env.SAMMATI_BASE_URL, // optional; defaults to production API
});
createSammatiClient(options) returns the same client.
Additional tools (on request)
CLI and Python clients call the same integrator API. Contact Sammati support or your account team to receive them. Command overview: CLI.
When these packages are published publicly, this guide will list the standard npm / pip install commands.
Services
APIs are grouped by domain on the Node client:
| Service | Covers |
|---|---|
client.consents | Grant, update, revoke, status, feed |
client.policies | Draft, publish, versions |
client.proofs | Proofs and verification |
client.anchors | Timestamp / anchor metadata |
client.audit | Auditor comparison helpers |
client.webhooks | Endpoints, test delivery, rotation |
client.widget | Sessions and hosted widget |
Full operation list: API Reference
Configuration
| Option | Purpose |
|---|---|
apiKey | Bearer token (smm_test_* or smm_live_*) |
environment | "test" or "live" — must match the key prefix |
baseUrl | API origin (for example your staging API host) |
timeoutMs | Per-request timeout |
retry | Retry policy for safe requests |
transport | Custom fetch / mock for tests |
apiKeyProvider | Async key rotation without recreating the client |
Retries
The SDK retries safe requests on transient failures (NetworkError, RateLimitError, ServerError, TimeoutError). Writes with an explicit Idempotency-Key may retry; other POSTs are limited.
Configure with retry: { maxAttempts, baseDelayMs, maxDelayMs, jitterRatio }.
Errors
Typed errors extend SammatiError: AuthenticationError, ValidationError, RateLimitError, ConflictError, NotFoundError, ServerError, NetworkError, TimeoutError.
Each includes HTTP status, message, requestId, and parsed details from the API body.
Pagination
List endpoints return cursor pages. Pass limit and cursor on list methods. Examples: listConsentRecords, listPolicyVersions, listWebhookEndpoints.
Webhook helpers
From @sammati/webhook-utils (also re-exported by the server SDK):
verifyWebhookSignature()/verifyWebhookDelivery()parseWebhookEvent()computeWebhookSignature()(for tests)client.webhooks.testEndpoint()— queue a sample delivery
Details: Webhooks
Examples
Runnable TypeScript samples ship with @sammati/server-sdk (grant, revoke, policy, webhooks, proofs). On the docs site, see SDK examples.