SesEvent: {
    Records: {
        eventSource: "aws:ses";
        eventVersion: string;
        ses: {
            mail: {
                commonHeaders: {
                    bcc?: string[];
                    cc?: string[];
                    date: string;
                    from: string[];
                    messageId: string;
                    "reply-to"?: string[];
                    returnPath: string;
                    sender?: string[];
                    subject: string;
                    to: string[];
                };
                destination: string[];
                headers: { name: string; value: string }[];
                headersTruncated: boolean;
                messageId: string;
                source: string;
                timestamp: string;
            };
            receipt: {
                action: {
                    functionArn: string;
                    invocationType: "Event";
                    type: "Lambda";
                };
                dkimVerdict: { status: "PASS"
                | "FAIL"
                | "GRAY"
                | "PROCESSING_FAILED" };
                dmarcPolicy: "none" | "quarantine" | "reject";
                dmarcVerdict: { status: "PASS" | "FAIL" | "GRAY" | "PROCESSING_FAILED" };
                processingTimeMillis: number;
                recipients: string[];
                spamVerdict: { status: "PASS" | "FAIL" | "GRAY" | "PROCESSING_FAILED" };
                spfVerdict: { status: "PASS" | "FAIL" | "GRAY" | "PROCESSING_FAILED" };
                timestamp: string;
                virusVerdict: { status: "PASS" | "FAIL" | "GRAY" | "PROCESSING_FAILED" };
            };
        };
    }[];
}

Zod schema for SES events from AWS.

Type declaration

  • Records: {
        eventSource: "aws:ses";
        eventVersion: string;
        ses: {
            mail: {
                commonHeaders: {
                    bcc?: string[];
                    cc?: string[];
                    date: string;
                    from: string[];
                    messageId: string;
                    "reply-to"?: string[];
                    returnPath: string;
                    sender?: string[];
                    subject: string;
                    to: string[];
                };
                destination: string[];
                headers: { name: string; value: string }[];
                headersTruncated: boolean;
                messageId: string;
                source: string;
                timestamp: string;
            };
            receipt: {
                action: {
                    functionArn: string;
                    invocationType: "Event";
                    type: "Lambda";
                };
                dkimVerdict: { status: "PASS"
                | "FAIL"
                | "GRAY"
                | "PROCESSING_FAILED" };
                dmarcPolicy: "none" | "quarantine" | "reject";
                dmarcVerdict: { status: "PASS" | "FAIL" | "GRAY" | "PROCESSING_FAILED" };
                processingTimeMillis: number;
                recipients: string[];
                spamVerdict: { status: "PASS" | "FAIL" | "GRAY" | "PROCESSING_FAILED" };
                spfVerdict: { status: "PASS" | "FAIL" | "GRAY" | "PROCESSING_FAILED" };
                timestamp: string;
                virusVerdict: { status: "PASS" | "FAIL" | "GRAY" | "PROCESSING_FAILED" };
            };
        };
    }[]
{
"Records": [
{
"eventVersion": "1.0",
"ses": {
"mail": {
"commonHeaders": {
"from": [
"Jane Doe <janedoe@example.com>"
],
"to": [
"johndoe@example.com"
],
"returnPath": "janedoe@example.com",
"messageId": "<0123456789example.com>",
"date": "Wed, 7 Oct 2015 12:34:56 -0700",
"subject": "Test Subject"
},
"source": "janedoe@example.com",
"timestamp": "1970-01-01T00:00:00.000Z",
"destination": [
"johndoe@example.com"
],
"headers": [
{
"name": "Return-Path",
"value": "<janedoe@example.com>"
},
{
"name": "Received",
"value": "from mailer.example.com (mailer.example.com [203.0.113.1]) by ..."
},
{
"name": "DKIM-Signature",
"value": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=example.com; s=example; ..."
},
{
"name": "MIME-Version",
"value": "1.0"
},
{
"name": "From",
"value": "Jane Doe <janedoe@example.com>"
},
{
"name": "Date",
"value": "Wed, 7 Oct 2015 12:34:56 -0700"
},
{
"name": "Message-ID",
"value": "<0123456789example.com>"
},
{
"name": "Subject",
"value": "Test Subject"
},
{
"name": "To",
"value": "johndoe@example.com"
},
{
"name": "Content-Type",
"value": "text/plain; charset=UTF-8"
}
],
"headersTruncated": false,
"messageId": "o3vrnil0e2ic28tr"
},
"receipt": {
"recipients": [
"johndoe@example.com"
],
"timestamp": "1970-01-01T00:00:00.000Z",
"spamVerdict": {
"status": "PASS"
},
"dkimVerdict": {
"status": "PASS"
},
"dmarcPolicy": "reject",
"processingTimeMillis": 574,
"action": {
"type": "Lambda",
"invocationType": "Event",
"functionArn": "arn:aws:lambda:us-west-2:012345678912:function:Example"
},
"dmarcVerdict": {
"status": "PASS"
},
"spfVerdict": {
"status": "PASS"
},
"virusVerdict": {
"status": "PASS"
}
}
},
"eventSource": "aws:ses"
}
]
}