---
title: "Approve invoices with n8n and SignatureAPI"
description: "An n8n workflow that sends an invoice PDF to a manager for approval, then to finance for a sign-off signature, from a webhook your accounting system calls."
canonical: "https://signatureapi.com/docs/integrations/n8n/invoice-approval"
source: "https://signatureapi.com/docs/integrations/n8n/invoice-approval.md"
last_verified_api_version: "1.18.0"
---

# Approve invoices with n8n and SignatureAPI

An n8n workflow that sends an invoice PDF to a manager for approval, then to finance for a sign-off signature, from a webhook your accounting system calls.

_Last verified against API version 1.18.0._

Your accounting system posts an invoice to an n8n webhook. The workflow creates an envelope in which a manager approves the invoice first, then finance signs it off. If either of them rejects it, SignatureAPI sends the `recipient.rejected` event.

![The Invoice approval workflow: New invoice, Build envelope, Create envelope and Respond nodes, with a note that a rejection sends recipient.rejected](https://signatureapi.com/docs/images/captured/n8n/canvas-invoice-approval.webp)

*The Invoice approval workflow*

Every envelope needs at least one signing recipient. An approver alone is not enough, so finance signs the invoice off. See [Approver](https://signatureapi.com/docs/api/resources/recipients/approver).

## Before you start

- The [Header Auth credential](https://signatureapi.com/docs/integrations/n8n#create-the-credential) named `SignatureAPI test key`.
- An invoice PDF at a URL SignatureAPI can fetch: an [upload](https://signatureapi.com/docs/api/resources/uploads/create) URL, or a file on a [supported host](https://signatureapi.com/docs/api/resources/documents/url#external-store).

## How the workflow runs

1. **New invoice** (Webhook) receives the invoice.
2. **Build envelope** (Code) checks the request and builds the envelope body.
3. **Create envelope** (HTTP Request) sends it to `POST /v1/envelopes`.
4. **Respond** (Respond to Webhook) answers with the envelope id, or with the API's error.

For the finished workflow, download [`invoice-approval.json`](https://github.com/signatureapi/examples/blob/main/no-code/n8n/invoice-approval.json) from GitHub and import it into n8n.

## Build it

1. **New invoice: the Webhook node**

   Add a **Webhook** node. Set **HTTP Method** to `POST`, **Path** to `invoice-approval`, and **Respond** to **Using 'Respond to Webhook' Node**.

2. **Build envelope: a Code node**

   Add a **Code** node in **Run Once for All Items** mode:

   ```javascript Build envelope
   // Builds an approval envelope for the invoice your accounting system sends to this webhook.
   // Request body: invoice_number, vendor, amount, currency, pdf_url (a URL SignatureAPI can fetch, such as an upload URL),
   // approver { name, email } who reviews it, and signer { name, email } who signs it off.
   const input = $input.first().json.body;
   for (const field of ['invoice_number', 'vendor', 'amount', 'currency', 'pdf_url']) {
     if (!input?.[field]) throw new Error(`The request needs ${field}`);
   }
   for (const person of ['approver', 'signer']) {
     if (!input[person]?.name || !input[person]?.email) throw new Error(`The request needs ${person}.name and ${person}.email`);
   }

   const envelope = {
     title: `Invoice ${input.invoice_number} from ${input.vendor}: ${input.currency} ${input.amount}`,
     message: 'Please review this invoice.',
     routing: 'sequential', // the approver reviews first; the signer gets it only after approval
     topics: ['invoices'],
     metadata: { invoice_number: String(input.invoice_number) },
     documents: [
       {
         key: 'invoice',
         url: input.pdf_url,
         format: 'pdf',
         places: [{ key: 'signoff', type: 'signature', recipient_key: 'signer' }],
         fixed_positions: [{ place_key: 'signoff', page: 1, top: 680, left: 72 }],
       },
     ],
     recipients: [
       { type: 'approver', key: 'approver', name: input.approver.name, email: input.approver.email },
       { type: 'signer', key: 'signer', name: input.signer.name, email: input.signer.email },
     ],
   };

   return [{ json: { envelope } }];
   ```

   The sign-off place sits on page 1, 680 points from the top and 72 from the left. That is near the bottom-left corner of a Letter or A4 page. Move it to free space on your invoices. See [fixed positions](https://signatureapi.com/docs/api/guides/how-to/use-fixed-positions). The `invoices` topic lets a webhook endpoint receive events for these envelopes only. See [topic filters](https://signatureapi.com/docs/api/webhooks#topic-filters).

3. **Create envelope: the HTTP Request node**

   Add an **HTTP Request** node:

   | Setting            | Value                                                                                          |
   | ------------------ | ---------------------------------------------------------------------------------------------- |
   | Method             | `POST`                                                                                         |
   | URL                | `https://api.signatureapi.com/v1/envelopes`                                                    |
   | Authentication     | Generic Credential Type, **Generic Auth Type** Header Auth, credential `SignatureAPI test key` |
   | Send Body          | On, **Body Content Type** JSON, **Specify Body** Using JSON                                    |
   | JSON               | `{{ JSON.stringify($json.envelope) }}`                                                         |
   | Options > Response | **Include Response Headers and Status** on, **Never Error** on, **Response Format** JSON       |

4. **Respond: the Respond to Webhook node**

   Add a **Respond to Webhook** node. Set **Respond With** to **JSON**, and add the **Response Code** option.

   - **Response Body**: `{{ JSON.stringify($json.statusCode === 201 ? { envelope_id: $json.body.id, status: $json.body.status } : $json.body) }}`
   - **Response Code**: `{{ $json.statusCode === 201 ? 201 : 502 }}`

5. **Activate the workflow**

   Activate (publish) the workflow so `https://<your-n8n>/webhook/invoice-approval` accepts requests.

## Try it

```bash Send an invoice for approval
curl -X POST https://<your-n8n>/webhook/invoice-approval \
  -H 'Content-Type: application/json' \
  -d '{
    "invoice_number": "INV-1001",
    "vendor": "Globex Example Ltd",
    "amount": "4,250.00",
    "currency": "USD",
    "pdf_url": "https://api.signatureapi.com/v1/uploads/upl_3JJz6t1o8A5YjX5VpnX27Z",
    "approver": { "name": "Alex Chen", "email": "alex.chen@example.com" },
    "signer": { "name": "John Smith", "email": "john.smith@example.com" }
  }'
```

```json 201 Created
{ "envelope_id": "eb4cf433-a8af-4161-b37b-7ef57d423e56", "status": "processing" }
```

The envelope becomes `in_progress` with the approver's request sent. The signer gets the invoice only after the approver approves it.

## Make it yours

- **Act on the decision.** Subscribe a second workflow to `envelope.completed` (approved and signed off) and `recipient.rejected` (refused at either step), and update the invoice in your accounting system. `data.envelope_metadata.invoice_number` identifies it in every event. A rejection does not cancel the envelope: [cancel it](https://signatureapi.com/docs/api/resources/envelopes/cancel) from that workflow when a rejected invoice should go no further.
- **Keep the signed invoice.** The [signed PDF workflow](https://signatureapi.com/docs/integrations/n8n/deliverable-on-completion) downloads it with the audit log. Approver actions are not recorded in the audit log; the envelope's [events](https://signatureapi.com/docs/api/resources/events/all) list them.
