{
  "$id": "https://intentschema.org/intents/productivity/calendar/availability/set/v1.json",
  "fqdn": "org.intentschema.productivity.calendar.availability.set.v1",
  "title": "Set calendar availability",
  "description": "Set the user's working hours, focus blocks, or out-of-office windows. The `mode` field selects which.",
  "payload": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "required": [
      "target",
      "object"
    ],
    "properties": {
      "target": {
        "$ref": "https://intentschema.org/common/target/v1.json"
      },
      "object": {
        "type": "object",
        "required": [
          "mode"
        ],
        "properties": {
          "mode": {
            "enum": [
              "working_hours",
              "focus",
              "ooo"
            ],
            "description": "Which availability concept to set."
          },
          "start": {
            "type": "string",
            "format": "date-time"
          },
          "end": {
            "type": "string",
            "format": "date-time"
          },
          "timezone": {
            "type": "string"
          },
          "recurrence": {
            "type": "string",
            "description": "RFC 5545 RRULE for recurring working hours / focus blocks."
          },
          "auto_reply": {
            "type": "string",
            "description": "OOO auto-reply text. Sieve vacation (RFC 5230) on supporting providers."
          }
        }
      },
      "idempotency_key": {
        "type": "string"
      }
    }
  },
  "result": {
    "type": "object",
    "required": [
      "external_id",
      "created_at"
    ],
    "properties": {
      "external_id": {
        "type": "string",
        "description": "Provider-assigned id."
      },
      "created_at": {
        "type": "string",
        "format": "date-time"
      }
    }
  },
  "examples": [
    {
      "name": "set OOO for vacation",
      "value": {
        "target": {
          "system": "google_calendar"
        },
        "object": {
          "mode": "ooo",
          "start": "2026-05-01T00:00:00-07:00",
          "end": "2026-05-08T23:59:59-07:00",
          "auto_reply": "Out of office through May 8; replies will be slow."
        }
      }
    },
    {
      "name": "weekly focus block",
      "value": {
        "target": {
          "system": "google_calendar"
        },
        "object": {
          "mode": "focus",
          "start": "2026-04-21T09:00:00-07:00",
          "end": "2026-04-21T11:00:00-07:00",
          "recurrence": "RRULE:FREQ=WEEKLY;BYDAY=TU,TH"
        }
      }
    }
  ]
}
