{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/flexpa/json-schema/flexpa-consent-schema.json",
  "title": "Consent",
  "x-generated": "2026-11-27",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/flexpa-openapi.yml#/components/schemas/Consent",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "state": {
      "type": "string",
      "enum": [
        "CREATED",
        "AUTHORIZED",
        "EXCHANGED",
        "ABANDONED",
        "REVOKED"
      ]
    },
    "mode": {
      "type": "string",
      "enum": [
        "TEST",
        "LIVE"
      ]
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "updatedAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "consentedAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "user": {
      "type": [
        "object",
        "null"
      ]
    },
    "patientAuthorizations": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/PatientAuthorization"
      }
    }
  },
  "$defs": {
    "PatientAuthorization": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "type": {
          "type": "string",
          "description": "How the patient connected, for example OAUTH, CREDENTIALS or IAL2."
        },
        "state": {
          "type": "string",
          "enum": [
            "CREATED",
            "AUTHORIZED",
            "EXCHANGED",
            "ERRORED",
            "ABANDONED",
            "REVOKED",
            "AUTHORIZING",
            "BOUNCED",
            "EXPIRED"
          ]
        },
        "usage": {
          "type": "string",
          "enum": [
            "ONE_TIME",
            "MULTIPLE"
          ]
        },
        "patient": {
          "type": [
            "string",
            "null"
          ]
        },
        "identityProvider": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "CLEAR",
            "IDME",
            "PERSONA",
            null
          ]
        },
        "active": {
          "type": "boolean"
        },
        "endpoint": {
          "type": [
            "object",
            "null"
          ]
        },
        "createdAt": {
          "type": "string",
          "format": "date-time"
        },
        "authorizedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "exchangedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "revokedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "expiredAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "sync": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "tefcaOutcomes": {
              "type": "object",
              "additionalProperties": true,
              "description": "Present on IAL2 patient authorizations only when the request passed `include=tefcaOutcomes` and a qualifying sync has completed. See https://www.flexpa.com/docs/consent."
            }
          }
        }
      }
    }
  }
}