{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/mojeeb-app/json-schema/mojeeb-app-ad-schema.json",
  "title": "Ad",
  "description": "A Meta ad customers reached the agent through, as the taps describe it, with what it brought in. The counts are read from the agent's touchpoints and comments when you ask, so they are always current.",
  "x-generated": "2026-11-19",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/mojeeb-app-openapi.yaml#/components/schemas/Ad",
  "type": "object",
  "required": [
    "id",
    "agent_id",
    "meta_ad_id",
    "title",
    "media_type",
    "image_url",
    "product_id",
    "first_seen_at",
    "last_seen_at",
    "taps",
    "taps_facebook",
    "taps_instagram",
    "taps_whatsapp",
    "comment_replies",
    "conversations_touched",
    "contacts_touched",
    "leads_touched",
    "comments_on_posts",
    "posts",
    "tool_runs",
    "tool_runs_by_tool"
  ],
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid",
      "description": "Mojeeb's id for the ad: a conversation's `latest_ad_id`, and `ad.id` on a touch in `attribution`."
    },
    "agent_id": {
      "type": "string",
      "format": "uuid"
    },
    "meta_ad_id": {
      "type": "string",
      "description": "The ad id as Ads Manager shows it."
    },
    "title": {
      "type": [
        "string",
        "null"
      ],
      "description": "The ad's headline as the tap carried it; null when Meta sent none."
    },
    "media_type": {
      "type": [
        "string",
        "null"
      ],
      "description": "`image` or `video`, when known."
    },
    "image_url": {
      "type": [
        "string",
        "null"
      ],
      "description": "The ad's image or video thumbnail, when known; a Meta CDN link that can expire."
    },
    "product_id": {
      "type": [
        "string",
        "null"
      ],
      "description": "The catalog product the ad featured, when it did."
    },
    "first_seen_at": {
      "type": "string",
      "format": "date-time",
      "description": "When Mojeeb first saw the ad (a tap, or an Instagram comment on its ad media); the list's order."
    },
    "last_seen_at": {
      "type": "string",
      "format": "date-time",
      "description": "When Mojeeb last saw the ad (a tap, or an Instagram comment on its ad media); what `active_since` follows."
    },
    "taps": {
      "type": "integer",
      "description": "Taps on the ad across all channels (ad, post and product taps), whether they opened a conversation or landed on an existing one."
    },
    "taps_facebook": {
      "type": "integer",
      "description": "Taps from Messenger."
    },
    "taps_instagram": {
      "type": "integer",
      "description": "Taps from Instagram."
    },
    "taps_whatsapp": {
      "type": "integer",
      "description": "Taps from WhatsApp."
    },
    "comment_replies": {
      "type": "integer",
      "description": "Private replies sent to comments on the ad's own post (an Instagram ad's media or a Facebook dark post), one per comment. Comments on a boosted published post are not attributed to an ad."
    },
    "conversations_touched": {
      "type": "integer",
      "description": "Distinct conversations the ad brought in or touched, taps and comment replies together."
    },
    "contacts_touched": {
      "type": "integer",
      "description": "Distinct contacts the ad's taps and comment replies reached, whether or not their conversation exists yet."
    },
    "leads_touched": {
      "type": "integer",
      "description": "Leads captured while the ad was the conversation's latest touch."
    },
    "comments_on_posts": {
      "type": "integer",
      "description": "Every comment Mojeeb received on the posts the ad runs on, replies to comments and hidden ones included."
    },
    "posts": {
      "type": "integer",
      "description": "Posts the ad is known to run on, including ones Mojeeb has not seen a comment on yet."
    },
    "tool_runs": {
      "type": "integer",
      "description": "Successful tool runs (bookings, sheet rows, API calls, lead captures) that happened while the ad was the conversation's latest touch; list them with `listToolRuns` and `ad_id`."
    },
    "tool_runs_by_tool": {
      "type": "object",
      "additionalProperties": {
        "type": "integer"
      },
      "description": "The same runs split by tool: each key is a tool id (a custom API tool's id, or the id `listToolRuns` shows as `tool.id`), each value its successful runs for this ad. Includes the built-in lead capture. Empty when nothing ran."
    }
  }
}