<a id="insertheader"></a>

# Kafka Connect InsertHeader SMT Usage Reference for Confluent Cloud

The following provides usage information for the Apache Kafka® SMT
`org.apache.kafka.connect.transforms.InsertHeader`.

## Description

Inserts a header for each record.

## Example

This configuration snippet shows how to use `InsertHeader` to insert a header
named `app.id` with the literal value `best-app-ever` on each record.

```json
"transforms": "insertAppIdHeader",
"transforms.insertAppIdHeader.type": "org.apache.kafka.connect.transforms.InsertHeader",
"transforms.insertAppIdHeader.header": "app.id",
"transforms.insertAppIdHeader.value.literal": "best-app-ever"
```

Before: No header named `app.id` or value in records.

After: Each record contains header value `best-app-ever`.

In the example above, Connect parses the literal value `best-app-ever` into
[STRING type](https://docs.confluent.io/platform/current/connect/javadocs/javadoc/org/apache/kafka/connect/data/Schema.Type.html#STRING).
The following lists sample values for the value property and the data types that
Connect parses the value into:

* `1234` is parsed into [INT16 type](https://docs.confluent.io/platform/current/connect/javadocs/javadoc/org/apache/kafka/connect/data/Schema.Type.html#INT16).
* `true` is parsed into [BOOLEAN type](https://docs.confluent.io/platform/current/connect/javadocs/javadoc/org/apache/kafka/connect/data/Schema.Type.html#BOOLEAN).
* `null` is parsed into null (with no type).
* `[-3, 0, 5]` is parsed into an [ARRAY](https://docs.confluent.io/platform/current/connect/javadocs/javadoc/org/apache/kafka/connect/data/Schema.Type.html#ARRAY) of [INT8 elements](https://docs.confluent.io/platform/current/connect/javadocs/javadoc/org/apache/kafka/connect/data/Schema.Type.html#INT8).
* `{3.4: 4761, -5.9: -9753186420}` is parsed into a [MAP](https://docs.confluent.io/platform/current/connect/javadocs/javadoc/org/apache/kafka/connect/data/Schema.Type.html#MAP) with [FLOAT32 keys](https://docs.confluent.io/platform/current/connect/javadocs/javadoc/org/apache/kafka/connect/data/Schema.Type.html#FLOAT32) and [INT64 values](https://docs.confluent.io/platform/current/connect/javadocs/javadoc/org/apache/kafka/connect/data/Schema.Type.html#INT64).

## Properties

| Name     | Description                                                                                                                                                                                                                                                                                                                            | Type   | Default   | Valid Values    | Importance   |
|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------|-----------|-----------------|--------------|
| `header` | Header name to use with the transformation.                                                                                                                                                                                                                                                                                            | string |           | non-null string | medium       |
| `value`  | The header value to add to each record. If the value appears to be a primitive literal (such as a 32-bit integer, boolean, or null) or a complex literal (such as an array or map denoted with JSON-like syntax), the value is parsed and added to the header as that type. Otherwise, the raw string for this property is used as-is. | string |           | non-null string | medium       |

## Predicates

Transformations can be configured with *predicates* so that the transformation
is applied only to records which satisfy a condition. You can use predicates in
a transformation chain and, when combined with the [Kafka Connect Filter (Kafka) SMT Usage Reference for Confluent Cloud](filter-ak.md#ak-filter), predicates
can conditionally filter out specific records. For details and examples, see [Predicates](filter-ak.md#predicates).
