---
source_url: https://www.pubnub.com/docs/integrations/event-forwarding/create-kafka-action
title: Create a Kafka action
updated_at: 2026-09-30T07:20:08.000Z
---

# Create a Kafka action

## Documentation index

To discover more PubNub resources:

1. Fetch [PubNub's llms.txt](https://www.pubnub.com/llms-full.txt) for a list of available pages in Markdown format.
2. Identify relevant URLs from that index.
3. Fetch the target pages.

Do not assume a path exists, always check the index first.

Create a Kafka action when you want [Events & Actions](https://www.pubnub.com/docs/integrations/event-forwarding/overview.md) to forward matching PubNub events to an [Apache Kafka](https://kafka.apache.org/) topic. You configure the action in the [Admin Portal](https://admin.pubnub.com/), and it connects to any correctly configured broker, self-hosted or managed, because Events & Actions is hosting-agnostic for Kafka.

If you already have a Kafka topic, broker address, and credentials, skip to [Configure the Kafka action](#configure-the-kafka-action).

## Set up your Kafka environment

Gather the following information from your Kafka environment before you configure the action:

* Topic and, optionally, a key.
* Broker URL and port.
* Username and password.

If you host Kafka yourself or on a managed service such as [Amazon MSK](https://aws.amazon.com/msk/), use the [Kafka Quick Start](https://kafka.apache.org/documentation/#quickstart) or your provider's setup guide to create a cluster and topic. Then gather the information above.

If you use [Confluent Cloud](https://confluent.cloud), follow these steps instead.

### Create a Confluent Cloud cluster, topic, and API key

1. Log in to Confluent Cloud and create a Kafka cluster to receive PubNub messages. Select a cloud provider and cluster type, and complete the wizard.
2. After the cluster launches, open **Cluster Settings** and note the **Bootstrap server**. This is the broker URL you enter in the Admin Portal.
3. On the cluster overview page, click **Topics**, then **Create topic**, and configure it. Create the topic before you send PubNub data to it, so the first delivery doesn't fail against a topic that doesn't exist yet.
4. On the cluster overview page, click **API keys**, then **Create key**, and configure it. Note the **Key** and **Secret** values before you click **Download and continue**. Clicking it hides the secret afterward, so copy both values first.

## Configure the Kafka action

1. In **Events & Actions** in the [Admin Portal](https://admin.pubnub.com/), select your app and keyset, then click **+ Add Action**.
2. Select **Apache Kafka** as the action type.
3. In **Routing Key**, enter your topic, for example `topic_0`.
4. If you want to keep related events in order, add a key by entering `topic:key`, for example `topic_0:stamford`. Kafka guarantees order only within a single partition, and a key routes matching messages to the same partition consistently.
5. In **Authentication Mechanism**, select the type your Kafka setup uses: [SASL/PLAIN](https://docs.confluent.io/platform/current/kafka/authentication_sasl/authentication_sasl_plain.html#kafka-sasl-auth-plain), [SCRAM-SHA-256](https://docs.confluent.io/platform/current/kafka/authentication_sasl/authentication_sasl_scram.html#kafka-sasl-auth-scram), or [SCRAM-SHA-512](https://docs.confluent.io/platform/current/kafka/authentication_sasl/authentication_sasl_scram.html#kafka-sasl-auth-scram).
6. In **Username** and **Password**, enter your Kafka credentials. In Confluent Cloud, use the **Key** as the username and the **Secret** as the password.
7. In **Brokers**, enter the broker URL, for example `574mf0rd-bridge.ldn-west:1905`, or a comma-separated list such as `hostname:port, hostname2:port`. Use a secure listener because PubNub rejects unsecured connections to Kafka.
8. If you want failed deliveries retried automatically, enable and configure **Kafka retry**. See [Available actions](https://www.pubnub.com/docs/integrations/event-forwarding/available-actions.md) for the retry policy and backoff formula.
9. Click **Add event listener** and pair the action with an existing event listener, or [create one](https://www.pubnub.com/docs/integrations/event-forwarding/configure.md).
10. Click **Save changes**.

[Publish](https://www.pubnub.com/docs/pub-sub/publish/overview.md) a message that matches the paired listener's filter and confirm it arrives on the Kafka topic.

## Related tasks

* [Configure Events & Actions](https://www.pubnub.com/docs/integrations/event-forwarding/configure.md). Create the event listener that triggers this action.
* [Available actions](https://www.pubnub.com/docs/integrations/event-forwarding/available-actions.md). Look up the retry and envelope settings shared by every action type.
* [Stream Kafka records to PubNub clients](https://www.pubnub.com/docs/integrations/connect-pubnub-to-kafka.md). Receive Kafka events into PubNub instead of forwarding PubNub events out.
* [Kafka integration overview](https://www.pubnub.com/docs/integrations/kafka-overview.md). Understand how this action relates to the PubNub Kafka Sink Connector.
* [Events & Actions](https://www.pubnub.com/docs/integrations/event-forwarding/overview.md). Understand event listeners, filters, and the concepts behind Events & Actions.

Last updated at: 2026-09-30T07:20:08.000Z
