Dazl Internal API Client
Type-safe SDK for Dazl Internal APIs, generated from OpenAPI specifications.
Installation
npm install @dazl/api-client
Usage
Create a client instance with createClient and pass it to every API call:
import { createClient } from '@dazl/api-client/internal/fetch-client';
import { Billing } from '@dazl/api-client/internal';
const client = createClient({
baseUrl: 'http://api-server-url/private',
headers: {
'x-api-key': 'my-secret-api-key',
},
});
const customerInfoRes = await Billing.getCustomerInfoByDazlId({
path: { dazlId: 'USER_DAZL_ID' },
client,
});
if (customerInfoRes.error) {
throw new Error(customerInfoRes.error.message);
}
const customerInfo = customerInfoRes.data;
Acting on behalf of a user
The recommended pattern is to create a per-request client with the x-user-id header baked in, and store it on the request context:
// middleware — runs once per request
const userClient = createClient({
baseUrl: 'http://api-server-url/private',
headers: {
'x-api-key': 'my-secret-api-key',
'x-user-id': context.userId, // userId from the authenticated request
},
});
context.apiClient = userClient;
// handler — no need to pass headers each time
const customerInfoRes = await Billing.getCustomerInfoByDazlId({
path: { dazlId: 'USER_DAZL_ID' },
client: context.apiClient,
});
Related Docs
Additional client fetch documentation can be found here: https://heyapi.dev/openapi-ts/clients/fetch
Major messaging compatibility
The generated WorkspaceMailbox, ChatInbox, and MajorConversation clients include additive
reply correlation, sender-only Retry eligibility/creation, and appendMajorIncoming. Generate
with npm run update:sdk:local from the repository root. Generated sources under sdk/src/ are
build outputs, as for the other API contracts.
Deploy the additive migration and API first, publish the regenerated SDK, then update the dazl
SDK dependency before deploying its caller. getWorkspaceMessagingCapabilities distinguishes
support from older servers; a failed check is unknown. Receipt responses remain status-only.
appendMajorIncoming accepts only the incoming mailbox identity, derives its content and owner
on the server, and preserves the destination conversation's title and retention timestamp.