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

# Kafka Connect InsertHeader SMT Usage Reference for Confluent Platform

The `InsertHeader` SMT (`org.apache.kafka.connect.transforms.InsertHeader`)
adds a header with a literal value to each Apache Kafka® record.

## Description

Use `InsertHeader` to add a header with a fixed literal value to every
record. Connect parses the literal into the corresponding data type based
on its format (for example, `1234` becomes an integer and `true` becomes a
boolean).

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

## Properties

| Name            | Description                                                                                                                                                                                                                                                                                                                      | Type   | Default   | Valid values    | Importance   |
|-----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------|-----------|-----------------|--------------|
| `header`        | Header name to use with the transformation.                                                                                                                                                                                                                                                                                      | string |           | non-null string | high         |
| `value.literal` | The header value to add to each record. If the value appears to be a primitive literal (such as an 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 | high         |

## 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 preceding example, 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.literal` 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).

## Predicates

Configure transformations with predicates to ensure they process only records
that satisfy a particular condition. You can also use predicates in a
transformation chain with the [Kafka Connect Filter (Kafka) SMT Usage Reference for Confluent Platform](filter-ak.md#ak-filter) to conditionally filter specific
records. For more information, see [Predicates](filter-ak.md#predicates).
