Connect your shop, your sales tools, or your EMR to MedGrid. One REST surface — standard token authentication, JSON in, JSON out. Every endpoint documented here ships in the live codebase.
# Month-to-date KPIs for the authenticated rep curl -H "Authorization: token API_KEY:API_SECRET" \ "https://uat.medgrid.com/api/method/medgrid.rep_dashboard.get_rep_kpis"
Onboard vendor accounts programmatically, push stock adjustments from your warehouse system, pull the same dashboard data that powers the vendor desk — or connect a Shopify shop via OAuth.
Vendor APIs →Pull rep KPIs, commission summaries, leaderboards, and customer attribution into your CRM or BI tool. Everything scopes automatically to the authenticated user's role.
Sales Team APIs →Provision patients into the PerfectRx pharmacy network, transmit e-prescriptions with server-side NPI validation, and track fulfillment status by event push or polling.
EMR APIs →MedGrid uses standard token-based authentication. There are two ways to authenticate, depending on where your code runs.
Generate an API key + secret pair under My Profile → API Access after you log in, and send it on every request. Treat the secret like a password — never ship it in client-side code.
Authorization: token API_KEY:API_SECRET Content-Type: application/json
Code running in a logged-in MedGrid browser session can rely on the MedGrid session cookie instead — fetch a CSRF token and send it with each write request.
# session cookie sent automatically by the browser X-Frappe-CSRF-Token: <csrf-token> Content-Type: application/json
https://uat.medgrid.com. Endpoints are auth-gated and permission-scoped: a request only sees what the authenticated user's role allows.If you're a distributor or manufacturer fulfilling orders on MedGrid, these endpoints cover vendor profile registration, stock adjustments, and shop OAuth installation. Most day-to-day vendor work — viewing orders, marking shipments — runs through the MedGrid vendor workspace and the /portal/vendor dashboard rather than direct API calls.
Programmatically onboard a vendor — creates a Vendor Profile in Pending Approval state for MedGrid admins to review.
curl -X POST \
-H "Authorization: token API_KEY:API_SECRET" \
-H "Content-Type: application/json" \
-d '{
"sales_representative_name": "Skydell Holdings",
"email": "vendor@example.com",
"password": "<strong-password>",
"country": "United States",
"profile_url": "skydell"
}' \
"https://uat.medgrid.com/api/method/medgrid.api.register_vendor"
Adjust on-hand quantity for one of your SKUs. Auto-advances to Requested for vendor-initiated changes; awaits Medgrid Marketplace Officer approval.
curl -X POST \
-H "Authorization: token API_KEY:API_SECRET" \
-H "Content-Type: application/json" \
-d '{
"item": "SKU-1234",
"action": "Add",
"warehouse": "Main Store - MG",
"quantity": 120,
"reason": "Restock from Q2 shipment"
}' \
"https://uat.medgrid.com/api/method/medgrid.api.create_stock_update_request"
Sales totals, recent orders, low-stock SKUs — same data that powers the vendor desk dashboard.
Pull rep KPIs, commission breakdowns, and customer attribution into your CRM or sales analytics tool. All endpoints scope automatically to the authenticated user — reps only see their own data, managers see their team, admins see everyone.
Month-to-date sales, commission estimate, tier, level, streak, customer count, badges earned.
curl -H "Authorization: token API_KEY:API_SECRET" \ "https://uat.medgrid.com/api/method/medgrid.rep_dashboard.get_rep_kpis"
Per-team rep + manager totals over the last N days. Manager-only.
curl -H "Authorization: token API_KEY:API_SECRET" \ "https://uat.medgrid.com/api/method/medgrid.team_commission.team_commission_summary?period_days=30"
Onboard a downline rep with a fixed slice of your base MedGrid commission. Auto-creates the User + Sales Person.
curl -X POST \
-H "Authorization: token API_KEY:API_SECRET" \
-H "Content-Type: application/json" \
-d '{
"email": "newrep@example.com",
"full_name": "Casey Brown",
"subrep_pct": 5
}' \
"https://uat.medgrid.com/api/method/medgrid.subrep_team.invite_subrep"
Top reps by MTD sales (or another metric). Use metric=mtd_sales | commission_estimate | streak_days.
Customers attributed to the authenticated rep — Customer.assigned_rep equality.
Sync patient records, transmit electronic prescriptions, and pull order status from MedGrid's PerfectRx-routed pharmacy network. Provider NPIs are validated server-side against NPPES before any e-script is transmitted.
Pass an existing MedGrid Customer name. We create (or look up) the corresponding patient record at PerfectRx and store its ID on the Customer. Idempotent.
curl -X POST \
-H "Authorization: token API_KEY:API_SECRET" \
-H "Content-Type: application/json" \
-d '{
"customer": "CUST-00001234"
}' \
"https://uat.medgrid.com/api/method/medgrid.perfectrx.ensure_patient"
Routes a submitted Sales Order's prescription items through PerfectRx for fulfillment. Validates provider NPI before transmission. Status is then driven asynchronously via the order events flow below.
curl -X POST \
-H "Authorization: token API_KEY:API_SECRET" \
-H "Content-Type: application/json" \
-d '{
"sales_order": "SO-MG-001234"
}' \
"https://uat.medgrid.com/api/method/medgrid.perfectrx.sync_to_perfectrx"
Status fallback for when an event push is missed. Returns Received / Shipped / Delivered + tracking info if available.
One-time setup so PerfectRx pushes order status events back to your MedGrid instance.
curl -X POST \
-H "Authorization: token API_KEY:API_SECRET" \
-H "Content-Type: application/json" \
-d '{
"public_base_url": "https://uat.medgrid.com",
"contact_email": "ops@your-emr.com"
}' \
"https://uat.medgrid.com/api/method/medgrid.perfectrx.register_webhook"
Pharmacy fulfillment is asynchronous: after a prescription is transmitted, status updates flow back as events rather than in the API response. Here's how the loop closes.
Once register_webhook has been called, PerfectRx pushes order status events (received, shipped, delivered — with carrier and tracking where available) to your MedGrid instance. MedGrid matches each event to its Sales Order and updates the order's status and tracking automatically.
If an event is missed, medgrid.perfectrx.poll_perfectrx_status fetches the current status for a Sales Order on demand — safe to call repeatedly.
public_base_url you pass to register_webhook. If you need additional event subscriptions for your integration, talk to the integrations team below.Our integrations team will pair with you on schema, test data, and webhook setup — reach out through the contact page and choose "Platform Support".
Contact the integrations team