Skip to content
v2.274.0

FromApiKeyIdentityOptions Struct ​

Optional gateway settings when binding an {@link IApiKeyCredentialProvider} to a target.

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 ​

credentialLocationoptionalApiKeyCredentialLocationcredential_locationoptionalApiKeyCredentialLocationcredentialLocationoptionalApiKeyCredentialLocationCredentialLocationoptionalApiKeyCredentialLocationCredentialLocationoptionalApiKeyCredentialLocation#
Where to place the API key on outbound requests.

Default: header Authorization with Bearer prefix