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

# MDI

> Send completed intake answers to MD Integrations (MDI)

Use this destination when the intake should create a case in MD Integrations (MDI). Setup for Forms
and Protocols is in [Overview & setup](/sdks/protocols/overview); below is what to pass when
calling **`send()`** with destination **`mdi`**.

Embeddables handles the send for you: it creates or finds the patient in MDI, creates a case with
their intake answers and any uploaded photos or documents, links the product you are selling, and
sends the case to MDI clinicians once the intake is complete.

<Note>
  Before the first send, an Embeddables admin must save your MDI **client secret** in the project's
  Integrations settings. This is a one-time setup step — you never pass the secret to `send()`.
</Note>

## Example

<Tabs>
  <Tab title="React">
    ```tsx lines theme={null}
    import { useProtocolsClient } from '@embeddables/protocols/react'

    function SendToMdi() {
      const client = useProtocolsClient()

      async function handleSubmit() {
        if (!client) return
        await client.send('mdi', {
          clientId: '<mdi-client-id>',
          productId: '<mdi-product-id>',
        })
      }

      return (
        <button type="button" onClick={handleSubmit}>
          Send to MDI
        </button>
      )
    }
    ```
  </Tab>

  <Tab title="JavaScript">
    ```typescript lines theme={null}
    await client.send('mdi', {
      clientId: '<mdi-client-id>',
      productId: '<mdi-product-id>',
    })
    ```
  </Tab>
</Tabs>

<h2 id="config">
  Settings
</h2>

<ParamField path="clientId" type="string" required>
  Your MDI client ID, from your MDI account. Pass it on every send.
</ParamField>

<ParamField path="productId" type="string" required>
  The MDI product this funnel sells. Pass it on every send — Embeddables adds that product to the
  case for you.
</ParamField>

<ParamField path="isPartialSubmit" type="boolean">
  Use **`true`** for lead capture — the case is created but stays on hold. Use **`false`** or omit
  when the intake is complete — for example after payment — so the case goes to MDI clinicians.
</ParamField>

<ParamField path="environment" type="string">
  Which saved MDI client secret to use: **`production`** (default), **`staging`**,
  **`development`**, or **`test`**. Only needed if your admin saved separate secrets per
  environment.
</ParamField>

<ParamField path="protocolId" type="string">
  Required only when more than one protocol is registered — the id of the protocol whose answers to
  send.
</ParamField>

<h2 id="data">
  Sending custom questions
</h2>

**`send()`** accepts an optional third argument when you want to add questions and answers to the
case that your intake does not ask — for example the plan the patient picked at checkout. Intake
answers are always sent; these are added after them.

<Tabs>
  <Tab title="React">
    ```tsx lines theme={null}
    await client.send(
      'mdi',
      { clientId: '<mdi-client-id>', productId: '<mdi-product-id>' },
      {
        customQuestions: [{ question: 'Selected plan', answer: '3-month supply' }],
      },
    )
    ```
  </Tab>

  <Tab title="JavaScript">
    ```typescript lines theme={null}
    await client.send(
      'mdi',
      { clientId: '<mdi-client-id>', productId: '<mdi-product-id>' },
      {
        customQuestions: [{ question: 'Selected plan', answer: '3-month supply' }],
      },
    )
    ```
  </Tab>
</Tabs>

<ParamField path="data.customQuestions" type="array">
  Each item has a **`question`** and an **`answer`**, plus an optional **`label`** shown to
  clinicians.
</ParamField>

<h2 id="result">
  What you get back
</h2>

<ResponseField name="caseId" type="string">
  The MDI case created for this send.
</ResponseField>

<ResponseField name="patientId" type="string">
  The MDI patient on the case — an existing patient when one matches the intake email, otherwise a
  new one.
</ResponseField>

<ResponseField name="caseOfferingId" type="string">
  The product added to the case, as MDI identifies it.
</ResponseField>

<ResponseField name="caseSubmitted" type="boolean">
  **`true`** when the case was sent to MDI clinicians. **`false`** when `isPartialSubmit` kept it on
  hold.
</ResponseField>

<ResponseField name="fileUploads" type="array">
  When the intake included photos or documents, one status per file — check that each one succeeded
  if uploads matter for your flow. A failed upload does not stop the send; the case is still created
  with the files that worked.
</ResponseField>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.