{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/asap-cool/json-schema/asap-cool-deal-view-schema.json",
  "title": "DealView",
  "description": "Public projection of a `crm.deal`.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/asap-cool-crm-api-openapi.yml#/components/schemas/DealView",
  "type": "object",
  "required": [
    "id",
    "contact_id",
    "title",
    "stage",
    "currency",
    "effective_probability",
    "created_at",
    "updated_at"
  ],
  "properties": {
    "amount_cents": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int64",
      "description": "Expected amount **in cents**, or `null` before there is an estimate."
    },
    "archived_at": {
      "type": [
        "string",
        "null"
      ],
      "description": "Soft-delete marker (RFC3339)."
    },
    "contact_id": {
      "type": "string",
      "format": "uuid",
      "description": "Contact the deal belongs to."
    },
    "created_at": {
      "type": "string",
      "description": "Creation timestamp (RFC3339)."
    },
    "currency": {
      "type": "string",
      "description": "ISO 4217 currency of `amount_cents`."
    },
    "effective_probability": {
      "type": "integer",
      "format": "int32",
      "description": "Probability actually used for the weighted pipeline.\n\nServed even though it is derivable: a client that had to recompute it\nwould need its own copy of the per-stage table, and the two would\ndiverge. The weighted *amount* is deliberately absent — it is an\naggregate, and it lives in `GET /v1/crm/pipeline`."
    },
    "expected_close_on": {
      "type": [
        "string",
        "null"
      ],
      "description": "Day the deal is expected to close on, `YYYY-MM-DD`."
    },
    "id": {
      "type": "string",
      "format": "uuid",
      "description": "Stable identifier."
    },
    "lost_at": {
      "type": [
        "string",
        "null"
      ],
      "description": "When it was lost (RFC3339)."
    },
    "lost_reason": {
      "type": [
        "string",
        "null"
      ],
      "description": "Why it was lost."
    },
    "owner_user_id": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid",
      "description": "Owner, or `null` for the org's backlog."
    },
    "probability": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int32",
      "description": "Probability override, `null` when the stage's default applies."
    },
    "source": {
      "type": [
        "string",
        "null"
      ],
      "description": "Where the deal came from."
    },
    "stage": {
      "type": "string",
      "description": "Pipeline stage token (`nouveau` … `perdu`)."
    },
    "title": {
      "type": "string",
      "description": "Short human title."
    },
    "updated_at": {
      "type": "string",
      "description": "Last write timestamp (RFC3339)."
    },
    "won_at": {
      "type": [
        "string",
        "null"
      ],
      "description": "When it was won (RFC3339)."
    }
  }
}