Skip to content

๐Ÿ“ง Email Alias Quick Start

Generate and manage email aliases to receive purchase orders via inbound email.

Open the webapp Settings โ†’ Email Intake page (or query erp_connections in Postgres) and select the active ERP connection for your organization.

Create aliases from the webapp Settings UI or via the /api/alias/* API routes (apps/webapp/src/pages/api/alias/):

  • POST /api/alias/generate โ€” Generates the organization alias and member aliases for the selected erpConnectionId
  • GET /api/alias โ€” Lists existing aliases for the organization
  • POST /api/alias/verify โ€” Verifies an email alias token

Verification emails are automatically sent to each alias address. Users can click the verification link to activate, or admins can verify an alias directly using the @repo/db CLI script:

Terminal window
pnpm --filter @repo/db verify-email-alias <alias-email-or-id>

For an organization named โ€œGenFitโ€:

  • Organization alias: orders+genfit@ordermatic.co
    • Receives emails for entire organization
  • Member aliases: orders+genfit_johnsmith@ordermatic.co
    • One for each organization member
    • Format: {org-slug}_{firstname}{lastname}
Terminal window
# View aliases in database
psql "$DATABASE_URL" -c \
"SELECT email, status, verified_at FROM email_aliases WHERE erp_connection_id = 'your-connection-id';"
  1. Send email to an alias (e.g., orders+genfit@ordermatic.co)
  2. Watch logs: webapp / Temporal logs will show email processing
  3. Verify: Order should be created in your system
Terminal window
# Manually verify an email alias via @repo/db script
pnpm --filter @repo/db verify-email-alias
# Migrate email alias domains (e.g. legacy domain -> ordermatic.co)
pnpm --filter @repo/db migrate-email-aliases-domain

Webapp API routes (apps/webapp/src/pages/api/alias/):

  • POST /api/alias/generate
  • GET /api/alias
  • POST /api/alias/verify
  • DELETE /api/alias/[id]
  • Sign in to the webapp with an active Clerk organization selected
  • Make sure CLERK_SECRET_KEY is set in your local environment
  • Check RESEND_API_KEY in your local environment
  • Verify WEBAPP_URL / APP_URL is set if you need generated verification links to use a public URL
  • Check DATABASE_URL is correct
  • Verify webapp is running: curl http://localhost:4321/api/health

Update DATABASE_URL in .env with valid PostgreSQL credentials.

The alias generation flow:

  1. Authenticates the caller and organization context via Clerk
  2. Calls the webapp /api/alias/* routes for the organizationโ€™s erpConnectionId
  3. Generates aliases for the organization and members in email_aliases
  4. Sends verification emails (or activates via pnpm --filter @repo/db verify-email-alias)
  1. Send test email to an alias to verify the end-to-end flow
  2. Monitor processing in webapp / Temporal logs