API Reference

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

POST/api/auth/register

Register a new tenant + owner user; auto-signs the user in.

{ "tenantName": "...", "tenantSlug": "...", "email": "...", "password": "..." }
POST/api/auth/[...nextauth]

NextAuth v5 handlers — used by the login form.

CRM

GET/api/leads

List leads for the current tenant.

POST/api/leads

Create a lead.

{ "fullName": "...", "email": "...", "pipelineStage": "new" }
GET/api/leads/[leadId]

Fetch one lead + activity timeline.

PATCH/api/leads/[leadId]

Update lead fields.

DELETE/api/leads/[leadId]

Delete a lead.

POST/api/leads/[leadId]/activities

Log a note / call / email activity on a lead.

Billing

POST/api/billing/create-payment

Generate a unique USDT payment amount + wallet for a purchase.

POST/api/billing/webhook

Called by the payment monitor when a TRC-20 transfer is matched.

PATCH/api/billing/modules

Toggle an add-on module on or off.

{ "module": "forwarder", "enabled": true }

Telegram Forwarder

GET/api/forwarder/accounts

List connected Telegram user accounts.

POST/api/forwarder/accounts

Start the connect flow (phone number).

GET/api/forwarder/sources

List configured source channels.

GET/api/forwarder/routes

List source→destination routes.

GET/api/forwarder/drafts

List AI-processed drafts awaiting approval.

PATCH/api/forwarder/drafts/[id]

Approve, reject, or publish a draft.

GET/api/forwarder/history

Paginated publish history.

Onboarding Bots

GET/api/onboarding/bots

List onboarding bots.

POST/api/onboarding/bots

Create + verify a bot token.

{ "botToken": "123:abc..." }
PUT/api/onboarding/bots/[id]/steps

Bulk replace the flow's step list.

GET/api/onboarding/bots/[id]/leads

Paginated leads captured by this bot.

POST/api/onboarding/bots/[id]/start

Start the bot (webhook or polling).

AI Outreach

GET/api/outreach/campaigns

List outreach campaigns.

POST/api/outreach/campaigns

Create a campaign.

GET/api/outreach/campaigns/[id]/analytics

Funnel + daily metrics.

GET/api/outreach/contacts/[contactId]/suggest

Generate an AI-suggested reply for a contact.

Copy Trading

GET/api/copy-trading/signals

List signals with filters (?status=open).

POST/api/copy-trading/signals

Create 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] }
GET/api/copy-trading/subscribers

List subscribers.

GET/api/copy-trading/stats

Win rate + totals.

Referrals

GET/api/referrals/partners

List partners.

POST/api/referrals/conversions

Record a conversion; commissions auto-compute from the partner's chain.

{ "partnerCode": "janes_code", "convertedName": "Alex", "value": 500 }
POST/api/referrals/apply

PUBLIC — called from the referral landing page; creates a lead + pending conversion.

Templates Marketplace

GET/api/templates?scope=mine|public|all

List templates. Scope defaults to "mine".

POST/api/templates

Publish a template from the current tenant.

POST/api/templates/[id]/install

Install a template into the current tenant.

Found something missing? The dashboard is the source of truth — each UI interaction shows the exact request it makes in your browser's network tab.