@sendmux/core
v1.2.0
Published
[](https://www.npmjs.com/package/@sendmux/core) [](https://github.com/Sendmux/sendmux-sdk/actions/workflows/ci.yml)
Readme
@sendmux/core
Shared runtime helpers and public types for the Sendmux TypeScript SDK packages.
Documentation
- Sendmux docs: sendmux.ai/docs
- Source repository: Sendmux/sendmux-sdk
Requirements
- A JavaScript runtime with the standard Fetch API.
- A surface package such as
@sendmux/sending,@sendmux/mailbox, or@sendmux/managementfor API operations.
Installation
npm install @sendmux/coreUsage
Validate a key prefix and prepare request headers before calling a surface package.
import {
assertApiKeyKind,
conditionalHeaders,
idempotencyHeaders,
} from "@sendmux/core";
assertApiKeyKind(process.env.SENDMUX_MAILBOX_API_KEY!, "mailbox");
const headers = {
...idempotencyHeaders("idem_123"),
...conditionalHeaders({ ifNoneMatch: 'W/"etag"' }),
};Helpers
assertApiKeyKindvalidatessmx_root_*prefixes for root clients, send-capablesmx_mbx_*prefixes or owner-approved Sending-resourcesmx_agent_*tokens for Sending clients, and mailbox-compatiblesmx_mbx_*orsmx_agent_*prefixes for Mailbox clients.paginateiterates cursor-paginated Sendmux list responses.idempotencyHeaders,conditionalHeaders, andresponseEtagcover idempotency and conditional requests.createRetryingFetchretries safe requests and idempotentPOSTrequests with replayable bodies. It honoursretryable: falseand server retry delays; when a delay exceeds the configured deadline or runtime limit, it returns the response instead of retrying early.SendmuxApiError,mapApiError, andcreateErrorInterceptornormalise API errors.
Support
Open an issue in Sendmux/sendmux-sdk with the package name and version.
Licence
MIT. See the licence file.
