Hwip Docs
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

FieldTypeDescription
apiKeystringRequired. API key from Hwip settings
baseUrlstring?API base URL (default: https://api.hwip.app/v1)
timeoutnumber?Request timeout in milliseconds (default: 30000)

Notify payload

FieldTypeDescription
titlestring?Push title
bodystring?Push body
urlstring?URL to include
type'note' | 'link' | 'file' | 'hook'?Push type (default: hook)
priority'low' | 'normal' | 'high' | 'urgent'?Priority (default: normal)
targetDeviceIdstring?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:

codeMeaning
NO_APP_DEVICENo app is signed in to the account, so nothing could read the push
E2E_REQUIREDAn 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 */ }
}

On this page