Skip to main content

Sync AWS billing invoices with FreeAgent and PostgreSQL tracking

Workflow preview

Workflow preview
100%
Sync AWS billing invoices with FreeAgent and PostgreSQL tracking preview
Open on n8n.io

1. Workflow Overview

Automatically retrieve AWS invoices and create corresponding bills in FreeAgent, marking them as paid. This workflow eliminates manual data entry for AWS billing. What It Does 1. Fetches invoices f...

Best for

  • Invoice Processing automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.code, n8n-nodes-base.splitinbatches, n8n-nodes-base.postgres, n8n-nodes-base.httprequest, n8n-nodes-base.if, n8n-nodes-base.stickynote, n8n-nodes-base.scheduletrigger

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Pernille-AI.

Original n8n.io source

1.1 Workflow description

Title
Sync AWS billing invoices with FreeAgent and PostgreSQL tracking
Workflow name
Sync AWS billing invoices with FreeAgent and PostgreSQL tracking

Automatically retrieve AWS invoices and create corresponding bills in FreeAgent, marking them as paid. This workflow eliminates manual data entry for AWS billing.

What It Does

  1. Fetches invoices from AWS Invoicing API for the previous month
  2. Filters invoices by issue date to ensure only new ones are processed
  3. Checks PostgreSQL database for previously processed invoices
  4. Creates a bill in FreeAgent with correct dates and amounts
  5. Marks the bill as paid with a bank transaction explanation
  6. Records the invoice in the database to prevent future duplication

Prerequisites

  • AWS account with Invoicing API access
  • FreeAgent account with OAuth API access
  • PostgreSQL database (you could modify to use n8n Data Table?)
  • AWS IAM user with invoicing:ListInvoiceSummaries permission

Quick Setup Checklist

  • Create PostgreSQL table (see below)
  • Add PostgreSQL credentials in n8n
  • Set up FreeAgent OAuth2 credentials
  • Update AWS access key and secret key in "Generate AWS Signature" node
  • Update AWS account ID in "Calculate Last Month" node
  • Get and update FreeAgent contact ID for AWS
  • Get and update FreeAgent category ID (cloud services/hosting)
  • Get and update FreeAgent bank account ID

Configuration Required

This template has placeholders that you need to replace:

In Code Nodes

  • YOUR_AWS_ACCESS_KEY_ID - Your AWS access key
  • YOUR_AWS_SECRET_ACCESS_KEY - Your AWS secret key
  • YOUR_AWS_ACCOUNT_ID - Your 12-digit AWS account number
  • YOUR_CONTACT_ID - FreeAgent contact ID for AWS
  • YOUR_CATEGORY_ID - FreeAgent category for cloud services
  • YOUR_BANK_ACCOUNT_ID - FreeAgent bank account for payments

Credentials to Add

  • PostgreSQL database credentials (3 nodes)
  • FreeAgent OAuth2 credentials (2 nodes)

Use Cases

  • Freelancers & Consultants: Automatically track AWS infrastructure costs
  • Small Businesses: Streamline bookkeeping for cloud expenses
  • Agencies: Manage multiple AWS accounts with separate workflows
  • Accountants: Reduce manual data entry for client AWS bills

Database Schema

The workflow uses a PostgreSQL table to track processed invoices - To initially create the table you need to run :

CREATE TABLE aws_invoices_processed (
 id SERIAL PRIMARY KEY,
 aws_invoice_id VARCHAR(255) UNIQUE NOT NULL,
 freeagent_invoice_url TEXT NOT NULL,
 billing_period VARCHAR(7) NOT NULL,
 amount DECIMAL(10, 2) NOT NULL,
 currency VARCHAR(3) NOT NULL,
 processed_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

Customization

  • VAT Rate: Default is 20% (UK), adjust in "Prepare FreeAgent Bill" node
  • Schedule: Modify cron expression in "Schedule Trigger" node
  • Description Format: Customize invoice description in code nodes
  • Multi-Account: Duplicate workflow for each AWS account

Notes

  • AWS dates are reversed: DueDate is earlier than IssuedDate, so the workflow swaps these
  • All amounts are processed in the currency specified by AWS
  • The "DELETE Test Record" node is disabled by default - use for testing only

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Generate AWS Signature

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 2 - Parse AWS Response

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 3 - Filter By Date

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 4 - Loop Over Invoices

Type / Role
n8n-nodes-base.splitInBatches - splitInBatches
Config choices
Version 3

Block 5 - Check If Already Processed

Type / Role
n8n-nodes-base.postgres - postgres
Config choices
Version 2.4

Block 6 - Record In PostgreSQL

Type / Role
n8n-nodes-base.postgres - postgres
Config choices
Version 2.4

Block 7 - Create FreeAgent Bill

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 8 - If New Invoice

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 9 - Prepare FreeAgent Bill

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 10 - Mark Bill as Paid

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 11 - Prepare Payment

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 12 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 13 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 14 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 15 - Workflow Overview

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 16 - Calculate Last Month Date Range

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 17 - Call AWS For Bills

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 18 - Trigger Monthly

Type / Role
n8n-nodes-base.scheduleTrigger - scheduleTrigger
Config choices
Version 1.3

3. Summary Table

Workflow Sync AWS billing invoices with FreeAgent and PostgreSQL tracking
Complexity advanced
Nodes 18
Categories Invoice Processing
Author Pernille-AI
Published 06 Jan 2026

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/12524/12524.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Sync AWS billing invoices with FreeAgent and PostgreSQL tracking do?

Automatically retrieve AWS invoices and create corresponding bills in FreeAgent, marking them as paid. This workflow eliminates manual data entry for AWS billing. What It Does 1. Fetches invoices f...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Invoice Processing use case.