curl -X GET "https://api.sully.ai/alpha/note-templates/template_abc123def456" \ -H "Authorization: Bearer YOUR_API_KEY"
{ "data": { "id": "template_abc123def456", "mode": "generate", "status": "completed", "created_at": "2024-01-15T10:30:00Z", "updated_at": "2024-01-15T10:35:00Z", "result": { "template": { "id": "generated-template-xyz789", "title": "Cardiology Consultation Template", "global_prompt": "Create a comprehensive cardiology consultation note following standard clinical documentation practices.", "sections": [ { "id": "chief_complaint", "type": "heading", "properties": { "level": 1, "text": "Chief Complaint" }, "children": [ { "id": "chief_complaint_text", "type": "text", "prompt": "Document the patient's primary concern in their own words.", "properties": { "formatting_style": "markdown", "detail_level": "standard", "tone": "formal" } } ] }, { "id": "assessment", "type": "heading", "properties": { "level": 1, "text": "Assessment" }, "children": [ { "id": "assessment_text", "type": "text", "prompt": "Provide clinical impression and differential diagnosis.", "properties": { "formatting_style": "markdown", "detail_level": "detailed", "tone": "technical" } } ] } ] } } } }
Retrieve a note template job (generation or refinement) by its unique identifier.
Show Note Template Job Object
pending
processing
completed
failed
generate
refine
Show Template Object
async function waitForTemplate(jobId) { let status = 'pending'; while (status === 'pending' || status === 'processing') { const response = await fetch(`https://api.sully.ai/alpha/note-templates/${jobId}`, { headers: { 'Authorization': 'Bearer YOUR_API_KEY' } }); const data = await response.json(); status = data.data.status; if (status === 'completed') { return data.data; } if (status === 'failed') { throw new Error(`Template job failed: ${data.data.result?.error || data.data.error || 'Unknown error'}`); } // Wait 10 seconds before polling again await new Promise(resolve => setTimeout(resolve, 10000)); } }
// Webhook handler example app.post('/webhook/note-template', (req, res) => { const { id, mode, status, result } = req.body.data; if (status === 'completed') { if (mode === 'generation') { // Process the completed generation console.log('Template generated:', result.template); console.log('Analysis insights:', result.insights); } else if (mode === 'refinement') { // Process the completed refinement console.log('Template refined:', result.refined_template); console.log('Changes applied:', result.refinement_analysis.changes_applied); } } else if (status === 'failed') { // Handle the error console.error('Template job failed:', result?.error || 'Unknown error'); } res.status(200).send('OK'); });