Skip to content

ApiGatewayRequestContextV2

reference
1 min readUpdated

Kind: Interface

Source: src/adapter/aws-lambda/types.ts

Part of: Adapter

ApiGatewayRequestContextV2 describes request metadata received from an API Gateway HTTP API event in the AWS Lambda adapter. It carries API, domain, route, stage, authorization, and client connection details for request handling and logging.

Properties

PropertyType
accountIdstring
apiIdstring
authenticationnull
authorizerAuthorizer
domainNamestring
domainPrefixstring
http{ method: string path: string protocol: string sourceIp: string userAgent: string }
requestIdstring
routeKeystring
stagestring
timestring
timeEpochnumber

Diagram

mermaid
graph LR
  Request[API Gateway request] --> Context[ApiGatewayRequestContextV2]
  Context --> Api[accountId and apiId]
  Context --> Domain[domainName and domainPrefix]
  Context --> Route[routeKey and stage]
  Context --> Auth[authentication and authorizer]
  Context --> Http[http method path protocol sourceIp userAgent]
  Context --> RequestId[requestId]

Usage

ts
import type { ApiGatewayRequestContextV2 } from './types'

function getRequestDetails(context: ApiGatewayRequestContextV2) {
  return {
    requestId: context.requestId,
    method: context.http.method,
    path: context.http.path,
    clientAddress: context.http.sourceIp,
    route: context.routeKey,
    stage: context.stage,
  }
}

AI Coding Instructions

  • Read request method, path, protocol, source IP, and user agent from context.http.
  • Treat authentication as null; read authorization data from context.authorizer.
  • Keep requestId attached to logs and error reports for request tracing.
  • Use domainName, domainPrefix, routeKey, and stage when routing or building request-specific metadata.

How it works

ApiGatewayRequestContextV2 is an exported TypeScript interface describing the requestContext field of an APIGatewayProxyEventV2. That event shape is used by the AWS Lambda adapter for HTTP API and direct Lambda Function URL invocations. src/adapter/aws-lambda/types.ts:128-147 src/adapter/aws-lambda/handler.ts:40-61

It is re-exported from the AWS Lambda adapter entry point as a type. src/adapter/aws-lambda/index.ts:8-14

Was this page helpful?

Download as PDF
ApiGatewayRequestContextV2 — Hono (narrator proof)