@sendmux/management
v2.0.2
Published
[](https://www.npmjs.com/package/@sendmux/management) [](https://github.com/Sendmux/sendmux-sdk/actions/workf
Readme
@sendmux/management
Generated TypeScript client for the Sendmux Management API.
Documentation
- Management API reference: sendmux.ai/docs/api/introduction
- Source repository: Sendmux/sendmux-sdk
Requirements
- A root Sendmux API key with the
smx_root_*prefix; alternatively, a REST OAuth grant for this surface. - A JavaScript runtime with the standard Fetch API.
Installation
npm install @sendmux/managementMigrate from 1.x to 2.0
If you pass sending-account list entries to code that expects a detail result,
update those types before upgrading to 2.0. managementListProviders returns
ProviderListItem entries without variables; managementGetProvider returns
a ProviderItem with required variables. A list entry no longer satisfies the
detail type.
Derive separate list and detail types from the public operations. The package doesn't export these generated model names directly:
import { managementGetProvider, managementListProviders, } from "@sendmux/management"; type ProviderListItem = NonNullable< Awaited<ReturnType<typeof managementListProviders>>["data"] >["data"][number]; type ProviderItem = NonNullable< Awaited<ReturnType<typeof managementGetProvider>>["data"] >["data"];For code that only needs list fields, replace the detail annotation with the list type:
// Before: type ProviderRow = ProviderItem; type ProviderRow = ProviderListItem;If you need
variables, fetch the detail withmanagementGetProviderusing the account'sidaspath.public_id. Don't cast a list entry toProviderItemor add an emptyvariablesobject to stand in for the account's actual variables.Run your application's TypeScript check. List-only code should accept
ProviderListItem; code that readsvariablesmust receive a detail result.
OAuth access tokens
Pass accessToken instead of apiKey for a REST OAuth token or synchronous/asynchronous provider.
import { createManagementClient } from "@sendmux/management";
const client = createManagementClient({
accessToken: () => process.env.SENDMUX_ACCESS_TOKEN!,
});The provider runs before each request. Your application owns token storage and refresh; required scopes still apply. See OAuth setup.
Usage
import {
createManagementClient,
managementListDomains,
} from "@sendmux/management";
const client = createManagementClient({
apiKey: process.env.SENDMUX_API_KEY!,
});
const domains = await managementListDomains({ client });
console.log(domains.data);The package exports every generated Management operation plus:
createManagementClientconfigureManagementManagementClient
Conditional requests
Use conditionalHeaders from @sendmux/core for operations that accept If-Match or If-None-Match.
import { conditionalHeaders } from "@sendmux/core";
import {
createManagementClient,
managementGetDomain,
} from "@sendmux/management";
const client = createManagementClient({
apiKey: process.env.SENDMUX_API_KEY!,
});
const domain = await managementGetDomain({
client,
path: { public_id: "mdom_123" },
headers: { ...conditionalHeaders({ ifNoneMatch: 'W/"etag"' }) },
});
console.log(domain.data);Support
Open an issue in Sendmux/sendmux-sdk with the package name, version, and request ID from any API error.
Licence
MIT. See the licence file.
