{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/everpop-app/json-schema/everpop-app-receipt-list-envelope-schema.json",
  "title": "ReceiptListEnvelope",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/everpop-app-receipts-api-openapi.yml#/components/schemas/ReceiptListEnvelope",
  "type": "object",
  "properties": {
    "ok": {
      "const": true
    },
    "data": {
      "type": "object",
      "properties": {
        "receipts": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ReceiptItem"
          }
        },
        "campaignReportUrl": {
          "type": [
            "string",
            "null"
          ],
          "format": "uri",
          "description": "One token-protected link bundling the measured receipts on this page; null when none on the page is measured."
        }
      },
      "required": [
        "receipts",
        "campaignReportUrl"
      ]
    },
    "nextCursor": {
      "type": [
        "string",
        "null"
      ],
      "description": "Pass back as ?cursor= for the next (older) page; null on the last page."
    }
  },
  "required": [
    "ok",
    "data",
    "nextCursor"
  ],
  "$defs": {
    "ReceiptItem": {
      "type": "object",
      "properties": {
        "postId": {
          "type": "string",
          "description": "The post id POST /api/v1/campaigns/{id}/attach takes."
        },
        "title": {
          "type": [
            "string",
            "null"
          ]
        },
        "publishedUrl": {
          "type": [
            "string",
            "null"
          ]
        },
        "postedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "outcomes": {
          "type": "object",
          "properties": {
            "h48": {
              "oneOf": [
                {
                  "$ref": "#/$defs/ReceiptWindow"
                },
                {
                  "type": "null"
                }
              ],
              "description": "The 48-hour window, or null until it is measured."
            },
            "d7": {
              "oneOf": [
                {
                  "$ref": "#/$defs/ReceiptWindow"
                },
                {
                  "type": "null"
                }
              ],
              "description": "The 7-day window, or null until it is measured."
            }
          },
          "required": [
            "h48",
            "d7"
          ]
        },
        "receiptUrl": {
          "type": [
            "string",
            "null"
          ],
          "format": "uri",
          "description": "Token-protected public receipt page, once the post has a measured window; null before."
        }
      },
      "required": [
        "postId",
        "title",
        "publishedUrl",
        "postedAt",
        "outcomes",
        "receiptUrl"
      ]
    },
    "ReceiptWindow": {
      "type": "object",
      "description": "Aggregate YouTube Analytics metrics for one measurement window.",
      "properties": {
        "views": {
          "type": [
            "number",
            "null"
          ]
        },
        "averageViewPercentage": {
          "type": [
            "number",
            "null"
          ],
          "description": "Average percentage of the Short viewed (retention)."
        },
        "likes": {
          "type": [
            "number",
            "null"
          ]
        },
        "comments": {
          "type": [
            "number",
            "null"
          ]
        },
        "shares": {
          "type": [
            "number",
            "null"
          ]
        },
        "subscribersGained": {
          "type": [
            "number",
            "null"
          ]
        },
        "measuredAt": {
          "type": "string",
          "format": "date-time"
        }
      },
      "required": [
        "views",
        "averageViewPercentage",
        "likes",
        "comments",
        "shares",
        "subscribersGained",
        "measuredAt"
      ]
    }
  }
}