SDK installation
The Driftstack SDKs share a typed surface generated from the same OpenAPI 3.1 contract. Pick the language that fits your stack.
TypeScript / Node.js
Status: published on npm. Pre-1.0 — the API contract is stable but the SDK shape may shift before 1.0. Don’t pin to an exact version yet.
Install:
npm install @driftstack/sdk
# or
pnpm add @driftstack/sdk
# or
yarn add @driftstack/sdk
Requirements: Node.js ≥ 18 (uses native fetch). Works in any modern runtime exposing fetch and node:crypto (Bun, Deno via npm specifier).
Configure:
import { Driftstack } from '@driftstack/sdk';
const client = new Driftstack({
apiKey: process.env.DRIFTSTACK_API_KEY!,
baseUrl: 'https://api.driftstack.dev', // optional override
timeoutMs: 30_000,
retry: {
maxAttempts: 3,
initialDelayMs: 250,
maxDelayMs: 8_000,
},
});
Resources (every method is fully typed):
client.sessions.create(body?);
client.sessions.list(query?);
client.sessions.navigate(id, body);
client.sessions.interact(id, body);
client.sessions.wait(id, body);
client.sessions.getState(id);
client.sessions.capture(id, body);
client.sessions.destroy(id);
client.profiles.create(body);
client.profiles.list(query?);
client.profiles.get(id);
client.profiles.delete(id);
client.apiKeys.create(body); // requires admin scope
client.apiKeys.list();
client.apiKeys.rotate(id); // V-296: 24-hour grace on prior key
client.apiKeys.revoke(id); // requires admin scope
client.webhooks.create(body);
client.webhooks.list();
client.webhooks.get(id);
client.webhooks.update(id, body); // V-464 partial update
client.webhooks.delete(id);
client.webhooks.listDeliveries(webhookId, query?);
client.webhooks.iterateDeliveries(webhookId, opts?);
client.webhooks.replayDelivery(deliveryId); // V-307
client.webhooks.rotateSecret(id); // V-359 24h grace dual-sign
client.webhooks.sendTest(id); // V-356 synthetic test.ping
client.auth.cliAuthorizeInitiate(body); // V-460 CLI/GUI activation
client.auth.cliAuthorizeBind(body);
client.auth.cliAuthorizeExchange(body);
client.auth.mfaChallenge(body); // V-353d login MFA exchange
client.auth.mfaStepUp(body); // V-353e step-up freshness
client.auditLog.list(query?);
client.auditLog.iterate(opts?);
client.auditLog.export(); // V-462 GDPR Article 20 JSON
client.legal.documents();
client.legal.required();
client.legal.accept(body);
client.mfa.status();
client.mfa.enroll();
client.mfa.verify(body);
client.mfa.disable();
client.mfa.regenerateRecoveryCodes();
client.team.invite(email, opts?); // V-298
client.team.listMembers();
client.team.listInvites();
client.team.acceptInvite(token);
client.team.removeMember(membershipId);
client.usage.current();
client.account.me();
Errors: every error extends DriftstackError. Catch the base for blanket handling, or specific subclasses (RateLimitError, ConcurrencyLimitError, ValidationError, AuthError) for granular logic.
Python
Status: alpha. The SDK is built, tested, and wheel-buildable. The first PyPI release tags shortly after launch verification.
Install (when published):
pip install driftstack-sdk
The dist name is driftstack-sdk; the import name is driftstack.
Requirements: Python 3.10+.
Configure (sync):
import os
from driftstack import Driftstack
with Driftstack(api_key=os.environ["DRIFTSTACK_API_KEY"]) as client:
me = client.account.me()
print(me.email)
Configure (async):
import asyncio
import os
from driftstack import AsyncDriftstack
async def main():
async with AsyncDriftstack(api_key=os.environ["DRIFTSTACK_API_KEY"]) as client:
me = await client.account.me()
print(me.email)
asyncio.run(main())
Resources:
| Accessor | Methods |
|---|---|
client.sessions | create, list, get, navigate, interact, wait, get_state, capture, destroy |
client.profiles | create, list, get, delete |
client.api_keys | create, list, rotate (V-296), revoke |
client.usage | current_period |
client.webhooks | create, list, get, update (V-464), delete, list_deliveries, iterate_deliveries, replay_delivery (V-307), rotate_secret (V-359), send_test (V-463) |
client.team | invite, list_members, list_invites, accept_invite, remove_member (V-298) |
client.account | me, update_me, upload_avatar, clear_avatar, list_web_sessions, revoke_web_session, revoke_all_other_web_sessions, rate_limits |
client.auth | cli_authorize_initiate / bind / exchange (V-460), mfa_challenge (V-353d), mfa_step_up (V-353e), plus signup / login / logout / refresh / magic-link / reset |
client.audit_log | list, iterate, export (V-462) |
client.mfa | status, enroll, verify, disable, regenerate_recovery_codes (V-353b) |
client.email_preferences | list, set, opt_in, opt_out (V-204) |
client.legal | documents, required, accept (V-049 / V-458) |
client.profile_snapshots | capture, list_for_profile, list, iterate, get, restore, delete (V-312) |
Inputs accept either a Pydantic model OR a plain dict. Outputs are typed Pydantic models.
Go
Status: alpha. Builds, tests pass, examples compile. The first tagged release lands shortly after launch verification.
Install:
go get github.com/driftstackdev/driftstack-api/packages/sdk-go
Requirements: Go 1.21+ (any version supporting errors.As and context.Cancel* patterns).
Configure:
package main
import (
"context"
"log"
"os"
driftstack "github.com/driftstackdev/driftstack-api/packages/sdk-go"
)
func main() {
client := driftstack.New(os.Getenv("DRIFTSTACK_API_KEY"))
defer client.Close()
ctx := context.Background()
me, err := client.Account.Me(ctx)
if err != nil {
log.Fatal(err)
}
log.Println(me.Email)
}
The Go SDK is single-package, has zero non-stdlib runtime dependencies, and is context-aware throughout.
Versioning across SDKs
The HTTP API and the SDKs version independently. SDKs at any version stay compatible with the live API contract; SDK upgrades unlock newer fields and new resource methods, but won’t break older method calls. See SDK versioning policy for the full guarantee.
What ships
| Capability | TS | Python | Go | Notes |
|---|---|---|---|---|
| Sessions | ✅ | ✅ | ✅ | Full CRUD + navigate/interact/wait |
| Profiles | ✅ | ✅ | ✅ | Create, list, get, delete |
| API keys | ✅ | ✅ | ✅ | Includes rotate with 24h grace (V-296) |
| Webhooks | ✅ | ✅ | ✅ | CRUD + delivery introspection + replayDelivery (V-307) |
| Team RBAC | ✅ | ✅ | ✅ | Invite/accept/list/remove (V-298) |
| Usage | ✅ | ✅ | ✅ | Current-period read |
| Account self | ✅ | ✅ | ✅ | me returns tier + concurrent + profile counts |
Next steps
- Quickstart — first session in under five minutes.
- Profile management — persistent profiles across sessions.
- Session lifecycle — full state diagram and recovery semantics.