Primitive Functions API
Deploy JavaScript handlers that run on inbound mail. Each function is a single ESM module whose default export is an object with an async `fetch(request, env)` method, in the shape of a Workers-style handler. Primitive signs each delivery and forwards the `Primitive-Signature` header to the handler; verify the raw request body with `PRIMITIVE_WEBHOOK_SECRET` before trusting the parsed event. The `event` field is `email.received` for normal inbound mail, or a machine-mail type (`email.bounced`, `email.tls_report`, `email.dmarc_report`, `email.dmarc_failure`) for bounces and reports; the payload shape is otherwise identical. Code runs on Primitive's edge runtime; there is no infrastructure to manage. Secrets land in `env` as encrypted bindings and are refreshed on every redeploy.