Reference

API reference

InstaChatbot exposes a JSON REST API. Base URL: https://api.instachatbot.online.

Authentication

Every request must include the shared internal secret and the authenticated user's id. The Next.js dashboard proxies these automatically — for direct integrations, sign your request with these two headers:

http
x-internal-secret: <API_INTERNAL_SECRET>
x-user-id: <NextAuth session.user.id>

Treat x-internal-secret like a database password. Never expose it to the browser; rotate immediately if compromised.

Endpoints

MethodPathDescription
GET/api/shopsList all shops on your account.
POST/api/shopsCreate a new shop.
GET/api/shops/:idGet one shop.
PUT/api/shops/:idUpdate a shop.
DELETE/api/shops/:idDelete a shop (cascades to rules + logs).
GET/api/shops/:id/rulesList all rules for a shop, ordered.
POST/api/shops/:id/rulesCreate a rule. Enforces plan caps.
PUT/api/shops/:id/rules/reorderBulk update rule ordering.
PUT/api/rules/:idUpdate an individual rule.
DELETE/api/rules/:idDelete an individual rule.
GET/api/shops/:id/messagesPaginated message log.
GET/api/shops/:id/analyticsToday/week/month counters + top keywords.
POST/api/billing/create-subscriptionCreate a Razorpay subscription.
POST/api/billing/webhookRazorpay webhook receiver (signed).

Create a rule (example)

bash
curl -X POST 'https://api.instachatbot.online/api/shops/shop_abc/rules' \
  -H 'x-internal-secret: $API_INTERNAL_SECRET' \
  -H 'x-user-id: usr_01HZX…' \
  -H 'Content-Type: application/json' \
  -d '{
    "keyword": "menu",
    "matchType": "contains",
    "replyType": "text",
    "replyText": "Here is our menu…",
    "isActive": true
  }'
json
{
  "rule": {
    "id": "rul_01HZX…",
    "shopId": "shop_abc",
    "keyword": "menu",
    "matchType": "contains",
    "replyType": "text",
    "replyText": "Here is our menu…",
    "isActive": true,
    "order": 4,
    "createdAt": "2026-05-12T18:00:00.000Z"
  }
}

Errors

InstaChatbot returns standard HTTP status codes with a JSON body:

json
{
  "error": "Plan limit reached: 5 rules allowed on the 'free' plan."
}
  • 400 — Validation failed (Zod-flattened details included)
  • 401 — Missing or invalid internal secret / user id
  • 402 — Plan cap exceeded (rules or messages)
  • 404 — Resource not found or not owned by you
  • 500 — Unexpected server error