Bots
Fetch Bot Usage
Fetch bot usage statistics
get
/v1/bot/{botId}/usage/fetch
Description
Retrieve usage statistics for a specific bot, including total tokens (BASE type only), total conversations, and total messages. Optionally filter by date range.
Authorization
ChatBotKit API Secret * Required
HTTP Authorization Scheme: bearer
Path Parameters
botIdstring* Required
The ID of the bot
fromstring
Start date for the period (ISO 8601 format)
tostring
End date for the period (ISO 8601 format)
import { ChatBotKit } from '@chatbotkit/sdk'
const cbk = new ChatBotKit({
secret: process.env.CHATBOTKIT_API_KEY!
})
const response = await cbk.bot.usage.fetch(
botId)
{"tokens":"integer","conversations":"integer","messages":"integer"}Bot usage statistics retrieved successfully