{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/rial-io/json-schema/rial-io-audit-verification-schema.json",
  "title": "AuditVerification",
  "description": "An audit as your API key sees it: the verification body with the audit verdict (`rial` plus the checks that tripped, each with its confidence).",
  "x-generated": "2026-11-23",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/rial-io-openapi.json#/components/schemas/AuditVerification",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "pattern": "^vfy_[0-9A-HJKMNP-TV-Z]{26}$"
    },
    "status": {
      "type": "string",
      "enum": [
        "pending",
        "partially_captured",
        "completed",
        "expired",
        "failed",
        "abandoned"
      ],
      "description": "Lifecycle state. `pending` → first capture flips to `partially_captured` → analysis sets the verdict and transitions to `completed`. Terminal: `completed`, `expired`, `failed`. `abandoned` is a side-branch off `pending`/`partially_captured`, reported by the capture screen via `POST /v1/verifications/:token/progress` when the end user leaves before finishing — NOT terminal: a later capture resurrects the row to `partially_captured` like any other."
    },
    "capture_url": {
      "type": "string",
      "format": "uri"
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "expires_at": {
      "type": "string",
      "format": "date-time"
    },
    "captures_count": {
      "type": "integer",
      "minimum": 0
    },
    "verdict": {
      "type": "object",
      "properties": {
        "reverse_search": {
          "type": "object",
          "properties": {
            "state": {
              "type": "string",
              "enum": [
                "pending",
                "review",
                "no_match",
                "inconclusive",
                "expired"
              ]
            },
            "sources": {
              "type": "array",
              "items": {
                "type": "string",
                "format": "uri"
              }
            }
          },
          "required": [
            "state",
            "sources"
          ],
          "description": "Secondary reverse-search state. Similarity candidates require review; they are not confirmed fraud findings."
        },
        "rial": {
          "type": "boolean",
          "description": "Rial/no Rial result of the audit, matching the dashboard."
        },
        "signals": {
          "type": "array",
          "items": {
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "screen_detected"
                    ]
                  }
                },
                "required": [
                  "type"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "ai_detected"
                    ]
                  },
                  "confidence": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                  }
                },
                "required": [
                  "type"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "found_online"
                    ]
                  }
                },
                "required": [
                  "type"
                ]
              }
            ],
            "description": "A check that tripped on an audited file."
          }
        },
        "unavailable": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "screen",
              "ai",
              "reverse",
              "context"
            ]
          },
          "minItems": 1,
          "description": "Checks that could not be completed because the detector never answered after every retry: `screen` (photo of a screen), `ai` (AI-generated), `reverse` (already online), `context`, `depth`. Present only when non-empty; `rial` is then false — the photo was not fully checked, which is not the same as a finding."
        }
      },
      "required": [
        "rial",
        "signals"
      ],
      "description": "Verdict of an audit (`mode: \"audit\"`, a file that already existed). Includes the Rial/no Rial result and the checks that tripped. This is an analysis result, not proof of live capture."
    },
    "location": {
      "type": "object",
      "properties": {
        "lat": {
          "type": "number"
        },
        "lng": {
          "type": "number"
        },
        "accuracy_m": {
          "type": "number",
          "minimum": 0
        },
        "derived_from": {
          "type": "string",
          "enum": [
            "exif",
            "live",
            "last_known_session",
            "last_known_system",
            "last_known_persisted"
          ]
        },
        "age_ms": {
          "type": "integer",
          "minimum": 0
        },
        "place": {
          "type": "string"
        }
      },
      "required": [
        "lat",
        "lng",
        "accuracy_m"
      ],
      "description": "Where the photo was taken, from the device. Absent for uploaded files and when the device reported no fix."
    },
    "location_match": {
      "type": "object",
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "verified",
            "no_match",
            "ungeocoded",
            "rejected",
            "not_applicable"
          ]
        },
        "expected_location": {
          "type": "string"
        },
        "observed_location": {
          "type": "string"
        },
        "expected_point": {
          "type": "object",
          "properties": {
            "lat": {
              "type": "number"
            },
            "lng": {
              "type": "number"
            }
          },
          "required": [
            "lat",
            "lng"
          ]
        },
        "observed_point": {
          "type": "object",
          "properties": {
            "lat": {
              "type": "number"
            },
            "lng": {
              "type": "number"
            }
          },
          "required": [
            "lat",
            "lng"
          ]
        },
        "distance_m": {
          "type": "number",
          "minimum": 0
        },
        "threshold_m": {
          "type": "number",
          "minimum": 0
        },
        "gps_accuracy_m": {
          "type": "number",
          "minimum": 0
        },
        "geocode_ref": {
          "type": "string"
        },
        "reason": {
          "type": "string"
        }
      },
      "required": [
        "status"
      ],
      "description": "Whether the photo was taken at `expected_location`. `verified` within GPS tolerance; `no_match` somewhere else; `ungeocoded` when the address or the fix could not be resolved; `rejected` when the device reported a mock location."
    },
    "object_match": {
      "type": "object",
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "match",
            "mismatch",
            "inconclusive"
          ]
        },
        "expected_object": {
          "type": "string"
        }
      },
      "required": [
        "status"
      ],
      "description": "Object-check result. Present when an object check was requested globally or on an image step. With step-only configuration the status is the worst step result and expected_object is omitted. Independent of the fraud verdict."
    },
    "object_matches": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "match",
              "mismatch",
              "inconclusive"
            ]
          },
          "expected_object": {
            "type": "string"
          }
        },
        "required": [
          "status",
          "expected_object"
        ],
        "description": "Object-check result for one image step, including its expected object."
      },
      "description": "Object-check results keyed by image step. Missing capture verdicts yield inconclusive; otherwise each value is the worst context result for the step, ignoring not_applicable when live evidence exists."
    },
    "condition": {
      "type": "object",
      "properties": {
        "score": {
          "type": "number",
          "minimum": 0,
          "maximum": 10
        },
        "label": {
          "type": "string",
          "enum": [
            "good",
            "fair",
            "poor"
          ]
        },
        "aspects": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "score": {
                "type": "number",
                "minimum": 0,
                "maximum": 10
              },
              "reasoning": {
                "type": "string"
              }
            },
            "required": [
              "name",
              "score",
              "reasoning"
            ],
            "description": "One scored aspect of the condition assessment. `name` echoes the free-form tenant-defined aspect from `condition_aspects` verbatim — any language, any domain, no fixed vocabulary. `score` is 0..10 with one decimal; `reasoning` is a one-or-two-sentence visual justification."
          }
        },
        "provenance": {
          "type": "object",
          "properties": {
            "model": {
              "type": "string"
            },
            "prompt": {
              "type": "string"
            },
            "instructions_sha256": {
              "type": "string",
              "minLength": 64,
              "maxLength": 64
            }
          },
          "required": [
            "model",
            "prompt"
          ],
          "description": "What produced this assessment: the model, the prompt (`id@version`) and, when your organization's condition instructions applied, their SHA-256 — so a result stays tied to the guidance and model of its day. Absent on assessments written before this field existed."
        },
        "steps": {
          "type": "object",
          "additionalProperties": {
            "type": "object",
            "properties": {
              "score": {
                "type": "number",
                "minimum": 0,
                "maximum": 10
              },
              "label": {
                "type": "string",
                "enum": [
                  "good",
                  "fair",
                  "poor"
                ]
              },
              "aspects": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "score": {
                      "type": "number",
                      "minimum": 0,
                      "maximum": 10
                    },
                    "reasoning": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "name",
                    "score",
                    "reasoning"
                  ],
                  "description": "One scored aspect of the condition assessment. `name` echoes the free-form tenant-defined aspect from `condition_aspects` verbatim — any language, any domain, no fixed vocabulary. `score` is 0..10 with one decimal; `reasoning` is a one-or-two-sentence visual justification."
                }
              },
              "provenance": {
                "type": "object",
                "properties": {
                  "model": {
                    "type": "string"
                  },
                  "prompt": {
                    "type": "string"
                  },
                  "instructions_sha256": {
                    "type": "string",
                    "minLength": 64,
                    "maxLength": 64
                  }
                },
                "required": [
                  "model",
                  "prompt"
                ],
                "description": "What produced this assessment: the model, the prompt (`id@version`) and, when your organization's condition instructions applied, their SHA-256 — so a result stays tied to the guidance and model of its day. Absent on assessments written before this field existed."
              }
            },
            "required": [
              "score",
              "label",
              "aspects"
            ],
            "description": "Condition assessment. Present only when the verification was created with `condition_aspects` — the free-form tenant-defined aspect names (any language, any domain). `score` is the one-decimal average of aspect scores; `label` buckets it (>=7.5 good, >=5 fair, else poor). Independent of the fraud verdict."
          },
          "description": "Condition results keyed by photo step. Each uses only that step’s photos and its rubric, falling back to the shared rubric. The aggregate averages all assessed aspect scores."
        }
      },
      "required": [
        "score",
        "label",
        "aspects"
      ],
      "description": "Condition assessment. Present only when the verification was created with `condition_aspects` — the free-form tenant-defined aspect names (any language, any domain). `score` is the one-decimal average of aspect scores; `label` buckets it (>=7.5 good, >=5 fair, else poor). Independent of the fraud verdict."
    },
    "video_analysis": {
      "type": "object",
      "properties": {
        "capture_id": {
          "type": "string"
        },
        "frames_extracted": {
          "type": "integer",
          "minimum": 0
        },
        "frames_analyzed": {
          "type": "integer",
          "minimum": 0
        },
        "scene": {
          "type": "object",
          "properties": {
            "verdict": {
              "type": "string",
              "enum": [
                "match",
                "mismatch",
                "inconclusive"
              ]
            },
            "confidence": {
              "type": "number",
              "minimum": 0,
              "maximum": 1
            },
            "reasoning": {
              "type": "string"
            }
          },
          "required": [
            "verdict",
            "confidence",
            "reasoning"
          ],
          "description": "Whether the clip as a whole shows what the video step's `expected_scene` asked for, judged once over a contact sheet of its frames, with the reason. Absent when the step declared no scene or the check did not run."
        },
        "condition": {
          "type": "object",
          "properties": {
            "score": {
              "type": "number",
              "minimum": 0,
              "maximum": 10
            },
            "label": {
              "type": "string",
              "enum": [
                "good",
                "fair",
                "poor"
              ]
            },
            "aspects": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "score": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 10
                  },
                  "reasoning": {
                    "type": "string"
                  }
                },
                "required": [
                  "name",
                  "score",
                  "reasoning"
                ],
                "description": "One scored aspect of the condition assessment. `name` echoes the free-form tenant-defined aspect from `condition_aspects` verbatim — any language, any domain, no fixed vocabulary. `score` is 0..10 with one decimal; `reasoning` is a one-or-two-sentence visual justification."
              }
            },
            "provenance": {
              "type": "object",
              "properties": {
                "model": {
                  "type": "string"
                },
                "prompt": {
                  "type": "string"
                },
                "instructions_sha256": {
                  "type": "string",
                  "minLength": 64,
                  "maxLength": 64
                }
              },
              "required": [
                "model",
                "prompt"
              ],
              "description": "What produced this assessment: the model, the prompt (`id@version`) and, when your organization's condition instructions applied, their SHA-256 — so a result stays tied to the guidance and model of its day. Absent on assessments written before this field existed."
            }
          },
          "required": [
            "score",
            "label",
            "aspects"
          ],
          "description": "The video step's `condition_aspects` scored over a contact sheet of the clip — the same 0..10 rubric and labels a photo step gets, read across the whole recording. Absent when the step declared no aspects or the check did not run."
        },
        "signals": {
          "type": "object",
          "properties": {
            "screen": {
              "type": "object",
              "properties": {
                "detected": {
                  "type": "boolean"
                },
                "frames_evaluated": {
                  "type": "integer",
                  "minimum": 0
                },
                "flagged_ratio": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 1
                },
                "longest_run_ms": {
                  "type": "integer",
                  "minimum": 0
                },
                "flagged_at_ms": {
                  "type": "array",
                  "items": {
                    "type": "integer",
                    "minimum": 0
                  }
                }
              },
              "required": [
                "detected",
                "frames_evaluated",
                "flagged_ratio",
                "longest_run_ms",
                "flagged_at_ms"
              ],
              "description": "How one check behaved across the sampled frames. `detected` is true when it tripped on at least half of `frames_evaluated` or on three consecutive frames; isolated trips are listed in `flagged_at_ms` without deciding."
            },
            "ai": {
              "type": "object",
              "properties": {
                "detected": {
                  "type": "boolean"
                },
                "frames_evaluated": {
                  "type": "integer",
                  "minimum": 0
                },
                "flagged_ratio": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 1
                },
                "longest_run_ms": {
                  "type": "integer",
                  "minimum": 0
                },
                "flagged_at_ms": {
                  "type": "array",
                  "items": {
                    "type": "integer",
                    "minimum": 0
                  }
                }
              },
              "required": [
                "detected",
                "frames_evaluated",
                "flagged_ratio",
                "longest_run_ms",
                "flagged_at_ms"
              ],
              "description": "How one check behaved across the sampled frames. `detected` is true when it tripped on at least half of `frames_evaluated` or on three consecutive frames; isolated trips are listed in `flagged_at_ms` without deciding."
            },
            "reverse": {
              "type": "object",
              "properties": {
                "detected": {
                  "type": "boolean"
                },
                "frames_evaluated": {
                  "type": "integer",
                  "minimum": 0
                },
                "flagged_ratio": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 1
                },
                "longest_run_ms": {
                  "type": "integer",
                  "minimum": 0
                },
                "flagged_at_ms": {
                  "type": "array",
                  "items": {
                    "type": "integer",
                    "minimum": 0
                  }
                }
              },
              "required": [
                "detected",
                "frames_evaluated",
                "flagged_ratio",
                "longest_run_ms",
                "flagged_at_ms"
              ],
              "description": "How one check behaved across the sampled frames. `detected` is true when it tripped on at least half of `frames_evaluated` or on three consecutive frames; isolated trips are listed in `flagged_at_ms` without deciding."
            },
            "context": {
              "type": "object",
              "properties": {
                "detected": {
                  "type": "boolean"
                },
                "frames_evaluated": {
                  "type": "integer",
                  "minimum": 0
                },
                "flagged_ratio": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 1
                },
                "longest_run_ms": {
                  "type": "integer",
                  "minimum": 0
                },
                "flagged_at_ms": {
                  "type": "array",
                  "items": {
                    "type": "integer",
                    "minimum": 0
                  }
                }
              },
              "required": [
                "detected",
                "frames_evaluated",
                "flagged_ratio",
                "longest_run_ms",
                "flagged_at_ms"
              ],
              "description": "How one check behaved across the sampled frames. `detected` is true when it tripped on at least half of `frames_evaluated` or on three consecutive frames; isolated trips are listed in `flagged_at_ms` without deciding."
            }
          },
          "description": "One entry per check that ran on the clip; a missing entry was not evaluated, never clean."
        },
        "analyzed_at": {
          "type": "string",
          "format": "date-time"
        }
      },
      "required": [
        "capture_id",
        "frames_extracted",
        "frames_analyzed",
        "signals",
        "analyzed_at"
      ],
      "description": "Analysis of a video-step clip, sampled at one frame per second and run through the same checks a photo gets. Written asynchronously after capture — poll or use webhooks; absent until the worker has run."
    },
    "ocr_primary": {
      "type": "string"
    },
    "similar_photo": {
      "type": "object",
      "properties": {
        "verification_id": {
          "type": "string"
        },
        "capture_id": {
          "type": "string"
        },
        "distance": {
          "type": "integer",
          "minimum": 0,
          "maximum": 64
        },
        "method": {
          "type": "string",
          "enum": [
            "phash",
            "embedding"
          ]
        },
        "cosine": {
          "type": "number",
          "minimum": -1,
          "maximum": 1
        },
        "inliers": {
          "type": "integer",
          "minimum": 0
        }
      },
      "required": [
        "verification_id",
        "capture_id",
        "distance"
      ],
      "description": "An earlier verification of yours whose photo matches this one. `method: \"phash\"`: the perceptual hashes are within threshold (Hamming `distance` 0–64; 0 is bit-identical) — a re-upload. `method: \"embedding\"`: the hashes differ but the photos are the same scene by embedding (`cosine`) and a geometric check confirmed it (`inliers`) — a screenshot or a crop. Present only when a match was found. It does not change `rial`: a legitimate re-submission and a recycled photo look the same — your reviewer decides."
    },
    "answers": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "properties": {
          "values": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "address": {
            "type": "object",
            "properties": {
              "street": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              },
              "number": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              },
              "neighborhood": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              },
              "complement": {
                "type": "string",
                "maxLength": 200
              },
              "city": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              },
              "region": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              },
              "postal_code": {
                "type": "string",
                "maxLength": 200
              }
            },
            "required": [
              "street",
              "number",
              "neighborhood",
              "city",
              "region",
              "postal_code"
            ],
            "additionalProperties": false
          },
          "value": {
            "type": "string",
            "maxLength": 2000
          },
          "answered_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "value",
          "answered_at"
        ],
        "description": "One answered text step. `value` is USER-DECLARED — typed by the person capturing; unlike live-captured content, it is never sensor-attested. Potential PII: it rides the operator/developer contracts and the webhook only, never OG cards or third-party public surfaces."
      }
    },
    "record_seal": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "algorithm": {
              "type": "string",
              "enum": [
                "sha256"
              ]
            },
            "hash": {
              "type": "string",
              "minLength": 64,
              "maxLength": 64
            },
            "covers": {
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "record",
                  "answers"
                ]
              }
            },
            "answers_provenance": {
              "type": "string",
              "enum": [
                "user_declared"
              ]
            }
          },
          "required": [
            "algorithm",
            "hash",
            "covers",
            "answers_provenance"
          ]
        },
        {
          "type": "object",
          "properties": {
            "algorithm": {
              "type": "string",
              "enum": [
                "sha3-512"
              ]
            },
            "hash": {
              "type": "string",
              "minLength": 128,
              "maxLength": 128
            },
            "covers": {
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "record",
                  "answers"
                ]
              }
            },
            "answers_provenance": {
              "type": "string",
              "enum": [
                "user_declared"
              ]
            }
          },
          "required": [
            "algorithm",
            "hash",
            "covers",
            "answers_provenance"
          ]
        }
      ],
      "description": "Integrity seal over the verification record including `answers`. Present only when answers exist and sealing is on (`seal !== false`). The hash proves the stored answers have not changed — it does NOT claim they are true or sensor-attested; `answers_provenance` carries that distinction explicitly."
    }
  },
  "required": [
    "id",
    "status",
    "capture_url",
    "created_at",
    "expires_at",
    "captures_count"
  ]
}