Developer platform

Build on MedGrid.

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.

terminal — your first call
# 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"
What you can build

Three audiences, one API.

Start here

Authentication

MedGrid uses standard token-based authentication. There are two ways to authenticate, depending on where your code runs.

1 — API token (servers & scripts)

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.

request headers
Authorization: token API_KEY:API_SECRET
Content-Type: application/json

2 — Session (logged-in browser apps)

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.

request headers
# session cookie sent automatically by the browser
X-Frappe-CSRF-Token: <csrf-token>
Content-Type: application/json
All endpoints run on https://uat.medgrid.com. Endpoints are auth-gated and permission-scoped: a request only sees what the authenticated user's role allows.
For Vendors / MedGrid Partners

Vendor APIs

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.

POST Register a vendor account

Programmatically onboard a vendor — creates a Vendor Profile in Pending Approval state for MedGrid admins to review.

https://uat.medgrid.com/api/method/medgrid.api.register_vendor
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"

POST Create a stock update request

Adjust on-hand quantity for one of your SKUs. Auto-advances to Requested for vendor-initiated changes; awaits Medgrid Marketplace Officer approval.

https://uat.medgrid.com/api/method/medgrid.api.create_stock_update_request
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"

GET Vendor dashboard data

Sales totals, recent orders, low-stock SKUs — same data that powers the vendor desk dashboard.

https://uat.medgrid.com/api/method/medgrid.api.get_vendor_dashboard_data
For Sales Teams

Sales Team APIs

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.

GET Rep KPIs

Month-to-date sales, commission estimate, tier, level, streak, customer count, badges earned.

https://uat.medgrid.com/api/method/medgrid.rep_dashboard.get_rep_kpis
curl -H "Authorization: token API_KEY:API_SECRET" \
  "https://uat.medgrid.com/api/method/medgrid.rep_dashboard.get_rep_kpis"

GET Team commission summary

Per-team rep + manager totals over the last N days. Manager-only.

https://uat.medgrid.com/api/method/medgrid.team_commission.team_commission_summary?period_days=30
curl -H "Authorization: token API_KEY:API_SECRET" \
  "https://uat.medgrid.com/api/method/medgrid.team_commission.team_commission_summary?period_days=30"

POST Invite a sub-rep

Onboard a downline rep with a fixed slice of your base MedGrid commission. Auto-creates the User + Sales Person.

https://uat.medgrid.com/api/method/medgrid.subrep_team.invite_subrep
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"

GET Sales leaderboard

Top reps by MTD sales (or another metric). Use metric=mtd_sales | commission_estimate | streak_days.

https://uat.medgrid.com/api/method/medgrid.rep_dashboard.get_leaderboard?metric=mtd_sales&limit=10

GET My customers

Customers attributed to the authenticated rep — Customer.assigned_rep equality.

https://uat.medgrid.com/api/method/medgrid.rep_dashboard.get_my_customers?limit=200
For EMR Systems

EMR APIs

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.

POST Ensure patient is provisioned in PerfectRx

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.

https://uat.medgrid.com/api/method/medgrid.perfectrx.ensure_patient
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"

POST Transmit prescription to PerfectRx

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.

https://uat.medgrid.com/api/method/medgrid.perfectrx.sync_to_perfectrx
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"

GET Poll order status

Status fallback for when an event push is missed. Returns Received / Shipped / Delivered + tracking info if available.

https://uat.medgrid.com/api/method/medgrid.perfectrx.poll_perfectrx_status?sales_order=<name>

POST Register your webhook endpoint with PerfectRx

One-time setup so PerfectRx pushes order status events back to your MedGrid instance.

https://uat.medgrid.com/api/method/medgrid.perfectrx.register_webhook
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"
Asynchronous events

Order status events

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.

EVENT Push — PerfectRx → MedGrid

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.

GET Pull — polling fallback

If an event is missed, medgrid.perfectrx.poll_perfectrx_status fetches the current status for a Sales Order on demand — safe to call repeatedly.

Heads up: event delivery requires your MedGrid instance to be reachable at a public HTTPS URL — that's the public_base_url you pass to register_webhook. If you need additional event subscriptions for your integration, talk to the integrations team below.

Need help integrating?

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