# Index incoming email in Cloudflare D1

Store the ID, subject, and date of each email received by the private Mailhook. Create a D1 mail\_deliveries table with message\_id TEXT PRIMARY KEY, subject TEXT, and received\_at TEXT. Duplicate message IDs reuse the existing record. The table excludes bodies and attachments.

[Use template](https://dashboard.fasthook.io/workflow/new?templateKey=mailhook-delivery-index-to-d1&templateName=Index+incoming+email+in+Cloudflare+D1)

**Required accounts**

- Cloudflare D1

## Workflow steps

### 1. Trigger · New inbound email

**Mailhook**. Start when an email arrives at the workflow’s FastHook address.

### 2. Action · Record the received email once

**Cloudflare D1**. Run a statement with bound values, or send a batch. Each row in the results uses the column names from your query.

## Set up your workflow

1. **Copy the template** Open the template in FastHook to create an editable Workflow Draft.
2. **Connect your accounts** Connect your accounts for Mailhook, Cloudflare D1.
3. **Review the Workflow** Review the Steps, field mappings, routes, and provider settings.
4. **Activate** Activate the Workflow when the Draft is ready, then verify a test run.

## Questions about this template

### Does the template copy someone else's credentials?

No. FastHook creates a disconnected Draft. Connect your own Mailhook, Cloudflare D1 accounts before activation.

### Can I change the Steps and mappings?

Yes. The copied Workflow is an editable Draft. Review every Step, input, mapping, and route before you activate it.

### What is copied into my workspace?

FastHook recreates the Trigger configuration, Action Steps, routes, and mappings with new IDs. Provider accounts, credentials, and secrets are never copied.

### When does the Workflow start running?

Only after you connect the required accounts, finish the configuration, and explicitly activate the Draft.

## Related integrations

- [Cloudflare D1 integrations](https://www.fasthook.io/apps/cloudflare-d1/integrations)
