# AddOpenApiTargetOptions

Options for adding an OpenAPI target to a gateway.

- Source: [`aws-bedrockagentcore/lib/gateway/gateway.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-bedrockagentcore/lib/gateway/gateway.ts#L77)
- Type last changed: v2.255.0 · 19 May 2026

## Example

```ts
const gateway = new agentcore.Gateway(this, "MyGateway", {
  gatewayName: "my-gateway",
});

// Create an API key credential provider in Token Vault
const apiKeyProvider = new agentcore.ApiKeyCredentialProvider(this, "MyApiKeyProvider", {
  apiKeyCredentialProviderName: "my-apikey",
});

const bucket = s3.Bucket.fromBucketName(this, "ExistingBucket", "my-schema-bucket");
const s3mySchema = agentcore.ApiSchema.fromS3File(bucket, "schemas/myschema.yaml");

// Add an OpenAPI target using the L2 construct directly
const target = gateway.addOpenApiTarget("MyTarget", {
  gatewayTargetName: "my-api-target",
  description: "Target for external API integration",
  apiSchema: s3mySchema,
  credentialProviderConfigurations: [
    agentcore.GatewayCredentialProvider.fromApiKeyIdentity(apiKeyProvider, {
      credentialLocation: agentcore.ApiKeyCredentialLocation.header({
        credentialParameterName: "X-API-Key",
      }),
    }),
  ],
});

// This makes sure your s3 bucket is available before target
target.node.addDependency(bucket);
```

## Properties

- `apiSchema`: [ApiSchema](/cdk/api/v2/docs/aws-cdk-lib.aws_bedrockagentcore.ApiSchema.html) (required) — The OpenAPI schema defining the API.

- `credentialProviderConfigurations`: [ICredentialProviderConfig](/cdk/api/v2/docs/aws-cdk-lib.aws_bedrockagentcore.ICredentialProviderConfig.html)[] — Credential providers for outbound authentication (OpenAPI targets use API Key or OAuth, not IAM).

  **Default:** none (no credential configuration on the target; supply providers for secured backends)

- `description`: string — Optional description for the gateway target.

  **Default:** No description

- `gatewayTargetName`: string — The name of the gateway target Valid characters are a-z, A-Z, 0-9, _ (underscore) and - (hyphen).

  **Default:** auto generate

- `validateOpenApiSchema`: boolean = true — Whether to validate the OpenAPI schema or not Note: Validation is only performed for inline and asset-based schema and during CDK synthesis.

  S3 schemas cannot be validated at synthesis time.
