---
title: Document Routing
description: "Subfolder strategies and file-naming patterns for documents delivered through FileRelay connections."
---

# Document Routing

Each connection has its own routing config — folder structure + file naming. A single source can deliver to multiple destinations with different routing at each.

## Subfolder strategies

| Strategy | Path pattern | When to use |
|---|---|---|
| **None (flat)** | `/invoice_ABC123.pdf` | Destination handles its own organisation, or low volume |
| **Date-based** (`Y/m/d`) | `/2026/04/04/invoice_ABC123.pdf` | High-volume archiving; date-prefix lifecycle rules (e.g. S3 Glacier) |
| **Repository-based** | `/Z1/invoice_ABC123.pdf` | Multiple sources writing to the same destination — keep them separated |
| **Combined** | `/Z1/2026/04/04/invoice_ABC123.pdf` | Both at once |

## File naming

### Original document ID (default)

Uses the SAP `doc_id` as the filename — preserves the link back to SAP, no collisions (IDs are unique per repository):

```
4A3F8B2C1D7E9F0A.pdf
```

### Custom pattern

Available placeholders:

| Placeholder | Description | Example |
|---|---|---|
| `{doc_id}` | SAP document ID | `4A3F8B2C1D7E9F0A` |
| `{repo_id}` | Source repository ID | `Z1` |
| `{date}` | Receive date (YYYY-MM-DD) | `2026-04-04` |
| `{timestamp}` | Unix timestamp | `1775404800` |
| `{content_type}` | MIME-type extension | `pdf` |

Pattern `invoice_{doc_id}_{date}.{content_type}` → `invoice_4A3F8B2C1D7E9F0A_2026-04-04.pdf`.

If you've enabled [RFC enrichment](/docs/workspaces/sap-connection), enriched fields (vendor name, invoice number, etc.) become available as additional placeholders in both subfolder paths and file names.

## Configure

Connection edit screen → **Routing** section → pick the subfolder strategy, optionally set a custom naming pattern → Save.

> **REPLACE:** Screenshot of the routing configuration section

## Per-destination routing

Same source, different routing per destination — useful for tailoring to each system's conventions:

| Connection | Destination | Subfolder | File naming |
|---|---|---|---|
| `Z1 → S3 Archive` | S3 bucket | Date-based | Original `doc_id` |
| `Z1 → SharePoint` | SharePoint | Repository-based | Custom pattern |
| `Z1 → Email Notify` | Email | None | Custom pattern |

## Duplicate file names

If the resolved path already exists at the destination, FileRelay appends a numeric suffix — no overwrites:

```
invoice_ABC123.pdf
invoice_ABC123_1.pdf
invoice_ABC123_2.pdf
```

## Next steps

- [Connections Overview](/docs/connections/overview)
- [Fan-Out to Multiple Destinations](/docs/connections/fan-out)
- [SAP Connection](/docs/workspaces/sap-connection) — enrichment for richer routing metadata
