# Node SDK

Typed resources, automatic idempotency, retries, pagination, uploads and webhook verification.


## Install {#install}

```bash
npm install @monoclan/node
```

```ts
import Sendforsign from '@monoclan/node';

const sfs = new Sendforsign(process.env.SENDFORSIGN_KEY!, { apiUrl: 'https://api2.sendforsign.com' });
```

## Resources {#resources}

| Resource | Methods |
| --- | --- |
| `documents` | `create`, `retrieve`, `update`, `delete`, `list`, `all`, `send`, `remind`, `void`, `content`, `editContent`, `pdf`, `docx`, `auditTrail`, `parties.add/update/remove` |
| `files` | `create`, `retrieve`, `list`, `content` |
| `templates` | `create`, `retrieve`, `update`, `list`, `createVersion`, `archive` |
| `sessions` | `create` |
| `webhookEndpoints` | `create`, `retrieve`, `update`, `delete`, `list`, `deliveries`, `retryDelivery` |
| `events`, `tenants`, `apiKeys`, `account` | list and manage |

## Behaviour {#behaviour}

- Every `POST` gets an idempotency key. Network errors, 429 and 5xx are retried with backoff, and so is a 409 while the same idempotent request is still in progress; a retry reuses the key.
- Errors are `MonoclanError` with `status`, `type`, `code`, `param` and `requestId`.
- `all()` iterates every page: `for await (const d of sfs.documents.all({ status: 'open' })) …`.
- `constructEvent(body, header, secret)` verifies a webhook and returns the event.
