# `@horamatch/sdk`

Typed, dependency-free client for HoraMatch API v1. Keep API keys on the server;
never ship them in browser JavaScript.

Install the versioned package served by HoraMatch:

```bash
npm install https://horamatch.com/downloads/horamatch-sdk-0.1.1.tgz
```

```ts
import { HoraMatch } from '@horamatch/sdk';

const horamatch = new HoraMatch({ apiKey: process.env.HORAMATCH_API_KEY! });
const { data: eventTypes } = await horamatch.eventTypes.list();
const { data: availability } = await horamatch.availability.list(eventTypes[0].id, {
  from: '2026-09-01T00:00:00Z',
  to: '2026-09-08T00:00:00Z',
});
const booking = await horamatch.bookings.create({
  eventTypeId: eventTypes[0].id,
  startsAt: availability.slots[0].startsAt,
  guest: { name: 'Ada Lovelace', email: 'ada@example.com', timezone: 'Europe/London' },
}, { idempotencyKey: 'order_01K4HORAMATCH001' });
```

Cloudflare Workers can inject a Service Binding-compatible `fetch` implementation.
Mutations require an idempotency key and are retried only with the exact same body.

Verify webhooks against the raw request body:

```ts
import { verifyWebhook } from '@horamatch/sdk';

const event = await verifyWebhook({
  payload: await request.text(),
  headers: request.headers,
  secret: env.HORAMATCH_WEBHOOK_SECRET,
});
```
