CLI & SDK
SDK
Send pushes from your own code with the HwipHook client.
HwipHook is the programmatic half of @hwip/cli. It uses native fetch and has no runtime
dependencies.
import { HwipHook } from '@hwip/cli';
const hook = new HwipHook({ apiKey: 'ak_...' });
// Notify
const result = await hook.notify({
title: 'Build Complete',
body: 'Deploy succeeded',
url: 'https://example.com/deploy/123',
priority: 'high',
});
console.log(result.pushId); // 'push_01JXY...'
// List
const list = await hook.list({ limit: 5 });
console.log(list.pushes);
// Dismiss
await hook.dismiss('push_01JXY...');
await hook.dismissAll();Constructor options
| Field | Type | Description |
|---|---|---|
apiKey | string | Required. API key from Hwip settings |
baseUrl | string? | API base URL (default: https://api.hwip.app/v1) |
timeout | number? | Request timeout in milliseconds (default: 30000) |
Notify payload
| Field | Type | Description |
|---|---|---|
title | string? | Push title |
body | string? | Push body |
url | string? | URL to include |
type | 'note' | 'link' | 'file' | 'hook'? | Push type (default: hook) |
priority | 'low' | 'normal' | 'high' | 'urgent'? | Priority (default: normal) |
targetDeviceId | string? | Send to a specific device |
Sealing
notify seals the push on your machine before sending, the same way the CLI does (see
Encryption). There is no plaintext fallback. When the push cannot be sent sealed,
it throws an HwipError instead:
code | Meaning |
|---|---|
NO_APP_DEVICE | No app is signed in to the account, so nothing could read the push |
E2E_REQUIRED | An app is signed in, but this send could not be sealed (the device list did not load, keys did not load, no device lists a key) |
Error handling
import { HwipHook, AuthenticationError, QuotaExceededError, HwipError } from '@hwip/cli';
try {
await hook.notify({ title: 'Hello' });
} catch (err) {
if (err instanceof AuthenticationError) { /* Invalid API key */ }
if (err instanceof QuotaExceededError) { /* Limit reached */ }
if (err instanceof HwipError) { /* Other API error; see err.code */ }
}