{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/scriptgrain-com/json-schema/scriptgrain-com-company-schema.json",
  "title": "Company",
  "x-generated": "2026-11-24",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/scriptgrain-com-openapi.json#/components/schemas/Company",
  "type": "object",
  "required": [
    "id",
    "name",
    "key_points",
    "terminology",
    "source",
    "created_at"
  ],
  "properties": {
    "id": {
      "$ref": "#/$defs/Uuid"
    },
    "name": {
      "type": "string"
    },
    "website_url": {
      "type": [
        "string",
        "null"
      ]
    },
    "summary": {
      "type": [
        "string",
        "null"
      ]
    },
    "audience": {
      "type": [
        "string",
        "null"
      ]
    },
    "key_points": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "terminology": {
      "type": "object",
      "properties": {
        "preferred": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "banned": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "source": {
      "type": "string",
      "description": "`website` for a URL import; `manual` for a description or manual fields. Rows made in the app may carry other values (not fixed in code)."
    },
    "organisation_id": {
      "oneOf": [
        {
          "$ref": "#/$defs/Uuid"
        },
        {
          "type": "null"
        }
      ],
      "description": "Set when the company is shared with an organisation in the app; always null for companies created through this endpoint."
    },
    "pending_facts": {
      "type": "array",
      "description": "Learning-loop suggestions not yet applied.",
      "items": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "fact",
              "preferred_term",
              "banned_term"
            ]
          },
          "text": {
            "type": "string"
          },
          "source": {
            "type": "string",
            "enum": [
              "edit",
              "crawl"
            ]
          },
          "learned_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      }
    },
    "fact_provenance": {
      "type": "object",
      "description": "Where each key point came from, keyed by the lowercased fact text.",
      "additionalProperties": {
        "type": "object",
        "properties": {
          "source": {
            "type": "string",
            "enum": [
              "crawl",
              "edit",
              "described",
              "manual"
            ]
          },
          "learned_at": {
            "type": "string",
            "format": "date-time"
          },
          "source_url": {
            "type": "string"
          }
        }
      }
    },
    "last_refresh_diff": {
      "type": [
        "object",
        "null"
      ],
      "description": "What the most recent website re-crawl changed or proposed. Null if never re-crawled.",
      "properties": {
        "refreshed_at": {
          "type": "string",
          "format": "date-time"
        },
        "pages_read": {
          "type": "integer"
        },
        "added_facts": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "summary_changed": {
          "type": "boolean"
        },
        "audience_changed": {
          "type": "boolean"
        },
        "proposed_facts": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "proposed_summary": {
          "type": [
            "string",
            "null"
          ]
        },
        "proposed_audience": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    }
  },
  "$defs": {
    "Uuid": {
      "type": "string",
      "format": "uuid",
      "description": "A UUID. Path ids that are not UUID-shaped never match a route (404 `not_found`)."
    }
  }
}