APIGatewayProxyEvent: {
    body: null | string;
    headers?: null | Record<string, string>;
    httpMethod:
        | "GET"
        | "POST"
        | "PUT"
        | "PATCH"
        | "DELETE"
        | "HEAD"
        | "OPTIONS";
    isBase64Encoded: boolean;
    multiValueHeaders?: null
    | Record<string, string[]>;
    multiValueQueryStringParameters: null | Record<string, string[]>;
    path: string;
    pathParameters?: null | Record<string, string>;
    queryStringParameters: null | Record<string, string>;
    requestContext: {
        accountId: string;
        apiId: string;
        authorizer?:
            | null
            | { integrationLatency: number; principalId: string }
            | { claims: Record<string, any>; scopes?: string[] };
        connectedAt?: null | number;
        connectionId?: null | string;
        deploymentId?: null | string;
        domainName?: null | string;
        domainPrefix?: null | string;
        eventType?: null | "CONNECT" | "MESSAGE" | "DISCONNECT";
        extendedRequestId?: null | string;
        httpMethod:
            | "GET"
            | "POST"
            | "PUT"
            | "PATCH"
            | "DELETE"
            | "HEAD"
            | "OPTIONS";
        identity: {
            accessKey?: null
            | string;
            accountId?: null | string;
            apiKey?: null | string;
            apiKeyId?: null | string;
            caller?: null | string;
            clientCert?:
                | null
                | {
                    clientCertPem: string;
                    issuerDN: string;
                    serialNumber: string;
                    subjectDN: string;
                    validity: { notAfter: string; notBefore: string };
                };
            cognitoAuthenticationProvider?: null
            | string;
            cognitoAuthenticationType?: null | string;
            cognitoIdentityId?: null | string;
            cognitoIdentityPoolId?: null | string;
            principalOrgId?: null | string;
            sourceIp?: string;
            user?: null | string;
            userAgent?: null | string;
            userArn?: null | string;
        };
        messageDirection?: null
        | string;
        messageId?: null | string;
        operationName?: null | string;
        path: string;
        protocol: string;
        requestId: string;
        requestTime: string;
        requestTimeEpoch: number;
        resourceId?: null | string;
        resourcePath: string;
        routeKey?: null | string;
        stage: string;
    };
    resource: string;
    stageVariables?: null
    | Record<string, string>;
}

A zod schema for an API Gateway Proxy event

Type declaration

  • body: null | string
  • Optionalheaders?: null | Record<string, string>
  • httpMethod: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS"
  • isBase64Encoded: boolean
  • OptionalmultiValueHeaders?: null | Record<string, string[]>
  • multiValueQueryStringParameters: null | Record<string, string[]>
  • path: string
  • OptionalpathParameters?: null | Record<string, string>
  • queryStringParameters: null | Record<string, string>
  • requestContext: {
        accountId: string;
        apiId: string;
        authorizer?:
            | null
            | { integrationLatency: number; principalId: string }
            | { claims: Record<string, any>; scopes?: string[] };
        connectedAt?: null | number;
        connectionId?: null | string;
        deploymentId?: null | string;
        domainName?: null | string;
        domainPrefix?: null | string;
        eventType?: null | "CONNECT" | "MESSAGE" | "DISCONNECT";
        extendedRequestId?: null | string;
        httpMethod:
            | "GET"
            | "POST"
            | "PUT"
            | "PATCH"
            | "DELETE"
            | "HEAD"
            | "OPTIONS";
        identity: {
            accessKey?: null
            | string;
            accountId?: null | string;
            apiKey?: null | string;
            apiKeyId?: null | string;
            caller?: null | string;
            clientCert?:
                | null
                | {
                    clientCertPem: string;
                    issuerDN: string;
                    serialNumber: string;
                    subjectDN: string;
                    validity: { notAfter: string; notBefore: string };
                };
            cognitoAuthenticationProvider?: null
            | string;
            cognitoAuthenticationType?: null | string;
            cognitoIdentityId?: null | string;
            cognitoIdentityPoolId?: null | string;
            principalOrgId?: null | string;
            sourceIp?: string;
            user?: null | string;
            userAgent?: null | string;
            userArn?: null | string;
        };
        messageDirection?: null
        | string;
        messageId?: null | string;
        operationName?: null | string;
        path: string;
        protocol: string;
        requestId: string;
        requestTime: string;
        requestTimeEpoch: number;
        resourceId?: null | string;
        resourcePath: string;
        routeKey?: null | string;
        stage: string;
    }
    • accountId: string
    • apiId: string
    • Optionalauthorizer?:
          | null
          | { integrationLatency: number; principalId: string }
          | { claims: Record<string, any>; scopes?: string[] }
    • OptionalconnectedAt?: null | number
    • OptionalconnectionId?: null | string
    • OptionaldeploymentId?: null | string
    • OptionaldomainName?: null | string
    • OptionaldomainPrefix?: null | string
    • OptionaleventType?: null | "CONNECT" | "MESSAGE" | "DISCONNECT"
    • OptionalextendedRequestId?: null | string
    • httpMethod: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS"
    • identity: {
          accessKey?: null | string;
          accountId?: null | string;
          apiKey?: null | string;
          apiKeyId?: null | string;
          caller?: null | string;
          clientCert?:
              | null
              | {
                  clientCertPem: string;
                  issuerDN: string;
                  serialNumber: string;
                  subjectDN: string;
                  validity: { notAfter: string; notBefore: string };
              };
          cognitoAuthenticationProvider?: null
          | string;
          cognitoAuthenticationType?: null | string;
          cognitoIdentityId?: null | string;
          cognitoIdentityPoolId?: null | string;
          principalOrgId?: null | string;
          sourceIp?: string;
          user?: null | string;
          userAgent?: null | string;
          userArn?: null | string;
      }
      • OptionalaccessKey?: null | string
      • OptionalaccountId?: null | string
      • OptionalapiKey?: null | string
      • OptionalapiKeyId?: null | string
      • Optionalcaller?: null | string
      • OptionalclientCert?:
            | null
            | {
                clientCertPem: string;
                issuerDN: string;
                serialNumber: string;
                subjectDN: string;
                validity: { notAfter: string; notBefore: string };
            }
      • OptionalcognitoAuthenticationProvider?: null | string
      • OptionalcognitoAuthenticationType?: null | string
      • OptionalcognitoIdentityId?: null | string
      • OptionalcognitoIdentityPoolId?: null | string
      • OptionalprincipalOrgId?: null | string
      • OptionalsourceIp?: string

        When invoking the API Gateway REST API using the Test Invoke feature, the sourceIp is hardcoded to test-invoke-source-ip. This is a stopgap solution to allow customers to test their API and have successful parsing.

        See aws-powertools/powertools-lambda-python#1562 for more information.

      • Optionaluser?: null | string
      • OptionaluserAgent?: null | string
      • OptionaluserArn?: null | string
    • OptionalmessageDirection?: null | string
    • OptionalmessageId?: null | string
    • OptionaloperationName?: null | string
    • path: string
    • protocol: string
    • requestId: string
    • requestTime: string
    • requestTimeEpoch: number
    • OptionalresourceId?: null | string
    • resourcePath: string
    • OptionalrouteKey?: null | string
    • stage: string
  • resource: string
  • OptionalstageVariables?: null | Record<string, string>
{
"type": "REQUEST",
"methodArn": "arn:aws:execute-api:us-east-1:123456789012:abcdef123/test/GET/request",
"resource": "/request",
"path": "/request",
"httpMethod": "GET",
"headers": {
"X-AMZ-Date": "20170718T062915Z",
"Accept": "application/json",
"HeaderAuth1": "headerValue1"
},
"queryStringParameters": {
"QueryString1": "queryValue1"
},
"pathParameters": {},
"stageVariables": null,
"requestContext": {
"path": "/request",
"accountId": "123456789012",
"resourceId": "05c7jb",
"stage": "test",
"requestId": "...",
"identity": {
"cognitoIdentityPoolId": null,
"accountId": null,
"cognitoIdentityId": null,
"caller": null,
"sourceIp": "192.168.1.1",
"principalOrgId": null,
"accessKey": null,
"cognitoAuthenticationType": null,
"cognitoAuthenticationProvider": null,
"userArn": null,
"userAgent": "HTTPie/3.2.2",
"user": null
}
},
"resourcePath": "/request",
"httpMethod": "GET",
"apiId": "abcdef123"
}