# n8n

The send21 community node for n8n creates payment requests and drafts and reacts to payments with a trigger that verifies the signed webhook. It only prepares payments: the payer signs and sends from their own wallet, and no API key can move funds.

## Install

The node is not on npm yet, so it needs a self-hosted n8n for now. Install it from GitHub in your n8n custom extensions directory, or as a dependency of your n8n install. Once it is on npm, it installs from **Settings, Community nodes** in n8n. Source and README: [n8n-nodes-send21](https://github.com/send21io/n8n-nodes-send21).

```bash
npm install github:send21io/n8n-nodes-send21
```

## Credential

Create an API key at [send21.io/api-keys](https://send21.io/api-keys) and add a **send21** credential in n8n: paste the key only (`s21_...`), without the word Bearer. The scopes `drafts:write` and `webhooks:manage` are enough to create payments and use the trigger; add `drafts:read` to read drafts and their status.

## What the node does

| Node | Operation | API call |
| --- | --- | --- |
| send21 | Payment Request: Create | `POST /api/v1/payment-requests` (with an Idempotency-Key) |
| send21 | Draft: Create | `POST /api/v1/drafts` (with an Idempotency-Key) |
| send21 | Draft: Get | `GET /api/v1/drafts/{id}` |
| send21 | Draft: Get Status | `GET /api/v1/drafts/{id}/status` |
| send21 Trigger | Webhook | Registers `POST /api/v1/webhooks` when the workflow is activated and removes it when deactivated |

## The signed trigger

- Verifies `X-Send21-Signature-V2` on every delivery and refuses deliveries older than 5 minutes; a missing or wrong signature gets 401.
- Suggested events: `draft.confirmed`, `draft.amount_mismatch`, `payment_request.expired` and `draft.expired`.
- It needs a public HTTPS address (n8n Cloud or a tunnel). send21 refuses private and internal callback addresses.
- Prefer the trigger over polling Draft: Get Status. The rate limit is 300 requests a minute per key.

## Two workflow templates

- `invoice-pay-link-confirmed.json`: fills in an invoice, creates a pay link, sends it to the payer, and on a verified `draft.confirmed` marks the order paid; a payment that differs goes to a review path.
- `draft-payout-confirmed.json`: creates a payout draft and records it when a person has signed and sent it and the payment is confirmed.
- Both are in the `workflows` folder of the [repository](https://github.com/send21io/n8n-nodes-send21); import them in n8n.

---
Source: https://send21.io/docs/n8n
