{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/mentio-dev/json-schema/mentio-dev-attention-item-schema.json",
  "title": "AttentionItem",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/mentio-dev-attention-api-openapi.yml#/components/schemas/AttentionItem",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "description": "Attention item id (att_...)."
    },
    "kind": {
      "type": "string",
      "enum": [
        "mention.spike",
        "sentiment.negative_spike",
        "keyword.noisy",
        "channel.failing",
        "feed.failing",
        "feed.recovered"
      ],
      "description": "mention.spike: far more mentions in the last hour than the keyword usually gets. sentiment.negative_spike: the negative share of the last 24 hours jumped. keyword.noisy: most scored matches are noise. channel.failing: the channel's last sends all failed. feed.failing: a workspace feed failed its last 3 hourly reads. feed.recovered: it read again after failing."
    },
    "status": {
      "type": "string",
      "enum": [
        "open",
        "resolved",
        "dismissed"
      ],
      "description": "open: the condition holds. resolved: it no longer does. dismissed: a person put it away; it does not come back for the same episode."
    },
    "subject": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "keyword",
            "channel",
            "feed"
          ],
          "description": "keyword, channel or feed."
        },
        "id": {
          "type": "string",
          "description": "The keyword (kw_...), the channel (dest_...) or the feed (fd_...)."
        }
      },
      "required": [
        "type",
        "id"
      ],
      "description": "What the item is about."
    },
    "title": {
      "type": "string",
      "description": "One line for a person: what happened."
    },
    "openedAt": {
      "type": "string",
      "description": "When the condition was first seen."
    },
    "resolvedAt": {
      "type": [
        "string",
        "null"
      ],
      "description": "When it no longer held; null while it does."
    },
    "dismissedAt": {
      "type": [
        "string",
        "null"
      ],
      "description": "When a person dismissed it; null if nobody did."
    },
    "data": {
      "anyOf": [
        {
          "$ref": "#/$defs/MentionSpikeEventData"
        },
        {
          "$ref": "#/$defs/NegativeSpikeEventData"
        },
        {
          "$ref": "#/$defs/KeywordNoisyEventData"
        },
        {
          "$ref": "#/$defs/ChannelFailingEventData"
        },
        {
          "$ref": "#/$defs/FeedFailingEventData"
        }
      ],
      "description": "The facts as they stood when it opened: the same object the account event of the same name carries as `data`."
    }
  },
  "required": [
    "id",
    "kind",
    "status",
    "subject",
    "title",
    "openedAt",
    "resolvedAt",
    "dismissedAt",
    "data"
  ],
  "$defs": {
    "ChannelFailingEventData": {
      "type": "object",
      "properties": {
        "attentionId": {
          "type": "string",
          "description": "The attention item (att_...): GET /v1/attention lists it, POST /v1/attention/{id}/dismiss puts it away."
        },
        "url": {
          "type": "string",
          "description": "Where to look in the dashboard."
        },
        "channel": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "description": "Channel id (dest_...)."
            },
            "kind": {
              "type": "string",
              "enum": [
                "slack",
                "email",
                "webhook",
                "telegram"
              ],
              "description": "slack, email, webhook or telegram."
            },
            "label": {
              "type": "string",
              "description": "The channel's label."
            }
          },
          "required": [
            "id",
            "kind",
            "label"
          ],
          "description": "The channel whose sends fail."
        },
        "failures": {
          "type": "integer",
          "minimum": 0,
          "description": "Failed sends in a row within the last 24 hours."
        },
        "lastError": {
          "type": [
            "string",
            "null"
          ],
          "description": "The newest failure, as the transport reported it."
        },
        "since": {
          "type": "string",
          "description": "The oldest of those failures."
        }
      },
      "required": [
        "attentionId",
        "url",
        "channel",
        "failures",
        "lastError",
        "since"
      ]
    },
    "FeedFailingEventData": {
      "type": "object",
      "properties": {
        "attentionId": {
          "type": "string",
          "description": "The attention item (att_...): GET /v1/attention lists it, POST /v1/attention/{id}/dismiss puts it away."
        },
        "url": {
          "type": "string",
          "description": "Where to look in the dashboard."
        },
        "feed": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "description": "Feed id (fd_...)."
            },
            "url": {
              "type": "string",
              "description": "The feed address."
            },
            "title": {
              "type": [
                "string",
                "null"
              ],
              "description": "The feed's own title, when it has one."
            }
          },
          "required": [
            "id",
            "url",
            "title"
          ],
          "description": "The workspace feed (GET /v1/feeds/{id})."
        },
        "reason": {
          "type": "string",
          "enum": [
            "login_required",
            "login_expired",
            "blocked",
            "not_found",
            "not_a_feed",
            "unreachable"
          ],
          "description": "login_required: the feed answers a sign-in or access-denied page (connect it with the forum's sign-in, auth). login_expired: the same on a feed that has a sign-in: copy a fresh cookie. blocked: a 403, a 429 or a bot check. not_found: the feed is gone. not_a_feed: the address answers a page, not RSS or Atom. unreachable: no answer or a server error."
        },
        "detail": {
          "type": [
            "string",
            "null"
          ],
          "description": "What the last failed read saw, in a few words."
        },
        "failingSince": {
          "type": "string",
          "description": "When it started failing: the third failed read in a row."
        },
        "keywordsAffected": {
          "type": "integer",
          "minimum": 0,
          "description": "Live keywords of the workspace that read workspace feeds: what misses its posts while it fails."
        }
      },
      "required": [
        "attentionId",
        "url",
        "feed",
        "reason",
        "detail",
        "failingSince",
        "keywordsAffected"
      ]
    },
    "KeywordNoisyEventData": {
      "type": "object",
      "properties": {
        "attentionId": {
          "type": "string",
          "description": "The attention item (att_...): GET /v1/attention lists it, POST /v1/attention/{id}/dismiss puts it away."
        },
        "url": {
          "type": "string",
          "description": "Where to look in the dashboard."
        },
        "keyword": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "description": "Keyword id (kw_...)."
            },
            "term": {
              "type": "string",
              "description": "The tracked term."
            },
            "kind": {
              "type": "string",
              "enum": [
                "brand",
                "competitor",
                "topic"
              ],
              "description": "brand, competitor or topic."
            },
            "name": {
              "type": "string",
              "description": "The keyword as Mentio names it: the term, or \"term (Group)\" outside the default group."
            },
            "groupId": {
              "type": "string",
              "description": "Its group (grp_...)."
            }
          },
          "required": [
            "id",
            "term",
            "kind",
            "name",
            "groupId"
          ],
          "description": "The keyword the item is about."
        },
        "windowDays": {
          "type": "integer",
          "minimum": 0,
          "description": "The window the noise is measured over, in days (since the keyword's last change when that is inside it)."
        },
        "scored": {
          "type": "integer",
          "minimum": 0,
          "description": "Matches the classifier scored in that window."
        },
        "relevant": {
          "type": "integer",
          "minimum": 0,
          "description": "Of those, relevant."
        },
        "noiseShare": {
          "type": "number",
          "minimum": 0,
          "maximum": 1,
          "description": "The share scored under the relevance line. Every match bills, relevant or not."
        }
      },
      "required": [
        "attentionId",
        "url",
        "keyword",
        "windowDays",
        "scored",
        "relevant",
        "noiseShare"
      ]
    },
    "MentionSpikeEventData": {
      "type": "object",
      "properties": {
        "attentionId": {
          "type": "string",
          "description": "The attention item (att_...): GET /v1/attention lists it, POST /v1/attention/{id}/dismiss puts it away."
        },
        "url": {
          "type": "string",
          "description": "Where to look in the dashboard."
        },
        "keyword": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "description": "Keyword id (kw_...)."
            },
            "term": {
              "type": "string",
              "description": "The tracked term."
            },
            "kind": {
              "type": "string",
              "enum": [
                "brand",
                "competitor",
                "topic"
              ],
              "description": "brand, competitor or topic."
            },
            "name": {
              "type": "string",
              "description": "The keyword as Mentio names it: the term, or \"term (Group)\" outside the default group."
            },
            "groupId": {
              "type": "string",
              "description": "Its group (grp_...)."
            }
          },
          "required": [
            "id",
            "term",
            "kind",
            "name",
            "groupId"
          ],
          "description": "The keyword the item is about."
        },
        "window": {
          "type": "object",
          "properties": {
            "from": {
              "type": "string",
              "description": "Start, inclusive."
            },
            "to": {
              "type": "string",
              "description": "End, exclusive."
            }
          },
          "required": [
            "from",
            "to"
          ],
          "description": "The stretch of time the counts cover, by match time."
        },
        "matches": {
          "type": "integer",
          "minimum": 0,
          "description": "Fresh matches in the hour: posts published at most 6 hours before they matched. Look-backs and free reviews never count."
        },
        "relevant": {
          "type": "integer",
          "minimum": 0,
          "description": "Of those, scored relevant so far."
        },
        "baseline": {
          "type": "object",
          "properties": {
            "meanPerHour": {
              "type": "number",
              "minimum": 0,
              "description": "Fresh matches per hour over the baseline."
            },
            "stddevPerHour": {
              "type": "number",
              "minimum": 0,
              "description": "Their standard deviation."
            },
            "hours": {
              "type": "integer",
              "minimum": 0,
              "description": "Hours in the baseline: the week before the window, or since the keyword started listening."
            }
          },
          "required": [
            "meanPerHour",
            "stddevPerHour",
            "hours"
          ],
          "description": "What the keyword usually gets."
        }
      },
      "required": [
        "attentionId",
        "url",
        "keyword",
        "window",
        "matches",
        "relevant",
        "baseline"
      ]
    },
    "NegativeSpikeEventData": {
      "type": "object",
      "properties": {
        "attentionId": {
          "type": "string",
          "description": "The attention item (att_...): GET /v1/attention lists it, POST /v1/attention/{id}/dismiss puts it away."
        },
        "url": {
          "type": "string",
          "description": "Where to look in the dashboard."
        },
        "keyword": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "description": "Keyword id (kw_...)."
            },
            "term": {
              "type": "string",
              "description": "The tracked term."
            },
            "kind": {
              "type": "string",
              "enum": [
                "brand",
                "competitor",
                "topic"
              ],
              "description": "brand, competitor or topic."
            },
            "name": {
              "type": "string",
              "description": "The keyword as Mentio names it: the term, or \"term (Group)\" outside the default group."
            },
            "groupId": {
              "type": "string",
              "description": "Its group (grp_...)."
            }
          },
          "required": [
            "id",
            "term",
            "kind",
            "name",
            "groupId"
          ],
          "description": "The keyword the item is about."
        },
        "window": {
          "type": "object",
          "properties": {
            "from": {
              "type": "string",
              "description": "Start, inclusive."
            },
            "to": {
              "type": "string",
              "description": "End, exclusive."
            }
          },
          "required": [
            "from",
            "to"
          ],
          "description": "The stretch of time the counts cover, by match time."
        },
        "negative": {
          "type": "integer",
          "minimum": 0,
          "description": "Relevant matches scored negative in the window."
        },
        "relevant": {
          "type": "integer",
          "minimum": 0,
          "description": "Relevant matches in the window."
        },
        "share": {
          "type": "number",
          "minimum": 0,
          "maximum": 1,
          "description": "negative / relevant."
        },
        "baseline": {
          "type": "object",
          "properties": {
            "negative": {
              "type": "integer",
              "minimum": 0,
              "description": "Negative relevant matches in the 7 days before the window."
            },
            "relevant": {
              "type": "integer",
              "minimum": 0,
              "description": "Relevant matches in those 7 days."
            },
            "share": {
              "type": "number",
              "minimum": 0,
              "maximum": 1,
              "description": "The usual negative share, smoothed so a quiet week still has one."
            }
          },
          "required": [
            "negative",
            "relevant",
            "share"
          ],
          "description": "What the keyword usually reads."
        }
      },
      "required": [
        "attentionId",
        "url",
        "keyword",
        "window",
        "negative",
        "relevant",
        "share",
        "baseline"
      ]
    }
  }
}