Egress Methods
Since Flatfile listeners run in TypeScript/JavaScript environments, you can egress data using any mechanism available in the language ecosystem. This includes direct API calls, file generation, database connections, message queues, or any custom integration pattern your application requires.API Transmission
Send data directly to external systems via HTTP requests to REST APIs, GraphQL endpoints, streaming services, or database APIs. Use any HTTP client library or built-in fetch to POST data to your existing endpoints.File Generation & Download
Build files in any format - CSV, XLSX, XML, JSON, PDF, or custom formats - using the appropriate TypeScript libraries. Generate formatted reports, structured documents, or data exports that users can download directly.File Transfer
Transmit generated files to external destinations like cloud storage, FTP servers, email attachments, or content delivery networks using the corresponding SDK or protocol library.Example: API Egress with Workbook Actions
The following example demonstrates egressing data via HTTP POST when users complete a workbook. This pattern listens for a workbook action and sends the data to an external webhook endpoint.Implementation
The example listener responds toworkbook:submitActionFg
events, retrieves all sheets and records from the workbook, and posts the data to a configured webhook URL. It uses the event.secrets()
method to securely access the destination URL.
Testing with webhook.site
To test this pattern:- Navigate to webhook.site and copy your unique URL
- Add the URL as a Flatfile secret named
WEBHOOK_SITE_URL
- Configure a workbook action in your blueprint to trigger the egress
- The listener will POST the workbook data to your webhook.site URL where you can inspect the payload
Example Projects
Example: File Export with Export Workbook Plugin
For file generation and download, Flatfile provides the Export Workbook Plugin that generates Excel files from workbook data. This plugin handles the entire process of extracting data, formatting it into Excel sheets, and making it available for download.Installation
Implementation
Workbook Configuration
Add a download action to your workbook to trigger the export:Example: Custom XML File Generation
For custom file formats, you can build files programmatically using any TypeScript library. This example demonstrates creating XML files using thexml2js
library to generate structured data exports.