{
  "openapi": "3.1.0",
  "info": {
    "title": "FuseApp External API",
    "version": "1.0.0",
    "description": "External API for FuseApp eligibility checking and patient management."
  },
  "servers": [
    {
      "url": "https://app.fuseinsight.com"
    }
  ],
  "security": [
    {
      "BearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Webhooks",
      "description": "Webhook subscriptions for eligibility check state changes. The set of subscriptions that fire for any given check is frozen at the moment the check execution starts; subscription create/update/delete operations and secret rotations apply only to checks started after the change. Deliveries are signed with HMAC-SHA256 over `{timestamp}.{payload}` and carry `X-Webhook-Signature: sha256=<hex>`, `X-Webhook-Timestamp`, and `Idempotency-Key` headers — verify the signature and dedupe on the idempotency key."
    }
  ],
  "components": {
    "schemas": {
      "OAuthTokenResponse": {
        "type": "object",
        "properties": {
          "access_token": {
            "type": "string",
            "description": "Bearer JWT to include as `Authorization: Bearer <token>` on subsequent v1 requests."
          },
          "token_type": {
            "type": "string",
            "enum": [
              "Bearer"
            ]
          },
          "expires_in": {
            "type": "integer",
            "exclusiveMinimum": 0,
            "description": "Token lifetime in seconds."
          },
          "scope": {
            "type": "string",
            "description": "Space-separated list of scopes granted to this token, taken from the API key's configured scopes."
          }
        },
        "required": [
          "access_token",
          "token_type",
          "expires_in",
          "scope"
        ]
      },
      "OAuthTokenError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "enum": [
              "invalid_request",
              "invalid_client",
              "unsupported_grant_type",
              "slow_down"
            ],
            "description": "RFC 6749 §5.2 error code."
          },
          "error_description": {
            "type": "string",
            "description": "Human-readable description of the failure."
          }
        },
        "required": [
          "error",
          "error_description"
        ]
      },
      "OAuthTokenRequest": {
        "type": "object",
        "properties": {
          "grant_type": {
            "type": "string",
            "enum": [
              "client_credentials"
            ],
            "description": "OAuth 2.0 grant type. Only `client_credentials` is supported."
          },
          "client_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128,
            "description": "API key identifier issued at key creation time. Treat as public."
          },
          "client_secret": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256,
            "description": "API key secret issued at key creation time. Treat as a credential — never log or commit."
          }
        },
        "required": [
          "grant_type",
          "client_id",
          "client_secret"
        ]
      },
      "EligibilityCheckWebhookPayload": {
        "type": "object",
        "properties": {
          "checkId": {
            "type": "string",
            "format": "uuid",
            "description": "Eligibility check ID."
          },
          "status": {
            "type": "string",
            "enum": [
              "RUNNING",
              "COMPLETED",
              "FAILED",
              "INCOMPLETE",
              "TIMED_OUT"
            ],
            "description": "Workflow-level status. `RUNNING` while any stage is still in flight (or the check is queued). Terminal values: `COMPLETED` (every stage succeeded or was skipped successfully), `FAILED` (every executed stage failed), `INCOMPLETE` (some stages succeeded but at least one failed), `TIMED_OUT` (the check stopped reporting before it finished and no stage failed; rerun it). Clients should treat any unknown value as terminal and not poll further."
          },
          "results": {
            "$ref": "#/components/schemas/EligibilityCheckResults"
          },
          "timestamp": {
            "type": "string",
            "description": "ISO-8601 timestamp of the most recent state change reflected in this payload."
          }
        },
        "required": [
          "checkId",
          "status",
          "results",
          "timestamp"
        ]
      },
      "EligibilityCheckResults": {
        "type": "object",
        "properties": {
          "edi": {
            "$ref": "#/components/schemas/EdiResult"
          },
          "call": {
            "$ref": "#/components/schemas/CallResult"
          },
          "cachedCall": {
            "$ref": "#/components/schemas/CachedCallResult"
          },
          "claims": {
            "$ref": "#/components/schemas/ClaimsResult"
          },
          "summary": {
            "$ref": "#/components/schemas/SummaryResult"
          }
        },
        "required": [
          "edi",
          "call"
        ]
      },
      "EdiResult": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "PENDING",
              "RUNNING",
              "COMPLETED",
              "FAILED",
              "SKIPPED",
              "TIMED_OUT"
            ],
            "description": "Per-stage status. `SKIPPED` means the stage was deliberately not run (e.g. `callPolicy = never` skips CALL). `TIMED_OUT` means the stage never reported a result and was closed out by Fuse; rerun the check."
          },
          "startedAt": {
            "type": "string"
          },
          "updatedAt": {
            "type": "string"
          },
          "data": {
            "$ref": "#/components/schemas/EligibilityEdiResult"
          },
          "error": {
            "$ref": "#/components/schemas/EligibilityResultError"
          },
          "info": {
            "$ref": "#/components/schemas/EdiResultInfo"
          }
        },
        "required": [
          "status"
        ]
      },
      "EligibilityEdiResult": {
        "type": "object",
        "properties": {
          "planInfo": {
            "type": "object",
            "properties": {
              "payerId": {
                "type": "string"
              },
              "isActive": {
                "type": [
                  "boolean",
                  "null"
                ]
              },
              "statusCodes": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "payerName": {
                "type": "string"
              },
              "planPeriodStart": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "planPeriodEnd": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "policyStart": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "policyEnd": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "payerPhone": {
                "type": "string"
              },
              "planNumber": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "groupNumber": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "groupDescription": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "messages": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "serviceTypes": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "description": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "name",
                    "code",
                    "serviceTypes",
                    "description"
                  ]
                }
              },
              "risks": {
                "type": "object",
                "properties": {
                  "coverageAtRisk": {
                    "type": "boolean"
                  },
                  "riskCategories": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "reason": {
                    "type": "string"
                  }
                },
                "required": [
                  "coverageAtRisk",
                  "riskCategories",
                  "reason"
                ]
              },
              "managedCareCoordinators": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "planCoverage": {
                      "type": "string"
                    },
                    "entityName": {
                      "type": "string"
                    },
                    "entityId": {
                      "type": "string"
                    },
                    "eligibilityStart": {
                      "type": "string"
                    },
                    "eligibilityEnd": {
                      "type": "string"
                    },
                    "phone": {
                      "type": "string"
                    },
                    "insuranceType": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "planCoverage",
                    "entityName"
                  ]
                }
              }
            },
            "required": [
              "payerId",
              "isActive",
              "statusCodes",
              "payerName",
              "planPeriodStart",
              "planPeriodEnd",
              "policyStart",
              "policyEnd",
              "payerPhone",
              "planNumber",
              "groupNumber",
              "groupDescription"
            ]
          },
          "accumulators": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "enum": [
                    "Deductible",
                    "Out of Pocket (Stop Loss)",
                    "Limitations"
                  ]
                },
                "amountType": {
                  "type": "string"
                },
                "amountTotal": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "serviceType": {
                  "type": "string"
                },
                "coverageLevel": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "enum": [
                    "Individual",
                    "Family",
                    null
                  ]
                },
                "insuranceType": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "timeQualifier": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "amountRemaining": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "inPlanNetworkIndicator": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "enum": [
                    "Yes",
                    "No",
                    null
                  ]
                },
                "additionalInfo": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              },
              "required": [
                "name",
                "amountType",
                "amountTotal",
                "serviceType",
                "coverageLevel",
                "insuranceType",
                "timeQualifier",
                "amountRemaining",
                "inPlanNetworkIndicator",
                "additionalInfo"
              ]
            }
          },
          "serviceLevel": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "coPayment": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "coInsurance": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "serviceType": {
                  "type": "string"
                },
                "facilityType": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "coverageLevel": {
                  "type": "string"
                },
                "insuranceType": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "additionalInfo": {
                  "type": "string"
                },
                "inPlanNetworkIndicator": {
                  "type": "string",
                  "enum": [
                    "Yes",
                    "No"
                  ]
                }
              },
              "required": [
                "coPayment",
                "coInsurance",
                "serviceType",
                "facilityType",
                "coverageLevel",
                "insuranceType",
                "additionalInfo",
                "inPlanNetworkIndicator"
              ]
            }
          },
          "subscriberInfo": {
            "type": "object",
            "properties": {
              "gender": {
                "type": "string"
              },
              "address": {
                "type": "object",
                "properties": {
                  "city": {
                    "type": "string"
                  },
                  "state": {
                    "type": "string"
                  },
                  "address1": {
                    "type": "string"
                  },
                  "postalCode": {
                    "type": "string"
                  }
                },
                "required": [
                  "city",
                  "state",
                  "address1",
                  "postalCode"
                ]
              },
              "lastName": {
                "type": "string"
              },
              "memberId": {
                "type": "string"
              },
              "firstName": {
                "type": "string"
              },
              "middleName": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "dateOfBirth": {
                "type": "string"
              }
            },
            "required": [
              "gender",
              "address",
              "lastName",
              "memberId",
              "firstName",
              "middleName",
              "dateOfBirth"
            ]
          },
          "dependents": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "firstName": {
                  "type": "string"
                },
                "lastName": {
                  "type": "string"
                },
                "middleName": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "dateOfBirth": {
                  "type": "string"
                },
                "gender": {
                  "type": "string"
                },
                "relationToSubscriber": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              },
              "required": [
                "firstName",
                "lastName",
                "middleName",
                "dateOfBirth",
                "gender",
                "relationToSubscriber"
              ]
            }
          },
          "providerInfo": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "providerName": {
                "type": "string"
              },
              "npi": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "entityType": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "providerName",
              "npi",
              "entityType"
            ]
          },
          "info": {
            "type": "object",
            "properties": {
              "troubleshooting": {
                "$ref": "#/components/schemas/Troubleshooting"
              }
            },
            "additionalProperties": {},
            "description": "Vendor-specific metadata about the EDI fetch. Carries `troubleshooting` (with status `SUCCEEDED`) when automated troubleshooting resolved this check."
          }
        },
        "required": [
          "planInfo",
          "accumulators",
          "serviceLevel",
          "subscriberInfo",
          "dependents",
          "providerInfo"
        ],
        "description": "Present when `status === 'COMPLETED'`."
      },
      "Troubleshooting": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "IN_PROGRESS",
              "SUCCEEDED",
              "FAILED"
            ],
            "description": "Outcome of the automated troubleshooting run. `IN_PROGRESS` while the strategy chain is running; `SUCCEEDED` when a strategy resolved the check; `FAILED` when the chain ran to completion without resolving it. Distinct from the EDI stage `status`."
          },
          "vendorCode": {
            "type": [
              "string",
              "null"
            ],
            "description": "Payer/vendor error code that triggered troubleshooting. Present on the `IN_PROGRESS` notification."
          },
          "strategiesAttempted": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Names of the corrective strategies attempted, in order. Present on terminal (`SUCCEEDED`/`FAILED`) results."
          },
          "successfulStrategy": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name of the strategy that resolved the check. Present when `status === 'SUCCEEDED'`."
          },
          "corrections": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TroubleshootingCorrection"
            },
            "description": "Field corrections discovered while resolving the check, so the caller can update stored data. Present when `status === 'SUCCEEDED'` and corrections were found."
          },
          "insuranceDiscovery": {
            "type": "object",
            "properties": {
              "plans": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/InsuranceDiscoveryPlan"
                }
              }
            },
            "required": [
              "plans"
            ],
            "description": "Alternate coverage surfaced by insurance discovery when the check could not be auto-resolved. Present on some `FAILED` results."
          }
        },
        "required": [
          "status"
        ]
      },
      "TroubleshootingCorrection": {
        "type": "object",
        "properties": {
          "field": {
            "type": "string",
            "description": "Dotted path of the corrected field, e.g. \"subscriber.lastName\"."
          },
          "original": {
            "description": "The originally submitted value."
          },
          "corrected": {
            "description": "The value that resolved the check."
          }
        },
        "required": [
          "field"
        ]
      },
      "InsuranceDiscoveryPlan": {
        "type": "object",
        "properties": {
          "payerId": {
            "type": "string"
          },
          "payerName": {
            "type": "string"
          },
          "memberId": {
            "type": [
              "string",
              "null"
            ]
          },
          "planName": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "payerId",
          "payerName"
        ]
      },
      "EligibilityResultError": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "payerAAACode": {
            "type": [
              "string",
              "null"
            ],
            "description": "Raw payer AAA reject code from the X12 271 response (e.g. `65` = invalid/missing patient name), when the payer returned one. Distinct from `code`, which is Fuse's internal domain classification. Absent when the failure did not originate from a payer AAA reject."
          }
        },
        "required": [
          "code",
          "message"
        ],
        "description": "Present when `status === 'FAILED'`."
      },
      "EdiResultInfo": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "troubleshooting": {
            "$ref": "#/components/schemas/Troubleshooting"
          }
        },
        "description": "Stage-level metadata. Carries `troubleshooting` with status `IN_PROGRESS` while automated troubleshooting runs (stage `RUNNING`) or `FAILED` when it could not resolve the check (stage `FAILED`)."
      },
      "CallResult": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "PENDING",
              "RUNNING",
              "COMPLETED",
              "FAILED",
              "SKIPPED",
              "TIMED_OUT"
            ],
            "description": "Per-stage status. `SKIPPED` means the stage was deliberately not run (e.g. `callPolicy = never` skips CALL). `TIMED_OUT` means the stage never reported a result and was closed out by Fuse; rerun the check."
          },
          "startedAt": {
            "type": "string"
          },
          "updatedAt": {
            "type": "string"
          },
          "data": {
            "$ref": "#/components/schemas/EligibilityCallResult"
          },
          "error": {
            "$ref": "#/components/schemas/EligibilityResultError"
          },
          "info": {
            "$ref": "#/components/schemas/EligibilityResultProgress"
          }
        },
        "required": [
          "status"
        ]
      },
      "EligibilityCallResult": {
        "type": "object",
        "properties": {
          "planInfo": {
            "$ref": "#/components/schemas/CallPlanInfo"
          },
          "codeLevel": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CallCodeLevelBenefit"
            }
          },
          "classLevel": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CallClassLevelBenefit"
            }
          },
          "callSummary": {
            "type": "string"
          },
          "accumulators": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "enum": [
                    "Deductible",
                    "Out of Pocket (Stop Loss)"
                  ]
                },
                "amountType": {
                  "type": "string"
                },
                "amountTotal": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "coverageLevel": {
                  "type": "string"
                },
                "amountRemaining": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              },
              "required": [
                "name",
                "amountType",
                "amountTotal",
                "coverageLevel",
                "amountRemaining"
              ]
            }
          },
          "callDetails": {
            "$ref": "#/components/schemas/CallDetails"
          }
        },
        "required": [
          "planInfo",
          "codeLevel",
          "classLevel",
          "callSummary",
          "accumulators",
          "callDetails"
        ],
        "description": "Present when `status === 'COMPLETED'`."
      },
      "CallPlanInfo": {
        "type": "object",
        "properties": {
          "planPeriodStart": {
            "type": [
              "string",
              "null"
            ]
          },
          "planPeriodEnd": {
            "type": [
              "string",
              "null"
            ]
          },
          "policyStart": {
            "type": [
              "string",
              "null"
            ]
          },
          "policyEnd": {
            "type": [
              "string",
              "null"
            ]
          },
          "isActive": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "planType": {
            "type": "string"
          },
          "planName": {
            "type": [
              "string",
              "null"
            ]
          },
          "isSelfFunded": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "Whether the plan is self-funded (the employer pays claims directly) rather than fully insured. `null` when the funding type could not be determined."
          },
          "isHsaQualified": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "Whether the plan is HSA-qualified, as stated on the call. `null` when the call did not say."
          },
          "isCalendarYearPlan": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "isPrimaryInsurance": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "isProviderInNetwork": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "referralRequired": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "referralInfo": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "CallCodeLevelBenefit": {
        "type": "object",
        "properties": {
          "coPayment": {
            "type": [
              "string",
              "null"
            ]
          },
          "isCovered": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "coInsurance": {
            "type": [
              "string",
              "null"
            ]
          },
          "priorAuthInfo": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/CallPriorAuthInfo"
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "procedureCode": {
            "type": "string"
          },
          "procedureName": {
            "type": "string"
          },
          "additionalInfo": {
            "type": [
              "string",
              "null"
            ]
          },
          "isDeductibleWaived": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "isPriorAuthRequired": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "frequencyLimitations": {
            "$ref": "#/components/schemas/FrequencyLimitations"
          },
          "deductibleWaivedReason": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "procedureCode",
          "procedureName"
        ]
      },
      "CallPriorAuthInfo": {
        "type": "object",
        "properties": {
          "management": {
            "type": [
              "string",
              "null"
            ]
          },
          "phoneNumber": {
            "type": [
              "string",
              "null"
            ]
          },
          "faxNumber": {
            "type": [
              "string",
              "null"
            ]
          },
          "email": {
            "type": [
              "string",
              "null"
            ]
          },
          "website": {
            "type": [
              "string",
              "null"
            ]
          },
          "caseNumber": {
            "type": [
              "string",
              "null"
            ]
          },
          "additionalInfo": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "FrequencyLimitations": {
        "type": [
          "object",
          "null"
        ],
        "properties": {
          "maximum": {
            "type": [
              "number",
              "null"
            ]
          },
          "utilized": {
            "type": [
              "number",
              "null"
            ]
          },
          "timeQualifier": {
            "type": [
              "string",
              "null"
            ]
          },
          "additionalInfo": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "CallClassLevelBenefit": {
        "type": "object",
        "properties": {
          "coPayment": {
            "type": [
              "string",
              "null"
            ]
          },
          "isCovered": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "coInsurance": {
            "type": [
              "string",
              "null"
            ]
          },
          "priorAuthInfo": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/CallPriorAuthInfo"
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "additionalInfo": {
            "type": [
              "string",
              "null"
            ]
          },
          "procedureClass": {
            "type": "string"
          },
          "isDeductibleWaived": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "isPriorAuthRequired": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "frequencyLimitations": {
            "$ref": "#/components/schemas/FrequencyLimitations"
          },
          "deductibleWaivedReason": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "procedureClass"
        ]
      },
      "CallDetails": {
        "type": "object",
        "properties": {
          "representativeName": {
            "type": [
              "string",
              "null"
            ]
          },
          "referenceNumber": {
            "type": [
              "string",
              "null"
            ]
          },
          "completedAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "callTranscript": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "EligibilityResultProgress": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "code",
          "message"
        ],
        "description": "Present when the stage is in progress or skipped (e.g. `CALL_NOT_SCHEDULED`)."
      },
      "CachedCallResult": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "COMPLETED",
              "SKIPPED"
            ]
          },
          "startedAt": {
            "type": "string"
          },
          "updatedAt": {
            "type": "string"
          },
          "data": {
            "$ref": "#/components/schemas/CachedCallData"
          },
          "reason": {
            "type": "string",
            "description": "Present when `status === 'SKIPPED'`."
          }
        },
        "required": [
          "status"
        ]
      },
      "CachedCallData": {
        "type": "object",
        "properties": {
          "planInfo": {
            "$ref": "#/components/schemas/CachedCallPlanInfo"
          },
          "codeLevel": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CachedCallCodeLevel"
            }
          },
          "accumulators": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CachedCallAccumulator"
            }
          }
        },
        "description": "Present when `status === 'COMPLETED'`."
      },
      "CachedCallPlanInfo": {
        "type": "object",
        "properties": {
          "isProviderInNetwork": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "planType": {
            "type": [
              "string",
              "null"
            ]
          },
          "isCalendarYearPlan": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "planPeriodStart": {
            "type": [
              "string",
              "null"
            ]
          },
          "planPeriodEnd": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "CachedCallCodeLevel": {
        "type": "object",
        "properties": {
          "procedureCode": {
            "type": "string"
          },
          "procedureName": {
            "type": [
              "string",
              "null"
            ]
          },
          "coPayment": {
            "type": [
              "string",
              "null"
            ]
          },
          "coInsurance": {
            "type": [
              "string",
              "null"
            ]
          },
          "isCovered": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "isPriorAuthRequired": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "priorAuthInfo": {
            "type": [
              "string",
              "null"
            ]
          },
          "additionalInfo": {
            "type": [
              "string",
              "null"
            ]
          },
          "isDeductibleWaived": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "frequencyLimitations": {
            "$ref": "#/components/schemas/FrequencyLimitations"
          }
        },
        "required": [
          "procedureCode"
        ]
      },
      "CachedCallAccumulator": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "enum": [
              "Deductible",
              "Out of Pocket (Stop Loss)"
            ]
          },
          "amountType": {
            "type": "string"
          },
          "amountTotal": {
            "type": [
              "string",
              "null"
            ]
          },
          "coverageLevel": {
            "type": "string",
            "enum": [
              "Individual",
              "Family"
            ]
          }
        },
        "required": [
          "name",
          "amountType",
          "coverageLevel"
        ]
      },
      "ClaimsResult": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "PENDING",
              "RUNNING",
              "COMPLETED",
              "FAILED",
              "SKIPPED",
              "TIMED_OUT"
            ],
            "description": "Per-stage status. `SKIPPED` means the stage was deliberately not run (e.g. `callPolicy = never` skips CALL). `TIMED_OUT` means the stage never reported a result and was closed out by Fuse; rerun the check."
          },
          "startedAt": {
            "type": "string"
          },
          "updatedAt": {
            "type": "string"
          },
          "data": {
            "type": "object",
            "additionalProperties": {},
            "description": "Present when `status === 'COMPLETED'`."
          },
          "reason": {
            "type": "string",
            "description": "Present when `status === 'SKIPPED'`."
          },
          "error": {
            "$ref": "#/components/schemas/EligibilityResultError"
          }
        },
        "required": [
          "status"
        ]
      },
      "SummaryResult": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "PENDING",
              "RUNNING",
              "COMPLETED",
              "FAILED",
              "SKIPPED",
              "TIMED_OUT"
            ],
            "description": "Per-stage status. `SKIPPED` means the stage was deliberately not run (e.g. `callPolicy = never` skips CALL). `TIMED_OUT` means the stage never reported a result and was closed out by Fuse; rerun the check."
          },
          "startedAt": {
            "type": "string"
          },
          "updatedAt": {
            "type": "string"
          },
          "data": {
            "$ref": "#/components/schemas/SummaryData"
          },
          "provenance": {
            "$ref": "#/components/schemas/SummaryProvenance"
          },
          "settings": {
            "type": "object",
            "additionalProperties": {},
            "description": "Snapshot of the summary settings used at generation time."
          },
          "info": {
            "$ref": "#/components/schemas/EligibilityResultProgress"
          }
        },
        "required": [
          "status"
        ]
      },
      "SummaryData": {
        "type": "object",
        "properties": {
          "text": {
            "type": "string"
          },
          "planInfo": {
            "$ref": "#/components/schemas/SummaryPlanInfo"
          }
        },
        "required": [
          "text"
        ]
      },
      "SummaryPlanInfo": {
        "type": "object",
        "properties": {
          "networkStatus": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "isActive": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "isPrimary": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "planType": {
            "type": [
              "string",
              "null"
            ]
          },
          "isSelfFunded": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "isHsaQualified": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "Whether the plan is HSA-qualified, as stated on the call. `null` when the call did not say."
          },
          "isHighDeductible": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "Whether the in-network individual or family deductible in `accumulators` meets the IRS high-deductible health plan minimum for the plan year (2026: $1,700 individual, $3,400 family). `null` when no in-network deductible was found."
          },
          "isCalendarYearPlan": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "planPeriodStart": {
            "type": [
              "string",
              "null"
            ]
          },
          "planPeriodEnd": {
            "type": [
              "string",
              "null"
            ]
          },
          "policyStart": {
            "type": [
              "string",
              "null"
            ]
          },
          "policyEnd": {
            "type": [
              "string",
              "null"
            ]
          },
          "groupNumber": {
            "type": [
              "string",
              "null"
            ]
          },
          "planNumber": {
            "type": [
              "string",
              "null"
            ]
          },
          "referralRequired": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "referralInfo": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "SummaryProvenance": {
        "type": "object",
        "properties": {
          "edi": {
            "type": "boolean"
          },
          "call": {
            "type": "boolean"
          },
          "cachedCall": {
            "type": "boolean"
          },
          "claims": {
            "type": "boolean"
          },
          "internal": {
            "type": "boolean"
          }
        },
        "description": "Where the summary's underlying call data came from."
      },
      "EligibilityCheckSummary": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "patientId": {
            "type": "string",
            "format": "uuid"
          },
          "templateId": {
            "type": "string",
            "format": "uuid"
          },
          "templateName": {
            "type": "string"
          },
          "statusEDI": {
            "type": "string",
            "enum": [
              "PENDING",
              "RUNNING",
              "COMPLETED",
              "FAILED",
              "SKIPPED",
              "TIMED_OUT"
            ]
          },
          "statusCall": {
            "type": "string",
            "enum": [
              "PENDING",
              "RUNNING",
              "COMPLETED",
              "FAILED",
              "SKIPPED",
              "TIMED_OUT"
            ]
          },
          "statusClaims": {
            "type": "string",
            "enum": [
              "PENDING",
              "RUNNING",
              "COMPLETED",
              "FAILED",
              "SKIPPED",
              "TIMED_OUT"
            ]
          },
          "statusPolicy": {
            "type": "string",
            "enum": [
              "PENDING",
              "RUNNING",
              "COMPLETED",
              "FAILED",
              "SKIPPED",
              "TIMED_OUT"
            ]
          },
          "runAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "checkGroupId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "parentCheckId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "resultSummary": {}
        },
        "required": [
          "id",
          "patientId",
          "templateId",
          "templateName",
          "statusEDI",
          "statusCall",
          "statusClaims",
          "statusPolicy",
          "runAt",
          "createdAt",
          "checkGroupId",
          "parentCheckId"
        ]
      },
      "CreateEligibilityCheckResult": {
        "type": "object",
        "properties": {
          "primaryCheckId": {
            "type": [
              "string",
              "null"
            ],
            "description": "ID of the primary check (typically the patient's primary insurance). Null if no primary check could be created."
          },
          "secondaryCheckId": {
            "type": [
              "string",
              "null"
            ],
            "description": "ID of the linked secondary check, when the patient has a secondary insurance configured."
          },
          "tertiaryCheckId": {
            "type": [
              "string",
              "null"
            ],
            "description": "ID of the linked tertiary check, when the patient has a tertiary insurance configured."
          },
          "checkGroupId": {
            "type": [
              "string",
              "null"
            ],
            "description": "Group ID linking the checks created together, when isLinked is true."
          },
          "isLinked": {
            "type": "boolean",
            "description": "True when more than one check was created."
          },
          "failedChecks": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "checkId": {
                  "type": "string"
                },
                "error": {
                  "type": "string"
                }
              },
              "required": [
                "checkId",
                "error"
              ]
            },
            "description": "Per-execution failures. Successful checks are persisted and running asynchronously — derive the executed set as `[primaryCheckId, secondaryCheckId, tertiaryCheckId] - failedChecks[].checkId`."
          }
        },
        "required": [
          "primaryCheckId",
          "secondaryCheckId",
          "tertiaryCheckId",
          "checkGroupId",
          "isLinked",
          "failedChecks"
        ]
      },
      "PayerSearchResult": {
        "type": "object",
        "properties": {
          "payerCode": {
            "type": "string",
            "description": "Payer ID — the electronic payer identifier used to route X12 EDI eligibility and claim transactions to this payer. Pass this value as `payerCode` when attaching insurance (e.g. `POST /v1/patients/{id}/insurances`).",
            "example": "60054"
          },
          "displayName": {
            "type": "string",
            "description": "Canonical payer name.",
            "example": "Aetna"
          },
          "names": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Alternate names this payer is also known by."
          },
          "aliases": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Alternate payer ids / codes this payer is also reachable under."
          },
          "eligibilityCheckSupport": {
            "type": "string",
            "enum": [
              "SUPPORTED",
              "NOT_SUPPORTED",
              "ENROLLMENT_REQUIRED"
            ],
            "description": "Whether an eligibility check can be run against this payer. `ENROLLMENT_REQUIRED` means a one-time enrollment is needed first."
          }
        },
        "required": [
          "payerCode",
          "displayName",
          "names",
          "aliases",
          "eligibilityCheckSupport"
        ]
      }
    },
    "parameters": {},
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    }
  },
  "paths": {
    "/api/v1/oauth/token": {
      "post": {
        "summary": "Exchange API key credentials for a bearer token",
        "description": "OAuth 2.0 client_credentials grant (RFC 6749 §4.4). Submit the API key's `client_id` and `client_secret` as `application/x-www-form-urlencoded` and receive a short-lived bearer JWT scoped to the key's organization. Tokens are not refreshable — request a new one when the previous expires. Both per-client and per-IP rate limits apply; on `slow_down` honor the `Retry-After` header.",
        "tags": [
          "OAuth"
        ],
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/OAuthTokenRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Token issued.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "`no-store` per RFC 6749 §5.1."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthTokenResponse"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request (missing/invalid `grant_type`, `client_id`, or `client_secret`, or wrong content-type).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthTokenError"
                }
              }
            }
          },
          "401": {
            "description": "Authentication failed (unknown client or bad secret).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthTokenError"
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeded the 4 KiB cap.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthTokenError"
                }
              }
            }
          },
          "429": {
            "description": "Rate-limited per `client_id` or per source IP. Retry after the duration in `Retry-After`.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds to wait before retrying."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthTokenError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/eligibility-checks/{id}": {
      "get": {
        "summary": "Get an eligibility check by ID",
        "description": "Returns the check in the same wire format that the runner posts to subscribed webhook URLs. Polling this endpoint and consuming a webhook delivery yield byte-compatible payloads — clients can share a single parser. The `status` field rolls up the per-stage statuses (EDI / call / summary); poll until it is `COMPLETED`.",
        "tags": [
          "Eligibility Checks"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Eligibility check ID."
            },
            "required": true,
            "description": "Eligibility check ID.",
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "requestId": {
                      "type": "string",
                      "description": "Trace id echoed on every v1 response. Format: `req_<16-hex>`. Useful for support correlation.",
                      "example": "req_a1b2c3d4e5f60718"
                    },
                    "data": {
                      "$ref": "#/components/schemas/EligibilityCheckWebhookPayload"
                    }
                  },
                  "required": [
                    "requestId",
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden / insufficient scope"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation error"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Feature disabled"
          }
        }
      }
    },
    "/api/v1/eligibility-checks/bulk": {
      "post": {
        "summary": "Bulk create and execute eligibility checks",
        "description": "Creates and executes up to 10 checks in a single request. Per-item failures are reported in `results[]` with `status: \"error\"`; successful items run asynchronously like the single-create endpoint. Requires an `Idempotency-Key` header.",
        "tags": [
          "Eligibility Checks"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "patientId": {
                          "type": "string",
                          "format": "uuid",
                          "description": "ID of the patient for this batch item."
                        },
                        "templateId": {
                          "type": "string",
                          "format": "uuid",
                          "description": "Eligibility-check template that defines payer, service codes, and prompts."
                        },
                        "appointmentId": {
                          "type": "string",
                          "format": "uuid",
                          "description": "Optional appointment to associate with the resulting check."
                        },
                        "additionalQuestions": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 200
                          },
                          "maxItems": 10,
                          "description": "Free-text questions appended to the LLM prompt for this item. Up to 10 items, 200 chars each."
                        }
                      },
                      "required": [
                        "patientId",
                        "templateId"
                      ],
                      "additionalProperties": false
                    },
                    "minItems": 1,
                    "maxItems": 10,
                    "description": "Batch of check requests. Up to 10 entries per call."
                  }
                },
                "required": [
                  "items"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden / insufficient scope"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation error"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Feature disabled"
          }
        }
      }
    },
    "/api/v1/eligibility-checks/group/{groupId}": {
      "get": {
        "summary": "List checks in a check group",
        "description": "Returns all checks (primary + secondary) that belong to a single check group. Use this to fetch both sides of a linked primary/secondary run.",
        "tags": [
          "Eligibility Checks"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Check group ID, returned as `checkGroupId` from the create endpoint when primary + secondary checks are linked."
            },
            "required": true,
            "description": "Check group ID, returned as `checkGroupId` from the create endpoint when primary + secondary checks are linked.",
            "name": "groupId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "requestId": {
                      "type": "string",
                      "description": "Trace id echoed on every v1 response. Format: `req_<16-hex>`. Useful for support correlation.",
                      "example": "req_a1b2c3d4e5f60718"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/EligibilityCheckSummary"
                      }
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "total": {
                          "type": "integer",
                          "minimum": 0,
                          "description": "Total matching rows. Populated for offset-paginated lists."
                        },
                        "limit": {
                          "type": "integer",
                          "exclusiveMinimum": 0,
                          "description": "Page size that was applied (may be clamped server-side)."
                        },
                        "offset": {
                          "type": "integer",
                          "minimum": 0,
                          "description": "Zero-based offset of this page. Offset-paginated lists."
                        },
                        "nextCursor": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "description": "Opaque cursor for the next page, or null if this was the last page. Cursor-paginated lists."
                        },
                        "hasMore": {
                          "type": "boolean",
                          "description": "True if more rows are available beyond this page."
                        }
                      },
                      "description": "Pagination metadata. Fields populated depend on the endpoint's pagination scheme (offset vs cursor)."
                    }
                  },
                  "required": [
                    "requestId",
                    "data",
                    "meta"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden / insufficient scope"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation error"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Feature disabled"
          }
        }
      }
    },
    "/api/v1/eligibility-checks": {
      "get": {
        "summary": "List eligibility checks",
        "description": "Cursor-paginated list of eligibility checks for the authenticated organization, newest first. Optionally filter by `patientId`.",
        "tags": [
          "Eligibility Checks"
        ],
        "parameters": [
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50,
              "description": "Maximum number of checks to return per page (1–200).",
              "example": 50
            },
            "required": false,
            "description": "Maximum number of checks to return per page (1–200).",
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256,
              "description": "Opaque pagination cursor returned by a previous list response. Omit on the first call."
            },
            "required": false,
            "description": "Opaque pagination cursor returned by a previous list response. Omit on the first call.",
            "name": "cursor",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Filter checks to a single patient."
            },
            "required": false,
            "description": "Filter checks to a single patient.",
            "name": "patientId",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "requestId": {
                      "type": "string",
                      "description": "Trace id echoed on every v1 response. Format: `req_<16-hex>`. Useful for support correlation.",
                      "example": "req_a1b2c3d4e5f60718"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/EligibilityCheckSummary"
                      }
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "total": {
                          "type": "integer",
                          "minimum": 0,
                          "description": "Total matching rows. Populated for offset-paginated lists."
                        },
                        "limit": {
                          "type": "integer",
                          "exclusiveMinimum": 0,
                          "description": "Page size that was applied (may be clamped server-side)."
                        },
                        "offset": {
                          "type": "integer",
                          "minimum": 0,
                          "description": "Zero-based offset of this page. Offset-paginated lists."
                        },
                        "nextCursor": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "description": "Opaque cursor for the next page, or null if this was the last page. Cursor-paginated lists."
                        },
                        "hasMore": {
                          "type": "boolean",
                          "description": "True if more rows are available beyond this page."
                        }
                      },
                      "description": "Pagination metadata. Fields populated depend on the endpoint's pagination scheme (offset vs cursor)."
                    }
                  },
                  "required": [
                    "requestId",
                    "data",
                    "meta"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden / insufficient scope"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation error"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Feature disabled"
          }
        }
      },
      "post": {
        "summary": "Create and execute an eligibility check",
        "description": "Creates a check from a patient + template and asynchronously runs the EDI / call / policy / summary stages. Returns the created check IDs immediately; poll `GET /eligibility-checks/{id}` for results. Requires an `Idempotency-Key` header — a repeat with the same key returns the original response. The set of active webhook subscriptions for the organization is snapshotted at the moment this request returns. Subsequent subscription changes do not affect this check's deliveries.",
        "tags": [
          "Eligibility Checks"
        ],
        "parameters": [
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50,
              "description": "Maximum number of checks to return per page (1–200).",
              "example": 50
            },
            "required": false,
            "description": "Maximum number of checks to return per page (1–200).",
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256,
              "description": "Opaque pagination cursor returned by a previous list response. Omit on the first call."
            },
            "required": false,
            "description": "Opaque pagination cursor returned by a previous list response. Omit on the first call.",
            "name": "cursor",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Filter checks to a single patient."
            },
            "required": false,
            "description": "Filter checks to a single patient.",
            "name": "patientId",
            "in": "query"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "patientId": {
                    "type": "string",
                    "format": "uuid",
                    "description": "ID of the patient to run the check against. Obtain by creating a patient via `POST /v1/patients` (returns `data.id`) or by listing existing patients via `GET /v1/patients`. The patient must have a primary insurance attached (via `POST /v1/patients/{id}/insurances` with `coverageOrder: 1`) — otherwise the request returns 422 `VALIDATION_ERROR` with `field: patientId`."
                  },
                  "templateId": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Eligibility-check template defining the billing provider, procedure codes, service-type codes, place-of-service, and the LLM prompt. The payer comes from the patient's primary insurance. Obtain by creating a template via `POST /v1/templates` (returns `data.id`) or by listing existing templates via `GET /v1/templates`. Templates are typically created once per common check shape and reused across many checks."
                  },
                  "appointmentId": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Optional appointment to associate with the check. Used by the pipeline ingest path so reports can join check ↔ appointment. Omit when running ad-hoc checks."
                  },
                  "additionalQuestions": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 200
                    },
                    "maxItems": 10,
                    "description": "Free-text questions appended to the LLM prompt at execution time. Up to 10 items, 200 chars each."
                  },
                  "providerOverride": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      "npi": {
                        "type": "string",
                        "pattern": "^\\d{10}$"
                      },
                      "taxId": {
                        "type": "string",
                        "pattern": "^\\d{9}$"
                      },
                      "ptan": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 10
                      },
                      "billingAddress": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 500
                      }
                    },
                    "required": [
                      "name",
                      "npi",
                      "taxId",
                      "billingAddress"
                    ],
                    "additionalProperties": false,
                    "description": "Override the template's provider identity for this check only. Partial overrides are supported — omitted fields fall back to the template provider. The persisted check reflects exactly what was sent."
                  },
                  "callPolicyOverride": {
                    "type": "object",
                    "properties": {
                      "mode": {
                        "type": "string",
                        "enum": [
                          "always",
                          "never",
                          "ifNeeded",
                          "conditions",
                          "override"
                        ]
                      }
                    },
                    "required": [
                      "mode"
                    ],
                    "description": "Override the template's call policy for this check. `always`/`never`/`ifNeeded`/`conditions` force the calling decision; `override` bypasses policy entirely."
                  },
                  "templateFieldsSourceId": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Reuse field values (additionalQuestions, callPolicy, etc.) from a previous check identified by this ID, instead of taking them from the template."
                  }
                },
                "required": [
                  "patientId",
                  "templateId"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "requestId": {
                      "type": "string",
                      "description": "Trace id echoed on every v1 response. Format: `req_<16-hex>`. Useful for support correlation.",
                      "example": "req_a1b2c3d4e5f60718"
                    },
                    "data": {
                      "$ref": "#/components/schemas/CreateEligibilityCheckResult"
                    }
                  },
                  "required": [
                    "requestId",
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden / insufficient scope"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation error"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Feature disabled"
          }
        }
      }
    },
    "/api/v1/insurances/{id}": {
      "get": {
        "summary": "Get an insurance entry by ID",
        "description": "Returns a single insurance entry. `relationship` is one of SELF, SPOUSE, CHILD, LIFE_PARTNER, OTHER or UNKNOWN; DEPENDENT is accepted on writes but never returned.",
        "tags": [
          "Insurance"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Insurance entry ID."
            },
            "required": true,
            "description": "Insurance entry ID.",
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden / insufficient scope"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation error"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Feature disabled"
          }
        }
      },
      "patch": {
        "summary": "Update an insurance entry",
        "description": "Partial update. Only the fields supplied are changed; omitted fields are left as-is. Changing `relationship` from SELF to another value needs a `subscriber` block; otherwise the subscriber on file is kept.",
        "tags": [
          "Insurance"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Insurance entry ID."
            },
            "required": true,
            "description": "Insurance entry ID.",
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "payerCode": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 50,
                    "description": "CMS payer code (e.g. \"60054\"). Look up via `/api/v1/payers` to find the right value for a given carrier.",
                    "example": "60054"
                  },
                  "memberId": {
                    "type": "string",
                    "description": "Member ID printed on the insurance card. 3–50 characters."
                  },
                  "relationship": {
                    "type": "string",
                    "enum": [
                      "SELF",
                      "SPOUSE",
                      "CHILD",
                      "LIFE_PARTNER",
                      "OTHER",
                      "UNKNOWN",
                      "DEPENDENT"
                    ]
                  },
                  "subscriber": {
                    "type": "object",
                    "properties": {
                      "firstName": {
                        "type": "string",
                        "maxLength": 100
                      },
                      "lastName": {
                        "type": "string",
                        "maxLength": 100
                      },
                      "dob": {
                        "type": "string",
                        "maxLength": 20,
                        "description": "Subscriber's date of birth (YYYY-MM-DD). Required for some payer eligibility flows."
                      }
                    },
                    "required": [
                      "firstName",
                      "lastName"
                    ],
                    "additionalProperties": false
                  },
                  "planNumber": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 64
                  },
                  "groupNumber": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 64
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden / insufficient scope"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation error"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Feature disabled"
          }
        }
      },
      "delete": {
        "summary": "Delete an insurance entry",
        "description": "Permanently removes the insurance entry from the patient.",
        "tags": [
          "Insurance"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Insurance entry ID."
            },
            "required": true,
            "description": "Insurance entry ID.",
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden / insufficient scope"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation error"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Feature disabled"
          }
        }
      }
    },
    "/api/v1/patients/{id}/archive": {
      "post": {
        "summary": "Archive a patient",
        "description": "Hides the patient from `GET /v1/patients` unless `archived` asks for them. The record, its checks and its claims are kept; `POST /v1/patients/{id}/unarchive` restores it. Patients cannot be deleted.",
        "tags": [
          "Patients"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Patient ID."
            },
            "required": true,
            "description": "Patient ID.",
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden / insufficient scope"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation error"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Feature disabled"
          }
        }
      }
    },
    "/api/v1/patients/{id}/insurances": {
      "get": {
        "summary": "List a patient's insurance entries",
        "description": "Returns up to three insurance tiers (primary, secondary, tertiary) for the given patient. `relationship` is one of SELF, SPOUSE, CHILD, LIFE_PARTNER, OTHER or UNKNOWN; DEPENDENT is accepted on writes but never returned.",
        "tags": [
          "Patients"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Patient ID."
            },
            "required": true,
            "description": "Patient ID.",
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden / insufficient scope"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation error"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Feature disabled"
          }
        }
      },
      "post": {
        "summary": "Attach an insurance entry to a patient",
        "description": "Adds or replaces the patient's insurance at the specified `coverageOrder`. The other orders are left untouched.",
        "tags": [
          "Patients"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Patient ID."
            },
            "required": true,
            "description": "Patient ID.",
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "coverageOrder": {
                    "anyOf": [
                      {
                        "type": "number",
                        "enum": [
                          1
                        ]
                      },
                      {
                        "type": "number",
                        "enum": [
                          2
                        ]
                      },
                      {
                        "type": "number",
                        "enum": [
                          3
                        ]
                      }
                    ],
                    "description": "Insurance order — 1 for primary, 2 for secondary, 3 for tertiary. Each patient may have at most one entry per order."
                  },
                  "payerCode": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 50,
                    "description": "CMS payer code (e.g. \"60054\"). Look up via `/api/v1/payers` to find the right value for a given carrier.",
                    "example": "60054"
                  },
                  "memberId": {
                    "type": "string",
                    "description": "Member ID printed on the insurance card. 3–50 characters."
                  },
                  "relationship": {
                    "type": "string",
                    "enum": [
                      "SELF",
                      "SPOUSE",
                      "CHILD",
                      "LIFE_PARTNER",
                      "OTHER",
                      "UNKNOWN",
                      "DEPENDENT"
                    ],
                    "description": "The patient's relationship to the subscriber (CHILD: the patient is the subscriber's child). SELF inherits the patient's identity; any other value requires a `subscriber` block. DEPENDENT is accepted and stored as UNKNOWN."
                  },
                  "subscriber": {
                    "type": "object",
                    "properties": {
                      "firstName": {
                        "type": "string",
                        "maxLength": 100
                      },
                      "lastName": {
                        "type": "string",
                        "maxLength": 100
                      },
                      "dob": {
                        "type": "string",
                        "maxLength": 20,
                        "description": "Subscriber's date of birth (YYYY-MM-DD). Required for some payer eligibility flows."
                      }
                    },
                    "required": [
                      "firstName",
                      "lastName"
                    ],
                    "additionalProperties": false,
                    "description": "Subscriber identity. Required unless `relationship` is SELF; ignored for SELF."
                  },
                  "planNumber": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 64,
                    "description": "Optional plan / policy number printed on the card."
                  },
                  "groupNumber": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 64,
                    "description": "Optional group number printed on the card."
                  }
                },
                "required": [
                  "coverageOrder",
                  "payerCode",
                  "memberId",
                  "relationship"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden / insufficient scope"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation error"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Feature disabled"
          }
        }
      }
    },
    "/api/v1/patients/{id}": {
      "get": {
        "summary": "Get a patient by ID",
        "description": "Returns the full patient record, including insurance entries. PII fields are redacted unless the caller has the `pii.read` scope.",
        "tags": [
          "Patients"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Patient ID."
            },
            "required": true,
            "description": "Patient ID.",
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden / insufficient scope"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation error"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Feature disabled"
          }
        }
      },
      "patch": {
        "summary": "Update a patient",
        "description": "Partial update of a patient. `insurances` is intentionally not accepted here — use the dedicated insurance endpoints (`POST /v1/patients/{id}/insurances`, `PATCH /v1/insurances/{id}`).",
        "tags": [
          "Patients"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Patient ID."
            },
            "required": true,
            "description": "Patient ID.",
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "firstName": {
                    "type": "string",
                    "maxLength": 100,
                    "description": "Legal first name as it appears on the insurance card."
                  },
                  "lastName": {
                    "type": "string",
                    "maxLength": 100,
                    "description": "Legal last name as it appears on the insurance card."
                  },
                  "dob": {
                    "type": "string",
                    "description": "Date of birth in YYYY-MM-DD form. Stored as midnight UTC.",
                    "example": "1985-04-12"
                  },
                  "demographics": {
                    "type": "object",
                    "properties": {
                      "preferredFirstName": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 100
                      },
                      "preferredLastName": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 100
                      },
                      "preferredLanguage": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 64
                      },
                      "gender": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 32
                      },
                      "pronouns": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 64
                      },
                      "sexAtBirth": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 32
                      },
                      "maritalStatus": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 32
                      },
                      "guardian": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 120
                      },
                      "race": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 64
                      },
                      "secondRace": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 64
                      },
                      "ethnicity": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 64
                      },
                      "secondEthnicity": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 64
                      },
                      "sexualOrientation": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 64
                      },
                      "preferredProvider": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 120
                      },
                      "primaryDepartment": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 120
                      },
                      "prefersSelfPay": {
                        "type": [
                          "boolean",
                          "null"
                        ]
                      },
                      "ssn": {
                        "type": [
                          "string",
                          "null"
                        ]
                      }
                    },
                    "additionalProperties": false,
                    "description": "Optional demographic fields (preferred name, language, gender, etc). Not required for eligibility but stored on the patient."
                  },
                  "contact": {
                    "type": "object",
                    "properties": {
                      "primaryPhone": {
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "secondaryPhone": {
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "workPhone": {
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "primaryEmail": {
                        "anyOf": [
                          {
                            "type": "string",
                            "maxLength": 254,
                            "format": "email"
                          },
                          {
                            "type": "string",
                            "enum": [
                              ""
                            ]
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "secondaryEmail": {
                        "anyOf": [
                          {
                            "type": "string",
                            "maxLength": 254,
                            "format": "email"
                          },
                          {
                            "type": "string",
                            "enum": [
                              ""
                            ]
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "homeAddress": {
                        "type": [
                          "object",
                          "null"
                        ],
                        "properties": {
                          "line1": {
                            "type": "string",
                            "maxLength": 120
                          },
                          "line2": {
                            "type": "string",
                            "maxLength": 120
                          },
                          "city": {
                            "type": "string",
                            "maxLength": 80
                          },
                          "state": {
                            "type": "string",
                            "maxLength": 40
                          },
                          "zip": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "line1",
                          "city",
                          "state",
                          "zip"
                        ],
                        "additionalProperties": false
                      },
                      "mailingAddress": {
                        "type": [
                          "object",
                          "null"
                        ],
                        "properties": {
                          "line1": {
                            "type": "string",
                            "maxLength": 120
                          },
                          "line2": {
                            "type": "string",
                            "maxLength": 120
                          },
                          "city": {
                            "type": "string",
                            "maxLength": 80
                          },
                          "state": {
                            "type": "string",
                            "maxLength": 40
                          },
                          "zip": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "line1",
                          "city",
                          "state",
                          "zip"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "additionalProperties": false,
                    "description": "Phone numbers, emails, and home/mailing addresses."
                  },
                  "emergencyContact": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string",
                        "maxLength": 120
                      },
                      "relationship": {
                        "type": "string",
                        "maxLength": 64
                      },
                      "phone": {
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "email": {
                        "anyOf": [
                          {
                            "type": "string",
                            "maxLength": 254,
                            "format": "email"
                          },
                          {
                            "type": "string",
                            "enum": [
                              ""
                            ]
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    },
                    "required": [
                      "name"
                    ],
                    "additionalProperties": false,
                    "description": "Emergency contact details for the patient."
                  },
                  "medical": {
                    "type": "object",
                    "properties": {
                      "diagnosisCodes": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 500
                      },
                      "clinic": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 120
                      }
                    },
                    "additionalProperties": false,
                    "description": "Free-text medical notes (diagnosis codes, clinic)."
                  },
                  "notes": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "label": {
                          "type": "string"
                        },
                        "content": {
                          "type": "string",
                          "maxLength": 10000
                        }
                      },
                      "required": [
                        "label",
                        "content"
                      ],
                      "additionalProperties": false
                    },
                    "description": "Free-text notes keyed by label. Bulk-upload uses CSV column headers as labels; the use case upserts each by (patientId, label)."
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden / insufficient scope"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation error"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Feature disabled"
          }
        }
      }
    },
    "/api/v1/patients/{id}/unarchive": {
      "post": {
        "summary": "Unarchive a patient",
        "description": "Returns an archived patient to `GET /v1/patients`.",
        "tags": [
          "Patients"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Patient ID."
            },
            "required": true,
            "description": "Patient ID.",
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden / insufficient scope"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation error"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Feature disabled"
          }
        }
      }
    },
    "/api/v1/patients/bulk": {
      "post": {
        "summary": "Bulk create or update patients",
        "description": "Accepts up to 200 patient rows in either `{ patients: [...] }` or raw-array form. Each row is processed independently — partial failures are reported with row indices in the response so a single bad row does not fail the batch. Set `existingPatientId` on a row to update instead of create. Rows carrying an `externalId` that matches a patient previously created with that identifier are treated as updates of that patient, so re-sending the same batch is idempotent.",
        "tags": [
          "Patients"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "patients": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "firstName": {
                              "type": "string",
                              "maxLength": 100,
                              "description": "Legal first name as it appears on the insurance card."
                            },
                            "lastName": {
                              "type": "string",
                              "maxLength": 100,
                              "description": "Legal last name as it appears on the insurance card."
                            },
                            "dob": {
                              "type": "string",
                              "description": "Date of birth in YYYY-MM-DD form. Stored as midnight UTC.",
                              "example": "1985-04-12"
                            },
                            "externalId": {
                              "type": "string",
                              "description": "Your identifier for this patient (e.g. an MRN from your own system). Optional. Must be unique within your organization; reusing one returns a 409 conflict. Patients can be searched and sorted by this value via `GET /v1/patients`."
                            },
                            "insurances": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "coverageOrder": {
                                    "anyOf": [
                                      {
                                        "type": "number",
                                        "enum": [
                                          1
                                        ]
                                      },
                                      {
                                        "type": "number",
                                        "enum": [
                                          2
                                        ]
                                      },
                                      {
                                        "type": "number",
                                        "enum": [
                                          3
                                        ]
                                      }
                                    ],
                                    "description": "Insurance order — 1 for primary, 2 for secondary, 3 for tertiary. Each patient may have at most one entry per order."
                                  },
                                  "payerCode": {
                                    "type": "string",
                                    "minLength": 2,
                                    "maxLength": 50,
                                    "description": "CMS payer code (e.g. \"60054\"). Look up via `/api/v1/payers` to find the right value for a given carrier.",
                                    "example": "60054"
                                  },
                                  "memberId": {
                                    "type": "string",
                                    "description": "Member ID printed on the insurance card. 3–50 characters."
                                  },
                                  "relationship": {
                                    "type": "string",
                                    "enum": [
                                      "SELF",
                                      "SPOUSE",
                                      "CHILD",
                                      "LIFE_PARTNER",
                                      "OTHER",
                                      "UNKNOWN",
                                      "DEPENDENT"
                                    ],
                                    "description": "The patient's relationship to the subscriber (CHILD: the patient is the subscriber's child). SELF inherits the patient's identity; any other value requires a `subscriber` block. DEPENDENT is accepted and stored as UNKNOWN."
                                  },
                                  "subscriber": {
                                    "type": "object",
                                    "properties": {
                                      "firstName": {
                                        "type": "string",
                                        "maxLength": 100
                                      },
                                      "lastName": {
                                        "type": "string",
                                        "maxLength": 100
                                      },
                                      "dob": {
                                        "type": "string",
                                        "maxLength": 20,
                                        "description": "Subscriber's date of birth (YYYY-MM-DD). Required for some payer eligibility flows."
                                      }
                                    },
                                    "required": [
                                      "firstName",
                                      "lastName"
                                    ],
                                    "additionalProperties": false,
                                    "description": "Subscriber identity. Required unless `relationship` is SELF; ignored for SELF."
                                  },
                                  "planNumber": {
                                    "type": [
                                      "string",
                                      "null"
                                    ],
                                    "maxLength": 64,
                                    "description": "Optional plan / policy number printed on the card."
                                  },
                                  "groupNumber": {
                                    "type": [
                                      "string",
                                      "null"
                                    ],
                                    "maxLength": 64,
                                    "description": "Optional group number printed on the card."
                                  }
                                },
                                "required": [
                                  "coverageOrder",
                                  "payerCode",
                                  "memberId",
                                  "relationship"
                                ],
                                "additionalProperties": false
                              },
                              "maxItems": 3,
                              "description": "Up to three insurance entries (one per coverage tier). Tier 1 is required for eligibility checks; tiers 2 and 3 are optional secondary and tertiary."
                            },
                            "demographics": {
                              "type": "object",
                              "properties": {
                                "preferredFirstName": {
                                  "type": [
                                    "string",
                                    "null"
                                  ],
                                  "maxLength": 100
                                },
                                "preferredLastName": {
                                  "type": [
                                    "string",
                                    "null"
                                  ],
                                  "maxLength": 100
                                },
                                "preferredLanguage": {
                                  "type": [
                                    "string",
                                    "null"
                                  ],
                                  "maxLength": 64
                                },
                                "gender": {
                                  "type": [
                                    "string",
                                    "null"
                                  ],
                                  "maxLength": 32
                                },
                                "pronouns": {
                                  "type": [
                                    "string",
                                    "null"
                                  ],
                                  "maxLength": 64
                                },
                                "sexAtBirth": {
                                  "type": [
                                    "string",
                                    "null"
                                  ],
                                  "maxLength": 32
                                },
                                "maritalStatus": {
                                  "type": [
                                    "string",
                                    "null"
                                  ],
                                  "maxLength": 32
                                },
                                "guardian": {
                                  "type": [
                                    "string",
                                    "null"
                                  ],
                                  "maxLength": 120
                                },
                                "race": {
                                  "type": [
                                    "string",
                                    "null"
                                  ],
                                  "maxLength": 64
                                },
                                "secondRace": {
                                  "type": [
                                    "string",
                                    "null"
                                  ],
                                  "maxLength": 64
                                },
                                "ethnicity": {
                                  "type": [
                                    "string",
                                    "null"
                                  ],
                                  "maxLength": 64
                                },
                                "secondEthnicity": {
                                  "type": [
                                    "string",
                                    "null"
                                  ],
                                  "maxLength": 64
                                },
                                "sexualOrientation": {
                                  "type": [
                                    "string",
                                    "null"
                                  ],
                                  "maxLength": 64
                                },
                                "preferredProvider": {
                                  "type": [
                                    "string",
                                    "null"
                                  ],
                                  "maxLength": 120
                                },
                                "primaryDepartment": {
                                  "type": [
                                    "string",
                                    "null"
                                  ],
                                  "maxLength": 120
                                },
                                "prefersSelfPay": {
                                  "type": [
                                    "boolean",
                                    "null"
                                  ]
                                },
                                "ssn": {
                                  "type": [
                                    "string",
                                    "null"
                                  ]
                                }
                              },
                              "additionalProperties": false,
                              "description": "Optional demographic fields (preferred name, language, gender, etc). Not required for eligibility but stored on the patient."
                            },
                            "contact": {
                              "type": "object",
                              "properties": {
                                "primaryPhone": {
                                  "type": [
                                    "string",
                                    "null"
                                  ]
                                },
                                "secondaryPhone": {
                                  "type": [
                                    "string",
                                    "null"
                                  ]
                                },
                                "workPhone": {
                                  "type": [
                                    "string",
                                    "null"
                                  ]
                                },
                                "primaryEmail": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "maxLength": 254,
                                      "format": "email"
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        ""
                                      ]
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "secondaryEmail": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "maxLength": 254,
                                      "format": "email"
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        ""
                                      ]
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "homeAddress": {
                                  "type": [
                                    "object",
                                    "null"
                                  ],
                                  "properties": {
                                    "line1": {
                                      "type": "string",
                                      "maxLength": 120
                                    },
                                    "line2": {
                                      "type": "string",
                                      "maxLength": 120
                                    },
                                    "city": {
                                      "type": "string",
                                      "maxLength": 80
                                    },
                                    "state": {
                                      "type": "string",
                                      "maxLength": 40
                                    },
                                    "zip": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "line1",
                                    "city",
                                    "state",
                                    "zip"
                                  ],
                                  "additionalProperties": false
                                },
                                "mailingAddress": {
                                  "type": [
                                    "object",
                                    "null"
                                  ],
                                  "properties": {
                                    "line1": {
                                      "type": "string",
                                      "maxLength": 120
                                    },
                                    "line2": {
                                      "type": "string",
                                      "maxLength": 120
                                    },
                                    "city": {
                                      "type": "string",
                                      "maxLength": 80
                                    },
                                    "state": {
                                      "type": "string",
                                      "maxLength": 40
                                    },
                                    "zip": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "line1",
                                    "city",
                                    "state",
                                    "zip"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "additionalProperties": false,
                              "description": "Phone numbers, emails, and home/mailing addresses."
                            },
                            "emergencyContact": {
                              "type": "object",
                              "properties": {
                                "name": {
                                  "type": "string",
                                  "maxLength": 120
                                },
                                "relationship": {
                                  "type": "string",
                                  "maxLength": 64
                                },
                                "phone": {
                                  "type": [
                                    "string",
                                    "null"
                                  ]
                                },
                                "email": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "maxLength": 254,
                                      "format": "email"
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        ""
                                      ]
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                }
                              },
                              "required": [
                                "name"
                              ],
                              "additionalProperties": false,
                              "description": "Emergency contact details for the patient."
                            },
                            "medical": {
                              "type": "object",
                              "properties": {
                                "diagnosisCodes": {
                                  "type": [
                                    "string",
                                    "null"
                                  ],
                                  "maxLength": 500
                                },
                                "clinic": {
                                  "type": [
                                    "string",
                                    "null"
                                  ],
                                  "maxLength": 120
                                }
                              },
                              "additionalProperties": false,
                              "description": "Free-text medical notes (diagnosis codes, clinic)."
                            },
                            "notes": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "label": {
                                    "type": "string"
                                  },
                                  "content": {
                                    "type": "string",
                                    "maxLength": 10000
                                  }
                                },
                                "required": [
                                  "label",
                                  "content"
                                ],
                                "additionalProperties": false
                              },
                              "description": "Free-text notes keyed by label. Bulk-upload uses CSV column headers as labels; the use case upserts each by (patientId, label)."
                            },
                            "existingPatientId": {
                              "type": "string",
                              "format": "uuid",
                              "description": "Set to update an existing patient instead of creating a new one. Must belong to the caller's organization. Omit for create."
                            }
                          },
                          "required": [
                            "firstName",
                            "lastName",
                            "dob"
                          ],
                          "additionalProperties": false
                        },
                        "minItems": 1,
                        "maxItems": 200
                      }
                    },
                    "required": [
                      "patients"
                    ]
                  },
                  {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "firstName": {
                          "type": "string",
                          "maxLength": 100,
                          "description": "Legal first name as it appears on the insurance card."
                        },
                        "lastName": {
                          "type": "string",
                          "maxLength": 100,
                          "description": "Legal last name as it appears on the insurance card."
                        },
                        "dob": {
                          "type": "string",
                          "description": "Date of birth in YYYY-MM-DD form. Stored as midnight UTC.",
                          "example": "1985-04-12"
                        },
                        "externalId": {
                          "type": "string",
                          "description": "Your identifier for this patient (e.g. an MRN from your own system). Optional. Must be unique within your organization; reusing one returns a 409 conflict. Patients can be searched and sorted by this value via `GET /v1/patients`."
                        },
                        "insurances": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "coverageOrder": {
                                "anyOf": [
                                  {
                                    "type": "number",
                                    "enum": [
                                      1
                                    ]
                                  },
                                  {
                                    "type": "number",
                                    "enum": [
                                      2
                                    ]
                                  },
                                  {
                                    "type": "number",
                                    "enum": [
                                      3
                                    ]
                                  }
                                ],
                                "description": "Insurance order — 1 for primary, 2 for secondary, 3 for tertiary. Each patient may have at most one entry per order."
                              },
                              "payerCode": {
                                "type": "string",
                                "minLength": 2,
                                "maxLength": 50,
                                "description": "CMS payer code (e.g. \"60054\"). Look up via `/api/v1/payers` to find the right value for a given carrier.",
                                "example": "60054"
                              },
                              "memberId": {
                                "type": "string",
                                "description": "Member ID printed on the insurance card. 3–50 characters."
                              },
                              "relationship": {
                                "type": "string",
                                "enum": [
                                  "SELF",
                                  "SPOUSE",
                                  "CHILD",
                                  "LIFE_PARTNER",
                                  "OTHER",
                                  "UNKNOWN",
                                  "DEPENDENT"
                                ],
                                "description": "The patient's relationship to the subscriber (CHILD: the patient is the subscriber's child). SELF inherits the patient's identity; any other value requires a `subscriber` block. DEPENDENT is accepted and stored as UNKNOWN."
                              },
                              "subscriber": {
                                "type": "object",
                                "properties": {
                                  "firstName": {
                                    "type": "string",
                                    "maxLength": 100
                                  },
                                  "lastName": {
                                    "type": "string",
                                    "maxLength": 100
                                  },
                                  "dob": {
                                    "type": "string",
                                    "maxLength": 20,
                                    "description": "Subscriber's date of birth (YYYY-MM-DD). Required for some payer eligibility flows."
                                  }
                                },
                                "required": [
                                  "firstName",
                                  "lastName"
                                ],
                                "additionalProperties": false,
                                "description": "Subscriber identity. Required unless `relationship` is SELF; ignored for SELF."
                              },
                              "planNumber": {
                                "type": [
                                  "string",
                                  "null"
                                ],
                                "maxLength": 64,
                                "description": "Optional plan / policy number printed on the card."
                              },
                              "groupNumber": {
                                "type": [
                                  "string",
                                  "null"
                                ],
                                "maxLength": 64,
                                "description": "Optional group number printed on the card."
                              }
                            },
                            "required": [
                              "coverageOrder",
                              "payerCode",
                              "memberId",
                              "relationship"
                            ],
                            "additionalProperties": false
                          },
                          "maxItems": 3,
                          "description": "Up to three insurance entries (one per coverage tier). Tier 1 is required for eligibility checks; tiers 2 and 3 are optional secondary and tertiary."
                        },
                        "demographics": {
                          "type": "object",
                          "properties": {
                            "preferredFirstName": {
                              "type": [
                                "string",
                                "null"
                              ],
                              "maxLength": 100
                            },
                            "preferredLastName": {
                              "type": [
                                "string",
                                "null"
                              ],
                              "maxLength": 100
                            },
                            "preferredLanguage": {
                              "type": [
                                "string",
                                "null"
                              ],
                              "maxLength": 64
                            },
                            "gender": {
                              "type": [
                                "string",
                                "null"
                              ],
                              "maxLength": 32
                            },
                            "pronouns": {
                              "type": [
                                "string",
                                "null"
                              ],
                              "maxLength": 64
                            },
                            "sexAtBirth": {
                              "type": [
                                "string",
                                "null"
                              ],
                              "maxLength": 32
                            },
                            "maritalStatus": {
                              "type": [
                                "string",
                                "null"
                              ],
                              "maxLength": 32
                            },
                            "guardian": {
                              "type": [
                                "string",
                                "null"
                              ],
                              "maxLength": 120
                            },
                            "race": {
                              "type": [
                                "string",
                                "null"
                              ],
                              "maxLength": 64
                            },
                            "secondRace": {
                              "type": [
                                "string",
                                "null"
                              ],
                              "maxLength": 64
                            },
                            "ethnicity": {
                              "type": [
                                "string",
                                "null"
                              ],
                              "maxLength": 64
                            },
                            "secondEthnicity": {
                              "type": [
                                "string",
                                "null"
                              ],
                              "maxLength": 64
                            },
                            "sexualOrientation": {
                              "type": [
                                "string",
                                "null"
                              ],
                              "maxLength": 64
                            },
                            "preferredProvider": {
                              "type": [
                                "string",
                                "null"
                              ],
                              "maxLength": 120
                            },
                            "primaryDepartment": {
                              "type": [
                                "string",
                                "null"
                              ],
                              "maxLength": 120
                            },
                            "prefersSelfPay": {
                              "type": [
                                "boolean",
                                "null"
                              ]
                            },
                            "ssn": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          },
                          "additionalProperties": false,
                          "description": "Optional demographic fields (preferred name, language, gender, etc). Not required for eligibility but stored on the patient."
                        },
                        "contact": {
                          "type": "object",
                          "properties": {
                            "primaryPhone": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "secondaryPhone": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "workPhone": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "primaryEmail": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "maxLength": 254,
                                  "format": "email"
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    ""
                                  ]
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "secondaryEmail": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "maxLength": 254,
                                  "format": "email"
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    ""
                                  ]
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "homeAddress": {
                              "type": [
                                "object",
                                "null"
                              ],
                              "properties": {
                                "line1": {
                                  "type": "string",
                                  "maxLength": 120
                                },
                                "line2": {
                                  "type": "string",
                                  "maxLength": 120
                                },
                                "city": {
                                  "type": "string",
                                  "maxLength": 80
                                },
                                "state": {
                                  "type": "string",
                                  "maxLength": 40
                                },
                                "zip": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "line1",
                                "city",
                                "state",
                                "zip"
                              ],
                              "additionalProperties": false
                            },
                            "mailingAddress": {
                              "type": [
                                "object",
                                "null"
                              ],
                              "properties": {
                                "line1": {
                                  "type": "string",
                                  "maxLength": 120
                                },
                                "line2": {
                                  "type": "string",
                                  "maxLength": 120
                                },
                                "city": {
                                  "type": "string",
                                  "maxLength": 80
                                },
                                "state": {
                                  "type": "string",
                                  "maxLength": 40
                                },
                                "zip": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "line1",
                                "city",
                                "state",
                                "zip"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "additionalProperties": false,
                          "description": "Phone numbers, emails, and home/mailing addresses."
                        },
                        "emergencyContact": {
                          "type": "object",
                          "properties": {
                            "name": {
                              "type": "string",
                              "maxLength": 120
                            },
                            "relationship": {
                              "type": "string",
                              "maxLength": 64
                            },
                            "phone": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "email": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "maxLength": 254,
                                  "format": "email"
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    ""
                                  ]
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          },
                          "required": [
                            "name"
                          ],
                          "additionalProperties": false,
                          "description": "Emergency contact details for the patient."
                        },
                        "medical": {
                          "type": "object",
                          "properties": {
                            "diagnosisCodes": {
                              "type": [
                                "string",
                                "null"
                              ],
                              "maxLength": 500
                            },
                            "clinic": {
                              "type": [
                                "string",
                                "null"
                              ],
                              "maxLength": 120
                            }
                          },
                          "additionalProperties": false,
                          "description": "Free-text medical notes (diagnosis codes, clinic)."
                        },
                        "notes": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "label": {
                                "type": "string"
                              },
                              "content": {
                                "type": "string",
                                "maxLength": 10000
                              }
                            },
                            "required": [
                              "label",
                              "content"
                            ],
                            "additionalProperties": false
                          },
                          "description": "Free-text notes keyed by label. Bulk-upload uses CSV column headers as labels; the use case upserts each by (patientId, label)."
                        },
                        "existingPatientId": {
                          "type": "string",
                          "format": "uuid",
                          "description": "Set to update an existing patient instead of creating a new one. Must belong to the caller's organization. Omit for create."
                        }
                      },
                      "required": [
                        "firstName",
                        "lastName",
                        "dob"
                      ],
                      "additionalProperties": false
                    },
                    "minItems": 1,
                    "maxItems": 200
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden / insufficient scope"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation error"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Feature disabled"
          }
        }
      }
    },
    "/api/v1/patients/note-labels": {
      "get": {
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden / insufficient scope"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation error"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Feature disabled"
          }
        }
      }
    },
    "/api/v1/patients": {
      "get": {
        "summary": "List patients",
        "description": "Returns patients in the authenticated organization. Supports name and ID search, optional date-range filter on creation, and a minimal projection for picker UIs.",
        "tags": [
          "Patients"
        ],
        "parameters": [
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000,
              "default": 50,
              "description": "Page size. Service-account callers (OAuth) are clamped to 200.",
              "example": 50
            },
            "required": false,
            "description": "Page size. Service-account callers (OAuth) are clamped to 200.",
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": [
                "integer",
                "null"
              ],
              "minimum": 0,
              "default": 0,
              "description": "Zero-based offset for pagination."
            },
            "required": false,
            "description": "Zero-based offset for pagination.",
            "name": "offset",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "maxLength": 200,
              "description": "Whitespace-separated tokens, all case-insensitive. Each token must match part of the first or last name, or equal a patient-source external ID or insurance member ID in full. Example: `Jane d` matches a patient with first name 'Jane' and last name 'Doe'; `100` does not match external ID `EXT-100`."
            },
            "required": false,
            "description": "Whitespace-separated tokens, all case-insensitive. Each token must match part of the first or last name, or equal a patient-source external ID or insurance member ID in full. Example: `Jane d` matches a patient with first name 'Jane' and last name 'Doe'; `100` does not match external ID `EXT-100`.",
            "name": "search",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "0",
                "1",
                "true",
                "false"
              ],
              "description": "Return a slim projection (id/firstName/lastName/dob + active insurances). Useful for picker UIs."
            },
            "required": false,
            "description": "Return a slim projection (id/firstName/lastName/dob + active insurances). Useful for picker UIs.",
            "name": "minimal",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "0",
                "1",
                "true",
                "false"
              ],
              "description": "Set to `false` to leave `meta.total` out. A typeahead that shows one page and never paginates saves the count query on every keystroke."
            },
            "required": false,
            "description": "Set to `false` to leave `meta.total` out. A typeahead that shows one page and never paginates saves the count query on every keystroke.",
            "name": "includeTotal",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "ISO-8601 datetime lower bound on `createdAt` (inclusive). Returns 422 on invalid input."
            },
            "required": false,
            "description": "ISO-8601 datetime lower bound on `createdAt` (inclusive). Returns 422 on invalid input.",
            "name": "fromDate",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "ISO-8601 datetime upper bound on `createdAt` (inclusive)."
            },
            "required": false,
            "description": "ISO-8601 datetime upper bound on `createdAt` (inclusive).",
            "name": "toDate",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "pattern": "^(name|lastName|firstName|dob|createdAt|externalId)\\.(asc|desc)$",
              "description": "Sort spec in `<field>.<direction>` form, e.g. `lastName.asc`. Defaults to `createdAt.desc`."
            },
            "required": false,
            "description": "Sort spec in `<field>.<direction>` form, e.g. `lastName.asc`. Defaults to `createdAt.desc`.",
            "name": "sort",
            "in": "query"
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              ],
              "description": "Repeatable filter on `patientMedical.clinic`. Use the literal `No Clinic` to match patients with no clinic recorded."
            },
            "required": false,
            "description": "Repeatable filter on `patientMedical.clinic`. Use the literal `No Clinic` to match patients with no clinic recorded.",
            "name": "clinic",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "exclude",
                "include",
                "only"
              ],
              "default": "exclude",
              "description": "Archived patients are left out by default. `include` lists them alongside the rest; `only` lists just them."
            },
            "required": false,
            "description": "Archived patients are left out by default. `include` lists them alongside the rest; `only` lists just them.",
            "name": "archived",
            "in": "query"
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              ],
              "description": "Repeatable filter on payer ID. Matches patients with any insurance (any coverage tier) for the given payer(s)."
            },
            "required": false,
            "description": "Repeatable filter on payer ID. Matches patients with any insurance (any coverage tier) for the given payer(s).",
            "name": "payer",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden / insufficient scope"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation error"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Feature disabled"
          }
        }
      },
      "post": {
        "summary": "Create a patient",
        "description": "Creates a patient with optional insurance, demographic, contact, emergency, and medical fields. Tier-1 insurance is required for eligibility checks; subsequent insurance changes go through the dedicated insurance endpoints.",
        "tags": [
          "Patients"
        ],
        "parameters": [
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000,
              "default": 50,
              "description": "Page size. Service-account callers (OAuth) are clamped to 200.",
              "example": 50
            },
            "required": false,
            "description": "Page size. Service-account callers (OAuth) are clamped to 200.",
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": [
                "integer",
                "null"
              ],
              "minimum": 0,
              "default": 0,
              "description": "Zero-based offset for pagination."
            },
            "required": false,
            "description": "Zero-based offset for pagination.",
            "name": "offset",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "maxLength": 200,
              "description": "Whitespace-separated tokens, all case-insensitive. Each token must match part of the first or last name, or equal a patient-source external ID or insurance member ID in full. Example: `Jane d` matches a patient with first name 'Jane' and last name 'Doe'; `100` does not match external ID `EXT-100`."
            },
            "required": false,
            "description": "Whitespace-separated tokens, all case-insensitive. Each token must match part of the first or last name, or equal a patient-source external ID or insurance member ID in full. Example: `Jane d` matches a patient with first name 'Jane' and last name 'Doe'; `100` does not match external ID `EXT-100`.",
            "name": "search",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "0",
                "1",
                "true",
                "false"
              ],
              "description": "Return a slim projection (id/firstName/lastName/dob + active insurances). Useful for picker UIs."
            },
            "required": false,
            "description": "Return a slim projection (id/firstName/lastName/dob + active insurances). Useful for picker UIs.",
            "name": "minimal",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "0",
                "1",
                "true",
                "false"
              ],
              "description": "Set to `false` to leave `meta.total` out. A typeahead that shows one page and never paginates saves the count query on every keystroke."
            },
            "required": false,
            "description": "Set to `false` to leave `meta.total` out. A typeahead that shows one page and never paginates saves the count query on every keystroke.",
            "name": "includeTotal",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "ISO-8601 datetime lower bound on `createdAt` (inclusive). Returns 422 on invalid input."
            },
            "required": false,
            "description": "ISO-8601 datetime lower bound on `createdAt` (inclusive). Returns 422 on invalid input.",
            "name": "fromDate",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "ISO-8601 datetime upper bound on `createdAt` (inclusive)."
            },
            "required": false,
            "description": "ISO-8601 datetime upper bound on `createdAt` (inclusive).",
            "name": "toDate",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "pattern": "^(name|lastName|firstName|dob|createdAt|externalId)\\.(asc|desc)$",
              "description": "Sort spec in `<field>.<direction>` form, e.g. `lastName.asc`. Defaults to `createdAt.desc`."
            },
            "required": false,
            "description": "Sort spec in `<field>.<direction>` form, e.g. `lastName.asc`. Defaults to `createdAt.desc`.",
            "name": "sort",
            "in": "query"
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              ],
              "description": "Repeatable filter on `patientMedical.clinic`. Use the literal `No Clinic` to match patients with no clinic recorded."
            },
            "required": false,
            "description": "Repeatable filter on `patientMedical.clinic`. Use the literal `No Clinic` to match patients with no clinic recorded.",
            "name": "clinic",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "exclude",
                "include",
                "only"
              ],
              "default": "exclude",
              "description": "Archived patients are left out by default. `include` lists them alongside the rest; `only` lists just them."
            },
            "required": false,
            "description": "Archived patients are left out by default. `include` lists them alongside the rest; `only` lists just them.",
            "name": "archived",
            "in": "query"
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              ],
              "description": "Repeatable filter on payer ID. Matches patients with any insurance (any coverage tier) for the given payer(s)."
            },
            "required": false,
            "description": "Repeatable filter on payer ID. Matches patients with any insurance (any coverage tier) for the given payer(s).",
            "name": "payer",
            "in": "query"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "firstName": {
                    "type": "string",
                    "maxLength": 100,
                    "description": "Legal first name as it appears on the insurance card."
                  },
                  "lastName": {
                    "type": "string",
                    "maxLength": 100,
                    "description": "Legal last name as it appears on the insurance card."
                  },
                  "dob": {
                    "type": "string",
                    "description": "Date of birth in YYYY-MM-DD form. Stored as midnight UTC.",
                    "example": "1985-04-12"
                  },
                  "externalId": {
                    "type": "string",
                    "description": "Your identifier for this patient (e.g. an MRN from your own system). Optional. Must be unique within your organization; reusing one returns a 409 conflict. Patients can be searched and sorted by this value via `GET /v1/patients`."
                  },
                  "insurances": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "coverageOrder": {
                          "anyOf": [
                            {
                              "type": "number",
                              "enum": [
                                1
                              ]
                            },
                            {
                              "type": "number",
                              "enum": [
                                2
                              ]
                            },
                            {
                              "type": "number",
                              "enum": [
                                3
                              ]
                            }
                          ],
                          "description": "Insurance order — 1 for primary, 2 for secondary, 3 for tertiary. Each patient may have at most one entry per order."
                        },
                        "payerCode": {
                          "type": "string",
                          "minLength": 2,
                          "maxLength": 50,
                          "description": "CMS payer code (e.g. \"60054\"). Look up via `/api/v1/payers` to find the right value for a given carrier.",
                          "example": "60054"
                        },
                        "memberId": {
                          "type": "string",
                          "description": "Member ID printed on the insurance card. 3–50 characters."
                        },
                        "relationship": {
                          "type": "string",
                          "enum": [
                            "SELF",
                            "SPOUSE",
                            "CHILD",
                            "LIFE_PARTNER",
                            "OTHER",
                            "UNKNOWN",
                            "DEPENDENT"
                          ],
                          "description": "The patient's relationship to the subscriber (CHILD: the patient is the subscriber's child). SELF inherits the patient's identity; any other value requires a `subscriber` block. DEPENDENT is accepted and stored as UNKNOWN."
                        },
                        "subscriber": {
                          "type": "object",
                          "properties": {
                            "firstName": {
                              "type": "string",
                              "maxLength": 100
                            },
                            "lastName": {
                              "type": "string",
                              "maxLength": 100
                            },
                            "dob": {
                              "type": "string",
                              "maxLength": 20,
                              "description": "Subscriber's date of birth (YYYY-MM-DD). Required for some payer eligibility flows."
                            }
                          },
                          "required": [
                            "firstName",
                            "lastName"
                          ],
                          "additionalProperties": false,
                          "description": "Subscriber identity. Required unless `relationship` is SELF; ignored for SELF."
                        },
                        "planNumber": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "maxLength": 64,
                          "description": "Optional plan / policy number printed on the card."
                        },
                        "groupNumber": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "maxLength": 64,
                          "description": "Optional group number printed on the card."
                        }
                      },
                      "required": [
                        "coverageOrder",
                        "payerCode",
                        "memberId",
                        "relationship"
                      ],
                      "additionalProperties": false
                    },
                    "maxItems": 3,
                    "description": "Up to three insurance entries (one per coverage tier). Tier 1 is required for eligibility checks; tiers 2 and 3 are optional secondary and tertiary."
                  },
                  "demographics": {
                    "type": "object",
                    "properties": {
                      "preferredFirstName": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 100
                      },
                      "preferredLastName": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 100
                      },
                      "preferredLanguage": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 64
                      },
                      "gender": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 32
                      },
                      "pronouns": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 64
                      },
                      "sexAtBirth": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 32
                      },
                      "maritalStatus": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 32
                      },
                      "guardian": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 120
                      },
                      "race": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 64
                      },
                      "secondRace": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 64
                      },
                      "ethnicity": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 64
                      },
                      "secondEthnicity": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 64
                      },
                      "sexualOrientation": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 64
                      },
                      "preferredProvider": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 120
                      },
                      "primaryDepartment": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 120
                      },
                      "prefersSelfPay": {
                        "type": [
                          "boolean",
                          "null"
                        ]
                      },
                      "ssn": {
                        "type": [
                          "string",
                          "null"
                        ]
                      }
                    },
                    "additionalProperties": false,
                    "description": "Optional demographic fields (preferred name, language, gender, etc). Not required for eligibility but stored on the patient."
                  },
                  "contact": {
                    "type": "object",
                    "properties": {
                      "primaryPhone": {
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "secondaryPhone": {
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "workPhone": {
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "primaryEmail": {
                        "anyOf": [
                          {
                            "type": "string",
                            "maxLength": 254,
                            "format": "email"
                          },
                          {
                            "type": "string",
                            "enum": [
                              ""
                            ]
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "secondaryEmail": {
                        "anyOf": [
                          {
                            "type": "string",
                            "maxLength": 254,
                            "format": "email"
                          },
                          {
                            "type": "string",
                            "enum": [
                              ""
                            ]
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "homeAddress": {
                        "type": [
                          "object",
                          "null"
                        ],
                        "properties": {
                          "line1": {
                            "type": "string",
                            "maxLength": 120
                          },
                          "line2": {
                            "type": "string",
                            "maxLength": 120
                          },
                          "city": {
                            "type": "string",
                            "maxLength": 80
                          },
                          "state": {
                            "type": "string",
                            "maxLength": 40
                          },
                          "zip": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "line1",
                          "city",
                          "state",
                          "zip"
                        ],
                        "additionalProperties": false
                      },
                      "mailingAddress": {
                        "type": [
                          "object",
                          "null"
                        ],
                        "properties": {
                          "line1": {
                            "type": "string",
                            "maxLength": 120
                          },
                          "line2": {
                            "type": "string",
                            "maxLength": 120
                          },
                          "city": {
                            "type": "string",
                            "maxLength": 80
                          },
                          "state": {
                            "type": "string",
                            "maxLength": 40
                          },
                          "zip": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "line1",
                          "city",
                          "state",
                          "zip"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "additionalProperties": false,
                    "description": "Phone numbers, emails, and home/mailing addresses."
                  },
                  "emergencyContact": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string",
                        "maxLength": 120
                      },
                      "relationship": {
                        "type": "string",
                        "maxLength": 64
                      },
                      "phone": {
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "email": {
                        "anyOf": [
                          {
                            "type": "string",
                            "maxLength": 254,
                            "format": "email"
                          },
                          {
                            "type": "string",
                            "enum": [
                              ""
                            ]
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    },
                    "required": [
                      "name"
                    ],
                    "additionalProperties": false,
                    "description": "Emergency contact details for the patient."
                  },
                  "medical": {
                    "type": "object",
                    "properties": {
                      "diagnosisCodes": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 500
                      },
                      "clinic": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 120
                      }
                    },
                    "additionalProperties": false,
                    "description": "Free-text medical notes (diagnosis codes, clinic)."
                  },
                  "notes": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "label": {
                          "type": "string"
                        },
                        "content": {
                          "type": "string",
                          "maxLength": 10000
                        }
                      },
                      "required": [
                        "label",
                        "content"
                      ],
                      "additionalProperties": false
                    },
                    "description": "Free-text notes keyed by label. Bulk-upload uses CSV column headers as labels; the use case upserts each by (patientId, label)."
                  }
                },
                "required": [
                  "firstName",
                  "lastName",
                  "dob"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden / insufficient scope"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation error"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Feature disabled"
          }
        }
      }
    },
    "/api/v1/payers": {
      "get": {
        "summary": "Search payers",
        "description": "Searches the payer directory by name or id and returns matching payers ranked by relevance, each with its `payerCode`, known names and aliases, and whether eligibility checks are supported.",
        "tags": [
          "Payers"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200,
              "description": "Free-text query matched against payer name and known aliases/ids (e.g. `aetna` or `60054`).",
              "example": "aetna"
            },
            "required": true,
            "description": "Free-text query matched against payer name and known aliases/ids (e.g. `aetna` or `60054`).",
            "name": "search",
            "in": "query"
          },
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 20,
              "description": "Maximum number of results to return, ranked by match score. Max 50.",
              "example": 20
            },
            "required": false,
            "description": "Maximum number of results to return, ranked by match score. Max 50.",
            "name": "limit",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "requestId": {
                      "type": "string",
                      "description": "Trace id echoed on every v1 response. Format: `req_<16-hex>`. Useful for support correlation.",
                      "example": "req_a1b2c3d4e5f60718"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PayerSearchResult"
                      }
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "total": {
                          "type": "integer",
                          "minimum": 0,
                          "description": "Total matching rows. Populated for offset-paginated lists."
                        },
                        "limit": {
                          "type": "integer",
                          "exclusiveMinimum": 0,
                          "description": "Page size that was applied (may be clamped server-side)."
                        },
                        "offset": {
                          "type": "integer",
                          "minimum": 0,
                          "description": "Zero-based offset of this page. Offset-paginated lists."
                        },
                        "nextCursor": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "description": "Opaque cursor for the next page, or null if this was the last page. Cursor-paginated lists."
                        },
                        "hasMore": {
                          "type": "boolean",
                          "description": "True if more rows are available beyond this page."
                        }
                      },
                      "description": "Pagination metadata. Fields populated depend on the endpoint's pagination scheme (offset vs cursor)."
                    }
                  },
                  "required": [
                    "requestId",
                    "data",
                    "meta"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden / insufficient scope"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation error"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Feature disabled"
          }
        }
      }
    },
    "/api/v1/providers/{id}": {
      "get": {
        "summary": "Get a provider by ID",
        "description": "Returns the full provider record.",
        "tags": [
          "Providers"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Provider ID."
            },
            "required": true,
            "description": "Provider ID.",
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden / insufficient scope"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation error"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Feature disabled"
          }
        }
      },
      "patch": {
        "summary": "Update a provider",
        "description": "Partial update. When `isBilling` is or becomes true, billing fields (NPI, Tax ID, billing address) must be present after the merge.",
        "tags": [
          "Providers"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Provider ID."
            },
            "required": true,
            "description": "Provider ID.",
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "description": "Provider name."
                  },
                  "billingAddress": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "minLength": 1,
                    "maxLength": 500,
                    "description": "Single-line billing address."
                  },
                  "npi": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "10-digit NPI. Required when `isBilling` becomes true."
                  },
                  "taxId": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "9-digit Tax ID / EIN."
                  },
                  "ptan": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "taxonomyCode": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "pattern": "^[0-9A-Z]{9}X$",
                    "description": "NUCC provider taxonomy code (e.g. 363LP0808X). Sent on claims and read as the credential rates are priced by."
                  },
                  "email": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Where the provider's Draft claim missing list is sent. Blank or null clears it."
                  },
                  "isBilling": {
                    "type": "boolean",
                    "description": "Toggle billing-provider status."
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden / insufficient scope"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation error"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Feature disabled"
          }
        }
      },
      "delete": {
        "summary": "Delete a provider",
        "description": "Permanently deletes the provider. Fails when the provider is referenced by an active template.",
        "tags": [
          "Providers"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Provider ID."
            },
            "required": true,
            "description": "Provider ID.",
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden / insufficient scope"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation error"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Feature disabled"
          }
        }
      }
    },
    "/api/v1/providers": {
      "get": {
        "summary": "List providers",
        "description": "Returns providers in the authenticated organization. Use `isBilling=true` to restrict to billing providers (templates require a billing provider).",
        "tags": [
          "Providers"
        ],
        "parameters": [
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000,
              "default": 50,
              "description": "Page size. Service-account callers are clamped to 200.",
              "example": 50
            },
            "required": false,
            "description": "Page size. Service-account callers are clamped to 200.",
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": [
                "integer",
                "null"
              ],
              "minimum": 0,
              "default": 0,
              "description": "Zero-based offset for pagination."
            },
            "required": false,
            "description": "Zero-based offset for pagination.",
            "name": "offset",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ],
              "description": "Filter to billing providers only when `true`. Omit to include both billing and dummy providers."
            },
            "required": false,
            "description": "Filter to billing providers only when `true`. Omit to include both billing and dummy providers.",
            "name": "isBilling",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden / insufficient scope"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation error"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Feature disabled"
          }
        }
      },
      "post": {
        "summary": "Create a provider",
        "description": "Creates a billing or non-billing provider. NPI, Tax ID, and billing address are required when `isBilling` is true.",
        "tags": [
          "Providers"
        ],
        "parameters": [
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000,
              "default": 50,
              "description": "Page size. Service-account callers are clamped to 200.",
              "example": 50
            },
            "required": false,
            "description": "Page size. Service-account callers are clamped to 200.",
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": [
                "integer",
                "null"
              ],
              "minimum": 0,
              "default": 0,
              "description": "Zero-based offset for pagination."
            },
            "required": false,
            "description": "Zero-based offset for pagination.",
            "name": "offset",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ],
              "description": "Filter to billing providers only when `true`. Omit to include both billing and dummy providers."
            },
            "required": false,
            "description": "Filter to billing providers only when `true`. Omit to include both billing and dummy providers.",
            "name": "isBilling",
            "in": "query"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "description": "Provider name as it appears on claims (legal entity or individual)."
                  },
                  "billingAddress": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "minLength": 1,
                    "maxLength": 500,
                    "description": "Single-line billing address. Required when `isBilling` is true."
                  },
                  "npi": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "10-digit National Provider Identifier. Required when `isBilling` is true."
                  },
                  "taxId": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "9-digit Tax ID / EIN. Required when `isBilling` is true."
                  },
                  "ptan": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "taxonomyCode": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "pattern": "^[0-9A-Z]{9}X$",
                    "description": "NUCC provider taxonomy code (e.g. 363LP0808X). Sent on claims and read as the credential rates are priced by."
                  },
                  "email": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Where the provider's Draft claim missing list is sent. Blank or null leaves it unset."
                  },
                  "isBilling": {
                    "type": "boolean",
                    "default": true,
                    "description": "Whether this provider is used for billing. Non-billing providers can be referenced by templates but won't appear in billing-only pickers. Defaults to `true`."
                  }
                },
                "required": [
                  "name"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden / insufficient scope"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation error"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Feature disabled"
          }
        }
      }
    },
    "/api/v1/templates/{id}": {
      "get": {
        "summary": "Get an eligibility check template by ID",
        "description": "Returns a single template. Use `?include=provider` to embed the full provider record.",
        "tags": [
          "Templates"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Template ID."
            },
            "required": true,
            "description": "Template ID.",
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden / insufficient scope"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation error"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Feature disabled"
          }
        }
      },
      "patch": {
        "summary": "Update an eligibility check template",
        "description": "Partial update. The call-policy refinement runs against the merged shape, so portal-only vs portal+phone field requirements still apply.",
        "tags": [
          "Templates"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Template ID."
            },
            "required": true,
            "description": "Template ID.",
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100,
                    "description": "Human-readable template name."
                  },
                  "providerId": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Switch the template to a different billing provider."
                  },
                  "placeOfServiceCode": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "pattern": "^\\d{2}$"
                  },
                  "procedureCodes": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "pattern": "^[A-Za-z0-9]{5}$"
                    },
                    "maxItems": 10,
                    "description": "Replacement list of procedure (CPT/HCPCS) codes."
                  },
                  "serviceTypeCodes": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "pattern": "^[A-Za-z0-9]{1,3}$"
                    },
                    "maxItems": 10,
                    "description": "Replacement list of EDI service-type codes."
                  },
                  "processingOptions": {
                    "type": "object",
                    "properties": {
                      "additionalQuestions": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "maxItems": 10,
                        "description": "Questions the insurance representative is explicitly asked during the call. Each question is answered individually in the check results when an answer is found. Up to 10 entries, 200 chars each."
                      },
                      "additionalContext": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 2000,
                        "description": "Free-text context shared with the insurance representative during the call (e.g. the patient is a new member). Unlike additionalQuestions, it is not treated as a set of questions to answer. Up to 2,000 chars."
                      },
                      "callPolicy": {
                        "type": "object",
                        "properties": {
                          "mode": {
                            "type": "string",
                            "enum": [
                              "always",
                              "never",
                              "ifNeeded",
                              "conditions",
                              "override"
                            ],
                            "description": "Whether the executor places a phone call. `never` = portal/EDI only; `always` = always call after EDI; `ifNeeded`/`conditions` = call only when EDI is incomplete; `override` = bespoke caller-defined behavior."
                          },
                          "conditions": {
                            "type": "object",
                            "properties": {
                              "requireEdiSuccess": {
                                "type": "boolean"
                              }
                            },
                            "required": [
                              "requireEdiSuccess"
                            ],
                            "additionalProperties": false,
                            "description": "Only meaningful when `mode = conditions`. Gates the call on EDI success."
                          }
                        },
                        "required": [
                          "mode"
                        ],
                        "additionalProperties": false
                      },
                      "summarySettings": {
                        "type": "object",
                        "properties": {
                          "accumulated": {
                            "type": "string",
                            "enum": [
                              "REMAINING",
                              "MET"
                            ],
                            "description": "Whether the summary reports remaining-to-meet or amount-met for accumulator fields."
                          },
                          "length": {
                            "type": "string",
                            "enum": [
                              "LONG",
                              "SHORT"
                            ],
                            "description": "Verbosity of the generated summary."
                          },
                          "additionalContext": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "maxLength": 4000,
                            "description": "Free-text context appended to the summary prompt."
                          },
                          "templateQuestions": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 1000
                            },
                            "maxItems": 50,
                            "description": "Template-level questions the summary should answer. Up to 50 entries."
                          }
                        },
                        "required": [
                          "accumulated",
                          "length"
                        ],
                        "additionalProperties": false
                      },
                      "cob": {
                        "type": "object",
                        "properties": {
                          "enabled": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "enabled"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "additionalProperties": false,
                    "description": "Execution-time settings (call policy, COB, summary settings, additional questions). All fields optional; unknown keys are rejected."
                  },
                  "isSpecialist": {
                    "type": [
                      "boolean",
                      "null"
                    ],
                    "description": "Whether the provider is considered a specialist (affects call results)."
                  },
                  "renderingProviderId": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "format": "uuid",
                    "description": "Provider who performs the visit, when different from the billing provider. Must have an NPI, which is sent to the payer call as the rendering NPI; the billing provider's NPI is sent when null. Look up via `/v1/providers`."
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden / insufficient scope"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation error"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Feature disabled"
          }
        }
      },
      "delete": {
        "summary": "Delete an eligibility check template",
        "description": "Permanently deletes the template. Existing checks already created from it remain intact.",
        "tags": [
          "Templates"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Template ID."
            },
            "required": true,
            "description": "Template ID.",
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden / insufficient scope"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation error"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Feature disabled"
          }
        }
      }
    },
    "/api/v1/templates": {
      "get": {
        "summary": "List eligibility check templates",
        "description": "Returns templates in the authenticated organization. Use `?include=provider` to embed the full provider record on each template.",
        "tags": [
          "Templates"
        ],
        "parameters": [
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000,
              "default": 50,
              "description": "Page size. Service-account callers are clamped to 200."
            },
            "required": false,
            "description": "Page size. Service-account callers are clamped to 200.",
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": [
                "integer",
                "null"
              ],
              "minimum": 0,
              "default": 0,
              "description": "Zero-based offset for pagination."
            },
            "required": false,
            "description": "Zero-based offset for pagination.",
            "name": "offset",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "description": "Comma-separated list of nested resources to embed. Currently supports `provider` to inline the full provider record.",
              "example": "provider"
            },
            "required": false,
            "description": "Comma-separated list of nested resources to embed. Currently supports `provider` to inline the full provider record.",
            "name": "include",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "description": "When true, returns a slim projection for pickers: id, name, providerId, processingOptions, and (with `include=provider`) the provider's id, name and NPI.",
              "example": "true"
            },
            "required": false,
            "description": "When true, returns a slim projection for pickers: id, name, providerId, processingOptions, and (with `include=provider`) the provider's id, name and NPI.",
            "name": "minimal",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden / insufficient scope"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation error"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Feature disabled"
          }
        }
      },
      "post": {
        "summary": "Create an eligibility check template",
        "description": "Creates a template that bundles a billing provider with the service/procedure/place-of-service codes used at check time. The call-policy refinement enforces portal-only vs portal+phone field requirements.",
        "tags": [
          "Templates"
        ],
        "parameters": [
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000,
              "default": 50,
              "description": "Page size. Service-account callers are clamped to 200."
            },
            "required": false,
            "description": "Page size. Service-account callers are clamped to 200.",
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": [
                "integer",
                "null"
              ],
              "minimum": 0,
              "default": 0,
              "description": "Zero-based offset for pagination."
            },
            "required": false,
            "description": "Zero-based offset for pagination.",
            "name": "offset",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "description": "Comma-separated list of nested resources to embed. Currently supports `provider` to inline the full provider record.",
              "example": "provider"
            },
            "required": false,
            "description": "Comma-separated list of nested resources to embed. Currently supports `provider` to inline the full provider record.",
            "name": "include",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "description": "When true, returns a slim projection for pickers: id, name, providerId, processingOptions, and (with `include=provider`) the provider's id, name and NPI.",
              "example": "true"
            },
            "required": false,
            "description": "When true, returns a slim projection for pickers: id, name, providerId, processingOptions, and (with `include=provider`) the provider's id, name and NPI.",
            "name": "minimal",
            "in": "query"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100,
                    "description": "Human-readable template name."
                  },
                  "providerId": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Billing provider this template runs as. Look up via `/v1/providers`."
                  },
                  "procedureCodes": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "pattern": "^[A-Za-z0-9]{5}$"
                    },
                    "maxItems": 10,
                    "description": "List of procedure (CPT/HCPCS) codes to check benefits for. Up to 10 entries."
                  },
                  "serviceTypeCodes": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "pattern": "^[A-Za-z0-9]{1,3}$"
                    },
                    "maxItems": 10,
                    "description": "EDI service-type codes that scope the eligibility request. Up to 10 entries."
                  },
                  "placeOfServiceCode": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "pattern": "^\\d{2}$"
                  },
                  "isSpecialist": {
                    "type": [
                      "boolean",
                      "null"
                    ],
                    "description": "Whether the provider is considered a specialist (affects call results)."
                  },
                  "renderingProviderId": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "format": "uuid",
                    "description": "Provider who performs the visit, when different from the billing provider. Must have an NPI, which is sent to the payer call as the rendering NPI; the billing provider's NPI is sent when null. Look up via `/v1/providers`."
                  },
                  "processingOptions": {
                    "type": "object",
                    "properties": {
                      "additionalQuestions": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "maxItems": 10,
                        "description": "Questions the insurance representative is explicitly asked during the call. Each question is answered individually in the check results when an answer is found. Up to 10 entries, 200 chars each."
                      },
                      "additionalContext": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 2000,
                        "description": "Free-text context shared with the insurance representative during the call (e.g. the patient is a new member). Unlike additionalQuestions, it is not treated as a set of questions to answer. Up to 2,000 chars."
                      },
                      "callPolicy": {
                        "type": "object",
                        "properties": {
                          "mode": {
                            "type": "string",
                            "enum": [
                              "always",
                              "never",
                              "ifNeeded",
                              "conditions",
                              "override"
                            ],
                            "description": "Whether the executor places a phone call. `never` = portal/EDI only; `always` = always call after EDI; `ifNeeded`/`conditions` = call only when EDI is incomplete; `override` = bespoke caller-defined behavior."
                          },
                          "conditions": {
                            "type": "object",
                            "properties": {
                              "requireEdiSuccess": {
                                "type": "boolean"
                              }
                            },
                            "required": [
                              "requireEdiSuccess"
                            ],
                            "additionalProperties": false,
                            "description": "Only meaningful when `mode = conditions`. Gates the call on EDI success."
                          }
                        },
                        "required": [
                          "mode"
                        ],
                        "additionalProperties": false
                      },
                      "summarySettings": {
                        "type": "object",
                        "properties": {
                          "accumulated": {
                            "type": "string",
                            "enum": [
                              "REMAINING",
                              "MET"
                            ],
                            "description": "Whether the summary reports remaining-to-meet or amount-met for accumulator fields."
                          },
                          "length": {
                            "type": "string",
                            "enum": [
                              "LONG",
                              "SHORT"
                            ],
                            "description": "Verbosity of the generated summary."
                          },
                          "additionalContext": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "maxLength": 4000,
                            "description": "Free-text context appended to the summary prompt."
                          },
                          "templateQuestions": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 1000
                            },
                            "maxItems": 50,
                            "description": "Template-level questions the summary should answer. Up to 50 entries."
                          }
                        },
                        "required": [
                          "accumulated",
                          "length"
                        ],
                        "additionalProperties": false
                      },
                      "cob": {
                        "type": "object",
                        "properties": {
                          "enabled": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "enabled"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "additionalProperties": false,
                    "description": "Execution-time settings (call policy, COB, summary settings, additional questions). All fields optional; unknown keys are rejected."
                  }
                },
                "required": [
                  "name",
                  "providerId"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden / insufficient scope"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation error"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Feature disabled"
          }
        }
      }
    },
    "/api/v1/webhook-configs/{id}": {
      "get": {
        "summary": "Get a webhook subscription by ID",
        "description": "Returns a single subscription. Secrets are never re-exposed; expect `secret` to be absent.",
        "tags": [
          "Webhooks"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Webhook subscription ID."
            },
            "required": true,
            "description": "Webhook subscription ID.",
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden / insufficient scope"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation error"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Feature disabled"
          }
        }
      },
      "patch": {
        "summary": "Update a webhook subscription",
        "description": "Partial update. Sending a new `secret` rotates the signing key. Toggle `enabled` to pause/resume deliveries. Changes (including enable/disable toggles, URL changes, and secret rotations) apply only to eligibility checks started after this request returns. Checks already in flight continue with the previous configuration and secret. To verify a rotation end-to-end, start a fresh check after the rotation completes.",
        "tags": [
          "Webhooks"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Webhook subscription ID."
            },
            "required": true,
            "description": "Webhook subscription ID.",
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "maxLength": 2048,
                    "format": "uri",
                    "description": "HTTPS URL that will receive event deliveries. Plain HTTP and private/loopback hosts are rejected."
                  },
                  "enabled": {
                    "type": "boolean",
                    "description": "Pause (`false`) or resume (`true`) deliveries without deleting the subscription."
                  },
                  "secret": {
                    "type": "string",
                    "minLength": 32,
                    "maxLength": 256,
                    "pattern": "^[\\x20-\\x7E]+$",
                    "description": "Replacement HMAC secret. Sending this rotates the signing key — old deliveries-in-flight signed with the prior secret will fail verification."
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden / insufficient scope"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation error"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Feature disabled"
          }
        }
      },
      "delete": {
        "summary": "Delete a webhook subscription",
        "description": "Permanently removes the subscription. Deletion takes effect for eligibility checks started after this request returns. Checks already in flight may still deliver to this subscription's URL using the previously configured secret.",
        "tags": [
          "Webhooks"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Webhook subscription ID."
            },
            "required": true,
            "description": "Webhook subscription ID.",
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden / insufficient scope"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation error"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Feature disabled"
          }
        }
      }
    },
    "/api/v1/webhook-configs": {
      "get": {
        "summary": "List webhook subscriptions",
        "description": "Returns webhook subscriptions for the authenticated organization. Secrets are never re-exposed after create.",
        "tags": [
          "Webhooks"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden / insufficient scope"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation error"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Feature disabled"
          }
        }
      },
      "post": {
        "summary": "Create a webhook subscription",
        "description": "Subscribes an HTTPS endpoint to event deliveries. The HMAC secret is returned on this response exactly once — store it server-side; subsequent reads omit it. Subscriptions take effect for eligibility checks started after this request returns. Checks already in flight at the moment of creation will not deliver to this subscription.",
        "tags": [
          "Webhooks"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "maxLength": 2048,
                    "format": "uri",
                    "description": "HTTPS URL that will receive event deliveries. Plain HTTP and private/loopback hosts are rejected.",
                    "example": "https://example.com/hooks/fuse"
                  },
                  "secret": {
                    "type": "string",
                    "minLength": 32,
                    "maxLength": 256,
                    "pattern": "^[\\x20-\\x7E]+$",
                    "description": "Optional caller-supplied HMAC secret used to sign deliveries. Most integrators should omit this and let the server generate one; the generated value is returned exactly once on create."
                  }
                },
                "required": [
                  "url"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden / insufficient scope"
          },
          "404": {
            "description": "Not found"
          },
          "422": {
            "description": "Validation error"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Feature disabled"
          }
        }
      }
    }
  },
  "webhooks": {}
}