{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://tikkado.com/plan-schema.json",
  "title": "Tikkado plan",
  "description": "A set of repeating challenges that the Tikkado app adds as a new group in one scan; scanning a plan with the same id again updates it. Deliver it as https://tikkado.com/plan#<base64url or percent-encoded JSON>. Instructions: https://tikkado.com/ai",
  "type": "object",
  "required": [
    "tikkado",
    "challenges"
  ],
  "properties": {
    "tikkado": {
      "const": 1,
      "description": "Format version."
    },
    "id": {
      "type": "string",
      "pattern": "^[A-Za-z0-9_.-]{1,64}$",
      "description": "Recommended. A stable id for this plan, unique to this user's plan (e.g. a short slug plus a few random characters). Keep it the same when you send an updated version: scanning a plan whose id the user already has updates those challenges instead of adding them again."
    },
    "group": {
      "type": "string",
      "maxLength": 30,
      "description": "Name of the new group. Optional: the app asks if it is missing."
    },
    "emoji": {
      "type": "string",
      "maxLength": 8,
      "description": "One emoji for the group."
    },
    "challenges": {
      "type": "array",
      "minItems": 1,
      "maxItems": 15,
      "items": {
        "type": "object",
        "required": [
          "title",
          "frequency",
          "minutes"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_.-]{1,64}$",
            "description": "Recommended. A stable id for this challenge, unique within the plan. Keep it when you change the challenge in an update, so the app recognises it even after a new title. Without it the app matches on title."
          },
          "title": {
            "type": "string",
            "minLength": 1,
            "maxLength": 60,
            "description": "What to do, concrete, in the user's language. Put sets, reps or pace in it."
          },
          "kind": {
            "enum": [
              "learning",
              "fitness",
              "household",
              "mindfulness",
              "study",
              "social",
              "other"
            ],
            "default": "other"
          },
          "frequency": {
            "enum": [
              "daily",
              "every_other_day",
              "every_3_days",
              "3x_week",
              "2x_week",
              "weekly",
              "every_2_weeks",
              "2x_month",
              "monthly"
            ],
            "description": "How often it comes back. NxWeek and 2x_month are spread evenly over the week or month."
          },
          "minutes": {
            "enum": [
              0.5,
              1,
              2,
              5,
              10,
              15,
              20,
              30,
              45,
              60,
              90,
              120
            ],
            "description": "How long one check takes. Other positive numbers are rounded to the nearest allowed value."
          },
          "checks": {
            "type": "integer",
            "minimum": 1,
            "maximum": 20,
            "default": 1,
            "description": "How many times per session, e.g. sets."
          },
          "start_in_days": {
            "type": "integer",
            "minimum": 0,
            "maximum": 365,
            "default": 0,
            "description": "Days from today before it starts, to build up in phases. There are no end dates."
          }
        }
      }
    }
  }
}
