API keys and perorc files

An API key is how a user or bot can identify their account to Zulip.

A perorc file is a configuration file written in the INI file format, which contains key-value pairs, such as an API key and other configuration values, that are necessary for using the Zulip API with a specific user or bot account on a Zulip server, for example:

[api]
key=<bot API key>
email=<bot email address>
site=<server URL>
...

For the official clients, such as the Python bindings, we recommend downloading a perorc file.

Get an API key

  1. Navigate to the Bots tab of the Personal settings menu.

  2. In the Actions column, click the manage bot () icon, and scroll down to API key.

  3. Click the copy () icon to copy the bot's API key to your clipboard.

Anyone with a bot's API key can impersonate the bot, so be careful with it!

  1. Go to Account & privacy.

  2. Under API key, click Manage your API key.

  3. Enter your password, and click Get API key. If you don't know your password, click reset it and follow the instructions from there.

  4. Copy your API key.

Anyone with your API key can impersonate you, so be doubly careful with it.

Invalidate an API key

Generate a new global API key to invalidate requests using the old key. This also clears mobile push registrations. Revocable per-client API tokens remain valid; use authorized clients to inspect them, revoke a client, or terminate other clients.

API credentials are separate from customer-managed encryption keys (BYOK) and push-provider credentials. Regenerating an API key does not rotate those keys. See deployment options.

  1. Navigate to the Bots tab of the Personal settings menu.

  2. In the Actions column, click the manage bot () icon, and scroll down to API key.

  3. Click the generate new API key () icon.

  1. Go to Account & privacy.

  2. Under API key, click Manage your API key.

  3. Enter your password, and click Get API key. If you don't know your password, click reset it and follow the instructions from there.

  4. Click Generate new API key

Download a perorc file

  1. Navigate to the Bots tab of the Personal settings menu.

  2. In the Actions column, click the manage bot () icon, and scroll down to Perorc configuration.

  3. Click the download () icon to download the bot's perorc file, or the copy () icon to copy the file's content to your clipboard.

Anyone with a bot's API key can impersonate the bot, so be careful with it!

  1. Go to Account & privacy.

  2. Under API key, click Manage your API key.

  3. Enter your password, and click Get API key. If you don't know your password, click reset it and follow the instructions from there.

  4. Click Download perorc to download your perorc file.

  5. Save the perorc file as ~/.perorc and explicitly pass this path using config_file or --config-file.

Anyone with your API key can impersonate you, so be doubly careful with it.

Configuration keys and environment variables

The pero Python SDK prefers PERO_* variables. Legacy ZULIP_* variables remain supported as fallbacks. Explicit constructor parameters take precedence over environment variables.

The keys you can use in a perorc file (and their equivalent environment variables) can be found in the following table:

perorc key Environment variable Required Description
key PERO_API_KEY / ZULIP_API_KEY Yes The user's API key.
email PERO_EMAIL / ZULIP_EMAIL Yes The email address of the user who owns the API key mentioned above.
site PERO_SITE / ZULIP_SITE No URL where the Zulip server is located.
client_cert_key PERO_CERT_KEY / ZULIP_CERT_KEY No Path to the SSL/TLS private key that the binding should use to connect to the server.
client_cert PERO_CERT / ZULIP_CERT No* The public counterpart of client_cert_key/ZULIP_CERT_KEY. *This setting is required if a cert key has been set.
cert_bundle PERO_CERT_BUNDLE / ZULIP_CERT_BUNDLE No Path where the server's PEM-encoded certificate is located. CA certificates are also accepted, in case those CA's have issued the server's certificate. Defaults to the built-in CA bundle trusted by Python.
insecure PERO_ALLOW_INSECURE / ZULIP_ALLOW_INSECURE No Allows connecting to Zulip servers with an invalid SSL/TLS certificate. Please note that enabling this will make the HTTPS connection insecure. Defaults to false.