{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "imports-v2/comments.json",
  "title": "Comments",
  "description": "A comment on a card, including a reply inside a thread. Give the text in `text` and the time in `created_at`; a reply points at its parent comment with `parent_comment_ref`, which must be a comment of the same card. If the author is unknown leave `author_ref` out and put the name in `author_name`. Files are `attachments` attached to the comment, and reactions are the `emojis` of the comment.",
  "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 the comment is on. Give the external_id of a `cards` record."
    },
    "parent_comment_ref": {
      "type": [
        "string",
        "null"
      ],
      "minLength": 1,
      "maxLength": 512,
      "x-ref": "comments",
      "description": "The comment this one replies to; leave it out for a comment that starts a thread. It must be a comment of the same card."
    },
    "author_ref": {
      "type": [
        "string",
        "null"
      ],
      "minLength": 1,
      "maxLength": 512,
      "x-ref": "users",
      "description": "The user who created the record, by the external_id of a `users` record, for example `u-ava`. Leave it out or use null when the author is unknown or has left."
    },
    "author_name": {
      "type": [
        "string",
        "null"
      ],
      "description": "The name of the author when the author is not a user of the package and `author_ref` is left out. The comment is then shown with the system AI user as its author, and its text starts with a line \"— <name>\" holding this name. Ignored when `author_ref` is given."
    },
    "text": {
      "type": "object",
      "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": "The comment text; give the format with the text."
    },
    "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 comment was written, for example `2026-02-02T10:05:00Z`."
    },
    "updated_at": {
      "type": [
        "string",
        "null"
      ],
      "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 comment was last edited."
    },
    "emojis": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "emoji": {
            "type": "string",
            "minLength": 1,
            "maxLength": 4,
            "description": "The reaction: one emoji as text, for example `\"👍\"` or `\"🎉\"`. Most emojis fit, skin tones included; a combined emoji longer than 4 characters, such as a family emoji, is rejected."
          },
          "user_ref": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "x-ref": "users",
            "description": "The user who reacted, by the external_id of a `users` record."
          }
        },
        "required": [
          "emoji",
          "user_ref"
        ],
        "additionalProperties": false
      },
      "uniqueItems": true,
      "description": "Reactions to the comment, one item per user and emoji, for example `[{\"emoji\": \"👍\", \"user_ref\": \"u-ava\"}]`. A user adds the same emoji to a comment once. Reactions to document comments are not supported.",
      "default": []
    }
  },
  "required": [
    "external_id",
    "card_ref",
    "text",
    "created_at"
  ],
  "additionalProperties": false
}
