Opening Problem Statement
Meet Sarah, a privacy-conscious developer who integrates email sign-ups into her app. She often struggles managing disposable or masked emails manually for testing and privacy. Each time she needs a new masked email, she wastes valuable time logging into her Fastmail account, navigating its settings, and creating these addresses individually. Not only is this process time-consuming, but human error often causes incorrect setup of masked email states and descriptions, leading to confusion and occasionally exposing her and her users to spam or unwanted emails.
Imagine wasting 15+ minutes every day just creating and managing masked emails for tests and client needs — across weeks and months, this inefficiency stacks up to several hours lost. Sarah needs a way to automate and streamline the creation of Fastmail masked emails, triggered directly from her app or testing suite, without manual intervention.
What This Automation Does
This n8n workflow offers a seamless solution by integrating the Fastmail API to create masked email addresses automatically upon a webhook trigger. Here’s what happens when you run this workflow:
- Webhook Triggered: Send a POST request with desired masked email parameters (state and description) to the workflow’s webhook endpoint.
- Session Retrieval: The workflow authenticates and retrieves session data from Fastmail’s API to get necessary account identifiers for masked email creation.
- Generate Masked Email: It calls Fastmail’s JMAP API to create a new masked email using the parameters from the webhook payload.
- Prepare Output: Extracts the new masked email address and its description for easy use downstream.
- Webhook Response: Returns the created masked email details as a response to the original POST request.
By automating these steps, Sarah saves 10-15 minutes per masked email created, completely eliminating manual errors and ensuring consistent masking parameters. This workflow empowers developers and users like Sarah to handle masked emails programmatically and scalably.
Prerequisites ⚙️
- Fastmail API Access: Valid API credentials set up with HTTP Header Authentication.
- n8n Account: Access to n8n automation platform to build and run the workflow.
- Webhook Client: Tool to send POST requests to the webhook endpoint, e.g., curl, Postman, or automation scripts.
- Optional – Authorization: Secure your webhook with authorization if exposed publicly.
Step-by-Step Guide to Build the Workflow
Step 1: Create a Webhook Trigger Node
Navigate to Triggers → Webhook. Create a new webhook with HTTP Method POST and a unique path like createMaskedEmail. Enable the Response Node mode to allow responding after workflow completion.
This webhook will accept POST requests with JSON payloads containing state and description for the masked email.
Expected Outcome: You’ll have a webhook URL ready to receive data.
Common Mistake: Forgetting to set the method to POST or not configuring the response mode.
Step 2: Retrieve Fastmail Session Data with HTTP Request Node
Add an HTTP Request node named Session. Configure it as follows:
- Method: GET (default)
- URL:
https://api.fastmail.com/jmap/session - Authentication: Generic Credential with HTTP Header Auth using your Fastmail API credentials
This fetches session data including account IDs needed for further API calls.
Expected Outcome: The node returns session JSON containing account identifiers.
Common Mistake: Incorrect authentication credentials or missing HTTP header authentication setup.
Step 3: Extract Fields for Masked Email Creation
Add a Set node named get fields for creation connected from Session. Map the following fields from the webhook data:
state: Use{{$json.body.state ?? "pending"}}to default if emptydescription: Use{{$json.body.description ?? "Test via N8n"}}as default
This sets the parameters for the masked email creation step dynamically based on webhook input.
Expected Outcome: Variables state and description are set correctly.
Common Mistake: Not correctly referencing the webhook input path.
Step 4: Create the Masked Email via Fastmail JMAP API
Add another HTTP Request node named create random masked email connected from get fields for creation. Configure as:
- Method: POST
- URL:
https://api.fastmail.com/jmap/api/ - Headers: Content-Type application/json
- Authentication: Use same Fastmail API HTTP header credentials
- Body Type: JSON
- Body:
={
"using": [
"urn:ietf:params:jmap:core",
"https://www.fastmail.com/dev/maskedemail"
],
"methodCalls": [
[
"MaskedEmail/set",
{
"accountId": "{{ $('Session').item.json.primaryAccounts['https://www.fastmail.com/dev/maskedemail'] }}",
"create": {
"maskedEmailId1": {
"description": "{{ $json.description }}",
"state": "{{ $json.state }}"
}
}
},
"c1"
]
]
}
This sends the masked email creation request using session data and webhook inputs.
Expected Outcome: The masked email is created, and the response returns the new email address details.
Common Mistake: Forgetting to map the accountId correctly from the session node.
Step 5: Prepare Output Data for Response
Add a Set node named prepare output after the masked email creation node. Map the following:
email:{{$json.methodResponses[0][1].created.maskedEmailId1.email}}description:{{ $('get fields for creation').item.json.description }}
This formats the output JSON with the new email and description for the webhook response.
Expected Outcome: Clean output JSON containing email and description.
Common Mistake: Typos in field names (like desciption instead of description).
Step 6: Respond to the Webhook with Created Email
Add a Respond to Webhook node named Respond to Webhook as the final node in the chain. Connect it from prepare output. Configure it to respond with the formatted JSON text.
Expected Outcome: When you send a POST request to the initial webhook, you immediately receive the new masked email and its description in the response.
Common Mistake: Not selecting the proper response mode or not linking the node correctly can cause empty responses.
Customizations ✏️
- Customize Masked Email State: In the
get fields for creationnode, change the default value ofstatefrompendingtoactiveordisableddepending on your preferred email masking lifecycle. - Add More Metadata: Modify the JSON body of the
create random masked emailHTTP node to include additional fields supported by Fastmail API such asnoteorexpiresto auto-expire masks. - Secure the Webhook Endpoint: Enable authorization settings on the
Webhooknode to restrict access and prevent unauthorized masked email creation. - Log Created Emails: Add a Google Sheets or database node after
prepare outputto record all generated masked emails and descriptions for audit and tracking. - Trigger Via Other Events: Change the webhook trigger or add additional triggers (like a scheduler) to create masked emails on specific time intervals or events.
Troubleshooting 🔧
- Problem: “401 Unauthorized” error from Fastmail API.
Cause: Incorrect or expired API credentials or missing HTTP header authentication.
Solution: Double-check and reconfigure the Fastmail HTTP Header Auth credentials under n8n Credentials. Test credentials with a simple GET request. - Problem: Webhook does not trigger or returns empty response.
Cause: Webhook path or HTTP method misconfigured; response node not linked correctly.
Solution: Verify webhook URL path and ensure it uses POST. Confirm the Respond to Webhook node is properly connected with correct response data. - Problem: Masked email creation fails with missing or invalid accountId.
Cause: The session node’s response structure changed or mapping for accountId is incorrect.
Solution: Inspect the session node output JSON carefully and adjust the reference toprimaryAccounts['https://www.fastmail.com/dev/maskedemail']accordingly.
Pre-Production Checklist ✅
- Verify Fastmail API credentials and HTTP Header Auth are correctly configured and tested.
- Test webhook POST requests with varying
stateanddescriptionto confirm correct masking behavior. - Ensure the session node successfully fetches account data every time before the creation call.
- Validate the output node returns clean JSON with expected fields.
- If deployed publicly, add authorization or IP whitelist to protect the webhook.
Deployment Guide
Once tested, activate the workflow in n8n by toggling its status to active. Copy the webhook URL and integrate it into your apps or automation tools. Monitor execution logs in n8n to track successful creation and diagnose any API errors.
This workflow doesn’t require complex infrastructure but ensure your n8n instance runs reliably if used in production. Consider self-hosting with providers like Hostinger for control and uptime.
FAQs
- Q: Can I use a different email provider API instead of Fastmail?
A: This workflow specifically integrates Fastmail’s JMAP API for masked emails, so switching providers would require significant adjustment. - Q: Does this automation consume API credits or have rate limits?
A: Fastmail may impose API rate limits; ensure your usage aligns with their policies to avoid throttling. - Q: Is my data safe when sending to this webhook?
A: Secure your webhook with authorization and use HTTPS to encrypt data in transit.
Conclusion
By completing this tutorial, you’ve built an automated n8n workflow to create Fastmail masked email addresses instantly via a simple webhook POST. This saves you and developers countless minutes otherwise spent manually generating these addresses, while avoiding mistakes and enabling scalable masking strategies.
Next, you could extend this workflow by adding logging to Google Sheets, automating masked email expiration, or integrating masked emails into broader user registration workflows. With n8n and Fastmail’s API combined, you now have a powerful tool for privacy-conscious email management.