{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "imports-v2/activities.json",
  "title": "Activities",
  "description": "One step in the life of a card. A step is either a change of the card (it was created, moved inside its board, taken off a board or put on another one) or a change of the people on it (a person became responsible or stopped being responsible, a person joined the card as a member or was removed). Write one record per step when `timeline_mode` is `explicit`. The changes of a card are ordered by `created_at`, and changes with the same `created_at` are one change of the card: a move is alone at its time, and a change of board is a `card_leave_board` and a `card_join_board` with the same `created_at`, the leave coming first. `card_add` is the first change. `card_history` keeps a snapshot of the card after every change except the last. A step about people is not a change of the card: it needs no snapshot and makes no new state of the card, and the import shows it in the card history at its `created_at`, with the state of the card at that time. A person is on the card as a member until removed, and the responsible person stays a member after being relieved, so a person who is no longer on the card is relieved first and then removed. At most one person is responsible at a time, so the previous responsible person is relieved before the next one is assigned. A person is assigned before being relieved or removed. The people who are on the card now are written in `card_members`. With `explicit`, the `card_add` of a card is its creation. With `current_state_only` leave this resource out; the cards then have no steps.",
  "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."
    },
    "action": {
      "type": "string",
      "enum": [
        "card_add",
        "card_move",
        "card_leave_board",
        "card_join_board",
        "card_assign_responsible",
        "card_relieve_responsible",
        "card_assign_member",
        "card_remove_member"
      ],
      "description": "What happened. `card_add` (the card was created), `card_move` (moved inside one board), `card_leave_board` or `card_join_board` (a change of board is a leave and a join) decide the shape of `payload`. `card_assign_responsible` and `card_relieve_responsible` are about the responsible person of the card, `card_assign_member` and `card_remove_member` about a member; they name the person in `payload.user_ref`. A person who is no longer on the card at all is two steps: `card_relieve_responsible`, then `card_remove_member`."
    },
    "card_ref": {
      "type": "string",
      "minLength": 1,
      "maxLength": 512,
      "x-ref": "cards",
      "description": "The card the action happened to, by its external_id (for example `k-mrr`)."
    },
    "author_ref": {
      "type": [
        "string",
        "null"
      ],
      "minLength": 1,
      "maxLength": 512,
      "x-ref": "users",
      "description": "The user who did the action, by the external_id of a `users` record, for example `u-ava`. Leave it out or use null when the user is unknown or has left. The steps of one change of the card, that is its `card_add`, `card_move`, `card_leave_board` and `card_join_board` steps with the same `created_at`, name the same user."
    },
    "created_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": "When the action happened, for example `2026-01-12T09:30:00Z`."
    },
    "payload": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "board_ref": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512,
              "x-ref": "boards",
              "description": "Board the card is created on (`card_add`) or arrives on (`card_join_board`)."
            },
            "column_ref": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512,
              "x-ref": "columns",
              "description": "Column of that board the card is put in."
            },
            "lane_ref": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512,
              "x-ref": "lanes",
              "description": "Lane of that board the card is put in; absent means the first lane."
            }
          },
          "required": [
            "board_ref",
            "column_ref"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "board_ref": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512,
              "x-ref": "boards",
              "description": "For `card_leave_board`: the board the card leaves."
            }
          },
          "required": [
            "board_ref"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "from": {
              "type": "object",
              "properties": {
                "board_ref": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 512,
                  "x-ref": "boards",
                  "description": "Board of the card; a move stays on one board."
                },
                "column_ref": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 512,
                  "x-ref": "columns",
                  "description": "Column the card leaves."
                },
                "lane_ref": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 512,
                  "x-ref": "lanes",
                  "description": "Lane the card leaves; absent means the first lane."
                }
              },
              "required": [
                "board_ref",
                "column_ref"
              ],
              "additionalProperties": false,
              "description": "Place of the card before the move."
            },
            "to": {
              "type": "object",
              "properties": {
                "board_ref": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 512,
                  "x-ref": "boards",
                  "description": "Board of the card, the same as `from.board_ref`."
                },
                "column_ref": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 512,
                  "x-ref": "columns",
                  "description": "Column the card moves to."
                },
                "lane_ref": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 512,
                  "x-ref": "lanes",
                  "description": "Lane the card moves to; absent means the first lane."
                }
              },
              "required": [
                "board_ref",
                "column_ref"
              ],
              "additionalProperties": false,
              "description": "Place of the card after the move. It is on the same board as from."
            }
          },
          "required": [
            "from",
            "to"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "user_ref": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512,
              "x-ref": "users",
              "description": "The person the step is about, by the external_id of a `users` record, for example `u-liam`."
            }
          },
          "required": [
            "user_ref"
          ],
          "additionalProperties": false
        }
      ],
      "description": "Details of the action. `card_add` and `card_join_board`: `board_ref`, `column_ref` and an optional `lane_ref`. `card_leave_board`: `board_ref`. `card_move`: `from` and `to` with the same fields, both on one board. The four steps about people: `user_ref`."
    }
  },
  "required": [
    "external_id",
    "action",
    "card_ref",
    "created_at",
    "payload"
  ],
  "additionalProperties": false,
  "allOf": [
    {
      "if": {
        "properties": {
          "action": {
            "enum": [
              "card_add",
              "card_join_board"
            ]
          }
        },
        "required": [
          "action"
        ]
      },
      "then": {
        "properties": {
          "payload": {
            "type": "object",
            "properties": {
              "board_ref": {
                "type": "string",
                "minLength": 1,
                "maxLength": 512,
                "x-ref": "boards",
                "description": "Board the card is created on (`card_add`) or arrives on (`card_join_board`)."
              },
              "column_ref": {
                "type": "string",
                "minLength": 1,
                "maxLength": 512,
                "x-ref": "columns",
                "description": "Column of that board the card is put in."
              },
              "lane_ref": {
                "type": "string",
                "minLength": 1,
                "maxLength": 512,
                "x-ref": "lanes",
                "description": "Lane of that board the card is put in; absent means the first lane."
              }
            },
            "required": [
              "board_ref",
              "column_ref"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "action": {
            "enum": [
              "card_leave_board"
            ]
          }
        },
        "required": [
          "action"
        ]
      },
      "then": {
        "properties": {
          "payload": {
            "type": "object",
            "properties": {
              "board_ref": {
                "type": "string",
                "minLength": 1,
                "maxLength": 512,
                "x-ref": "boards",
                "description": "For `card_leave_board`: the board the card leaves."
              }
            },
            "required": [
              "board_ref"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "action": {
            "enum": [
              "card_assign_responsible",
              "card_relieve_responsible",
              "card_assign_member",
              "card_remove_member"
            ]
          }
        },
        "required": [
          "action"
        ]
      },
      "then": {
        "properties": {
          "payload": {
            "type": "object",
            "properties": {
              "user_ref": {
                "type": "string",
                "minLength": 1,
                "maxLength": 512,
                "x-ref": "users",
                "description": "The person the step is about, by the external_id of a `users` record, for example `u-liam`."
              }
            },
            "required": [
              "user_ref"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "action": {
            "enum": [
              "card_move"
            ]
          }
        },
        "required": [
          "action"
        ]
      },
      "then": {
        "properties": {
          "payload": {
            "type": "object",
            "properties": {
              "from": {
                "type": "object",
                "properties": {
                  "board_ref": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 512,
                    "x-ref": "boards",
                    "description": "Board of the card; a move stays on one board."
                  },
                  "column_ref": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 512,
                    "x-ref": "columns",
                    "description": "Column the card leaves."
                  },
                  "lane_ref": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 512,
                    "x-ref": "lanes",
                    "description": "Lane the card leaves; absent means the first lane."
                  }
                },
                "required": [
                  "board_ref",
                  "column_ref"
                ],
                "additionalProperties": false,
                "description": "Place of the card before the move."
              },
              "to": {
                "type": "object",
                "properties": {
                  "board_ref": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 512,
                    "x-ref": "boards",
                    "description": "Board of the card, the same as `from.board_ref`."
                  },
                  "column_ref": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 512,
                    "x-ref": "columns",
                    "description": "Column the card moves to."
                  },
                  "lane_ref": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 512,
                    "x-ref": "lanes",
                    "description": "Lane the card moves to; absent means the first lane."
                  }
                },
                "required": [
                  "board_ref",
                  "column_ref"
                ],
                "additionalProperties": false,
                "description": "Place of the card after the move. It is on the same board as from."
              }
            },
            "required": [
              "from",
              "to"
            ],
            "additionalProperties": false
          }
        }
      }
    }
  ]
}
