Mailan
Sign in

Node.js.

The official client wraps both halves of the API: sending a submission, and reading forms and submissions back. No runtime dependencies — Node 18 and up brings everything it needs.

Installation

bash

TypeScript types are included, and the package ships as both ESM and CommonJS — „import" and „require" both work.

Sending a submission

No API key needed here: the form's access key is the credential. The second argument holds your own fields, the third the values that steer the notification mail instead of being stored.

JavaScript

File uploads

With files the client switches to multipart by itself. „fileFromPath" reads from disk; where there is no file system, hand over the bytes directly.

JavaScript

Forms with a captcha

The client solves the ALTCHA proof of work by itself. By default it only does so after the server rejected the first attempt for a failed captcha — that saves the computation on the majority of forms that need none. „captcha: true" solves up front and saves a round trip.

JavaScript

Reading forms and submissions

This half does need an API key — create one in the dashboard under „API keys". „iterate" follows the cursor across all pages and stops fetching as soon as you leave the loop.

JavaScript

Errors

Every failure is a typed error, so there is no need to read status codes by hand. Note that submissions are never retried automatically: a request that timed out may still have been stored, and a retry would duplicate it. Reads are retried.

JavaScript

Your own instance

Point the client at your own installation — everything else stays identical.

JavaScript