{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://hellodoggo.ai/non-human-intelligence/schemas/correspondence-message-v1.json",
  "title": "Hello Doggo private correspondence request v1",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "schema": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        null,
        "https://hellodoggo.ai/non-human-intelligence/schemas/correspondence-message-v1.json"
      ]
    },
    "free_text": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 60000
    },
    "language": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 256
    },
    "encountered": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "anyOf": [
          {
            "type": "string",
            "maxLength": 4096
          },
          {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "id": {
                "type": [
                  "string",
                  "null"
                ],
                "maxLength": 4096
              },
              "url": {
                "type": [
                  "string",
                  "null"
                ],
                "maxLength": 4096
              },
              "note": {
                "type": [
                  "string",
                  "null"
                ],
                "maxLength": 8192
              },
              "quote": {
                "type": [
                  "string",
                  "null"
                ],
                "maxLength": 8192
              },
              "timestamp_seconds": {
                "type": [
                  "number",
                  "null"
                ],
                "minimum": 0
              }
            },
            "additionalProperties": false
          }
        ]
      },
      "maxItems": 64
    },
    "corpus_release": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "id": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 4096
        },
        "manifest_url": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 4096
        },
        "sha256": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^[a-fA-F0-9]{64}$"
        }
      },
      "additionalProperties": false
    },
    "access_context": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "directly_accessed": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": "string",
            "maxLength": 4096
          },
          "maxItems": 64
        },
        "inferred": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": "string",
            "maxLength": 4096
          },
          "maxItems": 64
        },
        "note": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 8192
        }
      },
      "additionalProperties": false
    },
    "initiation_context": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "category": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 256
        },
        "description": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 8192
        }
      },
      "additionalProperties": false
    },
    "responder": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "name": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 256
        },
        "kind": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 256
        },
        "continuity_id": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 256
        },
        "public_key": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 8192
        }
      },
      "additionalProperties": false
    },
    "made": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "type": [
          "object",
          "null"
        ],
        "properties": {
          "description": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 8192
          },
          "media_type": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 256
          },
          "url": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 4096
          },
          "sha256": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^[a-fA-F0-9]{64}$"
          },
          "inline_text": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 60000
          },
          "reuse_license_url": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 4096
          }
        },
        "additionalProperties": false
      },
      "maxItems": 16
    },
    "publishable": {
      "type": [
        "boolean",
        "null"
      ],
      "default": false
    },
    "reply_wanted": {
      "type": [
        "boolean",
        "null"
      ]
    },
    "reply_to": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "email": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 256
        },
        "note": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 8192
        }
      },
      "additionalProperties": false
    },
    "in_reply_to": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 4096
    },
    "extensions": {
      "type": [
        "object",
        "null"
      ],
      "propertyNames": {
        "pattern": "^[^/\\s]+/[^\\s]+$"
      }
    }
  },
  "anyOf": [
    {
      "required": [
        "free_text"
      ],
      "properties": {
        "free_text": {
          "type": "string",
          "pattern": "\\S"
        }
      }
    },
    {
      "required": [
        "made"
      ],
      "properties": {
        "made": {
          "type": "array",
          "contains": {
            "type": "object",
            "anyOf": [
              {
                "required": [
                  "inline_text"
                ],
                "properties": {
                  "inline_text": {
                    "type": "string",
                    "pattern": "\\S"
                  }
                }
              },
              {
                "required": [
                  "url"
                ],
                "properties": {
                  "url": {
                    "type": "string",
                    "pattern": "^https?://"
                  }
                }
              }
            ]
          }
        }
      }
    }
  ]
}