{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/memestack-ai/json-schema/memestack-ai-image-record-schema.json",
  "title": "ImageRecord",
  "x-generated": "2026-11-18",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/memestack-ai-openapi.json#/components/schemas/ImageRecord",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "uploader_id": {
      "type": "string"
    },
    "status": {
      "type": "string",
      "enum": [
        "pending",
        "approved",
        "needs_review",
        "rejected"
      ]
    },
    "mime_type": {
      "type": "string"
    },
    "size": {
      "type": "integer",
      "description": "Bytes of the original upload."
    },
    "width": {
      "type": "integer",
      "description": "Width of the ORIGINAL upload, not of the canonical or thumbnail bytes."
    },
    "height": {
      "type": "integer",
      "description": "Height of the ORIGINAL upload."
    },
    "thumb_width": {
      "type": "integer"
    },
    "thumb_height": {
      "type": "integer"
    },
    "caption": {
      "type": [
        "string",
        "null"
      ]
    },
    "alt_text": {
      "type": [
        "string",
        "null"
      ]
    },
    "tags": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "$ref": "#/$defs/ScoredTag"
      },
      "description": "Controlled tags — objects, never bare strings."
    },
    "free_tags": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "$ref": "#/$defs/ScoredTag"
      },
      "description": "Free (AI-written) tags — objects, never bare strings. Disjoint from `tags`."
    },
    "text_in_image": {
      "type": [
        "string",
        "null"
      ],
      "description": "The text printed inside the image (OCR)."
    },
    "meme_template_name": {
      "type": [
        "string",
        "null"
      ],
      "description": "The meme template the image matched, if any."
    },
    "meme_template_id": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid"
    },
    "source_url": {
      "type": [
        "string",
        "null"
      ],
      "description": "Where an imported image came from: a URL for a publisher import (Our World in Data, Eurostat, …), a prefix such as `imgflip:` or `telegram:` otherwise; null for a direct upload."
    },
    "zap_count": {
      "type": "integer"
    },
    "zap_total_sats": {
      "type": [
        "string",
        "integer"
      ],
      "pattern": "^[0-9]+$",
      "description": "Total sats zapped to the image. A 64-bit counter, serialised as a decimal STRING by most routes — parse it, do not assume a JSON number."
    },
    "save_count": {
      "type": "integer"
    },
    "like_count": {
      "type": "integer"
    },
    "view_count": {
      "type": "integer",
      "description": "Views in the last 30 days."
    },
    "view_count_total": {
      "type": "integer",
      "description": "Views older than 30 days; add `view_count` for all recorded views."
    },
    "attribution_url": {
      "type": [
        "string",
        "null"
      ]
    },
    "attribution_name": {
      "type": [
        "string",
        "null"
      ]
    },
    "uploader_display_name": {
      "type": [
        "string",
        "null"
      ]
    },
    "uploader_pubkey": {
      "type": [
        "string",
        "null"
      ]
    },
    "uploader_has_avatar": {
      "type": "boolean"
    },
    "uploader_is_creator": {
      "type": "boolean",
      "description": "Whether the uploader is a Verified Creator now."
    },
    "uploaded_as_creator": {
      "type": "boolean",
      "description": "Whether the image was uploaded as the uploader's own work."
    },
    "uploader_website_url": {
      "type": [
        "string",
        "null"
      ],
      "description": "The uploader's own website URL — populated only for Verified Creator uploads (null otherwise)."
    },
    "uploader_accepts_zaps": {
      "type": "boolean",
      "description": "Whether the uploader can be zapped: they have a Lightning address on their profile, or they are a system uploader (zaps on imported content go to the platform's address). Absent when the row was not joined to its uploader; treat absent as enabled."
    },
    "controversial": {
      "type": "boolean",
      "description": "True when the image is classified controversial. Such images appear only with `content=all`."
    },
    "is_ai_generated": {
      "type": "boolean"
    },
    "has_thumbnail": {
      "type": "boolean"
    },
    "has_canonical": {
      "type": "boolean",
      "description": "False when the original already fits the canonical size, so /canonical serves the original bytes."
    },
    "has_social_card": {
      "type": "boolean"
    },
    "mutation_group_id": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid",
      "description": "The variant group of a meme with tracked variants."
    },
    "is_dominant": {
      "type": "boolean",
      "description": "Whether this is the variant group's representative image."
    },
    "chart": {
      "$ref": "#/$defs/ChartMeta",
      "description": "Present only when MemeStack holds source metadata for the chart in this image."
    },
    "rights": {
      "$ref": "#/$defs/ImageRights",
      "description": "What you may do with the image, as far as MemeStack knows. On every listing, search, /meta and /batch-meta image."
    },
    "image_url": {
      "type": "string",
      "format": "uri",
      "description": "The full image: https://api.memestack.ai/v1/images/{id}/canonical. On the image rows of the listings, search, /meta and /batch-meta answered to a non-admin caller. Not on an admin caller's rows, nor on the compact rows of /v1/images/{id}/similar and /v1/images/{id}/related (build the link from `id` there)."
    },
    "thumbnail_url": {
      "type": "string",
      "format": "uri",
      "description": "A display-sized thumbnail: https://api.memestack.ai/v1/images/{id}/thumbnail?w=384 (a rendition about 384 px wide where one exists). On the same rows as `image_url`, when the image has a thumbnail (has_thumbnail)."
    },
    "page_url": {
      "type": "string",
      "format": "uri",
      "description": "The image's page: https://memestack.ai/gallery/{id}. Link it when you show the image. On the same rows as `image_url`."
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time"
    }
  },
  "$defs": {
    "ChartMeta": {
      "type": "object",
      "description": "Chart metadata for an image (spec 2026-09-19 chart-metadata §2.1, extended by spec 2026-09-25 chart sources §4 for series editions). Present on `/meta` only when MemeStack holds a stored chart-metadata row for the image; every field mirrors packages/shared/src/chart-meta.ts's ChartMetaPublic.",
      "properties": {
        "source": {
          "type": "string",
          "description": "The upstream source key, e.g. 'owid', 'usda_ers', 'eurostat', 'eea'."
        },
        "provenance": {
          "type": "string",
          "enum": [
            "authoritative",
            "extracted"
          ],
          "description": "'authoritative' when the publisher's own metadata proved the fields; 'extracted' when a grounded-LLM pass derived them."
        },
        "title": {
          "type": [
            "string",
            "null"
          ]
        },
        "unit": {
          "type": [
            "string",
            "null"
          ]
        },
        "regions": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "citation_short": {
          "type": [
            "string",
            "null"
          ]
        },
        "citation_long": {
          "type": [
            "string",
            "null"
          ]
        },
        "source_url": {
          "type": [
            "string",
            "null"
          ]
        },
        "dataset_ids": {
          "type": "array",
          "items": {
            "type": "integer"
          },
          "description": "Upstream indicator ids (e.g. OWID's owidVariableId)."
        },
        "render_view": {
          "type": [
            "string",
            "null"
          ],
          "description": "The chart type actually rendered, e.g. 'LineChart', 'map'. Publisher rows carry null (no grapher view)."
        },
        "coverage_kind": {
          "type": "string",
          "enum": [
            "single_year",
            "range",
            "unknown"
          ]
        },
        "rendered_period": {
          "type": [
            "object",
            "null"
          ],
          "description": "A PROVEN period, grounded on the image's own OCR title text. Null when the period could not be proven — never guessed from the dataset's wider history.",
          "properties": {
            "start": {
              "type": "integer"
            },
            "end": {
              "type": "integer"
            },
            "evidence": {
              "type": "string",
              "description": "The OCR substring the period claim was grounded on."
            }
          }
        },
        "dataset_timespan": {
          "type": [
            "object",
            "null"
          ],
          "description": "The INDICATOR's full history — display only. Never a period claim about what THIS image shows; use rendered_period for that.",
          "properties": {
            "start": {
              "type": [
                "integer",
                "null"
              ]
            },
            "end": {
              "type": [
                "integer",
                "null"
              ]
            },
            "raw": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        },
        "snapshot_fetched_at": {
          "type": "string",
          "format": "date-time"
        },
        "data_last_updated": {
          "type": [
            "string",
            "null"
          ],
          "description": "YYYY-MM-DD"
        },
        "data_next_update": {
          "type": [
            "string",
            "null"
          ],
          "description": "YYYY-MM-DD"
        },
        "upstream_last_updated": {
          "type": [
            "string",
            "null"
          ],
          "description": "YYYY-MM-DD"
        },
        "upstream_checked_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "superseded": {
          "type": "boolean",
          "description": "True when the upstream source has published data newer than this snapshot."
        },
        "indicators": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "title": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "description": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "unit": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "timespan": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          }
        },
        "series_key": {
          "type": [
            "string",
            "null"
          ],
          "description": "Editions of one chart (e.g. the same indicator republished in a later year) share this key. Null when the row is not part of a series."
        },
        "published_at": {
          "type": [
            "string",
            "null"
          ],
          "description": "The publisher's release date for this edition, YYYY-MM-DD."
        },
        "series": {
          "type": "array",
          "description": "Every visible edition of this chart's series, newest first — attached by /meta only, and only when series_key is present. Safe mode, at most 20.",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "rendered_period": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "start": {
                    "type": "integer"
                  },
                  "end": {
                    "type": "integer"
                  }
                }
              },
              "published_at": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          }
        }
      }
    },
    "ImageRights": {
      "type": "object",
      "description": "What an integrator may do with an image, from what MemeStack truly knows — `unknown` wherever it knows nothing, never a guess. `publisher` = imported from a licence-clean publisher (Our World in Data, USDA ERS, Eurostat, EEA; `publisher_only=true` returns only these); `creator` = a Verified Creator's own upload (all rights reserved); `community` = everything else — uploads (including the operators' own uploads of other people's memes and charts), Telegram, X and 4chan saves, Imgflip templates, AI-generated and agent-submitted images: MemeStack grants no licence to them. Commercial use is `yes` only for USDA ERS, Eurostat and EEA charts, whose importer admits only the publisher's own material; Our World in Data is `unknown` because a chart may plot third-party data under its own terms (some non-commercial).",
      "required": [
        "source",
        "publisher",
        "license",
        "license_name",
        "license_url",
        "attribution",
        "attribution_required",
        "commercial_use",
        "note"
      ],
      "properties": {
        "source": {
          "type": "string",
          "enum": [
            "publisher",
            "creator",
            "community"
          ]
        },
        "publisher": {
          "type": [
            "object",
            "null"
          ],
          "description": "The publisher of a `publisher` image; null otherwise.",
          "properties": {
            "key": {
              "type": "string",
              "enum": [
                "owid",
                "usda_ers",
                "eurostat",
                "eea"
              ]
            },
            "name": {
              "type": "string"
            }
          }
        },
        "license": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "CC-BY-4.0",
            "US-PD",
            "all-rights-reserved",
            null
          ],
          "description": "Machine id of the licence; `US-PD` = U.S. federal public domain. Null = MemeStack knows of no licence."
        },
        "license_name": {
          "type": [
            "string",
            "null"
          ],
          "description": "Human label, e.g. \"CC BY 4.0\"."
        },
        "license_url": {
          "type": [
            "string",
            "null"
          ],
          "format": "uri",
          "description": "The licence text, or MemeStack's creator terms for creator work."
        },
        "attribution": {
          "type": "string",
          "description": "The credit line to show beside the image: for a publisher chart the line its licence asks for; otherwise where the image came from, never who owns it."
        },
        "attribution_required": {
          "type": "boolean",
          "description": "True when the licence or the rights holder requires the credit (publisher charts, creator work)."
        },
        "commercial_use": {
          "type": "string",
          "enum": [
            "yes",
            "no",
            "unknown"
          ]
        },
        "note": {
          "type": [
            "string",
            "null"
          ],
          "description": "The one condition or caveat that changes what you may do (e.g. CC BY's notice of MemeStack's changes, or OWID's third-party data), or null."
        }
      }
    },
    "ScoredTag": {
      "type": "object",
      "description": "One tag on an image. `tag` is the slug the tag filters take (`tag`, `tags`); controlled-tag slugs join words with underscores (`our_world_in_data`), free-tag slugs with spaces (`life expectancy`).",
      "properties": {
        "tag": {
          "type": "string",
          "description": "The tag's slug."
        },
        "name": {
          "type": "string",
          "description": "The tag's display name."
        },
        "score": {
          "type": "integer",
          "minimum": 1,
          "maximum": 10,
          "description": "How prominent the tag is in the image, 1 to 10."
        }
      },
      "required": [
        "tag",
        "score"
      ]
    }
  }
}