{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "imports-v2/card_history.json",
  "title": "Card history",
  "description": "A snapshot of an earlier state of a card: the card as it was before its next change. Use it with `timeline_mode` `explicit`. A card changes once for every group of its `card_add`, `card_move`, `card_leave_board` and `card_join_board` steps in `activities` that share a `created_at`; steps about people do not change the card. Write one snapshot for every change except the last, with no gaps and no repeats. A snapshot keeps the title, description, board, column, lane, type, owner, ASAP flag, due date, size, estimate, and planned dates; custom property values are not kept, and an earlier state is never archived. Who made a change is the `author_ref` of its steps in `activities`. Nothing is guessed or filled in: a history that contradicts the card or the activities is rejected.",
  "type": "object",
  "properties": {
    "external_id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 512,
      "description": "Your own identifier of the record, for example `k-mrr`, unique within the resource across all of its files and case sensitive. Other records refer to this one by it."
    },
    "card_ref": {
      "type": "string",
      "minLength": 1,
      "maxLength": 512,
      "x-ref": "cards",
      "description": "The card this snapshot belongs to. Give the external_id of a `cards` record."
    },
    "changed_at": {
      "type": "string",
      "format": "date-time",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})$",
      "description": "Time of the change that produced this state; it equals the `created_at` of the card actions of that change. A card has at most one snapshot for a `changed_at`."
    },
    "snapshot": {
      "type": "object",
      "properties": {
        "title": {
          "type": "string",
          "minLength": 1,
          "maxLength": 1024,
          "description": "Card title."
        },
        "description": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "format": {
              "type": "string",
              "enum": [
                "plain_text",
                "markdown",
                "html"
              ]
            },
            "text": {
              "type": "string"
            }
          },
          "required": [
            "format",
            "text"
          ],
          "additionalProperties": false,
          "x-link-tokens": [
            {
              "scheme": "attachment",
              "resource": "attachments"
            },
            {
              "scheme": "card",
              "resource": "cards"
            },
            {
              "scheme": "document",
              "resource": "documents"
            }
          ],
          "description": "Card description."
        },
        "board_ref": {
          "type": "string",
          "minLength": 1,
          "maxLength": 512,
          "x-ref": "boards",
          "description": "Board of the card."
        },
        "column_ref": {
          "type": "string",
          "minLength": 1,
          "maxLength": 512,
          "x-ref": "columns",
          "description": "Column of the card."
        },
        "lane_ref": {
          "type": [
            "string",
            "null"
          ],
          "minLength": 1,
          "maxLength": 512,
          "x-ref": "lanes",
          "description": "Lane the card was in at that state, a lane of `board_ref`. Absent or null means the first lane of that board, that is the first `lanes` record of the board."
        },
        "type_ref": {
          "type": "string",
          "minLength": 1,
          "maxLength": 512,
          "x-ref": "card_types",
          "description": "Type of the card."
        },
        "owner_ref": {
          "type": [
            "string",
            "null"
          ],
          "minLength": 1,
          "maxLength": 512,
          "x-ref": "users",
          "description": "Owner of the card."
        },
        "asap": {
          "type": "boolean",
          "description": "Whether the card is marked as urgent."
        },
        "due_date": {
          "anyOf": [
            {
              "oneOf": [
                {
                  "type": "object",
                  "properties": {
                    "precision": {
                      "type": "string",
                      "enum": [
                        "date"
                      ],
                      "description": "Always date."
                    },
                    "value": {
                      "type": "string",
                      "format": "date",
                      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                    }
                  },
                  "required": [
                    "precision",
                    "value"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "precision": {
                      "type": "string",
                      "enum": [
                        "date_time"
                      ],
                      "description": "Always date_time."
                    },
                    "value": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})$"
                    }
                  },
                  "required": [
                    "precision",
                    "value"
                  ],
                  "additionalProperties": false
                }
              ]
            },
            {
              "type": "null"
            }
          ],
          "description": "Due date."
        },
        "size": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "value": {
                  "type": "number",
                  "description": "Numeric size."
                },
                "unit": {
                  "type": "string",
                  "maxLength": 256,
                  "description": "Unit of `value`, for example `SP` for story points or `h` for hours. Without `display` the card shows the value and the unit together, for example `3 SP`."
                },
                "display": {
                  "type": "string",
                  "maxLength": 267,
                  "description": "The size as the card shows it, for example `3 SP`, or `XL` for a T-shirt size. Give `value`, `display` or both: without `display` the card shows `value` and `unit` together; a size that is not a number, such as `XL`, needs only `display`. Charts count only `value`."
                }
              },
              "required": [],
              "additionalProperties": false,
              "anyOf": [
                {
                  "required": [
                    "value"
                  ]
                },
                {
                  "required": [
                    "display"
                  ]
                }
              ]
            },
            {
              "type": "null"
            }
          ],
          "description": "Card size."
        },
        "estimate_workload": {
          "type": [
            "number",
            "null"
          ],
          "minimum": 0,
          "maximum": 99999.99,
          "description": "Estimated workload in hours, up to two decimal places."
        },
        "planned_start": {
          "anyOf": [
            {
              "oneOf": [
                {
                  "type": "object",
                  "properties": {
                    "precision": {
                      "type": "string",
                      "enum": [
                        "date"
                      ],
                      "description": "Always date."
                    },
                    "value": {
                      "type": "string",
                      "format": "date",
                      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                    }
                  },
                  "required": [
                    "precision",
                    "value"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "precision": {
                      "type": "string",
                      "enum": [
                        "date_time"
                      ],
                      "description": "Always date_time."
                    },
                    "value": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})$"
                    }
                  },
                  "required": [
                    "precision",
                    "value"
                  ],
                  "additionalProperties": false
                }
              ]
            },
            {
              "type": "null"
            }
          ],
          "description": "Planned start."
        },
        "planned_end": {
          "anyOf": [
            {
              "oneOf": [
                {
                  "type": "object",
                  "properties": {
                    "precision": {
                      "type": "string",
                      "enum": [
                        "date"
                      ],
                      "description": "Always date."
                    },
                    "value": {
                      "type": "string",
                      "format": "date",
                      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                    }
                  },
                  "required": [
                    "precision",
                    "value"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "precision": {
                      "type": "string",
                      "enum": [
                        "date_time"
                      ],
                      "description": "Always date_time."
                    },
                    "value": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})$"
                    }
                  },
                  "required": [
                    "precision",
                    "value"
                  ],
                  "additionalProperties": false
                }
              ]
            },
            {
              "type": "null"
            }
          ],
          "description": "Planned end."
        }
      },
      "required": [
        "title",
        "board_ref",
        "column_ref",
        "type_ref"
      ],
      "additionalProperties": false,
      "description": "The fields of the card in that state: `title`, `board_ref`, `column_ref` and `type_ref` are required; `description`, `lane_ref`, `owner_ref`, `asap`, `due_date`, `size`, `estimate_workload`, `planned_start` and `planned_end` are optional."
    }
  },
  "required": [
    "external_id",
    "card_ref",
    "changed_at",
    "snapshot"
  ],
  "additionalProperties": false
}
