Skip to content

Vendors API

Base route: /api/vendors
Auth required: ✅ JWT Bearer


GET /api/vendors

Returns a paginated, filtered list of vendors.

Permission: Vendor:Read

Query Parameters

ParameterTypeDefaultDescription
pageint1Page number (1-based)
pageSizeint10Items per page (max 100)
searchstringPartial name match (case-insensitive)
vendorTypestringFilter by type: Manufacturer | Wholesaler | Agency | Dealer | Pharmacy
isActivebooltruetrue = active vendors, false = soft-deleted (admin only)
sortBystringnameSort field: name | vendorType | outstandingBalance
sortDirstringascSort direction: asc | desc

WARNING

Passing isActive=false requires is_admin = "true" in the JWT — returns 403 Forbidden otherwise.

Response 200 OK

json
{
  "items": [
    {
      "id": 1,
      "name": "ABC Pharmaceuticals",
      "address": "123 MG Road, Mumbai",
      "phone": "+91 98765 43210",
      "email": "contact@abcpharma.com",
      "vendorType": "Manufacturer",
      "drugLicenseNumber1": "MH-12345",
      "drugLicenseNumber2": "",
      "additionalDrugLicenseNumbers": [],
      "isActive": true,
      "outstandingBalance": 45000.00,
      "totalInvoiceValue": 120000.00,
      "totalPaidAmount": 75000.00,
      "createdAt": "2026-01-15T10:00:00Z",
      "updatedAt": "2026-03-01T14:30:00Z"
    }
  ],
  "totalCount": 1,
  "page": 1,
  "pageSize": 10
}

GET /api/vendors/:id

Returns a single vendor with all computed financial totals.

Permission: Vendor:Read

Response 200 OK — VendorDto

Response 404 Not Found


POST /api/vendors

Creates a new vendor.

Permission: Vendor:Create

Request Body

json
{
  "name": "XYZ Wholesalers",
  "address": "456 Link Road, Delhi",
  "phone": "+91 98000 00001",
  "email": "xyz@wholesalers.com",
  "vendorType": "Wholesaler",
  "drugLicenseNumber1": "DL-67890",
  "drugLicenseNumber2": "",
  "additionalDrugLicenseNumbers": []
}
FieldRequiredDescription
nameDisplay name
vendorTypeMust be one of the valid VendorType values (not OwnPharmacy)
addressPhysical address
phoneContact number
emailContact email
drugLicenseNumber1Primary drug license
drugLicenseNumber2Secondary drug license
additionalDrugLicenseNumbersArray of extra license strings

Response — Created 201 — VendorDto


PUT /api/vendors/:id

Updates an existing vendor.

Permission: Vendor:Update

Response — Updated 200 OK — Updated VendorDto

Response — Not Found 404


DELETE /api/vendors/:id

Soft-deletes a vendor (sets isActive = false). Invoices and transactions are preserved.

Permission: Vendor:Delete

Request Body (optional)

json
{ "reason": "Vendor stopped operations" }

Response — Deleted 204 No Content

Response — Not Found 404


VendorType Values

ValueDescription
ManufacturerProduces pharmaceutical products
WholesalerBulk distributor
AgencyAuthorised sales agent
DealerLocal reseller
PharmacyAnother pharmacy
OwnPharmacyYour own pharmacy — only one allowed, created during onboarding

MedRegia — Pharmaceutical Vendor Management Platform