---
title: "Detect and expand text macros"
method: POST
path: "/v1/macros/detect"
tags: ["Macros"]
---

# Detect and expand text macros

`POST /v1/macros/detect`

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

## Request body

- MacroDetectPayload — Request payload for detecting and expanding macros in medical text
  - `text` string, required — The text to analyze for macros
  - `macros` object[], required — An array of macro objects to detect in the text
    - `id` string, required — A unique identifier for the macro
    - `examples` string[], required — An array of example strings that represent the macro in text
    - `expansion_text` string, required — The text that should replace the macro when expanded

## Response `200`

Macro detection result

- MacroDetectResponse — Response containing detected macros and expanded text
  - `data` object — Result data object containing detections and expanded text
    - `detections` object[] — Array of detected macros in the text
      - `macro_id` string — The ID of the detected macro
      - `text_span` object — Position information about the detected macro in the original text
        - `start_char` integer — The starting character position of the detected macro in the original text
        - `end_char` integer — The ending character position of the detected macro in the original text
        - `text` string — The text of the detected macro
      - `confidence` number — A confidence score between 0 and 1 indicating the system's confidence in the detection
    - `expanded_text` string — The original text with all detected macros expanded

## Other responses

- `400` — Invalid request

---

[API](https://skmtc.net/sullyai/apis/sully-api.md) · [All operations](https://skmtc.net/sullyai/apis/sully-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/sullyai/sully-api/revisions/a6ecf503233c/schema)
