APIGatewayRequestContextV2: {
    accountId: string;
    apiId: string;
    authentication?:
        | null
        | {
            clientCert?: {
                clientCertPem: string;
                issuerDN: string;
                serialNumber: string;
                subjectDN: string;
                validity: { notAfter: string; notBefore: string };
            };
        };
    authorizer?: {
        iam?: {
            accessKey?: string;
            accountId?: string;
            callerId?: string;
            cognitoIdentity?: | null
            | { amr: string[]; identityId: string; identityPoolId: string };
            principalOrgId?: null | string;
            userArn?: string;
            userId?: string;
        };
        jwt?: { claims: Record<string, any>; scopes: null | string[] };
        lambda?: null | Record<string, any>;
    };
    domainName: string;
    domainPrefix: string;
    http: {
        method: | "GET"
        | "POST"
        | "PUT"
        | "PATCH"
        | "DELETE"
        | "HEAD"
        | "OPTIONS";
        path: string;
        protocol: string;
        sourceIp: string;
        userAgent: string;
    };
    requestId: string;
    routeKey: string;
    stage: string;
    time: string;
    timeEpoch: number;
}

A zod schema for an API Gateway HTTP API Request Context

Type declaration

  • accountId: string
  • apiId: string
  • Optionalauthentication?:
        | null
        | {
            clientCert?: {
                clientCertPem: string;
                issuerDN: string;
                serialNumber: string;
                subjectDN: string;
                validity: { notAfter: string; notBefore: string };
            };
        }
  • Optionalauthorizer?: {
        iam?: {
            accessKey?: string;
            accountId?: string;
            callerId?: string;
            cognitoIdentity?:
                | null
                | { amr: string[]; identityId: string; identityPoolId: string };
            principalOrgId?: null | string;
            userArn?: string;
            userId?: string;
        };
        jwt?: { claims: Record<string, any>; scopes: null | string[] };
        lambda?: null | Record<string, any>;
    }
  • domainName: string
  • domainPrefix: string
  • http: {
        method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
        path: string;
        protocol: string;
        sourceIp: string;
        userAgent: string;
    }
  • requestId: string
  • routeKey: string
  • stage: string
  • time: string
  • timeEpoch: number
{
"accountId": "123456789012",
"apiId": "api-id",
"authentication": {}
"domainName": "id.execute-api.us-east-1.amazonaws.com",
"domainPrefix": "id",
"http": {
"method": "POST",
"path": "/my/path",
"protocol": "HTTP/1.1",
"sourceIp": "...",
"userAgent": "..."
},
"requestId": "...",
"routeKey": "$default",
"stage": "$default",
"time": "12/Mar/2020:19:03:58 +0000",
"timeEpoch": 1583348638390
}