{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "organizationId": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    },
    "replies": {
      "type": "object",
      "properties": {
        "items": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "thread": {
                "type": "object",
                "properties": {
                  "account_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500
                  },
                  "thread_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500
                  },
                  "provider": {
                    "type": "string",
                    "enum": ["gmail", "outlook", "instantly"]
                  }
                },
                "required": ["account_id", "thread_id", "provider"],
                "additionalProperties": false
              },
              "subject": {
                "type": "string"
              },
              "lastActivityAt": {
                "type": "string"
              },
              "needsReply": {
                "type": ["boolean", "null"]
              },
              "done": {
                "type": "boolean"
              },
              "replyStatus": {
                "type": ["string", "null"]
              },
              "latestMessage": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "date": {
                        "type": "string"
                      },
                      "direction": {
                        "type": "string",
                        "enum": ["incoming", "outgoing", "unknown"]
                      },
                      "subject": {
                        "type": "string"
                      },
                      "from": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "type": "string"
                          },
                          "email": {
                            "type": "string"
                          }
                        },
                        "required": ["name", "email"],
                        "additionalProperties": false
                      },
                      "to": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "name": {
                              "type": "string"
                            },
                            "email": {
                              "type": "string"
                            }
                          },
                          "required": ["name", "email"],
                          "additionalProperties": false
                        }
                      },
                      "labels": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    },
                    "required": [
                      "id",
                      "date",
                      "direction",
                      "subject",
                      "from",
                      "to"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "reviewUrl": {
                "type": "string",
                "format": "uri"
              }
            },
            "required": [
              "thread",
              "subject",
              "lastActivityAt",
              "needsReply",
              "done",
              "replyStatus",
              "latestMessage",
              "reviewUrl"
            ],
            "additionalProperties": false
          }
        },
        "hasMore": {
          "type": "boolean"
        },
        "syncing": {
          "type": "boolean"
        },
        "incomplete": {
          "type": "boolean"
        }
      },
      "required": ["items", "hasMore", "syncing", "incomplete"],
      "additionalProperties": false
    },
    "campaignReview": {
      "type": "object",
      "properties": {
        "items": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "campaignId": {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              "name": {
                "type": "string"
              },
              "prospects": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "emails": {
                "anyOf": [
                  {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "reviewUrl": {
                "type": "string",
                "format": "uri"
              }
            },
            "required": [
              "campaignId",
              "name",
              "prospects",
              "emails",
              "reviewUrl"
            ],
            "additionalProperties": false
          }
        },
        "hasMore": {
          "type": "boolean"
        }
      },
      "required": ["items", "hasMore"],
      "additionalProperties": false
    }
  },
  "required": ["organizationId", "replies", "campaignReview"],
  "additionalProperties": false
}
