{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.firstmilelabs.com/schemas/webhooks/document_request.submitted.v1.json",
  "title": "FirstMileLabs Outbound Webhook — document_request.submitted (v1)",
  "description": "The customer submitted the request: what they sent, declared or said they can't provide, and what is still pending. Ids, counts and statuses: never their reasons, a person's name or the upload link.",
  "type": "object",
  "additionalProperties": true,
  "required": [
    "event",
    "eventId",
    "eventVersion",
    "timestamp",
    "orgId",
    "caseId",
    "requestId",
    "submittedAt",
    "itemCount",
    "uploadedCount",
    "declaredCount",
    "answeredCount",
    "pendingCount",
    "items"
  ],
  "properties": {
    "event": {
      "type": "string",
      "const": "document_request.submitted"
    },
    "eventId": {
      "type": "string",
      "format": "uuid"
    },
    "eventVersion": {
      "type": "integer",
      "const": 1
    },
    "timestamp": {
      "type": "string",
      "format": "date-time"
    },
    "orgId": {
      "type": "string"
    },
    "crmRecordId": {
      "type": [
        "string",
        "null"
      ],
      "description": "Your own reference for the case, when it has one."
    },
    "crmSource": {
      "type": [
        "string",
        "null"
      ]
    },
    "caseId": {
      "type": "string",
      "description": "The customer's case."
    },
    "requestId": {
      "type": "integer",
      "description": "The request. Stable across its events, and what POST /v1/cases/{caseId}/document-requests returns."
    },
    "submittedAt": {
      "type": "string",
      "format": "date-time"
    },
    "itemCount": {
      "type": "integer",
      "minimum": 0
    },
    "uploadedCount": {
      "type": "integer",
      "minimum": 0,
      "description": "Items with documents."
    },
    "declaredCount": {
      "type": "integer",
      "minimum": 0,
      "description": "People's Source of Wealth declared."
    },
    "answeredCount": {
      "type": "integer",
      "minimum": 0,
      "description": "Items the customer said they can't provide, or that don't apply; their reasons are on the case."
    },
    "pendingCount": {
      "type": "integer",
      "minimum": 0,
      "description": "Items still owed: ask again to chase them."
    },
    "items": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": true,
        "required": [
          "index",
          "category",
          "docType",
          "eddReqKey",
          "personRef",
          "status",
          "documentIds"
        ],
        "properties": {
          "index": {
            "type": "integer",
            "minimum": 0,
            "description": "Its position on the request. GET /v1/cases/{caseId}/document-requests has the rest of it."
          },
          "category": {
            "type": [
              "string",
              "null"
            ]
          },
          "docType": {
            "type": [
              "string",
              "null"
            ],
            "description": "A document's requirement: a classifier type, or your own key."
          },
          "eddReqKey": {
            "type": [
              "string",
              "null"
            ],
            "description": "The EDD requirement it answers; sow_person for a person's Source of Wealth."
          },
          "personRef": {
            "type": [
              "string",
              "null"
            ],
            "description": "The person a Source of Wealth is for."
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "uploaded",
              "declared",
              "cannot_provide",
              "not_applicable"
            ]
          },
          "documentIds": {
            "type": "array",
            "items": {
              "type": [
                "integer",
                "string"
              ]
            },
            "description": "The documents the customer sent for it."
          }
        }
      }
    }
  }
}
