Intentional Blood Donation Network (iBDN)

Public API
Reference Documentation

Open REST API for integrating blood donor search, request management, donation tracking, and real-time availability into external applications, hospital systems, or mobile apps.

CORS: Open to all origins
Format: JSON
v2 — Approval Workflow
Base URL & Auth

Content-Type

application/json

Authentication

Session token from login — passed in POST body

Pattern

https://blood.islamos.org/api.php?action=ACTION

Calling the API: All requests go to https://blood.islamos.org/api.php?action=ACTION_NAME. GET params go in the query string; POST/PUT bodies are JSON. CORS is open to all origins — no preflight issues.
Donation Approval Flow

All donations now go through a two-step admin approval before donor stats are updated. This prevents fraud and ensures data integrity.

1. Donor logs / confirms donation  →  approval_status = "pending"
   (stats NOT updated yet)

2. Admin reviews pending list       →  GET ?action=pending_donations

3a. Admin approves                  →  POST ?action=approve_donation
    (donor total_donations++, last_donation_date set, is_available=0)

3b. Admin rejects (with note)       →  POST ?action=reject_donation
    (no stat change, donor notified by email + in-app notification)
Note: The confirm_donation and log_donation endpoints both return "submitted for admin approval" — donors are notified by email once approved or rejected.
Error Codes
HTTP CodeMeaningExample Body
400Bad Request — missing param or invalid login method{"error":"uid required"}
401Unauthorized — bad credentials or session token{"error":"Invalid credentials"}
404Resource not found{"error":"Donor not found"}
409Conflict — duplicate phone/email, or already approved/rejected{"error":"Already approved"}
422Unprocessable — required field absent in body{"error":"'name' is required"}
500Server / DB error{"error":"..."}
Blood Group Enum

Use exactly these strings in all blood_group fields:

"A+" | "A-" | "B+" | "B-" | "AB+" | "AB-" | "O+" | "O-"
Donor Endpoints
GET
?action=donors
Search and list donors with optional filters. Paginated.
▾
Parameters
Body
Response
Example
ParameterTypeDescription
blood_groupoptstringFilter by blood group enum
availableopt0 | 1Filter by availability flag
qoptstringSearch name, category, district, department, institution, address
limitoptint (1–100)Page size. Default: 20
offsetoptintPagination offset. Default: 0

No request body — GET only.

200 OK
JSON
{
      "donors": [{
        "id": 12, "unique_id": "Xb3Mn7291", "name": "Md. Rafiqul Islam",
        "blood_group": "B+", "is_available": 1, "total_donations": 7,
        "eligibility_status": "eligible", "recovery_pct": 100,
        "days_until_eligible": 0, "phone_masked": "01712••••••12",
        "is_verified": 1
      }],
      "count": 1, "total": 248, "offset": 0, "limit": 20, "has_more": true
      }
CURL
curl "https://blood.islamos.org/api.php?action=donors&blood_group=B%2B&available=1&q=Khulna&limit=10"
GET
?action=donor
Get a single donor by numeric ID, including last 10 donation history entries.
▾
Parameters
Body
Response
Example
ParameterTypeDescription
idreqintDonor's numeric database ID

No request body.

200 OK
JSON
{
  "id": 12, "unique_id": "Xb3Mn7291", "name": "Md. Rafiqul Islam",
  "blood_group": "B+", "is_verified": 1,
  "history": [{ "donated_at": "2024-11-03", "location": "iBDN" }]
}
404Not found
CURL
curl "https://blood.islamos.org/api.php?action=donor&id=12"
GET
?action=donor_profile
Fetch donor by their public unique ID (used in QR codes and share links).
▾
Parameters
Body
Response
Example
ParameterTypeDescription
uidreqstringPublic unique ID e.g. Xb3Mn7291

No request body.

200 OKSame as donor endpoint
404Donor not found
CURL
curl "https://blood.islamos.org/api.php?action=donor_profile&uid=Xb3Mn7291"
POST
?action=register
Register a new donor. Phone and email must each be unique across the platform.
▾
Parameters
Body
Response
Example

No query parameters.

FieldTypeDescription
namereqstringFull name
blood_groupreqstringSee Blood Group Enum
phonereqstringUnique BD mobile number — login username
passwordreqstringPlaintext (bcrypt-hashed server-side)
home_districtreqstringHome district name
emailoptstringUnique email — also usable as login username
genderoptstringmale | female | other
doboptdateYYYY-MM-DD
categoryoptstringstudent | employee | general
institution_nameoptstringUniversity / hospital / company
departmentoptstringDepartment or ward
designationoptstringJob title / designation
professionoptstringProfession field
present_addressoptstringCurrent address
last_donation_dateoptdateUsed to auto-compute next eligibility date
total_donationsoptintHistorical donation count (default: 0)
201 Created
JSON
{ "message": "Registered successfully", "id": 99, "unique_id": "Xb3Mn7291" }
409Duplicate phone or email
422Required field missing
CURL
curl -X POST "https://blood.islamos.org/api.php?action=register" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Numan Ibne Bashir",
    "blood_group": "O+",
    "phone": "+8801712345678",
    "email": "numan@example.com",
    "password": "SecurePass!1",
    "home_district": "Dhaka"
  }'
POST
?action=login
Authenticate a donor. Login accepts either phone or email.
▾
Parameters
Body
Response
Example

No query parameters.

FieldTypeDescription
passwordreqstringAccount password
phoneopt*stringRegistered phone number
emailopt*stringRegistered email address
* Provide either phone or email — at least one is required. If both are sent, email takes precedence.
200 OK
JSON
{
  "message": "Login successful",
  "token": "64-char-hex-session-token",
  "donor": { /* full donor object, password_hash and phone stripped */ }
}
401Invalid credentials
CURL
curl -X POST "https://blood.islamos.org/api.php?action=login" \
  -H "Content-Type: application/json" \
  -d '{"email":"fatema@example.com","password":"SecurePass!1"}'
PUT
?action=update_status
Toggle a donor's availability status.
▾
Parameters
Body
Response
Example

No query parameters.

FieldTypeDescription
donor_idreqintDonor's numeric ID
is_availablereq0 | 1New availability status
Changed in v2: This endpoint now takes donor_id directly instead of a session token. Validate identity in your integration layer before calling.
200 OK
JSON
{ "message": "Status updated" }
CURL
curl -X PUT "https://blood.islamos.org/api.php?action=update_status" \
  -H "Content-Type: application/json" \
  -d '{"donor_id":12,"is_available":1}'
Blood Request Endpoints
POST
?action=contact_request
Send a blood request to a specific donor. Emails are dispatched to the donor, requester, and admin.
▾
Parameters
Body
Response
Example

No query parameters.

FieldTypeDescription
donor_idreqintTarget donor's numeric ID
requester_namereqstringName of the person requesting blood
requester_phonereqstringRequester's contact number
messagereqstringReason / urgency details
requester_emailoptstringEmail for confirmation copy
bags_neededoptintNumber of blood bags required
needed_atoptdatetimeWhen blood is needed YYYY-MM-DD HH:MM:SS
locationoptstringHospital / ward name
200 OK
JSON
{
  "message": "Request sent. The donor will contact you if available.",
  "request_id": 45,
  "track_token": "3f8a2b1c...",
  "track_url": "https://blood.islamos.org/track/3f8a2b1c...",
  "email_results": {
    "donor_notified": true, "requester_confirmed": true, "admin_notified": true
  }
}
CURL
curl -X POST "https://blood.islamos.org/api.php?action=contact_request" \
  -H "Content-Type: application/json" \
  -d '{
    "donor_id": 12,
    "requester_name": "Dr. Hasan",
    "requester_phone": "01811223344",
    "message": "Emergency post-surgical patient needs 2 bags",
    "bags_needed": 2,
    "location": "Location of Donation"
  }'
GET
?action=public_requests
List open public broadcast blood requests. Phone numbers are partially masked. Expired entries auto-removed.
▾
Parameters
Body
Response
Example
ParameterTypeDescription
bgoptstringFilter by blood group (e.g. A+)

No request body.

200 OK
JSON
{
  "requests": [{
    "id": 7, "blood_group": "O-", "hospital": "Mayo Clinic",
    "urgency": "critical", "bags_needed": 3,
    "time_left": "4 hr left",
    "requester_phone": "017123****78"
  }],
  "total": 5
}
CURL
curl "https://blood.islamos.org/api.php?action=public_requests&bg=O-"
POST
?action=fulfill_public
Mark a public broadcast request as fulfilled.
▾
Parameters
Body
Response
Example

No query parameters.

FieldTypeDescription
request_idreqintID of the public request
200 OK
JSON
{ "message": "Marked as fulfilled" }
CURL
curl -X POST "https://blood.islamos.org/api.php?action=fulfill_public" \
  -H "Content-Type: application/json" \
  -d '{"request_id":7}'
GET
?action=track_request
Track the status of a contact request using the emailed tracking token.
▾
Parameters
Body
Response
Example
ParameterTypeDescription
tokenreqstring32-char hex tracking token

No request body.

200 OK
JSON
{
  "id": 45, "status": "accepted",
  "status_label": "Accepted by Donor", "status_icon": "✅",
  "status_color": "#16A34A",
  "status_desc": "The donor has accepted. They will contact you shortly.",
  "donor_name": "Md. Rafiqul Islam",
  "donor_uid": "Xb3Mn7291",
  "donor_blood_group": "B+",
  "donor_district": "Khulna",
  "donor_present_address": "Khulna Medical College Road",
  "donor_phone_masked": "01712••••••12",
  "donor_email_masked": "raf••••••ul@gmail.com"
}

Status values: pending · accepted · declined · donated

Privacy: Raw phone and email are never returned — only masked variants donor_phone_masked and donor_email_masked.
CURL
curl "https://blood.islamos.org/api.php?action=track_request&token=3f8a2b1c..."
POST
?action=update_request_status
Update the status of a contact request (accept / decline). Accepting auto-creates a pending donation record.
▾
Parameters
Body
Response
Example

No query parameters.

FieldTypeDescription
request_idreqintContact request ID
statusreqstringaccepted | declined | donated
Side effect: Setting status to accepted inserts a pending donation record and notifies the admin for approval. Donor stats are NOT updated yet.
200 OK
JSON
{ "message": "Status updated" }
CURL
curl -X POST "https://blood.islamos.org/api.php?action=update_request_status" \
  -H "Content-Type: application/json" \
  -d '{"request_id":45,"status":"accepted"}'
Donation Endpoints
POST
?action=log_donation
Self-log an external donation (e.g. at another hospital). Submitted as pending — admin must approve before stats update.
▾
Parameters
Body
Response
Example

No query parameters.

FieldTypeDescription
donor_idreqintDonor's numeric ID
donated_atreqdateDonation date YYYY-MM-DD
locationreqstringWhere the donation took place
recipient_infooptstringOptional recipient details
Changed in v2: Takes donor_id directly (not a session token). Donation goes to pending state awaiting admin approval.
200 OK
JSON
{ "message": "Donation submitted for admin approval. Your record will be updated once approved." }
CURL
curl -X POST "https://blood.islamos.org/api.php?action=log_donation" \
  -H "Content-Type: application/json" \
  -d '{"donor_id":12,"donated_at":"2025-06-01","location":"Location"}'
POST
?action=confirm_donation
Donor confirms a donation linked to a contact request. Submitted as pending for admin approval.
▾
Parameters
Body
Response
Example

No query parameters.

FieldTypeDescription
request_idreqintThe contact request ID to confirm
donated_atoptdateDate of donation (defaults to today)
locationoptstringDefaults to "Location of Donation"
409Already marked as donated
200 OK
JSON
{ "message": "Donation submitted for admin approval. Your record will be updated once approved." }
CURL
curl -X POST "https://blood.islamos.org/api.php?action=confirm_donation" \
  -H "Content-Type: application/json" \
  -d '{"request_id":45,"location":"Location of Donation"}'
Admin Endpoints
Admin only: These endpoints are intended for use by the iBDN admin panel. They are not authenticated via session token in the current version — protect access at the network/server level.
GET
?action=pending_donations
List all donations awaiting admin approval.
▾
Parameters
Body
Response
Example

No parameters required.

No request body.

200 OK
JSON
{
  "donations": [{
    "id": 88,
    "donor_id": 12, "donor_name": "Md. Rafiqul Islam",
    "donor_uid": "Xb3Mn7291", "blood_group": "B+",
    "donated_at": "2025-06-01", "location": "iBDN",
    "approval_status": "pending",
    "submitted_by": "donor",
    "donor_verified": 1
  }],
  "count": 3
}
CURL
curl "https://blood.islamos.org/api.php?action=pending_donations"
POST
?action=approve_donation
Approve a pending donation. Updates donor stats: total_donations++, last_donation_date set, is_available=0, next_available_date = +120 days.
▾
Parameters
Body
Response
Example

No query parameters.

FieldTypeDescription
donation_idreqintDonation record ID to approve
admin_idoptintAdmin user ID for audit trail
noteoptstringOptional note shown to donor in approval email
200 OK
JSON
{ "message": "Donation approved and donor stats updated." }
409Already approved
404Donation not found
CURL
curl -X POST "https://blood.islamos.org/api.php?action=approve_donation" \
  -H "Content-Type: application/json" \
  -d '{"donation_id":88,"admin_id":1,"note":"Verified via hospital record"}'
POST
?action=reject_donation
Reject a pending donation with a required note. Donor is notified by email and in-app notification.
▾
Parameters
Body
Response
Example

No query parameters.

FieldTypeDescription
donation_idreqintDonation record ID to reject
notereqstringReason for rejection — shown to donor
admin_idoptintAdmin user ID for audit trail
Side effect: If the donation was linked to a contact request (via recipient_info), that request status is reverted to accepted so the donor can re-confirm.
200 OK
JSON
{ "message": "Donation rejected. Donor notified." }
409Already rejected
CURL
curl -X POST "https://blood.islamos.org/api.php?action=reject_donation" \
  -H "Content-Type: application/json" \
  -d '{"donation_id":88,"note":"Could not verify — no hospital record found","admin_id":1}'
Stats & Preferences
GET
?action=stats
Platform-wide statistics including donor counts, blood group breakdown, top donors, and the active prize cycle countdown.
▾
Parameters
Body
Response
Example

No parameters required.

No request body.

200 OK
JSON
{
  "total_donors": 312, "available_donors": 198,
  "total_donations": 1074, "total_requests": 456,
  "by_blood_group": [{ "blood_group": "B+", "c": 89 }],
  "top_donors": [{
    "id": 12, "unique_id": "Xb3Mn7291", "name": "Md. Rafiqul",
    "blood_group": "B+", "total_donations": 23, "is_verified": 1
  }],
  "prize": {
    "cycle_number": 2,
    "cycle_end": "2026-12-31",
    "years_left": 0, "months_left": 6, "days_left": 24,
    "ended": false,
    "last_winners": []
  }
}
New in v2: The prize object contains the current prize cycle countdown and previous cycle winners from the built-in Prize Engine.
CURL
curl "https://blood.islamos.org/api.php?action=stats"
POST
?action=update_email_prefs
Update a donor's email notification preferences. Requires session token from login.
▾
Parameters
Body
Response
Example

No query parameters.

FieldTypeDescription
tokenreqstringSession token from login
contact_requestsoptboolNotify when someone requests blood
emergency_alertsoptboolCritical-urgency broadcast alerts
donation_remindersoptboolPeriodic reminders to update availability
reactivationoptboolNotify when donor becomes eligible again
newsletteroptboolMonthly newsletter
admin_broadcastoptboolAdmin-sent announcements
200 OK
JSON
{ "message": "Preferences updated", "preferences": { /* updated prefs */ } }
CURL
curl -X POST "https://blood.islamos.org/api.php?action=update_email_prefs" \
  -H "Content-Type: application/json" \
  -d '{"token":"abc123...","emergency_alerts":true,"newsletter":false}'
GET
?action=unsubscribe
One-click unsubscribe from one or all email notifications using the token in email footers.
▾
Parameters
Body
Response
Example
ParameterTypeDescription
tokenreqstringUnsubscribe token from email footer link
prefoptstringSpecific preference key. Omit to unsubscribe from all.

No request body.

200 OK
JSON
{ "message": "Unsubscribed successfully", "preferences": { /* updated */ } }
CURL
curl "https://blood.islamos.org/api.php?action=unsubscribe&token=TOKEN&pref=newsletter"

Intentional Blood Donation Network (iBDN) · API v1.0 · CORS open · https://blood.islamos.org