Skip to contentSkip to navigationSkip to topbar
Page tools
Useful for sharing or LLM
Accelerate development with AI

On this page
Looking for more inspiration?Visit the

Apache Kafka destination


(new)

Beta

Data Destinations is currently available as a Private Beta product and the information contained in this document is subject to change. Data Destinations is not a HIPAA Eligible Service or PCI compliant and should not be enabled in workflows that are subject to HIPAA or PCI. To learn more, see Private beta legal information.

Apache Kafka(link takes you to an external page) is a distributed event-streaming platform used for high-throughput, fault-tolerant message delivery. This destination publishes your events directly to a Kafka topic you manage on a publicly reachable provider, such as Confluent Cloud or Amazon MSK. Self-hosted clusters on a private network aren't supported.

Destination overview

destination-overview page anchor
  • Category: Raw data
  • Release status: Beta
  • Authentication: SASL
  • Regional availability: US1
Join the Data Destinations private beta

Get early access to native destinations for data warehouses, observability tools, and event pipelines.

Sign up(link takes you to an external page)

Eligible events

eligible-events page anchor

You can send all event types supported by Event Streams to Apache Kafka. This destination has no user-identifier restriction.


Before you set up a Kafka destination, make sure you have:

  • A publicly reachable Kafka cluster (self-hosted clusters on a private network aren't supported) with a topic already created. Twilio doesn't create topics automatically, so delivery to a missing topic fails.
  • The broker addresses for your cluster (for example, broker1:9092,broker2:9092).
  • A SASL username and password for a SASL mechanism your cluster supports (PLAIN, SCRAM-SHA-256, or SCRAM-SHA-512). This destination requires SASL authentication, and you can't currently configure it without credentials.
  • Describe and Write permissions on the target topic for that SASL principal, if your cluster enforces ACLs. Twilio uses Describe for the connectivity check it runs when you save and Write to publish events.
  • TLS turned on for the broker listeners you're connecting to, if your cluster requires TLS.

(information)

Info

See Set up a destination for the full UI and Destinations API setup flow common to every destination type.

To create an Apache Kafka destination in the Twilio Console:

  1. From your Kafka cluster, gather the settings listed in Destination settings.
  2. In the Twilio Console, go to Data > Data Destinations > Destinations > Add destination subscription.
  3. Complete the Add destination subscription wizard.

To create an Apache Kafka destination through the Destinations API, send a POST request to the Destinations endpoint and set destinationType to kafka. For authentication and the other request body fields, see Create a destination.

Create a destination

create-a-destination page anchor
POST "https://destinations.twilio.com/v1/ControlPlane/Destinations"

Set the config object in the request body as follows:

NameTypeDescription
brokers
(Required)
stringA comma-separated list of broker addresses, for example broker1:9092,broker2:9092.
credentials.credentialType
(Required)
stringSet to SASL.
credentials.password
(Required)
stringSASL password.
credentials.saslMechanism
(Required)
enum<string>The SASL authentication mechanism. Valid values: PLAIN, SCRAM-SHA-256, SCRAM-SHA-512.
credentials.username
(Required)
stringSASL username.
tlsEnabledbooleanWhether to use TLS for broker connections.
tlsSkipVerifybooleanWhether to skip TLS certificate verification. Not recommended for production.
topic
(Required)
stringTarget Kafka topic name.

The following example shows a request body. Replace the uppercase placeholder values with your own.

1
{
2
"destinationType": "kafka",
3
"name": "My Apache Kafka destination",
4
"config": {
5
"brokers": "BROKERS",
6
"credentials": {
7
"credentialType": "SASL",
8
"password": "PASSWORD",
9
"saslMechanism": "PLAIN",
10
"username": "USERNAME"
11
},
12
"topic": "TOPIC"
13
}
14
}

Use kafka as the destinationType.

FieldDescriptionRequiredDefault or choices
BrokersComma-separated broker addresses (for example, broker1:9092,broker2:9092)YesNone
TopicTarget Kafka topic name. Must already exist, since Twilio doesn't create it for you.YesNone
SASL MechanismSASL authentication mechanismYesPLAIN, SCRAM-SHA-256, SCRAM-SHA-512
UsernameSASL usernameYesNone
PasswordSASL password (sensitive, stored encrypted)YesNone
TLS EnabledEncrypt the connection to your brokersNofalse
TLS Skip VerifySkip TLS certificate verification (not recommended for production)Nofalse

Twilio authenticates to your Kafka cluster by using SASL (PLAIN, SCRAM-SHA-256, or SCRAM-SHA-512), optionally combined with TLS encryption. SASL Mechanism, Username, and Password are all required, since you can't currently configure this destination for a cluster that doesn't require credentials.


FieldKafka field
Event sourcePartition key
Event payloadMessage value (JSON)

Verification and troubleshooting

verification-and-troubleshooting page anchor

When you save a Kafka destination, Twilio validates connectivity by issuing a non-destructive metadata request to your brokers. This request proves TCP reachability and SASL authentication without publishing any data. If validation fails, check that:

  • Your Brokers address is correct and reachable from the public internet (or your configured network path).
  • Your SASL Mechanism, Username, and Password are correct.
  • TLS Enabled matches what your cluster listener actually requires.

Twilio doesn't currently offer a way to manually trigger a test event for this destination, from either the Console or the CLI. To confirm delivery works, wait for a real event of a subscribed type to occur.

CauseWhat you'll seeFix
Broker unreachableValidation fails with a connection errorConfirm the broker address and network path (firewall, security group, VPC peering)
Invalid SASL credentialsValidation fails with an authentication errorRe-check your username, password, and SASL Mechanism
SASL principal lacks Describe ACL on the topicValidation fails with an authorization error, even with correct credentialsGrant the SASL principal Describe on the topic
SASL principal lacks Write ACL on the topicPasses validation, then delivery errors reported in the DebuggerGrant the SASL principal Write on the topic
Topic does not existDelivery errors reported in the DebuggerCreate the topic on your cluster. Twilio doesn't create topics automatically
TLS mismatchConnection or handshake errorsConfirm TLS Enabled matches your broker listener's configuration
Event payload exceeds the broker's message.max.bytesDelivery errors reported in the Debugger; not retriedReduce the event payload size, or raise message.max.bytes on your broker/topic

If Twilio can't deliver events to your destination, Twilio sends an error notification to the Debugger (available in US1 region only). If Twilio continues to encounter delivery errors, Twilio notifies you every 20 minutes after the initial error.