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

# Detect Macros

> Detects macros in text and provides expanded text with the macros replaced by their expansions



## OpenAPI

````yaml POST /v1/macros/detect
openapi: 3.1.0
info:
  title: Sully API
  description: >
    The Sully API is a robust platform designed to empower healthcare technology
    companies and Electronic Health Record (EHR) vendors by integrating advanced
    AI-driven clinical capabilities to help save healthcare providers (HCPs)
    time and make better decisions.


    ## V2 Audio Transcriptions


    The V2 Audio Transcriptions API provides enhanced audio transcription
    services using advanced AI models with improved accuracy and language
    support.


    ### Authentication


    The API uses API key authentication. You must include both:

    - `X-API-Key`: Your API key

    - `X-Account-Id`: Your account identifier


    ### Rate Limiting


    The API implements rate limiting to ensure fair usage. Rate limit
    information is returned in response headers:

    - `X-RateLimit-Limit`: Maximum requests allowed

    - `X-RateLimit-Remaining`: Remaining requests in current window

    - `X-RateLimit-Reset`: When the rate limit resets


    ### Audio File Support


    Supported audio formats:

    - WAV (audio/wav, audio/wave, audio/x-wav)

    - MP3 (audio/mpeg, audio/mp3)

    - FLAC (audio/flac)

    - OGG (audio/ogg)

    - WebM (audio/webm)

    - MP4 (audio/mp4)

    - M4A (audio/m4a)

    - AAC (audio/aac)

    - Opus (audio/opus)


    Maximum file size: 100MB


    ### Language Support


    The API supports multiple languages, including:

    - English (en, en-US) with medical-optimized transcription

    - Spanish (es), German (de), French (fr), Hindi (hi), Italian (it), Japanese
    (ja), Dutch (nl), Portuguese (pt), and Russian (ru)

    - Additional support for languages including Chinese, Korean, and others


    ### Processing


    V2 Transcriptions are processed asynchronously:

    1. Upload returns immediately with `pending` status

    2. Processing happens in the background

    3. Status updates to `processing`, then `completed` or `failed`

    4. Webhook notifications are sent when processing completes (if configured)


    ### Dictation


    V2 transcriptions support an optional `dictation` boolean field.

    When enabled, the transcript is formatted for dictation-style output.

    The default is `false`.
  version: 0.2.0
servers:
  - url: https://api.sully.ai
    description: Sully Production API
  - url: https://api-testing.sully.ai
    description: Sully Testing API
security:
  - apiKeyAuth: []
    accountIdAuth: []
tags:
  - name: Notes
    description: >-
      Operations for creating and managing clinical notes from medical
      encounters
  - name: Note Styles
    description: Operations for managing templates and formatting styles for clinical notes
  - name: Audio Transcriptions
    description: >-
      Operations for converting medical audio to text, including streaming
      capability
  - name: V2 Transcriptions
    description: >
      V2 Audio transcription operations with enhanced features


      The V2 Transcriptions API allows you to convert audio files to text using
      advanced AI models.

      Features include:

      - Multi-language support with specialized medical models

      - Speaker diarization (identifying different speakers)

      - Word-level timestamps and confidence scores

      - Automatic audio format conversion

      - Optional dictation-oriented transcript formatting

      - Asynchronous processing with webhook notifications
  - name: Utilities
    description: Utility operations for transforming and processing medical data
  - name: Codings
    description: >-
      Operations for medical coding analysis including ICD-10 and CPT code
      extraction
  - name: Macros
    description: >-
      Operations for detecting and expanding text macros in medical
      documentation
paths:
  /v1/macros/detect:
    post:
      tags:
        - Macros
      summary: Detect and expand text macros
      description: >-
        Detects macros in text and provides expanded text with the macros
        replaced by their expansions
      operationId: detectAndExpandMacros
      requestBody:
        description: Text to analyze for macros
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MacroDetectPayload'
        required: true
      responses:
        '200':
          description: Macro detection result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MacroDetectResponse'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    MacroDetectPayload:
      type: object
      description: Request payload for detecting and expanding macros in medical text
      required:
        - text
        - macros
      properties:
        text:
          type: string
          description: The text to analyze for macros
          example: >-
            The patient is a 54-year-old male here for a routine follow-up.
            Reports feeling well overall. Quickcheck. Denies any new symptoms.
            Medications reviewed and no changes needed. No signs of infection.
            Standard plan applies. Discussed flu vaccine and colonoscopy
            timeline. Return visit scheduled in six months.
        macros:
          type: array
          description: An array of macro objects to detect in the text
          items:
            type: object
            description: A macro definition with examples and expansion text
            required:
              - id
              - examples
              - expansion_text
            properties:
              id:
                type: string
                description: A unique identifier for the macro
                example: brief_exam_note
              examples:
                type: array
                description: An array of example strings that represent the macro in text
                items:
                  type: string
                  description: An example text string representing the macro
                example:
                  - quickcheck
                  - quick check
                  - quick-check
              expansion_text:
                type: string
                description: The text that should replace the macro when expanded
                example: >-
                  General: Patient appears well-nourished and in no acute
                  distress. HEENT: Normocephalic, atraumatic. Heart: Regular
                  rate and rhythm. Lungs: Clear to auscultation bilaterally.
    MacroDetectResponse:
      type: object
      description: Response containing detected macros and expanded text
      properties:
        data:
          type: object
          description: Result data object containing detections and expanded text
          properties:
            detections:
              type: array
              description: Array of detected macros in the text
              items:
                type: object
                description: A single macro detection result
                properties:
                  macro_id:
                    type: string
                    description: The ID of the detected macro
                    example: brief_exam_note
                  text_span:
                    type: object
                    description: >-
                      Position information about the detected macro in the
                      original text
                    properties:
                      start_char:
                        type: integer
                        description: >-
                          The starting character position of the detected macro
                          in the original text
                        example: 94
                      end_char:
                        type: integer
                        description: >-
                          The ending character position of the detected macro in
                          the original text
                        example: 104
                      text:
                        type: string
                        description: The text of the detected macro
                        example: Quickcheck
                  confidence:
                    type: number
                    description: >-
                      A confidence score between 0 and 1 indicating the system's
                      confidence in the detection
                    example: 0.98
                    minimum: 0
                    maximum: 1
            expanded_text:
              type: string
              description: The original text with all detected macros expanded
              example: >-
                The patient is a 54-year-old male here for a routine follow-up.
                Reports feeling well overall. General: Patient appears
                well-nourished and in no acute distress. HEENT: Normocephalic,
                atraumatic. Heart: Regular rate and rhythm. Lungs: Clear to
                auscultation bilaterally.. Denies any new symptoms. Medications
                reviewed and no changes needed. No signs of infection. Plan:
                Continue current medications. Reassess in 6 months or as needed.
                Patient advised to follow up for any new or worsening symptoms.
                applies. Discussed flu vaccine and colonoscopy timeline. Return
                visit scheduled in six months.
    Error:
      required:
        - error
        - message
      type: object
      properties:
        error:
          type: integer
          format: int32
        message:
          type: string
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY
    accountIdAuth:
      type: apiKey
      in: header
      name: X-ACCOUNT-ID

````