# AddHeader

Adds a header to the received email.

Implements: [IReceiptRuleAction](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ses.IReceiptRuleAction.html)

- Source: [`aws-ses-actions/lib/add-header.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-ses-actions/lib/add-header.ts#L26)
- Type last changed: v2.235.0 · 15 Jan 2026

## Example

TypeScript:

```ts
import * as s3 from 'aws-cdk-lib/aws-s3';
import * as actions from 'aws-cdk-lib/aws-ses-actions';

const bucket = new s3.Bucket(this, 'Bucket');
const topic = new sns.Topic(this, 'Topic');

new ses.ReceiptRuleSet(this, 'RuleSet', {
  rules: [
    {
      recipients: ['hello@aws.com'],
      actions: [
        new actions.AddHeader({
          name: 'X-Special-Header',
          value: 'aws',
        }),
        new actions.S3({
          bucket,
          objectKeyPrefix: 'emails/',
          topic,
        }),
      ],
    },
    {
      recipients: ['aws.com'],
      actions: [
        new actions.Sns({
          topic,
        }),
      ],
    },
  ],
});
```

Python:

```python
import aws_cdk.aws_s3 as s3
import aws_cdk.aws_ses_actions as actions

bucket = s3.Bucket(self, "Bucket")
topic = sns.Topic(self, "Topic")

ses.ReceiptRuleSet(self, "RuleSet",
    rules=[ses.ReceiptRuleOptions(
        recipients=["hello@aws.com"],
        actions=[
            actions.AddHeader(
                name="X-Special-Header",
                value="aws"
            ),
            actions.S3(
                bucket=bucket,
                object_key_prefix="emails/",
                topic=topic
            )
        ]
    ), ses.ReceiptRuleOptions(
        recipients=["aws.com"],
        actions=[
            actions.Sns(
                topic=topic
            )
        ]
    )
    ]
)
```

Java:

```java
import software.amazon.awscdk.services.s3.*;
import software.amazon.awscdk.services.ses.actions.*;

Bucket bucket = new Bucket(this, "Bucket");
Topic topic = new Topic(this, "Topic");

ReceiptRuleSet.Builder.create(this, "RuleSet")
        .rules(List.of(ReceiptRuleOptions.builder()
                .recipients(List.of("hello@aws.com"))
                .actions(List.of(
                    AddHeader.Builder.create()
                            .name("X-Special-Header")
                            .value("aws")
                            .build(),
                    S3.Builder.create()
                            .bucket(bucket)
                            .objectKeyPrefix("emails/")
                            .topic(topic)
                            .build()))
                .build(), ReceiptRuleOptions.builder()
                .recipients(List.of("aws.com"))
                .actions(List.of(
                    Sns.Builder.create()
                            .topic(topic)
                            .build()))
                .build()))
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.S3;
using Amazon.CDK.AWS.SES.Actions;

var bucket = new Bucket(this, "Bucket");
var topic = new Topic(this, "Topic");

new ReceiptRuleSet(this, "RuleSet", new ReceiptRuleSetProps {
    Rules = new [] { new ReceiptRuleOptions {
        Recipients = new [] { "hello@aws.com" },
        Actions = new [] {
            new AddHeader(new AddHeaderProps {
                Name = "X-Special-Header",
                Value = "aws"
            }),
            new S3(new S3Props {
                Bucket = bucket,
                ObjectKeyPrefix = "emails/",
                Topic = topic
            }) }
    }, new ReceiptRuleOptions {
        Recipients = new [] { "aws.com" },
        Actions = new [] {
            new Sns(new SnsProps {
                Topic = topic
            }) }
    } }
});
```

Golang:

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

bucket := s3.NewBucket(this, jsii.String("Bucket"))
topic := sns.NewTopic(this, jsii.String("Topic"))

ses.NewReceiptRuleSet(this, jsii.String("RuleSet"), &ReceiptRuleSetProps{
	Rules: []ReceiptRuleOptions{
		&ReceiptRuleOptions{
			Recipients: []*string{
				jsii.String("hello@aws.com"),
			},
			Actions: []IReceiptRuleAction{
				actions.NewAddHeader(&AddHeaderProps{
					Name: jsii.String("X-Special-Header"),
					Value: jsii.String("aws"),
				}),
				actions.NewS3(&S3Props{
					Bucket: *Bucket,
					ObjectKeyPrefix: jsii.String("emails/"),
					Topic: *Topic,
				}),
			},
		},
		&ReceiptRuleOptions{
			Recipients: []*string{
				jsii.String("aws.com"),
			},
			Actions: []IReceiptRuleAction{
				actions.NewSns(&SnsProps{
					Topic: *Topic,
				}),
			},
		},
	},
})
```

## Initializer

TypeScript:

```ts
new AddHeader(props: AddHeaderProps)
```

Python:

```python
AddHeader(props: AddHeaderProps)
```

Java:

```java
new AddHeader(AddHeaderProps props)
```

C# / .NET:

```csharp
new AddHeader(AddHeaderProps props)
```

Golang:

```go
NewAddHeader(Props AddHeaderProps)
```

## Methods

- `bind(_rule: IReceiptRuleRef): ReceiptRuleActionConfig` — Returns the receipt rule action specification.
