Archive invoices older than 72 hours via Toku

Recipe ToolsMarketingWorkatoDatabaseDeveloper ToolAPI Integration

What it does

When a scheduled time arrives, this automation queries PostgreSQL for invoices older than 72 hours. Each matching invoice is decrypted and deleted through the Toku API.

Who it's for

Accounting teams who need to automatically remove aged invoices from Toku without manual intervention.

Apps used

How teams use this

Remove aged invoices automatically

Run this automation on a schedule to delete invoices older than 72 hours without opening Toku or PostgreSQL. The team no longer needs to manually track which invoices to remove.

Adjust the age threshold

Change the SQL query to delete invoices older than 30 days or 90 days instead of 72 hours. Only the query logic changes, and the rest of the flow stays the same.

Add a condition to skip certain invoices

Include a filter in the SQL query to exclude invoices with a status of pending or flagged so only completed invoices are deleted. This requires adding a where clause to the query.

How it works

  1. Run on a custom schedule. This automation starts at the scheduled time you set, such as daily or weekly.
  2. Find invoices older than 72 hours. Query PostgreSQL with custom SQL to select all invoices with a timestamp more than 72 hours in the past.
  3. Decrypt the invoice ID in Toku. For each invoice found, send a request to the Toku API to decrypt the invoice ID before deletion can proceed.
  4. Delete the invoice from Toku. Send a request to the Toku API to remove each decrypted invoice from the system permanently.