Back to SOPwise

SOPwise AI Plugin API Documentation

Overview

SOPwise AI is a specialized medical assistant API that processes and analyzes Standard Operating Procedures (SOPs) documents. It helps healthcare professionals find specific medical information like drug dosages, treatment protocols, and procedural guidelines.

Base URL: https://app.sopwise.ai

Current Version: v1

Medical Focus: This API is specifically designed for medical professionals and healthcare applications. It processes medical documents and provides clinically relevant information.

Authentication

All API endpoints require Bearer token authentication:

Authorization: Bearer YOUR_API_KEY

Getting an API Key

  1. Login to your SOPwise account
  2. Navigate to account settings by clicking your email in the sidebar
  3. Scroll down to the "API Keys" section
  4. Generate a new API key for plugin use
Security Note: Keep your API keys secure and never expose them in client-side code or public repositories.

API Endpoints

1. Upload SOP Documents

POST /upload_sop

Upload medical SOP documents for analysis and Q&A.

Parameters:

Parameter Type Required Description
files File[] Yes Array of medical documents (PDF, DOCX)
ocr_mode String No OCR processing mode: "fast" or "accurate" (default: "fast")

Example Request:

POST /upload_sop
Content-Type: multipart/form-data
Authorization: Bearer YOUR_API_KEY

files: [file1.pdf, file2.docx]
ocr_mode: "fast"

Example Response:

{
  "reply": "Uploaded 2 document(s) successfully!",
  "suggestions": [
    "What are the dosage recommendations?",
    "What are the contraindications?"
  ]
}

2. Ask Questions

POST /ask

Send questions about uploaded SOP documents and get AI-powered answers.

Parameters:

Parameter Type Required Description
message String Yes The question about the SOPs
stream Boolean No Whether to stream the response (default: false)

Example Request:

POST /ask
Content-Type: application/json
Authorization: Bearer YOUR_API_KEY

{
  "message": "What are the dosage recommendations for vancomycin?",
  "stream": false
}

Example Response:

{
  "reply": "Based on the uploaded SOPs, vancomycin dosage recommendations are:\n\n1. Loading dose: 25-30 mg/kg IV\n2. Maintenance dose: 15-20 mg/kg every 8-12 hours\n3. Target trough levels: 15-20 mg/L for serious infections",
  "suggestions": [
    "What are the monitoring requirements?",
    "What are the contraindications?"
  ]
}

3. List Uploaded SOPs

GET /sops

Get a list of all uploaded SOP documents with metadata.

Example Response:

{
  "sops": [
    {
      "id": 1,
      "filename": "vancomycin-protocol-2021.pdf",
      "topic": "Antibiotic Protocols",
      "language": "en",
      "created_at": "2024-01-15T10:30:00Z"
    }
  ]
}

4. Get Detected Topics

GET /topics

Retrieve all detected medical topics from uploaded SOPs.

Example Response:

{
  "topics": [
    "Antibiotic Protocols",
    "Emergency Procedures",
    "ICU Management"
  ]
}

5. Plugin Status

GET /status

Check plugin operational status and current document load.

Example Response:

{
  "status": "operational",
  "documents_loaded": 5,
  "available_languages": ["en", "de"]
}

6. View SOP Document

GET /sop/{id}/view

View or download a specific SOP document by ID.

Parameters:

Parameter Type Required Description
id String Yes SOP document identifier

Returns the original document file with appropriate Content-Type headers.

Usage Examples

Python Example

import requests

# Upload documents
files = {'files': open('sop.pdf', 'rb')}
response = requests.post(
    'https://app.sopwise.ai/upload_sop/',
    files=files,
    data={'ocr_mode': 'fast'},
    headers={'Authorization': 'Bearer YOUR_API_KEY'}
)

# Ask question
response = requests.post(
    'https://app.sopwise.ai/ask/',
    json={'message': 'What are the dosage recommendations?'},
    headers={
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json'
    }
)

JavaScript Example

// Upload documents
const formData = new FormData();
formData.append('files', fileInput.files[0]);
formData.append('ocr_mode', 'fast');

const uploadResponse = await fetch('/upload_sop/', {
    method: 'POST',
    body: formData,
    headers: {
        'Authorization': 'Bearer YOUR_API_KEY'
    }
});

// Ask question
const askResponse = await fetch('/ask/', {
    method: 'POST',
    headers: {
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json'
    },
    body: JSON.stringify({
        message: 'What are the dosage recommendations?'
    })
});

cURL Example

# Upload document
curl -X POST "https://app.sopwise.ai/upload_sop/" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "files=@sop.pdf" \
  -F "ocr_mode=fast"

# Ask question
curl -X POST "https://app.sopwise.ai/ask/" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"message": "What are the dosage recommendations?"}'

Error Handling

All endpoints return JSON error responses with the following structure:

{
  "error": "Error description",
  "code": "ERROR_CODE"
}

Common HTTP Status Codes

Code Meaning Description
200 Success Request completed successfully
400 Bad Request Invalid parameters or request format
401 Unauthorized Invalid or missing API key
404 Not Found Resource doesn't exist
413 Payload Too Large File size exceeded limits
429 Too Many Requests Rate limit exceeded
500 Internal Server Error Server encountered an error

Rate Limiting & Quotas

Plan Daily Requests File Uploads File Size Limit
Free 100 requests 2 files 5MB per file
Plus 1000 requests Unlimited 10MB per file
Enterprise Custom limits Unlimited Custom limits

Support & Resources

Need Help? Our support team is available to help you integrate the SOPwise API into your healthcare applications.