{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/ayhire-com/json-schema/ayhire-com-outcome-event-schema.json",
  "title": "OutcomeEvent",
  "x-generated": "2026-10-30",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/ayhire-com-openapi.yml#/components/schemas/OutcomeEvent",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "role_id": {
      "type": "string",
      "format": "uuid"
    },
    "github_username": {
      "type": "string"
    },
    "stage": {
      "$ref": "#/$defs/OutcomeStage"
    },
    "happened_at": {
      "type": "string",
      "description": "When it happened (may be backdated)",
      "format": "date-time"
    },
    "approximate": {
      "type": "boolean",
      "description": "True when it was made from a decision saved before outcomes existed: happened_at is the latest it can have been"
    },
    "source": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "human",
        "automated",
        null
      ],
      "description": "human: a person recorded it; automated: an agent did"
    },
    "via": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "web",
        "api",
        "agent",
        "backfill",
        null
      ]
    },
    "user_id": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid",
      "description": "Who recorded it"
    },
    "by": {
      "type": [
        "string",
        "null"
      ],
      "description": "Their name in the workspace"
    },
    "by_you": {
      "type": "boolean"
    },
    "client": {
      "type": [
        "string",
        "null"
      ],
      "description": "The connected app, when an agent recorded it"
    },
    "note": {
      "type": [
        "string",
        "null"
      ],
      "description": "A short handoff note"
    },
    "replaces": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid",
      "description": "The outcome this one corrects"
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "retracted_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "Set when it was corrected or removed: it then never counts"
    },
    "retracted_by": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid"
    },
    "retracted_by_name": {
      "type": [
        "string",
        "null"
      ]
    }
  },
  "required": [
    "id",
    "stage",
    "happened_at",
    "approximate",
    "retracted_at"
  ],
  "$defs": {
    "OutcomeStage": {
      "type": "string",
      "description": "reviewed, shortlisted, contacted, replied, interview, offer, hired (in that order), or declined (at any point)",
      "enum": [
        "reviewed",
        "shortlisted",
        "contacted",
        "replied",
        "interview",
        "offer",
        "hired",
        "declined"
      ]
    }
  }
}