# RuntimeCustomClaim

Represents a custom claim validation configuration for Runtime JWT authorizers.

Custom claims allow you to validate additional fields in JWT tokens beyond
the standard audience, client, and scope validations.

Obtainable from: RuntimeCustomClaim.withStringArrayValue, RuntimeCustomClaim.withStringValue
Used as argument in: [RuntimeAuthorizerConfiguration.usingCognito](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_bedrockagentcore.RuntimeAuthorizerConfiguration.html#usingcognito), RuntimeAuthorizerConfiguration.usingJWT, RuntimeAuthorizerConfiguration.usingOAuth

- Source: [`aws-bedrockagentcore/lib/runtime/inbound-auth/custom-claim.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-bedrockagentcore/lib/runtime/inbound-auth/custom-claim.ts#L26)
- Type last changed: v2.255.0 · 19 May 2026

## Example

TypeScript:

```ts
declare const userPool: cognito.UserPool;
declare const userPoolClient: cognito.UserPoolClient;
declare const anotherUserPoolClient: cognito.UserPoolClient;

const repository = new ecr.Repository(this, "TestRepository", {
  repositoryName: "test-agent-runtime",
});
const agentRuntimeArtifact = agentcore.AgentRuntimeArtifact.fromEcrRepository(repository, "v1.0.0");

// Optional: Create custom claims for additional validation
const customClaims = [
  agentcore.RuntimeCustomClaim.withStringValue('department', 'engineering'),
  agentcore.RuntimeCustomClaim.withStringArrayValue('roles', ['admin'], agentcore.CustomClaimOperator.CONTAINS),
  agentcore.RuntimeCustomClaim.withStringArrayValue('permissions', ['read', 'write'], agentcore.CustomClaimOperator.CONTAINS_ANY),
];

const runtime = new agentcore.Runtime(this, "MyAgentRuntime", {
  runtimeName: "myAgent",
  agentRuntimeArtifact: agentRuntimeArtifact,
  authorizerConfiguration: agentcore.RuntimeAuthorizerConfiguration.usingCognito(
    userPool, // User Pool (required)
    [userPoolClient, anotherUserPoolClient], // User Pool Clients
    ["audience1"], // Allowed Audiences (optional)
    ["read", "write"], // Allowed Scopes (optional)
    customClaims, // Custom claims (optional) - see Custom Claims Validation section
  ),
});
```

Python:

```python
# user_pool: cognito.UserPool
# user_pool_client: cognito.UserPoolClient
# another_user_pool_client: cognito.UserPoolClient

repository = ecr.Repository(self, "TestRepository",
    repository_name="test-agent-runtime"
)
agent_runtime_artifact = agentcore.AgentRuntimeArtifact.from_ecr_repository(repository, "v1.0.0")

# Optional: Create custom claims for additional validation
custom_claims = [
    agentcore.RuntimeCustomClaim.with_string_value("department", "engineering"),
    agentcore.RuntimeCustomClaim.with_string_array_value("roles", ["admin"], agentcore.CustomClaimOperator.CONTAINS),
    agentcore.RuntimeCustomClaim.with_string_array_value("permissions", ["read", "write"], agentcore.CustomClaimOperator.CONTAINS_ANY)
]

runtime = agentcore.Runtime(self, "MyAgentRuntime",
    runtime_name="myAgent",
    agent_runtime_artifact=agent_runtime_artifact,
    authorizer_configuration=agentcore.RuntimeAuthorizerConfiguration.using_cognito(user_pool, [user_pool_client, another_user_pool_client], ["audience1"], ["read", "write"], custom_claims)
)
```

Java:

```java
UserPool userPool;
UserPoolClient userPoolClient;
UserPoolClient anotherUserPoolClient;

Repository repository = Repository.Builder.create(this, "TestRepository")
        .repositoryName("test-agent-runtime")
        .build();
AgentRuntimeArtifact agentRuntimeArtifact = AgentRuntimeArtifact.fromEcrRepository(repository, "v1.0.0");

// Optional: Create custom claims for additional validation
RuntimeCustomClaim[] customClaims = List.of(RuntimeCustomClaim.withStringValue("department", "engineering"), RuntimeCustomClaim.withStringArrayValue("roles", List.of("admin"), CustomClaimOperator.CONTAINS), RuntimeCustomClaim.withStringArrayValue("permissions", List.of("read", "write"), CustomClaimOperator.CONTAINS_ANY));

Runtime runtime = Runtime.Builder.create(this, "MyAgentRuntime")
        .runtimeName("myAgent")
        .agentRuntimeArtifact(agentRuntimeArtifact)
        .authorizerConfiguration(RuntimeAuthorizerConfiguration.usingCognito(userPool, List.of(userPoolClient, anotherUserPoolClient), List.of("audience1"), List.of("read", "write"), customClaims))
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
UserPool userPool;
UserPoolClient userPoolClient;
UserPoolClient anotherUserPoolClient;

var repository = new Repository(this, "TestRepository", new RepositoryProps {
    RepositoryName = "test-agent-runtime"
});
var agentRuntimeArtifact = AgentRuntimeArtifact.FromEcrRepository(repository, "v1.0.0");

// Optional: Create custom claims for additional validation
var customClaims = new [] { RuntimeCustomClaim.WithStringValue("department", "engineering"), RuntimeCustomClaim.WithStringArrayValue("roles", new [] { "admin" }, CustomClaimOperator.CONTAINS), RuntimeCustomClaim.WithStringArrayValue("permissions", new [] { "read", "write" }, CustomClaimOperator.CONTAINS_ANY) };

var runtime = new Runtime(this, "MyAgentRuntime", new RuntimeProps {
    RuntimeName = "myAgent",
    AgentRuntimeArtifact = agentRuntimeArtifact,
    AuthorizerConfiguration = RuntimeAuthorizerConfiguration.UsingCognito(userPool, new [] { userPoolClient, anotherUserPoolClient }, new [] { "audience1" }, new [] { "read", "write" }, customClaims)
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var userPool UserPool
var userPoolClient UserPoolClient
var anotherUserPoolClient UserPoolClient

repository := ecr.NewRepository(this, jsii.String("TestRepository"), &RepositoryProps{
	RepositoryName: jsii.String("test-agent-runtime"),
})
agentRuntimeArtifact := agentcore.AgentRuntimeArtifact_FromEcrRepository(repository, jsii.String("v1.0.0"))

// Optional: Create custom claims for additional validation
customClaims := []RuntimeCustomClaim{
	agentcore.RuntimeCustomClaim_WithStringValue(jsii.String("department"), jsii.String("engineering")),
	agentcore.RuntimeCustomClaim_WithStringArrayValue(jsii.String("roles"), []*string{
		jsii.String("admin"),
	}, agentcore.CustomClaimOperator_CONTAINS),
	agentcore.RuntimeCustomClaim_WithStringArrayValue(jsii.String("permissions"), []*string{
		jsii.String("read"),
		jsii.String("write"),
	}, agentcore.CustomClaimOperator_CONTAINS_ANY),
}

runtime := agentcore.NewRuntime(this, jsii.String("MyAgentRuntime"), &RuntimeProps{
	RuntimeName: jsii.String("myAgent"),
	AgentRuntimeArtifact: agentRuntimeArtifact,
	AuthorizerConfiguration: agentcore.RuntimeAuthorizerConfiguration_UsingCognito(userPool, []IUserPoolClient{
		userPoolClient,
		anotherUserPoolClient,
	}, []*string{
		jsii.String("audience1"),
	}, []*string{
		jsii.String("read"),
		jsii.String("write"),
	}, customClaims),
})
```

## Methods

- `withStringArrayValue(name: string, values: string[], operator?: CustomClaimOperator): RuntimeCustomClaim // chainable` (static) — Create a custom claim with a string array value.

  String array claims can use CONTAINS (default) or CONTAINS_ANY operator.

  **Parameters**

  - `name` — The name of the claim in the JWT token.
  - `values` — The array of string values to match.
  - `operator` — The match operator (defaults to CONTAINS).

  **Returns:** A RuntimeCustomClaim configured for string array validation

- `withStringValue(name: string, value: string): RuntimeCustomClaim // chainable` (static) — Create a custom claim with a string value.

  String claims must use the EQUALS operator.

  **Parameters**

  - `name` — The name of the claim in the JWT token.
  - `value` — The string value to match (must exactly equal).

  **Returns:** A RuntimeCustomClaim configured for string validation
