{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/anchord-ai/json-schema/anchord-ai-resolve-response-schema.json",
  "title": "ResolveResponse",
  "x-generated": "2026-11-01",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/anchord-ai-openapi.yaml#/components/schemas/ResolveResponse",
  "type": "object",
  "required": [
    "attempt_id",
    "status",
    "safe_to_write",
    "reasons",
    "conflicts",
    "candidates",
    "request_id"
  ],
  "properties": {
    "attempt_id": {
      "type": "string",
      "format": "uuid"
    },
    "status": {
      "$ref": "#/$defs/ResolveStatus"
    },
    "entity_id": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid",
      "description": "AnchorID of the resolved entity (null when not resolved)."
    },
    "confidence": {
      "type": [
        "number",
        "null"
      ],
      "minimum": 0,
      "maximum": 1
    },
    "safe_to_write": {
      "type": "boolean"
    },
    "match": {
      "anyOf": [
        {
          "$ref": "#/$defs/Match"
        },
        {
          "type": "null"
        }
      ],
      "description": "Match details when resolved. Null when needs_review or not_found."
    },
    "targets": {
      "$ref": "#/$defs/TargetMap"
    },
    "missing_targets": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Systems requested via target_system that the entity lacks records in."
    },
    "reasons": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Signal codes explaining why a match was made. Examples: DOMAIN_EXACT_MATCH, STRIPE_CUSTOMER_ID_EXACT_MATCH, NAME_EXACT_CITY_STATE_MATCH, ALTERNATE_DOMAIN_MATCH.\n"
    },
    "conflicts": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Conflict codes. Examples: AMBIGUOUS_CANDIDATES, MISSING_TARGET_SYSTEM_RECORD, BELOW_AUTO_LINK_THRESHOLD.\n"
    },
    "candidates": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Candidate"
      }
    },
    "coverage": {
      "$ref": "#/$defs/Coverage"
    },
    "request_id": {
      "type": "string"
    }
  },
  "$defs": {
    "Candidate": {
      "type": "object",
      "required": [
        "entity_id",
        "confidence"
      ],
      "properties": {
        "entity_id": {
          "type": "string",
          "format": "uuid"
        },
        "source_record_id": {
          "type": "string",
          "format": "uuid"
        },
        "system": {
          "type": "string"
        },
        "object_type": {
          "type": "string"
        },
        "object_id": {
          "type": "string"
        },
        "integration_id": {
          "type": [
            "string",
            "null"
          ],
          "format": "uuid"
        },
        "confidence": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        },
        "reasons": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "Coverage": {
      "type": "object",
      "properties": {
        "searched_systems": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "signals_considered": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "candidates_evaluated": {
          "type": "integer"
        },
        "warnings": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Person resolve only. E.g. ROLE_EMAIL_POSSIBLE."
        }
      }
    },
    "EntityKind": {
      "type": "string",
      "enum": [
        "company",
        "person"
      ]
    },
    "EntityRef": {
      "type": "object",
      "required": [
        "id",
        "kind"
      ],
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "kind": {
          "$ref": "#/$defs/EntityKind"
        }
      }
    },
    "LinkSource": {
      "type": "string",
      "enum": [
        "resolution",
        "auto_resolve",
        "reconcile",
        "manual",
        "merge",
        "api",
        "manual_review"
      ],
      "description": "How a source record was linked to an entity (provenance). resolution = query-time resolve, auto_resolve = post-ingest exact match, reconcile = deferred fuzzy reconciliation, manual = user action, merge = entity merge/dedup, api = public link API, manual_review = review confirm.\n"
    },
    "Match": {
      "type": "object",
      "description": "Present when status is resolved.",
      "properties": {
        "source_record_id": {
          "type": "string",
          "format": "uuid"
        },
        "entity_id": {
          "type": "string",
          "format": "uuid"
        },
        "entity": {
          "$ref": "#/$defs/EntityRef"
        },
        "system": {
          "type": "string"
        },
        "object_type": {
          "type": "string"
        },
        "object_id": {
          "type": "string"
        },
        "integration_id": {
          "type": [
            "string",
            "null"
          ],
          "format": "uuid"
        }
      }
    },
    "ResolveStatus": {
      "type": "string",
      "enum": [
        "resolved",
        "needs_review",
        "not_found"
      ]
    },
    "TargetEntry": {
      "type": "object",
      "required": [
        "object_type",
        "object_id",
        "source_record_id"
      ],
      "properties": {
        "object_type": {
          "type": "string"
        },
        "object_id": {
          "type": "string"
        },
        "source_record_id": {
          "type": "string",
          "format": "uuid"
        },
        "linked_by": {
          "$ref": "#/$defs/LinkSource"
        },
        "confidence": {
          "type": [
            "number",
            "null"
          ],
          "minimum": 0,
          "maximum": 1
        },
        "integration_id": {
          "type": [
            "string",
            "null"
          ],
          "format": "uuid"
        },
        "integration_label": {
          "type": [
            "string",
            "null"
          ]
        },
        "integration_external_id": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "TargetMap": {
      "type": "object",
      "description": "Keys are system names (hubspot, salesforce, stripe, etc.). Values are arrays of target records from that system.\n",
      "additionalProperties": {
        "type": "array",
        "items": {
          "$ref": "#/$defs/TargetEntry"
        }
      }
    }
  }
}