{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/bewary/json-schema/bewary-backtest-report-schema.json",
  "title": "BacktestReport",
  "description": "GET /v1/backtest/{id}. Kept 7 days after it is ready; the upload itself is deleted when the report is\nwritten.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/bewary-backtest-api-openapi.yml#/components/schemas/BacktestReport",
  "properties": {
    "id": {
      "type": "string",
      "title": "Id"
    },
    "status": {
      "type": "string",
      "enum": [
        "queued",
        "running",
        "done",
        "failed"
      ],
      "title": "Status"
    },
    "created_at": {
      "type": "string",
      "title": "Created At"
    },
    "finished_at": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Finished At"
    },
    "expires_at": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Expires At"
    },
    "items": {
      "type": "integer",
      "title": "Items"
    },
    "valid": {
      "type": "integer",
      "title": "Valid"
    },
    "free_items": {
      "type": "integer",
      "title": "Free Items"
    },
    "credits": {
      "type": "integer",
      "title": "Credits"
    },
    "history": {
      "anyOf": [
        {
          "additionalProperties": {
            "$ref": "#/$defs/HistoryStart"
          },
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "History",
      "description": "Where our data for each type begins."
    },
    "summary": {
      "anyOf": [
        {
          "$ref": "#/$defs/BacktestSummary"
        },
        {
          "type": "null"
        }
      ]
    },
    "results": {
      "items": {
        "anyOf": [
          {
            "$ref": "#/$defs/BacktestResult"
          },
          {
            "$ref": "#/$defs/BacktestItemError"
          }
        ]
      },
      "type": "array",
      "title": "Results",
      "description": "In upload order; empty until the report is done."
    }
  },
  "type": "object",
  "required": [
    "id",
    "status",
    "created_at",
    "items",
    "valid",
    "free_items",
    "credits",
    "results"
  ],
  "$defs": {
    "BacktestItemError": {
      "properties": {
        "index": {
          "type": "integer",
          "title": "Index"
        },
        "error": {
          "$ref": "#/$defs/ItemError"
        }
      },
      "type": "object",
      "required": [
        "index",
        "error"
      ],
      "title": "BacktestItemError"
    },
    "BacktestLeads": {
      "properties": {
        "caught_before": {
          "anyOf": [
            {
              "$ref": "#/$defs/LeadStats"
            },
            {
              "type": "null"
            }
          ]
        },
        "caught_after": {
          "anyOf": [
            {
              "$ref": "#/$defs/LeadStats"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "type": "object",
      "title": "BacktestLeads"
    },
    "BacktestResult": {
      "properties": {
        "index": {
          "type": "integer",
          "title": "Index",
          "description": "The item's position in the upload."
        },
        "type": {
          "type": "string",
          "enum": [
            "domain",
            "url",
            "phone",
            "email",
            "wallet"
          ],
          "title": "Type"
        },
        "value": {
          "type": "string",
          "title": "Value",
          "description": "As uploaded."
        },
        "normalized": {
          "type": "string",
          "title": "Normalized",
          "description": "Our canonical form (the email's domain for an email)."
        },
        "reported_at": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Reported At",
          "description": "Your date, RFC 3339 UTC."
        },
        "outcome": {
          "type": "string",
          "enum": [
            "caught_before",
            "caught_after",
            "caught",
            "flagged",
            "missed",
            "before_history"
          ],
          "title": "Outcome",
          "description": "caught_before: on your date we listed it. caught_after: we listed it only later. caught (no date): we listed it. flagged: only a caution or a caller-ID report. missed. before_history: your date is before our data for this type begins."
        },
        "answer_then": {
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "listed",
                "sanctioned",
                "frozen",
                "caution",
                "caller_id",
                "not_listed"
              ]
            },
            {
              "type": "null"
            }
          ],
          "title": "Answer Then",
          "description": "What a lookup on your date answered."
        },
        "answer_now": {
          "type": "string",
          "enum": [
            "listed",
            "sanctioned",
            "frozen",
            "caution",
            "caller_id",
            "not_listed"
          ],
          "title": "Answer Now",
          "description": "What a lookup answers now."
        },
        "first_seen": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "First Seen",
          "description": "The earliest we saw it at all, a certificate included."
        },
        "first_listed": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "First Listed",
          "description": "When we first asserted it (listed or sanctioned)."
        },
        "lead_hours": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Lead Hours",
          "description": "Your date minus our listing, in hours: positive when we had it first, negative when we listed it later."
        },
        "severity": {
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "info",
                "low",
                "medium",
                "high",
                "critical"
              ]
            },
            {
              "type": "null"
            }
          ],
          "title": "Severity"
        },
        "reason_code": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Reason Code",
          "description": "LISTED_BLOCKLIST, WALLET_SANCTIONED, WALLET_FROZEN_BY_ISSUER (1.9.0), LISTED_CAUTION or PHONE_REPORTED_CALLER_ID."
        }
      },
      "type": "object",
      "required": [
        "index",
        "type",
        "value",
        "normalized",
        "outcome",
        "answer_now"
      ],
      "title": "BacktestResult"
    },
    "BacktestSummary": {
      "properties": {
        "items": {
          "type": "integer",
          "title": "Items"
        },
        "valid": {
          "type": "integer",
          "title": "Valid"
        },
        "invalid": {
          "type": "integer",
          "title": "Invalid"
        },
        "outcomes": {
          "additionalProperties": {
            "type": "integer"
          },
          "type": "object",
          "title": "Outcomes",
          "description": "Items by outcome."
        },
        "listed_now": {
          "type": "integer",
          "title": "Listed Now",
          "description": "Items a lookup asserts now (listed or sanctioned)."
        },
        "lead_hours": {
          "$ref": "#/$defs/BacktestLeads"
        },
        "by_type": {
          "additionalProperties": {
            "$ref": "#/$defs/BacktestTypeSummary"
          },
          "type": "object",
          "title": "By Type"
        }
      },
      "type": "object",
      "required": [
        "items",
        "valid",
        "invalid",
        "outcomes",
        "listed_now",
        "lead_hours",
        "by_type"
      ],
      "title": "BacktestSummary"
    },
    "BacktestTypeSummary": {
      "properties": {
        "items": {
          "type": "integer",
          "title": "Items"
        },
        "outcomes": {
          "additionalProperties": {
            "type": "integer"
          },
          "type": "object",
          "title": "Outcomes"
        },
        "listed_now": {
          "type": "integer",
          "title": "Listed Now"
        }
      },
      "type": "object",
      "required": [
        "items",
        "outcomes",
        "listed_now"
      ],
      "title": "BacktestTypeSummary"
    },
    "HistoryStart": {
      "properties": {
        "from": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "From",
          "description": "Our earliest record for this type, RFC 3339 UTC."
        }
      },
      "type": "object",
      "title": "HistoryStart"
    },
    "ItemError": {
      "properties": {
        "code": {
          "type": "string",
          "enum": [
            "invalid_input",
            "unsupported_type"
          ],
          "title": "Code"
        }
      },
      "type": "object",
      "required": [
        "code"
      ],
      "title": "ItemError"
    },
    "LeadStats": {
      "properties": {
        "count": {
          "type": "integer",
          "title": "Count"
        },
        "median": {
          "type": "number",
          "title": "Median"
        },
        "p25": {
          "type": "number",
          "title": "P25"
        },
        "p75": {
          "type": "number",
          "title": "P75"
        },
        "max": {
          "type": "number",
          "title": "Max"
        }
      },
      "type": "object",
      "required": [
        "count",
        "median",
        "p25",
        "p75",
        "max"
      ],
      "title": "LeadStats"
    }
  }
}