Get a bot's API key

GET https://chat.zulip.org/api/v1/bots/{bot_id}/api_key

Fetch the API key for a bot user. Only the bot's owner and organization administrators have access to a bot's API key.

Changes: New in Zulip 12.0 (feature level 463).

Usage examples

#!/usr/bin/env python3

import zulip

# Pass the path to your zuliprc file here.
client = zulip.Client(config_file="~/zuliprc")

# Fetch a bot's API key, given the bot's ID.
result = client.call_endpoint(
    url=f"/bots/{bot_id}/api_key",
    method="GET",
)
print(result)

The -u line implements HTTP Basic authentication. See the Authorization header documentation for how to get those credentials for Zulip users and bots.

curl -sSX GET -G https://chat.zulip.org/api/v1/bots/17/api_key \
    -u EMAIL_ADDRESS:API_KEY

Parameters

bot_id integer required in path

Example: 17

The user ID of the target bot.


Response

Return values

  • api_key: string

    The API key for the bot.

Example response(s)

Changes: As of Zulip 7.0 (feature level 167), if any parameters sent in the request are not supported by this endpoint, a successful JSON response will include an ignored_parameters_unsupported array.

A typical successful JSON response may look like:

{
    "api_key": "hkA04ZYcqXKalvYMA8OeXSfzUOLrtbZv",
    "msg": "",
    "result": "success"
}

An example JSON response when the bot ID is invalid:

{
    "code": "BAD_REQUEST",
    "msg": "No such bot",
    "result": "error"
}