NxCreateDocs

API Reference

Complete reference for the NxCreator v2 REST API and the custom webhook system supported by globalHandler.

The NxCreator backend exposes a versioned REST API for bot management and a per-bot custom webhook system you can define directly from your bot code.

Authentication

All v2 API calls are POST requests that carry credentials in the JSON body. No header tokens are needed.

FieldTypeDescription
uidstringYour NxCreator user ID.
authKeystringSession auth key returned at login.

Both fields are required on every request. A missing or expired session returns 401 Session Expired. Login Again.

Base URL
https://api-prod-nexcreate-01.nx3r.com

v2 Endpoints

POST /v2/fetchAllBots

Returns a paginated list of all bots owned by the authenticated user, with optional status and search filters.

Body fieldTypeRequiredDescription
uidstringYesUser ID.
authKeystringYesSession key.
pagenumberNoPage number. Default: 1.
limitnumberNoResults per page. Default: 20.
statusstringNoFilter by bot state: `"Active"` or `"Inactive"`.
searchstringNoFilter by bot name or username (case-insensitive).
// Response
{
  "ok": true,
  "stat_code": 200,
  "data": [
    {
      "botId": "abc123",
      "botName": "My Bot",
      "botUsername": "@mybot",
      "botIcon": "https://...",
      "botState": "Active",
      "totalUsers": 412,
      "webhookSet": true
    }
  ],
  "pagination": { "total": 3, "page": 1, "limit": 20, "totalPages": 1 }
}

POST /v2/getBotDetails

Returns full details for a single bot.

Body fieldTypeRequiredDescription
uidstringYesUser ID.
authKeystringYesSession key.
botIdstringYesThe bot ID to look up.
// Response
{
  "ok": true,
  "stat_code": 200,
  "data": {
    "botId": "abc123",
    "botName": "My Bot",
    "botUsername": "@mybot",
    "botIcon": "https://...",
    "tgToken": "123:AAA...",
    "totalUsers": 412,
    "botState": "Active",
    "webhookUrl": "https://api-prod2-next-bot.nx3r.com/webhook/...",
    "webhookSet": true,
    "mode": "production",
    "sections": [...],
    "sectionsUpdatedAt": "2026-04-01T10:00:00.000Z"
  }
}

POST /v2/batchGetBotDetails

Returns details for multiple bots in a single request. Useful for dashboard list views.

Body fieldTypeRequiredDescription
uidstringYesUser ID.
authKeystringYesSession key.
botIdsstring[]YesArray of bot IDs to fetch.
// Response
{
  "ok": true,
  "stat_code": 200,
  "data": [
    { "botId": "abc123", "botName": "My Bot", "botState": "Active", "totalUsers": 412 }
  ]
}

POST /v2/fetchBotUsers

Returns a paginated list of users who have interacted with a bot. Each record includes the Telegram username, display name, profile photo, and join date fetched live from the Telegram API.

Body fieldTypeRequiredDescription
uidstringYesUser ID.
authKeystringYesSession key.
botIdstringYesBot ID.
pagenumberNoPage number. Default: 1.
limitnumberNoResults per page. Default: 30.
// Response
{
  "ok": true,
  "stat_code": 200,
  "data": [
    {
      "userId": 9876543,
      "username": "john_doe",
      "name": "John Doe",
      "startedAt": "1/4/2026, 9:12:00 AM",
      "profilePhoto": "https://api.telegram.org/file/bot.../..."
    }
  ],
  "pagination": { "total": 412, "page": 1, "limit": 30, "totalPages": 14 }
}

POST /v2/getBotStats

Returns aggregate statistics for a bot: total users, new users in the last 7 days, error count, and total log entries.

Body fieldTypeRequiredDescription
uidstringYesUser ID.
authKeystringYesSession key.
botIdstringYesBot ID.
// Response
{
  "ok": true,
  "stat_code": 200,
  "data": {
    "totalUsers": 412,
    "newUsersLast7Days": 38,
    "totalErrors": 5,
    "totalLogs": 203
  }
}

Custom Webhooks

Every bot can expose its own HTTP endpoints without any extra server setup. You define handlers directly in your bot code and NxCreator routes incoming requests to them via globalHandler.

Webhook base URL
https://api-prod2-next-bot.nx3r.com

Route pattern
/custom/:botId/:customPath

The customPath value maps to a key you define on the logic object inside your bot code. All HTTP methods (GET, POST, PUT, etc.) are accepted on the same route.

Custom webhook endpoints do not require authentication at the route level. If your endpoint should be private, add your own token check inside the handler using the query or body parameters.

Webhook handler contract

Define a handler by assigning an async function to logic['yourPath']. The function receives four arguments:

ParameterTypeDescription
queryobjectParsed URL query string parameters.
bodyobjectParsed JSON request body.
dbSafeDbBot-scoped database helper (same as the `db` global in normal bot code).
responseobjectMutable response descriptor — set fields to control the HTTP response.
paramsobjectExpress route parameters (e.g. `{ botId, customPath }`).
// Accessible at:
// POST https://api-prod2-next-bot.nx3r.com/custom/<botId>/notify

logic['notify'] = async (query, body, db, response, params) => {
  const userId = body.userId;

  if (!userId) {
    response.statusCode = 400;
    response.message = 'userId is required';
    return;
  }

  const user = await db.operation.findOne('users', { userId });
  await bot.telegram.sendMessage(userId, `Hello ${user?.name ?? 'there'}!`);

  response.statusCode = 200;
  response.data = { sent: true };
};

If the handler returns a value and response.data has not been set, the return value is used as data automatically.

Response object

Mutate the response object to control what the caller receives:

FieldTypeDescription
statusCodenumberHTTP status code. Defaults to 200.
headersobjectExtra response headers to set (e.g. `{ "X-My-Header": "value" }`).
messagestringShort human-readable message included in the JSON response.
dataanyPayload returned under the `data` key in the JSON body.

The JSON response body always includes an ok boolean (true when statusCode < 400) plus whatever fields you set on response.

curl -X POST "https://api-prod2-next-bot.nx3r.com/custom/<botId>/notify" \
  -H "Content-Type: application/json" \
  -d '{"userId": 9876543}'

Error codes

HTTP statusCause
400Invalid `customPath` format, or no handler registered for the requested path.
403Bot is under halt — requests are rejected until the bot is restarted.
404Bot ID not found in the platform configuration.
500Compile error or unhandled exception in the handler. Details are written to `infoCollection` for the bot.
Compile and execution errors appear in the bot's error log inside the NxCreator editor, so you can debug failed webhook calls without needing external logging.
Last updated March 22, 2026
Was this page helpful?