@babelforce/manager-sdk
v0.46.0
Published
TypeScript SDK for the babelforce manager APIs — auth, user & agent management, call reporting, metrics, and task automations.
Readme
@babelforce/manager-sdk
TypeScript SDK for the babelforce manager APIs — auth, user & agent management, call reporting, metrics, and task automations.
One client, configured once, exposes resource namespaces over the API. Authentication, paging, and error handling are handled for you.
📖 Docs: https://babelforce.github.io/manager-sdk/
Install
npm install @babelforce/manager-sdkESM-only, ships with types. Node 18+ (for global fetch). There is no CommonJS build — from
CJS, load it with a dynamic import(). Top-level main/types fields are provided as a fallback
so legacy resolvers (TypeScript moduleResolution: "node10", bundlers that predate exports)
still find the entry point and typings.
Usage
import { ManagerClient } from "@babelforce/manager-sdk";
const mgr = await ManagerClient.connect({
auth: { kind: "clientCredentials", clientId, clientSecret }, // or { kind: "password", user, pass }
// baseUrl defaults to https://services.babelforce.com
});
// list users (auto-paginated)
for await (const user of mgr.users.list()) {
console.log(user.email);
}
await mgr.users.create({ email: "[email protected]", roles: [] });
await mgr.users.enable(["[email protected]"]);Authentication
{ kind: "refreshToken", refreshToken, clientId }— a refresh token from the Authorization Code + PKCE flow (helpers:pkceChallenge,buildAuthorizeUrl,authorizationCodeGrant); transparent refresh with rotation. Best for apps acting on behalf of a user.{ kind: "clientCredentials", clientId, clientSecret }— OAuth2 client_credentials grant with transparent refresh, for server-to-server use (credential issuance is in security review — see the Authentication guide).{ kind: "bearer", token }— a token you already hold.{ kind: "password", user, pass }— OAuth2 password grant (legacy) with transparent refresh.
Errors
Non-2xx responses throw a ManagerApiError with status, code, and body. Failed OAuth2 token
grants (e.g. invalid client credentials) throw the same typed error — branch on status/code
instead of the message string.
Custom host
await ManagerClient.connect({
baseUrl: "https://acme.babelforce.com",
auth: { kind: "bearer", token },
});License
Apache-2.0
