API Reference
Complete reference for the NxCreator public API — API key authentication, bot management, and custom webhooks.
The NxCreator public API uses a personal API key for authentication. All endpoints live under the same base URL and accept JSON.
Authentication
Pass your API key as apiKey in the JSON body (POST) or query string (GET). The authenticated user is resolved from the key — no separate uid needed.
An invalid or missing key returns 401 Invalid API Key.
Getting your API key
Your API key is available in the NxCreator dashboard. Open Settings, scroll to the API Key section, and click Copy. The key is generated automatically on first visit and remains stable until you regenerate it.
apiv3 — Bot management
The /apiv3/:path route accepts both GET and POST. Pass apiKey in the body (POST) or query string (GET). The authenticated user is resolved from the key — no separate uid needed.
restartBot
transferBot
Copies the bot and its code to another NxCreator account. Optionally starts the bot immediately on the new account if run_now is true (requires newBotToken). You can also seed initial data into the new bot's collections using dbProps.
| Field | Type | Required | Description |
|---|---|---|---|
apiKey | string | Yes | Your API key. |
botId | string | Yes | ID of the bot to transfer. |
targetEmail | string | Yes | Email of the recipient NxCreator account. |
newBotToken | string | No | Bot token for the new bot on the recipient account. |
run_now | boolean | No | Start the new bot immediately. Requires `newBotToken`. |
dbProps | object | No | Initial collection data to seed into the new bot. Keys are collection names (no underscores), values are arrays of documents. |
dbProps must not contain underscores and follow the same rules as regular bot collection names. Each document array is seeded into the corresponding collection on the new bot. Errors per collection are reported individually without blocking the rest of the transfer.editBotCoreLogic
Overwrites the full bot code file. The bot must be restarted separately for changes to take effect.
getbotCode
Broadcast API
The Broadcast API lets you send a message to all your bot's users in one call. Jobs run at 30–40 messages per second with automatic 429 back-off. Each bot can have at most one active broadcast at a time — new jobs queue automatically behind the running one.
POST /broadcast — queue a job
| Field | Type | Required | Description |
|---|---|---|---|
botId | string | Yes | Your bot ID. |
type | string | No | Message type. One of: text, photo, video, audio, document, animation, voice, video_note, sticker, location, contact, poll. Defaults to text. |
text | string | text type | Message body. Required when type=text. |
media | string | media types | file_id or public URL. Required for photo/video/audio/document/animation/voice/video_note/sticker. |
caption | string | No | Caption for photo/video/audio/document/animation/voice. |
parseMode | string | No | HTML, Markdown, or MarkdownV2. |
buttons | array | No | Up to 2 inline URL buttons. Each item: { text, url }. |
extra | object | No | Any extra Telegram API params (merged last, after buttons). |
filter | object | No | Scope broadcast: { lang: "en" } sends only to users with that language. |
You can attach up to 2 inline URL buttons via the buttons field. Each button requires a text label and an url (must start with http:// or https://). The buttons appear in a single row below the message.
GET /broadcast/:jobId — check status
DELETE /broadcast/:jobId — cancel
GET /jobs/:botId — recent jobs
Returns the last 20 broadcast jobs for a bot. Running jobs show live progress.
Custom Webhooks
Every bot can expose HTTP endpoints you define directly in bot code. No API key is required to call them — auth is up to you inside the handler.
Webhook handler contract
Assign an async function to logic['yourPath'] in your bot code:
Response object
Mutate the response object inside your handler to control the HTTP response:
| Field | Type | Description |
|---|---|---|
statusCode | number | HTTP status code. Defaults to 200. The top-level `ok` field is `true` when < 400. |
headers | object | Extra response headers (e.g. `{ "X-Request-Id": "abc" }`). |
message | string | Short human-readable message included in the JSON body. |
data | any | Payload returned under the `data` key. If unset and the handler returns a value, that return value is used automatically. |
| HTTP status | Cause |
|---|---|
| 400 | Invalid path format, or no `logic` handler registered for the requested path. |
| 403 | Bot is under halt — restart it from the dashboard to resume. |
| 404 | Bot ID not found. |
| 500 | Compile or runtime error inside the handler. Full details appear in the bot error log. |
Common use cases
Custom webhooks let any external service trigger bot actions over HTTP. Because they run inside the full bot runtime, you have access to bot.telegram, the db helper, and axios — everything your normal bot code can use.
Push notifications from an external service
Trigger a Telegram message to a user from a payment gateway, CI pipeline, or any backend event.
Broadcast a message to all bot users
Receive third-party webhooks
Use a custom webhook as the callback URL for Stripe, GitHub, or any other service. Validate the payload and store or act on it inside the handler.
Expose bot data as a mini API
Read from your bot's collections and return JSON — useful for a companion web app or dashboard.
Simple token-based auth
Custom webhook routes have no built-in auth. Add your own secret check at the top of any handler that should be private.
process.env.MY_SECRET instead of hardcoding it.