Skip to the content
DarpanaAI

๐Ÿ”— For your ERP

API and webhooks

Connect your school's own system. Keys are made in your school panel under Integrations (the ERP integration module).

Overview

The API lets your school's own system (an ERP, a CRM, a spreadsheet script) read admission enquiries, bookings and the call log, add enquiries and move them along the board. Webhooks tell your system the moment something happens, so it does not have to keep asking. Both need the ERP integration module and a key made by a person who holds Manage API keys and webhooks (Integrations in the school panel).

Students, notes, parents' phone register and recordings are not reachable through the API. To bring students in, use the roster import in the school panel.

Keys and scopes

Send a key with every call: Authorization: Bearer dk_xxxxxxxx_.... A key is shown once, when you make it; we keep only a fingerprint, so a lost key cannot be found again (make a new one and revoke the old). A key can expire and can be revoked at any time. Each key may do only what you ticked:

  • enquiries:read: Read admission enquiries (including the family's name, number and what they said)
  • enquiries:write: Add enquiries and move them along the board
  • appointments:read: Read bookings (including the number that booked)
  • calls:read: Read the call log (never recordings, words or numbers)

Treat a key like a password: keep it on your server, never in a web page or an app. A key that can read enquiries can read the names and numbers of families.

Calling it

curl https://darpanaai.sepl.site/api/v1/ping \
  -H "Authorization: Bearer dk_xxxxxxxx_..." \
  -H "Accept: application/json"
  • Base address: https://darpanaai.sepl.site/api/v1. Always send Accept: application/json. Times are ISO 8601 in UTC.
  • Lists are read a page at a time: ?limit=50 (up to 100) and ?cursor=.... The answer is {"data": [...], "next_cursor": "..."}; next_cursor is null on the last page.
  • Limit: 120 calls a minute for each key. Past that you get 429; wait and try again.
  • Errors are JSON: 401 (no key, or a wrong, expired or revoked one), 403 (the key lacks the scope, or the school's account is not in use / lacks the module), 404 (nothing with that id), 422 (a field is wrong: {"message": "...", "errors": {"field": ["..."]}}), 429.

Endpoints

GET /ping (any key)

Who the key is for and what it may do. The first call to try.

{ "school": {"id": "...", "name": "Greenfield Public School"},
  "key": {"name": "ERP", "prefix": "dk_a1b2c3d4", "scopes": ["enquiries:read"], "expires_at": null},
  "scopes_available": ["enquiries:read", "enquiries:write", "appointments:read", "calls:read"],
  "version": "v1" }

GET /enquiries and GET /enquiries/{id} (enquiries:read)

Newest first. Filters: stage (new, contacted, visit, applied, admitted, lost), band (hot, warm, cold), source (call, widget, manual), since (a date or time). Only finished enquiries are listed. Every read is written to your activity log as a count.

{ "id": "0190f3a2-...", "source": "call", "stage": "new", "lost_reason": null,
  "band": "warm", "score": 52, "sentiment": "positive",
  "class_sought": "Class 1 to 5", "language": "hi-IN",
  "name": "Asha Verma", "phone": "+919876543210",
  "summary": "Asha Verma enquired by phone about Class 1 to 5. ...",
  "visit_at": "2026-10-06T04:30:00+00:00",
  "created_at": "2026-10-05T07:02:11+00:00", "stage_changed_at": "2026-10-05T07:02:11+00:00" }

POST /enquiries (enquiries:write)

Add a family you heard from somewhere else. Body: name (required), phone (required), class_sought, note. It is scored and shown on the board; the school's admins are not messaged. Answers 201 with the enquiry. Do not send a child's name.

PATCH /enquiries/{id} (enquiries:write)

Move it along the board. Body: stage (required) and, for lost, lost_reason (price, distance, other_school, no_reply, other).

GET /appointments and GET /appointments/{id} (appointments:read)

Bookings made by phone, earliest first. Filters: status (booked, cancelled, completed, no_show), from, to. Includes the number that booked (encrypted at rest here, so reading it is logged as a count).

{ "id": "0190f3a9-...", "type_id": "...", "type": "Admission visit", "kind": "admission",
  "status": "booked", "source": "call",
  "starts_at": "2026-10-06T04:30:00+00:00", "ends_at": "2026-10-06T04:50:00+00:00",
  "phone": "+919876543210", "created_at": "2026-10-05T07:09:40+00:00" }

GET /calls and GET /calls/{id} (calls:read)

The call log, newest first. Filters: direction, status, since. No number, no words, no recording.

{ "id": "0190f3b4-...", "direction": "inbound", "status": "completed", "outcome": "answered_by_brain",
  "language": "hi-IN", "campaign_id": null, "is_test": false,
  "started_at": "2026-10-05T07:00:12+00:00", "ended_at": "2026-10-05T07:01:26+00:00",
  "duration_seconds": 74, "billed_minutes": 2 }

Webhooks

Add an address under Integrations โ†’ Webhooks and choose what to be told about. We send a POST with a small JSON body. The body is thin on purpose: it says what happened and gives the id; ask the API for the details. Nothing personal is ever pushed to your address.

{ "id": "0190f3c0-...",            // the event; the same for every address told about it
  "type": "enquiry.created",
  "created_at": "2026-10-05T07:02:11+00:00",
  "data": { "enquiry_id": "0190f3a2-...", "source": "call", "band": "warm", "score": 52 } }

Events

  • enquiry.created: A family sent an admission enquiry. data: {"enquiry_id":"0190f3a2-...","source":"call","band":"warm","score":52}
  • enquiry.updated: An enquiry moved to another stage. data: {"enquiry_id":"0190f3a2-...","stage":"visit"}
  • appointment.booked: A visit or meeting was booked. data: {"appointment_id":"0190f3a9-...","type_id":"0190f3a1-...","starts_at":"2026-10-06T04:30:00+00:00","source":"call"}
  • appointment.cancelled: A booking was cancelled. data: {"appointment_id":"0190f3a9-...","cancelled_by":"school"}
  • call.completed: A call ended. data: {"call_id":"0190f3b4-...","direction":"inbound","status":"completed","outcome":"answered","duration_seconds":74}
  • webhook.test: A test, sent when you press "Send a test". data: {"note":"This is a test event."}

Headers on every call

  • X-Darpana-Event: the type. X-Darpana-Event-Id: the event's id. X-Darpana-Delivery: this call's id.
  • X-Darpana-Timestamp: when we signed it (seconds since 1970).
  • X-Darpana-Signature: v1= followed by the hex HMAC-SHA256 of "{timestamp}.{raw body}", keyed with your endpoint's secret (it starts whsec_ and is shown once when you add the address).

Check the signature before you trust a call

Use the raw body, before any JSON parsing. Refuse a call whose timestamp is more than five minutes old, and compare with a constant-time function.

// PHP
$body = file_get_contents('php://input');
$ts   = $_SERVER['HTTP_X_DARPANA_TIMESTAMP'] ?? '';
$sig  = $_SERVER['HTTP_X_DARPANA_SIGNATURE'] ?? '';
$want = 'v1=' . hash_hmac('sha256', $ts . '.' . $body, $secret);
if (abs(time() - (int) $ts) > 300 || ! hash_equals($want, $sig)) { http_response_code(400); exit; }
// Node.js (Express: use express.raw({type: 'application/json'}) so req.body is the raw Buffer)
const crypto = require('crypto');
const ts = req.get('X-Darpana-Timestamp') || '';
const want = 'v1=' + crypto.createHmac('sha256', secret).update(ts + '.' + req.body).digest('hex');
const got = req.get('X-Darpana-Signature') || '';
const ok = Math.abs(Date.now() / 1000 - Number(ts)) <= 300 &&
  got.length === want.length && crypto.timingSafeEqual(Buffer.from(got), Buffer.from(want));
# Python
import hmac, hashlib, time
want = 'v1=' + hmac.new(secret.encode(), (ts + '.').encode() + raw_body, hashlib.sha256).hexdigest()
ok = abs(time.time() - int(ts)) <= 300 and hmac.compare_digest(want, signature)

What we do, and what you should do

  • Answer with any 2xx within 8 seconds and do the real work afterwards. Redirects are not followed.
  • Retries. Anything else (or no answer) is tried again after 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours and 24 hours, then given up on. You can see every call, and send one again, under Integrations โ†’ Webhooks. After 20 failures in a row we switch the address off and tell your admins in Telegram; answering 410 Gone switches it off at once.
  • Calls can repeat and arrive out of order. Use id (the event id) to ignore a repeat, and ask the API for the current state rather than trusting the order of events.
  • Only public https addresses are called, to a host name (not a number), with no login in it. An address that points inside a private network is refused when you save it and again before every call.
  • Finished call records are kept for 30 days.

Not covered yet

Writing students, parents or results into DarpanaAI through the API, reading call transcripts or recordings, and webhooks for notes or messages are not offered: they would put a child's information on the move. Use the roster import for students.