...
See the new Filestack Workflows 2.0 in action with our sales engineer. Book a Walkthrough
We are aware of the recently disclosed PHP2Shell vulnerabilities (CVE-2026-109618 and CVE-2026-109619) and can confirm Filestack is not impacted by these vulnerabilities.

Digital Mailroom Automation, From Envelope to Inbox

Digital mailroom automation with Filestack reads the sender and recipient off every scanned envelope and routes each item to the right person.

Redfern, a fictional mailroom built on FilestackOpen
The Redfern demo home page, a virtual mailroom offering to open, scan, route and index a business's post the morning it arrives.
Sample envelope_ocr response
{
  "recipient_name": "Tomasz Wisniewski",
  "recipient_address": {
    "text": "Tomasz Wisniewski\\n1200 Commerce St #2045\\nTacoma, WA 98402"
  },
  "sender": "A. Wisniewska\\n19 Birch Hollow Rd\\nBend, OR 97701"
}
Use case

Redfern is a fictional company. It was made up to show how Filestack works in mail and document services, so the firm, its people and its figures are invented.

Live Filestack API

What powers it is real. Every upload, Envelope OCR read, document detection and OCR pass in Redfern is a real call to the Filestack API.

View source on GitHub

What Is Digital Mailroom Automation?

Digital mailroom automation turns incoming post into routed, searchable digital mail. Each envelope is scanned, its sender and recipient are read, and the item goes to the named person, with the contents indexed for search. Filestack’s envelope_ocr task returns the sender, recipient name and recipient address as named fields, so routing becomes a directory lookup.

Two Ways to Route a Scanned Envelope

Read by staff

  1. Scan Each envelope photographed
  2. Staff read it Name and box number typed in
  3. Mailbox Filed by hand

Read by Filestack

  1. Upload The scan lands in Filestack
  2. envelope_ocr Sender and recipient as fields
  3. Directory match Routed to the named person
Tasks
envelope_ocr, doc_detection and ocr
Input
Scans and phone photos of envelopes and letters
Envelope fields
sender, recipient_name and recipient_address
Contents
Straightened by doc_detection, read by ocr for full-text search
Access
Each read carries a policy signed with your app secret
Trigger
The fp.upload webhook, or a Workflow on every upload
Plans
Envelope OCR, OCR and document detection on paid plans. Pricing
Demo source
Redfern, a Next.js app. View on GitHub

One Signed URL Reads the Envelope

To read an envelope with Filestack, put envelope_ocr in a signed CDN URL in front of the scan’s handle. The response names each part of the address block, so your code works with fields instead of positions on the page.

  1. cdn.filestackcontent.comThe Filestack CDN
  2. security=p:POLICY,s:SIGNATUREA policy your server signs, scoped to one handle
  3. envelope_ocrReads the envelope
  4. Jg9vWLjTB6ky5UPUHGKRThe scan's handle, a sample
recipient_name
Matched against the staff directory to choose a mailbox.
recipient_address.text
The full recipient block, with the box or suite number that confirms the match.
sender
Stored with the item, so post is searchable by who sent it.
Empty fields
A scan that is not an envelope returns every field empty, and the item goes to review.
Sample envelope_ocr response
{
  "recipient_address": {
    "text": "Tomasz Wisniewski\\n1200 Commerce St #2045\\nTacoma, WA 98402"
  },
  "recipient_name": "Tomasz Wisniewski",
  "sender": "A. Wisniewska\\n19 Birch Hollow Rd\\nBend, OR 97701"
}

Inside Redfern, a Mailroom Built on Filestack

Redfern is a demo virtual mailroom built on Filestack and Next.js. The firm is invented and every file call is real: scans upload from the browser, a server route signs each read, envelope_ocr routes the item, and the contents are indexed.


  1. File Picker uploads a batch of envelope scans from the browser straight to Filestack storage. Each file comes back with a handle, the one value the app stores.


  2. envelope_ocr, ocr and doc_detection run on signed requests. A server route signs a policy for one handle with read and convert, valid for ten minutes, and signs only the tasks on its allowlist.


  3. The app matches recipient_name against the staff directory, on the full name first and then the surname. A match files the item to that person's inbox, and every other item waits in a supervisor's queue.


  4. The letter inside takes a two-task chain in one URL. doc_detection finds the page in the photo and flattens it, then ocr reads the flattened page, and its text field feeds the search index.

upload.js
const client = filestack.init('YOUR_API_KEY');

client.picker({
  accept: ['image/*'],
  maxFiles: 50,
  onUploadDone: ({ filesUploaded }) => {
    filesUploaded.forEach((file) => readEnvelope(file.handle));
  },
}).open();
sign.js
import { createHmac } from 'node:crypto';

export function signedUrl(handle, tasks) {
  const expiry = Math.floor(Date.now() / 1000) + 600;
  const policy = Buffer.from(JSON.stringify({ call: ['read', 'convert'], handle, expiry }))
    .toString('base64').replace(/\\+/g, '-').replace(/\\//g, '_');
  const signature = createHmac('sha256', process.env.FILESTACK_APP_SECRET)
    .update(policy).digest('hex');
  return `https://cdn.filestackcontent.com/security=p:${policy},s:${signature}/${tasks.join('/')}/${handle}`;
}
route.js
const res = await fetch(signedUrl(handle, ['envelope_ocr']));
const { sender, recipient_name } = await res.json();

const person =
  DIRECTORY.find((p) => recipient_name?.includes(p.name)) ??
  DIRECTORY.find((p) => recipient_name?.includes(p.surname));

await saveItem(handle, person
  ? { to: person.id, sender }
  : { queue: 'review', sender });
index.js
const res = await fetch(signedUrl(handle, [
  'doc_detection=coords:false,preprocess:true',
  'ocr',
]));
const { text } = await res.json();

await searchIndex.add({ handle, text });

What a Digital Mailroom Needs to Route Post

A digital mailroom needs scan intake, storage, an address reader, deskewing for photographed letters, full-text indexing and a review queue. Filestack hosts the files and returns the address block as fields, and your app keeps the directory and the queue.

Build It In-House

6 parts your team builds and runs
01 Scan intake and file storage
02 An OCR engine for envelopes and letters
03 A parser that finds the recipient block on every layout
04 Deskewing for photographed pages
05 Queues and retries for each morning’s batch
06 Signed access to every scan

Read It With Filestack

1 signed URL per envelope, with storage hosted
Envelope read
https://cdn.filestackcontent.com/security=p:POLICY,s:SIGNATURE/envelope_ocr/HANDLE

Your app keeps the directory match and the review queue.

Tour the Redfern Mailroom

Upload envelope scans on the Redfern demo page, then sign in as staff to see each item routed to a desk or held for a supervisor.

  1. 1

    The firm's site /

    How a letter reaches the team: it arrives, the envelope is read, and it lands in the right inbox.

  2. 2

    This morning's post /demo

    Upload envelope photos. Each one is read, and the recipient is matched against the staff list.

  3. 3

    Staff sign-in /login

    Pick a name to sign in. The login is emulated for the demo.

  4. 4

    The sorting floor /admin

    Every scanned item appears with what was read off it, and unmatched items wait for a supervisor.

Open Redfern in your browser and follow the route, or read the Next.js code it runs.

Redfern home page
Redfern's How a letter reaches your team section: it arrives here, we read the envelope, it lands in the right inbox.
Redfern's home page sets out the three steps its demo runs on the Filestack API.

Run the Mailroom on Upload Webhooks

To read envelopes as they arrive, subscribe a server endpoint to the File upload webhook and read each new scan once. Verify FS-Signature on every delivery and key each record by handle. Webhooks

  • Read on fp.upload

    The File upload event names each new file. Its handle is the last segment of text.url.

  • Verify every delivery

    Recompute HMAC-SHA256 over FS-Timestamp, a period and the raw body, with the endpoint's secret.

  • Store the fields once

    Save the envelope_ocr fields against the handle. Each request runs the task again.

  • Key records by handle

    Filestack retries a delivery your server answers with an error, so a handle already on record gets a 204.

  • Keep the review queue in view

    Unmatched names and empty reads go to a supervisor with the reason attached.

  • Read contents in a Workflow

    A Workflow runs doc_detection and ocr on the server for a whole batch.

verify.js
import { createHmac, timingSafeEqual } from 'node:crypto';

export function verifyWebhook(raw, timestamp, signature) {
  if (!timestamp || !signature) return false;
  const expected = createHmac('sha256', process.env.FILESTACK_WEBHOOK_SECRET)
    .update(`${timestamp}.${raw}`)
    .digest('hex');
  const a = Buffer.from(expected);
  const b = Buffer.from(signature);
  return a.length === b.length && timingSafeEqual(a, b);
}
Sample fp.upload event
{
  "action": "fp.upload",
  "text": {
    "url": "https://cdn.filestackcontent.com/HANDLE",
    "type": "image/png",
    "filename": "scan.png"
  }
}

Ways to Read the Recipient Off an Envelope

Envelope OCR returns the recipient block as fields. General OCR returns every line of text with its position on the page, and staff read the scan by eye.

Staff read and type General OCR Filestack envelope_ocr
What comes back A name and box number typed into your system Every line of text with its coordinates sender, recipient_name and recipient_address
Finding the recipient Judgment on each envelope Rules that choose a block by where it sits The task labels the recipient block
A name printed apart from the address Read by eye Found by position rules Plain ocr on the same scan reads the name
Growth in volume Staff hours grow with the post Engine hosting grows with the post Plans by usage. Pricing
Time to production Hiring and training An OCR engine, a parser and hosting Most teams ship their first upload within minutes

Staff reading suits a mailroom with a few dozen items a day and envelopes that need judgment.

Earth Class Mail Case Study

Earth Class Mail turns paper mail into searchable digital documents. Filestack OCR, then called Filestack Capture, read and sorted the mail automatically.

Earth Class Mail logo

"A simple integration with Filestack's content intelligence API allowed us to offload the analysis of a large volume of mail quickly and reliably. This automation has proven critically important as our team has more time to focus on enhancing our core product."

Steven Maguire, VP Technology at Earth Class Mail

Read the Earth Class Mail case study

  • 70%of Earth Class Mail's mail processing completed through the Filestack API
  • 50%+increase in the overall auto-delivery rate
  • 6,000+customer inboxes served
  • 10,000images processed in a day, at peak

Envelope OCR Beyond the Mailroom

The scan, read and route pattern also runs returned-mail handling, remittance capture, parcel sorting and searchable archives.

Returned mail and address correction

Read the recipient block on each returned item and update the record.

  • envelope_ocr

Check and remittance capture

Flatten the photographed slip, then read its text.

  • doc_detection
  • ocr

Parcel label sorting

Read the label text off each parcel photo and route the parcel.

  • ocr

Searchable archives

Index a year of post by sender, recipient and the words inside.

  • ocr

Screening emailed documents

Scan files that arrive by email or upload before staff open them.

  • virus_detection

Batch intake

Run the contents chain on every upload in a morning's batch.

  • Workflows

Route every scanned envelope to the right desk.

  • 70% of Earth Class Mail's mail processing completed through the Filestack API
  • Most teams ship their first upload within minutes
  • SOC 2 compliant

Digital Mailroom Automation FAQs

What is a digital mailroom, and how is it automated?

A digital mailroom receives paper post, scans it and delivers each item to its recipient as a digital file. An automated mailroom reads the envelope, routes the item to the named person and indexes the contents for search.

How does envelope OCR differ from regular OCR?

Envelope OCR returns the sender, recipient name and recipient address as named fields. Regular OCR returns all the text on the page with word positions, and your code decides which block is the recipient.

Where does an unmatched envelope go?

An unmatched envelope goes to a review queue. The app tries the full recipient name, then the surname, and a scan that returns empty fields also lands in review with the reason.

Which plans include Envelope OCR?

Envelope OCR runs on paid plans, with a free trial. Each read carries a policy signed with your app secret that grants read and convert on the scan’s handle. See pricing.

Can the contents be read on the server as each scan arrives?

Yes. A Filestack Workflow attached to the upload runs doc_detection and ocr as each scan arrives, and the fs.workflow webhook delivers the results to your endpoint.

Is Redfern a real company or a Filestack customer?

Redfern is a fictional company, created to show how Filestack works in mail and document services. The firm, its people and its figures are invented, and the demo runs on the real Filestack API.

Can I see the code behind the Redfern demo?

Yes. Redfern is open source on GitHub in the filestack-use-cases repository, under apps/fs-mailroom. It is a Next.js app with the signing route and the routing code.