# HttpStage

Represents a stage where an instance of the API is deployed.

Extends: [Construct](https://docs.aws.amazon.com/cdk/api/v2/docs/constructs.Construct.html) › [Resource](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Resource.html) › HttpStage
Implements: [IResource](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResource.html), [IHttpStage](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.IHttpStage.html), [IHttpStageRef](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.IHttpStageRef.html), [IStage](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.IStage.html), [IEnvironmentAware](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.interfaces.IEnvironmentAware.html), IStageRef, IConstruct, IDependable
Returned by: [HttpApi.addStage](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.HttpApi.html#addstage)

- CloudFormation: [`AWS::ApiGatewayV2::Stage`](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-apigatewayv2-stage.html)
- L1 type: [`CfnStage`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnStage.html)
- Source: [`aws-apigatewayv2/lib/http/stage.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-apigatewayv2/lib/http/stage.ts#L157)
- Type last changed: v2.235.0 · 15 Jan 2026

## Example

TypeScript:

```ts
import * as apigw from 'aws-cdk-lib/aws-apigateway';
import * as logs from 'aws-cdk-lib/aws-logs';

declare const api: apigwv2.HttpApi;
declare const logGroup: logs.LogGroup;

const stage = new apigwv2.HttpStage(this, 'Stage', {
  httpApi: api,
  accessLogSettings: {
    destination: new apigwv2.LogGroupLogDestination(logGroup),
    format: apigw.AccessLogFormat.clf(),
  },
});
```

Python:

```python
import aws_cdk.aws_apigateway as apigw
import aws_cdk.aws_logs as logs

# api: apigwv2.HttpApi
# log_group: logs.LogGroup

stage = apigwv2.HttpStage(self, "Stage",
    http_api=api,
    access_log_settings={
        "destination": apigwv2.LogGroupLogDestination(log_group),
        "format": apigw.AccessLogFormat.clf()
    }
)
```

Java:

```java
import software.amazon.awscdk.services.apigateway.*;
import software.amazon.awscdk.services.logs.*;

HttpApi api;
LogGroup logGroup;

HttpStage stage = HttpStage.Builder.create(this, "Stage")
        .httpApi(api)
        .accessLogSettings(Map.of(
                "destination", new LogGroupLogDestination(logGroup),
                "format", AccessLogFormat.clf()))
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.APIGateway;
using Amazon.CDK.AWS.Logs;

HttpApi api;
LogGroup logGroup;

var stage = new HttpStage(this, "Stage", new HttpStageProps {
    HttpApi = api,
    AccessLogSettings = new Dictionary<string, object> {
        { "destination", new LogGroupLogDestination(logGroup) },
        { "format", AccessLogFormat.Clf() }
    }
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import apigw "github.com/aws/aws-cdk-go/awscdk"
import logs "github.com/aws/aws-cdk-go/awscdk"

var api HttpApi
var logGroup LogGroup

stage := apigwv2.NewHttpStage(this, jsii.String("Stage"), &HttpStageProps{
	HttpApi: api,
	AccessLogSettings: map[string]interface{}{
		"destination": apigwv2.NewLogGroupLogDestination(logGroup),
		"format": apigw.AccessLogFormat_clf(),
	},
})
```

## Initializer

TypeScript:

```ts
new HttpStage(scope: Construct, id: string, props: HttpStageProps)
```

Python:

```python
HttpStage(scope: Construct, id: str, props: HttpStageProps)
```

Java:

```java
new HttpStage(Construct scope, String id, HttpStageProps props)
```

C# / .NET:

```csharp
new HttpStage(Construct scope, string id, HttpStageProps props)
```

Golang:

```go
NewHttpStage(Scope Construct, Id *string, Props HttpStageProps)
```

## Construct Props

- `accessLogSettings`: [IAccessLogSettings](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.IAccessLogSettings.html) — Settings for access logging.

  **Default:** No access logging

- `autoDeploy`: boolean = false — Whether updates to an API automatically trigger a new deployment.

- `description`: string — The description for the API stage.

  **Default:** no description

- `detailedMetricsEnabled`: boolean = false — Specifies whether detailed metrics are enabled.

- `domainMapping`: [DomainMappingOptions](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.DomainMappingOptions.html) — The options for custom domain and api mapping.

  **Default:** no custom domain and api mapping configuration

- `httpApi`: [IHttpApiRef](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.IHttpApiRef.html) (required) — The HTTP API to which this stage is associated.

- `stageName`: string — The name of the stage.

  **Default:** '$default' the default stage of the API. This stage will have the URL at the root of the API endpoint.

  See `StageName` class for more details.

- `stageVariables`: { [key: string]: string } — Stage variables for the stage. These are key-value pairs that you can define and use in your API routes.

  **Default:** No stage variables

  The allowed characters for variable names and the required pattern for variable values are specified here: https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-apigateway-stage.html#cfn-apigateway-stage-variables

- `throttle`: [ThrottleSettings](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.ThrottleSettings.html) — Throttle settings for the routes of this stage.

  **Default:** no throttling configuration

## Properties

- `api`: [IHttpApi](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.IHttpApi.html) — The API this stage is associated to.

- `domainUrl`: string — The custom domain URL to this stage.

- `env`: [ResourceEnvironment](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.interfaces.ResourceEnvironment.html) — The environment this resource belongs to.

  For resources that are created and managed in a Stack (those created by
  creating new class instances like `new Role()`, `new Bucket()`, etc.), this
  is always the same as the environment of the stack they belong to.

  For referenced resources (those obtained from referencing methods like
  `Role.fromRoleArn()`, `Bucket.fromBucketName()`, etc.), they might be
  different than the stack they were imported into.

- `isHttpStage`: boolean — Indicates that this is an HTTP Stage.

  Will always return true, but is necessary to prevent accidental structural
  equality in TypeScript.

- `node`: [Node](https://docs.aws.amazon.com/cdk/api/v2/docs/constructs.Node.html) — The tree node.

- `PROPERTY_INJECTION_ID`: string (static) — Uniquely identifies this class.

- `stack`: [Stack](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Stack.html) — The stack in which this resource is defined.

- `stageName`: string — The name of the stage;

  its primary identifier.

- `stageRef`: [StageReference](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_apigatewayv2.StageReference.html) — A reference to a Stage resource.

- `url`: string — The URL to this stage.

## Methods

- `addStageVariable(name: string, value: string): void` — Adds a stage variable to this stage.

- `applyCrossStackReferenceStrength(strength: ReferenceStrength): void` — Override the cross-stack reference strength for this resource.

  When set, any cross-stack reference to this resource will use the specified
  mechanism instead of the global default determined by the
  `@aws-cdk/core:defaultCrossStackReferences` context key. This is useful for
  selectively weakening specific references to avoid the "deadly embrace" problem
  without changing the app-wide default.

  **Parameters**

  - `strength` — - The reference strength to use for this resource.

- `applyRemovalPolicy(policy: RemovalPolicy): void` — Apply the given removal policy to this resource.

  The Removal Policy controls what happens to this resource when it stops
  being managed by CloudFormation, either because you've removed it from the
  CDK application or because you've made a change that requires the resource
  to be replaced.

  The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS
  account for data recovery and cleanup later (`RemovalPolicy.RETAIN`).

- `defaultAccessLogFormat(): AccessLogFormat` — CLF Log format for HTTP API Stage.

- `fromHttpStageAttributes(scope: Construct, id: string, attrs: HttpStageAttributes): IHttpStage` (static) — Import an existing stage into this CDK app.

- `isConstruct(x: any): boolean` (static) — Checks if `x` is a construct.

  Use this method instead of `instanceof` to properly detect `Construct`
  instances, even when the construct library is symlinked.

  Explanation: in JavaScript, multiple copies of the `constructs` library on
  disk are seen as independent, completely different libraries. As a
  consequence, the class `Construct` in each copy of the `constructs` library
  is seen as a different class, and an instance of one class will not test as
  `instanceof` the other class. `npm install` will not create installations
  like this, but users may manually symlink construct libraries together or
  use a monorepo tool: in those cases, multiple copies of the `constructs`
  library can be accidentally installed, and `instanceof` will behave
  unpredictably. It is safest to avoid using `instanceof`, and using
  this type-testing method instead.

  **Parameters**

  - `x` — Any object.

  **Returns:** true if `x` is an object created from a class which extends `Construct`.

- `isOwnedResource(construct: IConstruct): boolean` (static) — Returns true if the construct was created by CDK, and false otherwise.

- `isResource(construct: IConstruct): boolean` (static) — Check whether the given construct is a Resource.

- `metric(metricName: string, props?: MetricOptions): Metric` — Return the given named metric for this HTTP Api Gateway Stage.

- `metricClientError(props?: MetricOptions): Metric` — Metric for the number of client-side errors captured in a given period.

- `metricCount(props?: MetricOptions): Metric` — Metric for the total number API requests in a given period.

- `metricDataProcessed(props?: MetricOptions): Metric` — Metric for the amount of data processed in bytes.

- `metricIntegrationLatency(props?: MetricOptions): Metric` — Metric for the time between when API Gateway relays a request to the backend and when it receives a response from the backend.

- `metricLatency(props?: MetricOptions): Metric` — The time between when API Gateway receives a request from a client and when it returns a response to the client.

  The latency includes the integration latency and other API Gateway overhead.

- `metricServerError(props?: MetricOptions): Metric` — Metric for the number of server-side errors captured in a given period.

- `toString(): string` — Returns a string representation of this construct.

- `with(...mixins: IMixin[]): IConstruct` — Applies one or more mixins to this construct.

  Mixins are applied in order. The list of constructs is captured at the
  start of the call, so constructs added by a mixin will not be visited.
  Use multiple `with()` calls if subsequent mixins should apply to added
  constructs.
