> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sully.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Note Template Job

> Retrieve a note template job (generation or refinement) by its unique identifier.

## 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

<ParamField path="id" type="string" required>
  The unique identifier of the note template job to retrieve
</ParamField>

## Response

<ResponseField name="data" type="object">
  The note template job object with current status and results

  <Expandable title="Note Template Job Object">
    <ResponseField name="id" type="string">
      Unique identifier for the template job
    </ResponseField>

    <ResponseField name="status" type="string">
      Current status of the job

      * `pending`: Job is queued for processing
      * `processing`: Currently processing the request
      * `completed`: Processing complete, results available
      * `failed`: Processing failed
    </ResponseField>

    <ResponseField name="mode" type="string">
      The operation mode for this job

      * `generate`: Creating a template from provider notes
      * `refine`: Improving an existing template
    </ResponseField>

    <ResponseField name="created_at" type="string">
      Timestamp when the job was created (ISO 8601 format)
    </ResponseField>

    <ResponseField name="updated_at" type="string" optional>
      Timestamp when the job was last updated (ISO 8601 format)
    </ResponseField>

    <ResponseField name="result" type="object" optional>
      Available when status is "completed" - contains the generated/refined template

      <ResponseField name="template" type="object" optional>
        The generated or refined note template

        <Expandable title="Template Object">
          <ResponseField name="id" type="string">
            Unique identifier for the template
          </ResponseField>

          <ResponseField name="title" type="string">
            Title for the template
          </ResponseField>

          <ResponseField name="global_prompt" type="string" optional>
            Global prompt/instructions for the template
          </ResponseField>

          <ResponseField name="sections" type="array">
            Array of template sections with structure and prompts
          </ResponseField>
        </Expandable>
      </ResponseField>

      <ResponseField name="error" type="string" optional>
        Error message if processing failed
      </ResponseField>
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X GET "https://api.sully.ai/alpha/note-templates/template_abc123def456" \
    -H "Authorization: Bearer YOUR_API_KEY"
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.sully.ai/alpha/note-templates/template_abc123def456', {
    method: 'GET',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY'
    }
  });

  const data = await response.json();
  console.log(data);
  ```

  ```python Python theme={null}
  import requests

  url = "https://api.sully.ai/alpha/note-templates/template_abc123def456"
  headers = {
      "Authorization": "Bearer YOUR_API_KEY"
  }

  response = requests.get(url, headers=headers)
  result = response.json()
  print(result)
  ```
</RequestExample>

<ResponseExample>
  ```json 200 OK - Completed Generation Job theme={null}
  {
    "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"
                  }
                }
              ]
            }
          ]
        }
      }
    }
  }
  ```

  ```json 200 OK - Completed Refinement Job theme={null}
  {
    "data": {
      "id": "template_xyz789ghi012",
      "status": "completed",
      "mode": "refine",
      "created_at": "2024-01-15T10:30:00Z",
      "updated_at": "2024-01-15T10:37:00Z",
      "result": {
        "template": {
          "id": "refined-template-xyz789",
          "title": "Enhanced Cardiology Consultation Template",
          "global_prompt": "Create a comprehensive cardiology consultation note with enhanced assessment detail and differential diagnosis.",
          "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, including severity (1-10) and duration.",
                  "properties": {
                    "formatting_style": "markdown",
                    "detail_level": "detailed",
                    "tone": "formal"
                  }
                }
              ]
            },
            {
              "id": "assessment",
              "type": "heading",
              "properties": {
                "level": 1,
                "text": "Assessment"
              },
              "children": [
                {
                  "id": "assessment_text",
                  "type": "text",
                  "prompt": "Provide clinical impression with severity scoring, differential diagnosis (minimum 3 options), and risk stratification.",
                  "properties": {
                    "formatting_style": "markdown",
                    "detail_level": "detailed",
                    "tone": "technical"
                  }
                }
              ]
            }
          ]
        }
      }
    }
  }
  ```

  ```json 200 OK - Pending Job theme={null}
  {
    "data": {
      "id": "template_abc123def456",
      "status": "pending",
      "mode": "generate",
      "created_at": "2024-01-15T10:30:00Z",
      "updated_at": "2024-01-15T10:30:00Z"
    }
  }
  ```

  ```json 200 OK - Failed Job theme={null}
  {
    "data": {
      "id": "template_abc123def456",
      "status": "failed",
      "mode": "generate",
      "created_at": "2024-01-15T10:30:00Z",
      "updated_at": "2024-01-15T10:35:00Z",
      "result": {
        "error": "Failed to generate note template"
      }
    }
  }
  ```
</ResponseExample>

## Status Codes

<ResponseField name="200" type="OK">
  Note template job retrieved successfully
</ResponseField>

<ResponseField name="401" type="Unauthorized">
  Invalid or missing API key
</ResponseField>

<ResponseField name="404" type="Not Found">
  Note template job with the specified ID was not found
</ResponseField>

<ResponseField name="500" type="Internal Server Error">
  Server error occurred while retrieving the job
</ResponseField>

## Polling for Results

Since note template jobs are processed asynchronously, you may need to poll this endpoint periodically to check for completion:

```javascript theme={null}
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:

```javascript theme={null}
// 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');
});
```

## Related Endpoints

* [Create Note Template](/api-reference-alpha/note-templates/create) - Create a new template job
* [Delete Note Template](/api-reference-alpha/note-templates/delete) - Delete a template job
