# ApiMappingOptions

Options for creating an api mapping.

Used as argument in: [DomainName.addApiMapping](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.DomainName.html#addapimapping)

- Source: [`aws-apigateway/lib/domain-name.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-apigateway/lib/domain-name.ts#L21)
- Type last changed: v2.47.0 · 20 Oct 2022

## Example

TypeScript:

```ts
declare const acmCertificateForExampleCom: any;
declare const restApi: apigateway.RestApi;
declare const secondRestApi: apigateway.RestApi;

const domain = new apigateway.DomainName(this, 'custom-domain', {
  domainName: 'example.com',
  certificate: acmCertificateForExampleCom,
  mapping: restApi,
});

domain.addApiMapping(secondRestApi.deploymentStage, {
  basePath: 'orders/v2/api',
});
```

Python:

```python
# acm_certificate_for_example_com: Any
# rest_api: apigateway.RestApi
# second_rest_api: apigateway.RestApi

domain = apigateway.DomainName(self, "custom-domain",
    domain_name="example.com",
    certificate=acm_certificate_for_example_com,
    mapping=rest_api
)

domain.add_api_mapping(second_rest_api.deployment_stage,
    base_path="orders/v2/api"
)
```

Java:

```java
Object acmCertificateForExampleCom;
RestApi restApi;
RestApi secondRestApi;

DomainName domain = DomainName.Builder.create(this, "custom-domain")
        .domainName("example.com")
        .certificate(acmCertificateForExampleCom)
        .mapping(restApi)
        .build();

domain.addApiMapping(secondRestApi.getDeploymentStage(), ApiMappingOptions.builder()
        .basePath("orders/v2/api")
        .build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
var acmCertificateForExampleCom;
RestApi restApi;
RestApi secondRestApi;

var domain = new DomainName(this, "custom-domain", new DomainNameProps {
    DomainName = "example.com",
    Certificate = acmCertificateForExampleCom,
    Mapping = restApi
});

domain.AddApiMapping(secondRestApi.DeploymentStage, new ApiMappingOptions {
    BasePath = "orders/v2/api"
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var acmCertificateForExampleCom interface{}
var restApi RestApi
var secondRestApi RestApi

domain := apigateway.NewDomainName(this, jsii.String("custom-domain"), &DomainNameProps{
	DomainName: jsii.String("example.com"),
	Certificate: acmCertificateForExampleCom,
	Mapping: restApi,
})

domain.AddApiMapping(secondRestApi.DeploymentStage, &ApiMappingOptions{
	BasePath: jsii.String("orders/v2/api"),
})
```

## Properties

- `basePath`: string — The api path name that callers of the API must provide in the URL after the domain name (e.g. `example.com/base-path`). If you specify this property, it can't be an empty string.

  **Default:** map requests from the domain root (e.g. `example.com`).

  If this is undefined, a mapping will be added for the empty path. Any request
  that does not match a mapping will get sent to the API that has been mapped
  to the empty path.
