Skip to main content
POST
/
notes
/
regenerate-notes
/
{id}
curl -X POST \
  'https://app.medisync.me/api/notes/regenerate-notes/664e0b1f7c2a5e0011fa9911' \
  -H 'Authorization: Bearer your_jwt_token_here' \
  -H 'Content-Type: application/json' \
  -d '{
    "notes_template_type": "6650a2f19b1e8a0012ab7788",
    "language": "en"
  }'
const response = await fetch(
  'https://app.medisync.me/api/notes/regenerate-notes/664e0b1f7c2a5e0011fa9911',
  {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer your_jwt_token_here',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      notes_template_type: '6650a2f19b1e8a0012ab7788',
      language: 'en'
    })
  }
);

const result = await response.json();
import requests

response = requests.post(
    'https://app.medisync.me/api/notes/regenerate-notes/664e0b1f7c2a5e0011fa9911',
    headers={
        'Authorization': 'Bearer your_jwt_token_here',
        'Content-Type': 'application/json'
    },
    json={
        'notes_template_type': '6650a2f19b1e8a0012ab7788',
        'language': 'en'
    }
)

result = response.json()
{
  "success": true,
  "data": {
    "notes": "S: Patient reports chest pain on exertion, denies dyspnea.\nO: VS stable, HR 72, BP 120/80; EKG normal.\nA: Atypical chest pain, likely musculoskeletal.\nP: Continue monitoring, follow up in 1 week.",
    "summary": "Chest pain evaluation with normal findings - continue monitoring",
    "citations": null,
    "deltas": null,
    "changes_summary": null
  }
}

Overview

Regenerate the clinical notes for an appointment from its existing transcription. MediSync generates fresh notes and a summary using the requested template and language, updates the stored notes document, and records the chosen template and language on the appointment. The appointment must already have a transcription; if none exists the request returns 404 Transcription not found.
This operation is scoped to the owning doctor. The appointment identified by {id} must belong to the authenticated user. A request for an appointment you do not own returns 403 Forbidden, and an unknown appointment returns 404 Appointment not found.

Authentication

Authorization
string
required
Bearer token for authenticated access. The doctor (user) identity is taken from the JWT.
Authorization: Bearer your_jwt_token_here
A missing or invalid token returns 401 with a message field. See Error Responses.

Path Parameters

id
string
required
Appointment ID (MongoDB ObjectId, 24 hex characters) to regenerate notes for. Must be owned by the authenticated doctor and have an existing transcription.

Body Parameters

notes_template_type
string
required
Identifier of the template to generate against — the ID of a Template document. Omitting it returns 400. A value that is not a valid template ID returns 500 with Template not found in database.
language
string
ISO language code for generation (for example de or en). Falls back to the appointment’s stored language when omitted.

Response

success
boolean
Indicates whether the operation succeeded.
data
object
The regenerated notes content.
error
string
Error message (only present when success is false).
Additional fields may be present in the response and should be treated as opaque.

Example Request

curl -X POST \
  'https://app.medisync.me/api/notes/regenerate-notes/664e0b1f7c2a5e0011fa9911' \
  -H 'Authorization: Bearer your_jwt_token_here' \
  -H 'Content-Type: application/json' \
  -d '{
    "notes_template_type": "6650a2f19b1e8a0012ab7788",
    "language": "en"
  }'
const response = await fetch(
  'https://app.medisync.me/api/notes/regenerate-notes/664e0b1f7c2a5e0011fa9911',
  {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer your_jwt_token_here',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      notes_template_type: '6650a2f19b1e8a0012ab7788',
      language: 'en'
    })
  }
);

const result = await response.json();
import requests

response = requests.post(
    'https://app.medisync.me/api/notes/regenerate-notes/664e0b1f7c2a5e0011fa9911',
    headers={
        'Authorization': 'Bearer your_jwt_token_here',
        'Content-Type': 'application/json'
    },
    json={
        'notes_template_type': '6650a2f19b1e8a0012ab7788',
        'language': 'en'
    }
)

result = response.json()

Example Response

{
  "success": true,
  "data": {
    "notes": "S: Patient reports chest pain on exertion, denies dyspnea.\nO: VS stable, HR 72, BP 120/80; EKG normal.\nA: Atypical chest pain, likely musculoskeletal.\nP: Continue monitoring, follow up in 1 week.",
    "summary": "Chest pain evaluation with normal findings - continue monitoring",
    "citations": null,
    "deltas": null,
    "changes_summary": null
  }
}

Error Responses

{
  "success": false,
  "error": "Missing appointmentId or notes_template_type"
}
{
  "success": false,
  "message": "Unauthorized"
}
{
  "success": false,
  "message": "Session ended on this device because you signed in elsewhere.",
  "code": "SESSION_REVOKED"
}
{
  "success": false,
  "error": "Forbidden"
}
{
  "success": false,
  "error": "Appointment not found"
}
{
  "success": false,
  "error": "Transcription not found"
}
{
  "success": false,
  "error": "Failed to regenerate notes and update database"
}
{
  "success": false,
  "error": "Template not found in database."
}

Behavior Notes

  • Order of checks: The request is validated (400 if notes_template_type is missing), then the appointment is loaded (404 / 403), then its transcription is loaded (404), then notes are generated.
  • Language fallback: When language is omitted, the appointment’s stored language is used.
  • Appointment update: On success the appointment’s stored template and language are updated to match the request.
  • Real-time updates: A real-time note update is emitted to connected clients on success.

Status Codes

  • 200 — Notes regenerated successfully.
  • 400 — Missing notes_template_type.
  • 401 — Missing, invalid, or revoked authentication token.
  • 403 — Authenticated user does not own the appointment.
  • 404 — Appointment or transcription not found.
  • 500 — Generation failure, database update failure, or an invalid template ID.