message_id, a UUID generated at send time and echoed back by the provider in every webhook. The table is provider-agnostic: no column names SendGrid directly, so future provider swaps require no schema change. The entity is associated to a Workspace via a nullable SET NULL foreign key so bounce/suppression history outlives workspace deletion.
Internal object. Not currently exposed on the public REST API. The operations below describe the intended contract.
API operations
Data model
Attributes
Relationships
System-computed
- email_event_id — gen_random_uuid() default at insert, never caller-supplied
- received_at — set by MikroORM onCreate hook to new Date(); represents the DB write timestamp
- workspace FK on delete SET NULL — workspace deletion orphans rows rather than cascading deletes, preserving suppression history
- Partial unique index on (provider, provider_event_id) WHERE provider_event_id IS NOT NULL — idempotency guard for provider webhook retries; index maintained by Postgres, not application code
- No created_at / updated_at / deleted_at — this entity is append-only (no soft-delete, no update semantics); created_at was dropped in Migration20260507121000 as redundant with received_at
Example
apps/api/src/database/entities/EmailEvent.ts — migrations: apps/api/src/database/migrations/Migration20260507094935_email_events.ts, Migration20260507120000_email_events_workspace_set_null.ts, Migration20260507121000_email_events_drop_created_at.ts · domain: platform · tier: Activity