Build on top of your tenant
Every action in the IBHQ dashboard is backed by a REST endpoint. Hit them from your own scripts with the same session cookie you use to log in — no separate token system, no keys to rotate. Public endpoints are marked explicitly.
Conventions
- All authenticated calls are scoped to your tenant automatically — no tenant_id parameter needed.
- Request bodies are JSON (Content-Type: application/json).
- Validation errors come back as { "error": "<human-readable>" } with HTTP 400.
- Write endpoints require the owner or admin role on your user.
- Decimals and BigInts are serialized as strings in responses.
Authentication
/api/auth/registerRegister a new tenant + owner user; auto-signs the user in.
{ "tenantName": "...", "tenantSlug": "...", "email": "...", "password": "..." }/api/auth/[...nextauth]NextAuth v5 handlers — used by the login form.
CRM
/api/leadsList leads for the current tenant.
/api/leadsCreate a lead.
{ "fullName": "...", "email": "...", "pipelineStage": "new" }/api/leads/[leadId]Fetch one lead + activity timeline.
/api/leads/[leadId]Update lead fields.
/api/leads/[leadId]Delete a lead.
/api/leads/[leadId]/activitiesLog a note / call / email activity on a lead.
Billing
/api/billing/create-paymentGenerate a unique USDT payment amount + wallet for a purchase.
/api/billing/webhookCalled by the payment monitor when a TRC-20 transfer is matched.
/api/billing/modulesToggle an add-on module on or off.
{ "module": "forwarder", "enabled": true }Telegram Forwarder
/api/forwarder/accountsList connected Telegram user accounts.
/api/forwarder/accountsStart the connect flow (phone number).
/api/forwarder/sourcesList configured source channels.
/api/forwarder/routesList source→destination routes.
/api/forwarder/draftsList AI-processed drafts awaiting approval.
/api/forwarder/drafts/[id]Approve, reject, or publish a draft.
/api/forwarder/historyPaginated publish history.
Onboarding Bots
/api/onboarding/botsList onboarding bots.
/api/onboarding/botsCreate + verify a bot token.
{ "botToken": "123:abc..." }/api/onboarding/bots/[id]/stepsBulk replace the flow's step list.
/api/onboarding/bots/[id]/leadsPaginated leads captured by this bot.
/api/onboarding/bots/[id]/startStart the bot (webhook or polling).
AI Outreach
/api/outreach/campaignsList outreach campaigns.
/api/outreach/campaignsCreate a campaign.
/api/outreach/campaigns/[id]/analyticsFunnel + daily metrics.
/api/outreach/contacts/[contactId]/suggestGenerate an AI-suggested reply for a contact.
Copy Trading
/api/copy-trading/signalsList signals with filters (?status=open).
/api/copy-trading/signalsCreate a signal; set destinations to auto-post the formatted signal.
{ "pair": "EURUSD", "direction": "long", "entry": 1.085, "stopLoss": 1.080, "takeProfits": [1.090, 1.095] }/api/copy-trading/subscribersList subscribers.
/api/copy-trading/statsWin rate + totals.
Referrals
/api/referrals/partnersList partners.
/api/referrals/conversionsRecord a conversion; commissions auto-compute from the partner's chain.
{ "partnerCode": "janes_code", "convertedName": "Alex", "value": 500 }/api/referrals/applyPUBLIC — called from the referral landing page; creates a lead + pending conversion.
Templates Marketplace
/api/templates?scope=mine|public|allList templates. Scope defaults to "mine".
/api/templatesPublish a template from the current tenant.
/api/templates/[id]/installInstall a template into the current tenant.