marketing
Insider-backed contact management, newsletter subscription, transactional email queueing, callback forwarding, and email-event fanout.
| Field | Value |
|---|
| Serverless service | drive-api-marketing |
| Runtime | nodejs22.x, arm64 |
| Deployed HTTP operations | 6 |
| Local worker harnesses | 1 (POST /marketing/email/transactional/process) |
| OpenAPI | /openapi/marketing.yaml · interactive |
Deployed routes
| Function | Method | Path | Auth | Input | Output |
|---|
getContact | GET | /subscription/contact | API key | Query email or profileId | {fetchMode, success, status, message, contact} |
upsertContact | POST | /subscription/contact | API key | Insider contact body; optional dryRun=1 | Insider upsert response |
emailSubscription | POST | /subscription/email | Public | Email subscription body | Insider contact update response |
transactionalEmailQueue | POST | /marketing/email/transactional/queue | API key | TransactionalEmailRequest | Queue result or dry-run payload |
transactionalEmailCallback | POST | /marketing/email/transactional/callback | Public plus X-Ins-Auth | Insider callback payload plus requestId | Forwarded callback response |
emailEventNotify | POST | /marketing/email/webhook | Public | Email event notification body | SNS publish result |
Worker harnesses
| Function | Local method/path | Deployed trigger | Purpose |
|---|
transactionalEmailProcess | POST /marketing/email/transactional/process | SQS | Resolves attachment URLs and sends queued transactional email through InsiderMessaging. |
The process operation is present in OpenAPI because it is mounted as an HTTP-shaped local harness for offline testing. It is marked with x-drive-deployment: local-test-http and is removed from deployed stacks by serverless-ifelse.
Behaviour notes
getContact requires exactly one lookup identity: email or Insider UUID profileId.
upsertContact requires identifiers.email; ContactSource=ENQUIRY sets BehaviourLastEnquiryDate, and ContactSource=ASKDRIVE applies name/value mapping.
emailSubscription normalises email before sending to Insider and uses NEWSLETTER_2023_DRIVE as the contact source.
transactionalEmailQueue resolves templateKey from DynamoDB, supports rawContent, rewrites callback URLs to the proxy endpoint, and deduplicates FIFO SQS messages by sha256 of the request body.
transactionalEmailCallback forwards Insider delivery events to the original callback URL stored by the queue handler. HMAC verification is currently disabled in code because the proxied request body is modified before forwarding.
emailEventNotify validates with EmailEventNotifySchema and publishes SNS attributes for eventSource, eventName, subject, and subjectHasFromDrive.
Source map
- Routes and triggers:
services/marketing/serverless.yml
- Handlers:
services/marketing/functions/
- Insider integration:
libs/marketing-automation/
- Transactional email schema:
services/marketing/schemas/transactional.email.request.ts