{
  "version": "1.0",
  "exportedAt": "2026-10-29T00:00:00.000Z",
  "metadata": {
    "notes": "API to API recipe (medhook.dev/docs/guides/recipes/api-to-api). Choose the destination profile on the Send step, set the trigger's signing secret, and fill the workflow's Senders table before you deploy."
  },
  "workflow": {
    "name": "Demo Health appointments, API to API",
    "description": "A signed JSON webhook from each Demo Health clinic, checked against a JSON Schema, mapped to the scheduling API's JSON with per-sender settings, posted with OAuth2, and answered with the API's confirmation.",
    "enabled": false,
    "maxWorkflowRetries": 0,
    "trigger": {
      "type": "webhook",
      "webhookId": "demo-health-appointments",
      "requireTimestamp": true,
      "timestampToleranceSeconds": 300,
      "senderFrom": { "path": "sender" },
      "bodySchema": {
        "type": "object",
        "required": ["sender", "appointmentId", "start", "patient"],
        "properties": {
          "sender": { "type": "string", "minLength": 1 },
          "appointmentId": { "type": "string", "pattern": "^APT-[0-9]{4,}$" },
          "start": { "type": "string", "format": "date-time" },
          "durationMinutes": {
            "type": "integer",
            "minimum": 5,
            "maximum": 480
          },
          "reminder": { "type": "string", "enum": ["sms", "email", "none"] },
          "clinicCode": { "type": "string" },
          "patient": {
            "type": "object",
            "required": ["mrn", "family"],
            "properties": {
              "mrn": { "type": "string", "minLength": 3 },
              "family": { "type": "string" },
              "given": { "type": "string" }
            }
          }
        }
      },
      "response": {
        "mode": "destination",
        "nodeId": "answer",
        "statusCode": 201,
        "timeoutMs": 20000
      }
    },
    "startNodeId": "map",
    "nodes": [
      {
        "id": "map",
        "type": "transform",
        "label": "Map to the scheduling API",
        "position": { "x": 0, "y": 0 },
        "data": {
          "type": "transform",
          "label": "Map to the scheduling API",
          "transformType": "field-mapping",
          "mapping": [
            { "source": "$.data.appointmentId", "target": "externalId" },
            { "source": "$.data.patient.mrn", "target": "patient.identifier" },
            { "source": "$.data.patient.family", "target": "patient.lastName" },
            { "source": "$.data.patient.given", "target": "patient.firstName" },
            { "source": "$.data.start", "target": "slot.start" },
            {
              "source": "$.data.durationMinutes",
              "target": "slot.minutes",
              "default": "30"
            },
            {
              "source": "$.data.clinicCode",
              "target": "slot.clinic",
              "default": "{{sender.clinicCode}}"
            },
            {
              "source": "$.data.reminder",
              "target": "reminderChannel",
              "lookupValues": [
                { "from": "sms", "to": "TEXT" },
                { "from": "email", "to": "EMAIL" }
              ],
              "default": "NONE"
            }
          ],
          "errorHandling": { "strategy": "fail" }
        }
      },
      {
        "id": "send",
        "type": "adapter",
        "label": "Post to the scheduling API",
        "position": { "x": 260, "y": 0 },
        "data": {
          "type": "adapter",
          "label": "Post to the scheduling API",
          "adapterType": "generic-rest",
          "adapterProfileId": "REPLACE_WITH_SCHEDULING_API_PROFILE",
          "action": "post",
          "config": {
            "endpoint": "/accounts/{{sender.accountId}}/appointments"
          },
          "errorHandling": { "strategy": "fail" }
        }
      },
      {
        "id": "answer",
        "type": "transform",
        "label": "Answer the clinic",
        "position": { "x": 520, "y": 0 },
        "data": {
          "type": "transform",
          "label": "Answer the clinic",
          "transformType": "field-mapping",
          "mapping": [
            { "source": "$.id", "target": "confirmation" },
            { "source": "$.status", "target": "status" }
          ],
          "errorHandling": { "strategy": "fail" }
        }
      }
    ],
    "edges": [
      { "id": "map-send", "source": "map", "target": "send" },
      { "id": "send-answer", "source": "send", "target": "answer" }
    ]
  }
}
