Telebot Creator API v2 - Flexible Authentication Documentation
Overview
This document describes the flexible authentication system implemented for the Telebot Creator API v2. The system supports both JWT cookie-based authentication and API key authentication, allowing users to choose the most appropriate method for their use case.
Authentication Methods
1. JWT Cookie Authentication (Web Interface)
Used by the web interface for user sessions.
Cookie Name:
login_tokenAlgorithm: HS256
Expiration: 6 hours (default) or 30 days (remember me)
2. API Key Authentication (Programmatic Access)
Used for programmatic access to the API.
Header:
Authorization: Bearer <api_key>Query Parameter:
?api_key=<api_key>JSON Body:
{"api_key": "<api_key>"}
Endpoints with Flexible Authentication
The following endpoints support both authentication methods:
Bot Management
Create Bot
Endpoint:
POST /v2/create-botDescription: Creates a new bot with the provided token and name
Request Body:
Response:
Delete Bot
Endpoint:
DELETE /v2/bots/{botid}Description: Soft deletes a bot (moves to deleted_bots collection)
URL Parameters:
botid: The unique identifier of the bot
Response:
Update Bot Token
Endpoint:
POST /v2/bots/{botid}/update-bot-tokenDescription: Updates the bot's Telegram token
URL Parameters:
botid: The unique identifier of the bot
Request Body:
Response:
Update Bot Version
Endpoint:
POST /v2/bots/{botid}/versionDescription: Updates the bot's telebot library version
URL Parameters:
botid: The unique identifier of the bot
Request Body:
Response:
Command Management
Create Command
Endpoint:
POST /v2/bots/{botid}/commandsDescription: Creates a new command for the bot
URL Parameters:
botid: The unique identifier of the bot
Request Body:
Response:
Update Command
Endpoint:
PUT /v2/bots/{botid}/commands/{command}Description: Updates an existing command's code
URL Parameters:
botid: The unique identifier of the botcommand: Base64 encoded command name
Request Body:
Response:
Get Command
Endpoint:
GET /v2/bots/{botid}/commands/{command}Description: Retrieves a specific command's details
URL Parameters:
botid: The unique identifier of the botcommand: Base64 encoded command name
Response:
Delete Command
Endpoint:
DELETE /v2/bots/{botid}/commands/{command}Description: Deletes a command from the bot
URL Parameters:
botid: The unique identifier of the botcommand: Base64 encoded command name
Response:
Rename Command
Endpoint:
PATCH /v2/bots/{botid}/commands/{command}/renameDescription: Renames an existing command
URL Parameters:
botid: The unique identifier of the botcommand: Base64 encoded current command name
Request Body:
Response:
Folder Management
Get Folders
Endpoint:
GET /v2/bots/{botid}/commands/foldersDescription: Retrieves all folders for a bot
URL Parameters:
botid: The unique identifier of the bot
Response:
Data Management
Export Users File
Endpoint:
POST /v2/export-users-file/{botid}Description: Exports bot users data in specified format
URL Parameters:
botid: The unique identifier of the bot
Request Body:
Response: File download with users data
Export Bot
Endpoint:
GET /v2/bots/{botid}/export-botDescription: Exports bot configuration and commands
URL Parameters:
botid: The unique identifier of the bot
Query Parameters:
format:json,yaml, ortxt(default:json)include_data:trueorfalse(default:false)
Response: File download with bot data
Import Commands
Endpoint:
POST /v2/bots/{botid}/import-commandsDescription: Imports commands from exported data
URL Parameters:
botid: The unique identifier of the bot
Request Body:
Response:
Bot Operations
Transfer Bot
Endpoint:
POST /v2/bots/{botid}/transfer-botDescription: Transfers bot ownership to another user
URL Parameters:
botid: The unique identifier of the bot
Request Body:
Response:
Clone Bot
Endpoint:
POST /v2/bots/{botid}/clone-botDescription: Creates a copy of the bot with optional new token
URL Parameters:
botid: The unique identifier of the bot
Request Body:
Response:
Command Name Encoding
For endpoints that require a command name in the URL path, the command name must be Base64 encoded to handle special characters safely.
Encoding Process
Original Command:
/startURL-Safe Base64 Encoding:
L3N0YXJ0Final URL:
/v2/bots/{botid}/commands/L3N0YXJ0
Examples
/start
L3N0YXJ0
/help
L2hlbHA=
/settings
L3NldHRpbmdz
hello_world
aGVsbG9fd29ybGQ=
user info
dXNlciBpbmZv
Code Examples
JavaScript/Node.js
Python
cURL Examples
Authentication Examples
Using Bearer Token in Header
Using API Key as Query Parameter
Using API Key in JSON Body
Error Responses
Authentication Errors
Invalid API Key
Bot Not Found
Command Not Found
Validation Errors
Rate Limiting
The API implements rate limiting to prevent abuse:
Rate Limit: 60 requests per minute per IP
Headers: Rate limit information is provided in response headers
X-RateLimit-Limit: Maximum requests per windowX-RateLimit-Remaining: Remaining requests in current windowX-RateLimit-Reset: Time when the rate limit resets
Best Practices
Security
Store API keys securely and never expose them in client-side code
Use HTTPS for all API requests
Rotate API keys regularly
Error Handling
Always check the
okfield in responsesImplement proper retry logic for transient errors
Log errors for debugging purposes
Performance
Respect rate limits to avoid being temporarily blocked
Use batch operations when available
Cache responses when appropriate
Command Encoding
Always Base64 encode command names for URL paths
Use URL-safe Base64 encoding
Handle encoding/decoding errors gracefully
Support
For additional support or questions about the API:
Check the error messages for specific guidance
Review this documentation for proper usage
Contact support through the official channels
Last updated: 2025-07-20
Last updated