For Enterprise suppliers
Connect your Medagora desk with your ERP or CRM. New leads reach your system the moment they reach you, your team quotes and records outcomes from there, and prices stay in sync. Base URL https://medagora.in/api/v1 · JSON over HTTPS · OpenAPI 3.1 file (import into Postman) · part of the Enterprise plan.
curl -H "Authorization: Bearer $MEDAGORA_KEY" "https://medagora.in/api/v1/me"
Send the key on every request: Authorization: Bearer mdg_live_…. We keep only a hash of it, so a lost key cannot be shown again: replace it on the desk (the old one stops working at once). Only the account owner can create or revoke a key. Keys work only while the account is on Enterprise.
Lists come oldest first, 50 rows a page (limit up to 200). When there is more, the answer has next: pass it back as cursor. To fetch only what is new, use since (an ISO time) or keep the last cursor. Every answer is { data, next } for lists and { data } for one item.
Errors are { "error": { "code": "…", "message": "…" } } with the HTTP status: 400 bad parameter or JSON, 401 missing or wrong key, 404 not on your desk, 422 the change was refused (the message says why), 429 too many requests, 500 our side. The limit is 600 requests an hour per account; every call appears in your desk activity log for 30 days.
GET /leads | Your leads. Filters: since, stage (open, quoted, won, lost), limit, cursor. |
GET /leads/{id} | One lead, by lead id (L-…) or requestId. |
PATCH /leads/{id} | { "stage": "won" | "lost" | "open" }: record the outcome from your CRM. “quoted” follows from sending a quotation. |
A lead carries the buyer’s contact details, as on your desk: the buyer agreed to share them with the suppliers their request was sent to.
{
"data": [
{
"id": "L-261121-A1B2",
"requestId": "rfq_…",
"receivedAt": "2026-11-21T09:14:02.000Z",
"stage": "open",
"closed": false,
"need": "Paracetamol 650 mg tablets",
"product": "paracetamol 650 mg tablets",
"quantity": "500 boxes",
"specification": null,
"neededBy": "2026-12-05",
"categoryId": "third-party-and-contract-manufacturing/oral-solids/tablets",
"buyer": { "name": "Sharma Medical", "type": "Retailer / Chemist", "city": "Jaipur", "phone": "98XXXXXXXX", "email": null },
"assignedTo": null,
"quotation": null
}
],
"next": "WyIyMDI2LTExLTIxVDA5OjE0OjAyLjAwMFoiLCJyZnFf…"
}curl -X PATCH "https://medagora.in/api/v1/leads/L-261121-A1B2" -H "Authorization: Bearer $MEDAGORA_KEY" -H "Content-Type: application/json" -d '{ "stage": "won" }'GET /quotations | Quotations you sent, by last change. Filters: since, limit, cursor. |
POST /leads/{id}/quotation | Send or change your quotation; the buyer is told and compares it side by side. Fields: unitPrice, unit, gstRate (0, 5, 18, 40), gstIncluded, moq, deliveryDays (0 = ready stock), freight (included, extra, ex-works), paymentTerms, validUntil (YYYY-MM-DD), price (text, when there is no unit price), lines (up to 8 extra terms, each with a label and a value; shown on the comparison, not used to rank), note. A price, a note, or an extra line is required. |
curl -X POST "https://medagora.in/api/v1/leads/L-261121-A1B2/quotation" \
-H "Authorization: Bearer $MEDAGORA_KEY" -H "Content-Type: application/json" \
-d '{ "unitPrice": 18.5, "unit": "box", "gstRate": 5, "gstIncluded": false, "moq": "100 boxes",
"deliveryDays": 7, "freight": "included", "paymentTerms": "30 days credit",
"validUntil": "2026-12-31", "note": "Batch with 24-month expiry." }'GET /products | Your catalogue: SKU, name, status, category, composition, strength, dosage form, pack, HSN, price range, unit, MOQ. |
GET /products/{id or sku} | One product. |
PATCH /products/{id or sku} | Change priceMin, priceMax (rupees, or null), unit, moq, status (live or hidden). A draft must be finished on the desk before it can go live. |
POST /products/bulk | Up to 500 rows, matched by sku (or id). Each row succeeds or fails on its own; the answer lists both. |
curl -X POST "https://medagora.in/api/v1/products/bulk" -H "Authorization: Bearer $MEDAGORA_KEY" -H "Content-Type: application/json" \
-d '{ "items": [ { "sku": "PCM650", "priceMin": 18.5, "priceMax": 21, "moq": "100 boxes" },
{ "sku": "AZI500", "status": "hidden" } ] }'Add up to 5 HTTPS URLs on the desk and choose the events. We POST a JSON message signed with the webhook’s secret. Answer with any 2xx within 8 seconds; otherwise we try again after 10 s and 60 s. After 20 failures in a row the webhook is switched off (switch it on again on the desk). Each message has a unique X-Medagora-Delivery id: if you see it twice, ignore the second.
lead.created | A new buyer requirement reached you. data: the lead (as in GET /leads/{id}) |
lead.updated | You marked a lead won, lost or open again. data: the lead (as in GET /leads/{id}) |
quotation.sent | You sent or changed a quotation. data: the quotation |
message.received | A buyer wrote to you about a lead. data: { message, lead } |
POST /your/webhook HTTP/1.1
Content-Type: application/json
User-Agent: Medagora-Webhooks/1.0
X-Medagora-Event: lead.created
X-Medagora-Delivery: dlv_…
X-Medagora-Timestamp: 1763716442
X-Medagora-Signature: t=1763716442,v1=5f1c…e9
{ "id": "dlv_…", "event": "lead.created", "createdAt": "2026-11-21T09:14:03.120Z",
"data": { "id": "L-261121-A1B2", "stage": "open", "need": "Paracetamol 650 mg tablets", "buyer": { … }, … } }X-Medagora-Signature is t=<unix time>,v1=<hex>, where v1 is HMAC-SHA256 of `${t}.${raw body}` with your webhook secret. Compute it on the raw body, compare in constant time, and refuse messages older than five minutes.
import crypto from "node:crypto";
// Use the raw request body (a string), not a re-serialised object.
export function fromMedagora(rawBody, signatureHeader, secret) {
const t = Number(/(?:^|,)t=(\d+)/.exec(signatureHeader)?.[1]);
const v1 = /(?:^|,)v1=([a-f0-9]{64})/.exec(signatureHeader)?.[1];
if (!t || !v1 || Math.abs(Date.now() / 1000 - t) > 300) return false; // older than 5 minutes: refuse
const want = crypto.createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex");
return crypto.timingSafeEqual(Buffer.from(want), Buffer.from(v1));
}<?php
function from_medagora(string $rawBody, string $signatureHeader, string $secret): bool {
if (!preg_match('/(?:^|,)t=(\d+)/', $signatureHeader, $t) || !preg_match('/(?:^|,)v1=([a-f0-9]{64})/', $signatureHeader, $v)) return false;
if (abs(time() - (int)$t[1]) > 300) return false;
$want = hash_hmac('sha256', $t[1] . '.' . $rawBody, $secret);
return hash_equals($want, $v[1]);
}
// $ok = from_medagora(file_get_contents('php://input'), $_SERVER['HTTP_X_MEDAGORA_SIGNATURE'] ?? '', getenv('MEDAGORA_WEBHOOK_SECRET'));import hashlib, hmac, re, time
def from_medagora(raw_body: bytes, signature_header: str, secret: str) -> bool:
t = re.search(r"(?:^|,)t=(\d+)", signature_header)
v1 = re.search(r"(?:^|,)v1=([a-f0-9]{64})", signature_header)
if not t or not v1 or abs(time.time() - int(t.group(1))) > 300:
return False
want = hmac.new(secret.encode(), t.group(1).encode() + b"." + raw_body, hashlib.sha256).hexdigest()
return hmac.compare_digest(want, v1.group(1))In a Google Sheet: Extensions › Apps Script, paste this, save, and run setup once (it asks for your key). A “Medagora leads” tab refreshes every hour, and a Medagora menu refreshes it on demand.
// Medagora → Google Sheets. In your sheet: Extensions › Apps Script, paste this, save, then run "setup" once.
const MEDAGORA = "https://medagora.in/api/v1";
function setup() {
const key = Browser.inputBox("Your Medagora API key (mdg_live_…)");
if (!/^mdg_live_/.test(key)) throw new Error("That is not a Medagora API key.");
PropertiesService.getScriptProperties().setProperty("MEDAGORA_KEY", key);
ScriptApp.getProjectTriggers().forEach((t) => ScriptApp.deleteTrigger(t));
ScriptApp.newTrigger("syncLeads").timeBased().everyHours(1).create();
syncLeads();
}
function onOpen() {
SpreadsheetApp.getUi().createMenu("Medagora").addItem("Sync leads now", "syncLeads").addToUi();
}
function syncLeads() {
const key = PropertiesService.getScriptProperties().getProperty("MEDAGORA_KEY");
if (!key) throw new Error('Run "setup" first.');
const book = SpreadsheetApp.getActive();
const sheet = book.getSheetByName("Medagora leads") || book.insertSheet("Medagora leads");
const head = ["Lead", "Received", "Stage", "Product", "Quantity", "Need", "City", "Buyer", "Phone", "Email", "Quoted price", "Quoted at"];
const rows = [head];
let cursor = "";
do {
const url = MEDAGORA + "/leads?limit=200" + (cursor ? "&cursor=" + encodeURIComponent(cursor) : "");
const res = UrlFetchApp.fetch(url, { headers: { Authorization: "Bearer " + key }, muteHttpExceptions: true });
if (res.getResponseCode() !== 200) throw new Error(res.getContentText());
const page = JSON.parse(res.getContentText());
page.data.forEach((l) => rows.push([
l.id, l.receivedAt, l.stage, l.product || "", l.quantity || "", l.need, l.buyer.city, l.buyer.name, l.buyer.phone, l.buyer.email || "",
l.quotation ? (l.quotation.unitPrice || l.quotation.price || "") : "", l.quotation ? l.quotation.sentAt : "",
]));
cursor = page.next;
} while (cursor);
sheet.clearContents();
sheet.getRange(1, 1, rows.length, head.length).setValues(rows);
sheet.setFrozenRows(1);
}