Use the Confluent CLI with multiple credentials on Confluent Cloud

You can use the Confluent CLI confluent kafka topic produce and confluent kafka topic consume commands to set up API keys not tied to any user account.

This is recommended for a more secure setup, in cases where you are not using service accounts.

User-agnostic API keys for produce and consume

Specify API keys and API secrets directly on producers and consumers.

Previous versions of the Confluent CLI offered the option to create your own custom contexts for user-agnostic authentication of producers and consumers into Confluent Cloud. (You could pair API keys and API secrets with custom contexts instead of user accounts.)

In current versions of the Confluent CLI (v.3 and newer), confluent kafka topic produce and confluent kafka topic consume support the --bootstrap, --api-key, and --api-secret flags directly so that custom contexts are not unnecessary.

Use these produce and consume commands for user-agnostic authentication into Confluent Cloud.

Using system-provided contexts

You can provide restricted access to Confluent Cloud resources by using the Confluent CLI with system-provided contexts.

A context represents a user’s login state, whether that be with Confluent Cloud or Confluent Platform, and other associated settings that persist between command executions.

Hybrid use cases

The ability to quickly switch contexts is especially important to hybrid users using both Confluent Cloud and Confluent Platform. Run confluent context list to see the list of available contexts:

confluent context list

If a context name is too tedious to type, it can be renamed:

confluent context update --name cloud

Then, switching to a new context is as easy as:

confluent context use cloud

For a detailed example, see Context switching and Hybrid demo in the CLI blog posts.

Schema contexts

Contexts can also be used to group schema subject names and IDs, and provide flexibility for referencing schemas, and are a key component of Schema Linking. In these scenarios, you do have the option to create custom schema contexts. To learn more, see Work with schema contexts.