# ApiGatewayRequestContextV2

**Kind:** Interface

**Source:** [`src/adapter/aws-lambda/types.ts`](https://github.com/honojs/hono/blob/main/src/adapter/aws-lambda/types.ts#L128)

**Part of:** [Adapter](subsystem-src-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

| Property | Type |
|---|---|
| `accountId` | `string` |
| `apiId` | `string` |
| `authentication` | `null` |
| `authorizer` | `Authorizer` |
| `domainName` | `string` |
| `domainPrefix` | `string` |
| `http` | `{ method: string path: string protocol: string sourceIp: string userAgent: string }` |
| `requestId` | `string` |
| `routeKey` | `string` |
| `stage` | `string` |
| `time` | `string` |
| `timeEpoch` | `number` |

## 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/types.ts#L128-L147) [`src/adapter/aws-lambda/handler.ts:40-61`](src/adapter/aws-lambda/handler.ts#L40-L61)

It is re-exported from the AWS Lambda adapter entry point as a type. [`src/adapter/aws-lambda/index.ts:8-14`](src/adapter/aws-lambda/index.ts#L8-L14)
