GET
/
alpha
/
note-templates
/
{id}
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"
                }
              }
            ]
          }
        ]
      }
    }
  }
}

Overview

Retrieve the details and results of a specific note template job using its unique identifier. This endpoint returns the current status of the job and any available results, supporting both generation and refinement jobs.

Path Parameters

id
string
required
The unique identifier of the note template job to retrieve

Response

data
object
The note template job object with current status and results
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"
                }
              }
            ]
          }
        ]
      }
    }
  }
}

Status Codes

200
OK
Note template job retrieved successfully
401
Unauthorized
Invalid or missing API key
404
Not Found
Note template job with the specified ID was not found
500
Internal Server Error
Server error occurred while retrieving the job

Polling for Results

Since note template jobs are processed asynchronously, you may need to poll this endpoint periodically to check for completion:
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));
  }
}

Understanding the Results

Template Structure

The generated template includes:
  • Sections: Organized structure based on your notes
  • Prompts: AI-generated prompts for each section
  • Types: Section types (text, list, structured) based on content patterns

Analysis Insights

The insights provide valuable information about your documentation patterns:
  • Common Headings: Most frequently used section headers
  • Style Analysis: Your writing tone and detail preferences
  • Statistics: Quantitative analysis of your notes

Using the Results

Generation Jobs: Once a template is generated, you can:
  1. Import the template into your documentation system
  2. Customize sections and prompts as needed
  3. Use it as a starting point for similar note types
  4. Analyze the insights to understand your documentation patterns
Refinement Jobs: Once a template is refined, you can:
  1. Replace your existing template with the refined version
  2. Review the refinement analysis to understand what changed
  3. Use the quality metrics to assess improvement
  4. Further refine if needed based on the analysis

Webhook Integration

For production use, consider setting up webhooks instead of polling:
// 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');
});