{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://developers.youareaccountable.com/schemas/coaching_session.created.json",
  "title": "CoachingSessionCreated",
  "description": "A session or a recurring series is scheduled. Check data.is_recurring to tell the two shapes apart.",
  "type": "object",
  "required": [
    "event_type",
    "data"
  ],
  "properties": {
    "event_type": {
      "const": "coaching_session.created"
    },
    "data": {
      "oneOf": [
        {
          "title": "CoachingSessionCreatedOneSession",
          "description": "One session.",
          "type": "object",
          "required": [
            "medical_record_number",
            "session_id",
            "scheduled_date",
            "meeting_url",
            "status",
            "is_recurring"
          ],
          "properties": {
            "medical_record_number": {
              "type": "string",
              "format": "uuid",
              "description": "The member's medical record number. Always a UUID. Use it to match the event to your own record."
            },
            "plan_name": {
              "type": [
                "string",
                "null"
              ],
              "description": "The member's Accountable plan. Can be null or left out."
            },
            "session_id": {
              "type": "string",
              "description": "The session's ID."
            },
            "scheduled_date": {
              "type": "string",
              "format": "date-time",
              "description": "The scheduled start time."
            },
            "end_time": {
              "type": [
                "string",
                "null"
              ],
              "format": "date-time",
              "description": "The scheduled end time."
            },
            "duration_minutes": {
              "type": [
                "number",
                "null"
              ],
              "description": "The scheduled length."
            },
            "meeting_url": {
              "type": "string",
              "description": "The video link. An empty string when there is none."
            },
            "status": {
              "enum": [
                "scheduled",
                "completed",
                "canceled",
                "no-show"
              ]
            },
            "is_recurring": {
              "const": false
            }
          }
        },
        {
          "title": "CoachingSessionCreatedSeries",
          "description": "A recurring series. One event is sent for the whole series, not one per session.",
          "type": "object",
          "required": [
            "medical_record_number",
            "recurrence_group_id",
            "first_session_date",
            "meeting_url",
            "is_recurring",
            "recurrence_rule"
          ],
          "properties": {
            "medical_record_number": {
              "type": "string",
              "format": "uuid",
              "description": "The member's medical record number. Always a UUID. Use it to match the event to your own record."
            },
            "plan_name": {
              "type": [
                "string",
                "null"
              ],
              "description": "The member's Accountable plan. Can be null or left out."
            },
            "recurrence_group_id": {
              "type": "string",
              "description": "The series ID."
            },
            "first_session_date": {
              "type": "string",
              "format": "date-time",
              "description": "The start time of the first session."
            },
            "duration_minutes": {
              "type": [
                "number",
                "null"
              ],
              "description": "The scheduled length."
            },
            "meeting_url": {
              "type": "string",
              "description": "The video link. An empty string when there is none."
            },
            "is_recurring": {
              "const": true
            },
            "recurrence_rule": {
              "type": [
                "object",
                "null"
              ],
              "description": "How the series repeats.",
              "properties": {
                "frequency": {
                  "enum": [
                    "weekly",
                    "biweekly",
                    "monthly"
                  ]
                },
                "day_of_week": {
                  "type": [
                    "integer",
                    "null"
                  ],
                  "minimum": 0,
                  "maximum": 6,
                  "description": "0 is Sunday, 6 is Saturday."
                },
                "time_utc": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "pattern": "^[0-9]{2}:[0-9]{2}$",
                  "description": "Start time in UTC, as HH:mm."
                },
                "end_date": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "format": "date-time",
                  "description": "When the series ends."
                }
              }
            }
          }
        }
      ]
    }
  },
  "examples": [
    {
      "event_type": "coaching_session.created",
      "data": {
        "medical_record_number": "3f2b8c1e-7a4d-4e9b-9c55-0d6a1f2e8b47",
        "plan_name": "Standard Plan",
        "session_id": "665f1c2ab7e4d90012a3f4c5",
        "scheduled_date": "2026-01-06T15:00:00.000Z",
        "end_time": "2026-01-06T15:30:00.000Z",
        "duration_minutes": 30,
        "meeting_url": "https://example.zoom.us/j/1234567890",
        "status": "scheduled",
        "is_recurring": false
      }
    },
    {
      "event_type": "coaching_session.created",
      "data": {
        "medical_record_number": "3f2b8c1e-7a4d-4e9b-9c55-0d6a1f2e8b47",
        "plan_name": "Standard Plan",
        "recurrence_group_id": "0b9d6c1e-5d2a-4a57-8f43-2f6a9d3c7e10",
        "first_session_date": "2026-01-06T15:00:00.000Z",
        "duration_minutes": 30,
        "meeting_url": "https://example.zoom.us/j/1234567890",
        "is_recurring": true,
        "recurrence_rule": {
          "frequency": "weekly",
          "day_of_week": 2,
          "time_utc": "15:00",
          "end_date": "2026-06-30T00:00:00.000Z"
        }
      }
    }
  ]
}
