# HttpApiProps

Properties to initialize an instance of `HttpApi`.

Used as props by: [HttpApi](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.HttpApi.html)

- Source: [`aws-apigatewayv2/lib/http/api.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-apigatewayv2/lib/http/api.ts#L131)
- Type last changed: v2.189.0 · 9 Apr 2025

## Example

TypeScript:

```ts
import { HttpAlbIntegration } from 'aws-cdk-lib/aws-apigatewayv2-integrations';

declare const lb: elbv2.ApplicationLoadBalancer;
const listener = lb.addListener('listener', { port: 80 });
listener.addTargets('target', {
  port: 80,
});

const httpEndpoint = new apigwv2.HttpApi(this, 'HttpProxyPrivateApi', {
  defaultIntegration: new HttpAlbIntegration('DefaultIntegration', listener, {
    parameterMapping: new apigwv2.ParameterMapping().custom('myKey', 'myValue'),
  }),
});
```

Python:

```python
from aws_cdk.aws_apigatewayv2_integrations import HttpAlbIntegration

# lb: elbv2.ApplicationLoadBalancer

listener = lb.add_listener("listener", port=80)
listener.add_targets("target",
    port=80
)

http_endpoint = apigwv2.HttpApi(self, "HttpProxyPrivateApi",
    default_integration=HttpAlbIntegration("DefaultIntegration", listener,
        parameter_mapping=apigwv2.ParameterMapping().custom("myKey", "myValue")
    )
)
```

Java:

```java
import software.amazon.awscdk.aws_apigatewayv2_integrations.HttpAlbIntegration;

ApplicationLoadBalancer lb;

ApplicationListener listener = lb.addListener("listener", BaseApplicationListenerProps.builder().port(80).build());
listener.addTargets("target", AddApplicationTargetsProps.builder()
        .port(80)
        .build());

HttpApi httpEndpoint = HttpApi.Builder.create(this, "HttpProxyPrivateApi")
        .defaultIntegration(HttpAlbIntegration.Builder.create("DefaultIntegration", listener)
                .parameterMapping(new ParameterMapping().custom("myKey", "myValue"))
                .build())
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AwsApigatewayv2Integrations;

ApplicationLoadBalancer lb;

var listener = lb.AddListener("listener", new BaseApplicationListenerProps { Port = 80 });
listener.AddTargets("target", new AddApplicationTargetsProps {
    Port = 80
});

var httpEndpoint = new HttpApi(this, "HttpProxyPrivateApi", new HttpApiProps {
    DefaultIntegration = new HttpAlbIntegration("DefaultIntegration", listener, new HttpAlbIntegrationProps {
        ParameterMapping = new ParameterMapping().Custom("myKey", "myValue")
    })
});
```

Golang:

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

var lb ApplicationLoadBalancer

listener := lb.AddListener(jsii.String("listener"), &BaseApplicationListenerProps{
	Port: jsii.Number(80),
})
listener.AddTargets(jsii.String("target"), &AddApplicationTargetsProps{
	Port: jsii.Number(80),
})

httpEndpoint := apigwv2.NewHttpApi(this, jsii.String("HttpProxyPrivateApi"), &HttpApiProps{
	DefaultIntegration: awscdk.NewHttpAlbIntegration(jsii.String("DefaultIntegration"), listener, &HttpAlbIntegrationProps{
		ParameterMapping: apigwv2.NewParameterMapping().Custom(jsii.String("myKey"), jsii.String("myValue")),
	}),
})
```

## Properties

- `apiName`: string — Name for the HTTP API resource.

  **Default:** id of the HttpApi construct.

- `corsPreflight`: [CorsPreflightOptions](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.CorsPreflightOptions.html) — Specifies a CORS configuration for an API.

  **Default:** CORS disabled.

- `createDefaultStage`: boolean = true — Whether a default stage and deployment should be automatically created.

- `defaultAuthorizationScopes`: string[] — Default OIDC scopes attached to all routes in the gateway, unless explicitly configured on the route.

  **Default:** no default authorization scopes

  The scopes are used with a COGNITO_USER_POOLS authorizer to authorize the method invocation.

- `defaultAuthorizer`: [IHttpRouteAuthorizer](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.IHttpRouteAuthorizer.html) — Default Authorizer applied to all routes in the gateway.

  **Default:** no default authorizer

- `defaultDomainMapping`: [DomainMappingOptions](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.DomainMappingOptions.html) — Configure a custom domain with the API mapping resource to the HTTP API.

  **Default:** no default domain mapping configured. meaningless if `createDefaultStage` is `false`.

- `defaultIntegration`: [HttpRouteIntegration](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.HttpRouteIntegration.html) = none — An integration that will be configured on the catch-all route ($default).

- `description`: string = none — The description of the API.

- `disableExecuteApiEndpoint`: boolean — Specifies whether clients can invoke your API using the default endpoint.

  **Default:** false execute-api endpoint enabled.

  By default, clients can invoke your API with the default
  `https://{api_id}.execute-api.{region}.amazonaws.com` endpoint. Set this to
  true if you would like clients to use your custom domain name.

- `ipAddressType`: [IpAddressType](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.IpAddressType.html) — The IP address types that can invoke the API.

  **Default:** undefined - AWS default is IPV4

- `routeSelectionExpression`: boolean = false — Whether to set the default route selection expression for the API.

  When enabled, "${request.method} ${request.path}" is set as the default route selection expression.
