Skip to main content
Beta ← Back to Guided Synthesis overview Use this when you don’t have a template that matches your need, but you do have the sections. List the sections you want, in the order they should appear, and supply template-level instructions. The response includes the new auto-generated template aggregate — keep its templateId to reuse the same composition on subsequent calls. The aggregate is retained for 30 days only (see Auto-generated template aggregates — 30-day retention); convert it into a permanent project-owned template if you want long-lived reuse.
// Replace these with your values
const ALLERGIES_SECTION_ID = "<your-section-id>";
const ASSESSMENT_SECTION_ID = "<your-section-id>";
const HPI_SECTION_ID = "<your-section-id>";
const INTERACTION_ID = "<your-interaction-id>";
const PLAN_SECTION_ID = "<your-section-id>";
const PLAN_VERSION_ID = "<your-version-id>";

const result = await client.documents.generate({
  outputLanguage: "en-US",
  interactionId: INTERACTION_ID,
  assemblyTemplate: {
    name: "Allergy follow-up note",
    instructions: {
      prompt: "Produce a focused follow-up note for an allergy consultation.",
    },
    sectionRefs: [
      { sectionId: HPI_SECTION_ID },
      { sectionId: ALLERGIES_SECTION_ID },
      {
        sectionId: ASSESSMENT_SECTION_ID,
        overrides: {
          heading: "Impression",
          instructions: { writingStylePrompt: "Telegraphic; no narrative." },
        },
      },
      { sectionId: PLAN_SECTION_ID, sectionVersionId: PLAN_VERSION_ID },
    ],
  },
});
using Corti;

// Replace these with your values
const string AllergiesSectionId = "<your-section-id>";
const string AssessmentSectionId = "<your-section-id>";
const string HpiSectionId = "<your-section-id>";
const string InteractionId = "<your-interaction-id>";
const string PlanSectionId = "<your-section-id>";
const string PlanVersionId = "<your-version-id>";

var result = await client.Documents.GenerateAsync(
    new GuidedDocumentsGenerateByAssembly
    {
        OutputLanguage = "en-US",
        InteractionId = InteractionId,
        AssemblyTemplate = new GuidedAssemblyRequest
        {
            Name = "Allergy follow-up note",
            Instructions = new GuidedTemplateInstructions
            {
                Prompt = "Produce a focused follow-up note for an allergy consultation.",
            },
            SectionRefs = new[]
            {
                new GuidedAssemblySectionRef { SectionId = HpiSectionId },
                new GuidedAssemblySectionRef { SectionId = AllergiesSectionId },
                new GuidedAssemblySectionRef
                {
                    SectionId = AssessmentSectionId,
                    Overrides = new GuidedSectionOverrides
                    {
                        Heading = "Impression",
                        Instructions = new GuidedSectionInstructionsOverride
                        {
                            WritingStylePrompt = "Telegraphic; no narrative.",
                        },
                    },
                },
                new GuidedAssemblySectionRef
                {
                    SectionId = PlanSectionId,
                    SectionVersionId = PlanVersionId,
                },
            },
        },
    });
import requests

# Replace these with your values
ALLERGIES_SECTION_ID = "<your-section-id>"
ASSESSMENT_SECTION_ID = "<your-section-id>"
ENVIRONMENT = "<eu-or-us>"
HPI_SECTION_ID = "<your-section-id>"
INTERACTION_ID = "<your-interaction-id>"
PLAN_SECTION_ID = "<your-section-id>"
PLAN_VERSION_ID = "<your-version-id>"
TENANT = "<your-tenant-name>"
TOKEN = "<your-access-token>"

response = requests.post(
    f"https://api.{ENVIRONMENT}.corti.app/v2/documents",
    headers={
        "Authorization": f"Bearer {TOKEN}",
        "Tenant-Name": TENANT,
        "Content-Type": "application/json",
    },
    json={
        "outputLanguage": "en-US",
        "interactionId": INTERACTION_ID,
        "assemblyTemplate": {
            "name": "Allergy follow-up note",
            "instructions": {
                "prompt": "Produce a focused follow-up note for an allergy consultation.",
            },
            "sectionRefs": [
                {"sectionId": HPI_SECTION_ID},
                {"sectionId": ALLERGIES_SECTION_ID},
                {
                    "sectionId": ASSESSMENT_SECTION_ID,
                    "overrides": {
                        "heading": "Impression",
                        "instructions": {"writingStylePrompt": "Telegraphic; no narrative."},
                    },
                },
                {"sectionId": PLAN_SECTION_ID, "sectionVersionId": PLAN_VERSION_ID},
            ],
        },
    },
)
response.raise_for_status()
result = response.json()
# Replace these with your values
ALLERGIES_SECTION_ID="<your-section-id>"
ASSESSMENT_SECTION_ID="<your-section-id>"
ENVIRONMENT="<eu-or-us>"
HPI_SECTION_ID="<your-section-id>"
INTERACTION_ID="<your-interaction-id>"
PLAN_SECTION_ID="<your-section-id>"
PLAN_VERSION_ID="<your-version-id>"
TENANT="<your-tenant-name>"
TOKEN="<your-access-token>"

curl --request POST \
  --url "https://api.${ENVIRONMENT}.corti.app/v2/documents" \
  --header "Authorization: Bearer ${TOKEN}" \
  --header "Tenant-Name: ${TENANT}" \
  --header "Content-Type: application/json" \
  --data "{
    \"outputLanguage\": \"en-US\",
    \"interactionId\": \"${INTERACTION_ID}\",
    \"assemblyTemplate\": {
      \"name\": \"Allergy follow-up note\",
      \"instructions\": {
        \"prompt\": \"Produce a focused follow-up note for an allergy consultation.\"
      },
      \"sectionRefs\": [
        { \"sectionId\": \"${HPI_SECTION_ID}\" },
        { \"sectionId\": \"${ALLERGIES_SECTION_ID}\" },
        {
          \"sectionId\": \"${ASSESSMENT_SECTION_ID}\",
          \"overrides\": {
            \"heading\": \"Impression\",
            \"instructions\": { \"writingStylePrompt\": \"Telegraphic; no narrative.\" }
          }
        },
        { \"sectionId\": \"${PLAN_SECTION_ID}\", \"sectionVersionId\": \"${PLAN_VERSION_ID}\" }
      ]
    }
  }"

Behavior notes

  • sectionRefs is order-significant — sections appear in the rendered document in declaration order.
  • Each sectionRef resolves to the section’s published version unless you pin sectionVersionId.
  • overrides on a sectionRef follow the same partial/wholesale rules as Path 2.

When to use this path

ScenarioWhy Path 3
EHR-field-driven note where the section set varies per encounterCompose the right sections per call without authoring a template per combination.
One document built from a few Corti Standard sectionsSkip the template authoring step entirely. The auto-generated aggregate is your “receipt.”
Customer-specific composition that you may eventually promote to a permanent templateRun Path 3 first; if the same composition recurs, convert the aggregate into a project-owned template via the retention workaround.

Guided Synthesis overview

Shared concepts: input context, response shape, errors, 30-day retention.

Create a Template

When you’re ready to promote a recurring assembly into a stable, versioned template.