Skip to content

How do I collect API Gateway extended request IDs?

2 minute read
1

I want to collect Amazon API Gateway extended request IDs.

Resolution

The extended request ID contains information to debug and troubleshoot issues.

To collect extended request IDs for REST APIs or HTTP APIs, check access log records, execution log records, or HTTP response headers.

Turn on logging for APIs

If you haven't already done so, turn on logging to write logs to Amazon CloudWatch Logs for HTTP APIs. To turn on logging for REST APIs, see Set up CloudWatch logging for REST APIs in API Gateway.

Note: You must activate access logging to capture extended request IDs. Access logs capture all requests that reach API Gateway, including requests rejected by authentication, authorization, throttling, and AWS WAF.

Check access log records

To view who accessed your API and how, check your access logs. To get the request IDs in access logs, include the context.extendedRequestId context variable when you customize the content for your logs.

Check execution log records for REST APIs

Check extended request IDs in execution logs that API Gateway manages for REST APIs.

Extended request IDs appear as one of the following formats:

  • Log group format: API-Gateway-Execution-Logs_{rest-api-id}/{stage_name}
  • Extended request ID format: "XxxXXXxx="

Note: Execution log records don't support HTTP APIs.

Check HTTP response headers

You can find extended request IDs in API response headers.

To view response headers, run the following curl command with the verbose flag (-v):

curl -v https://your-api-id.execute-api.region.amazonaws.com/stage/resource

Example REST API response header:

x-amz-apigw-id: b5i0ig3WIAMEVOQ=

Example HTTP response header:

apigw-requestid: b5i0ig3WIAMEVOQ=

Related information

Variables for access logging for API Gateway