{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://yougrow.ai/developers/schema/patch-response.json",
  "title": "Patch response",
  "description": "What PATCH /api/v2/users/{userId} returns with 200: the write applied, or skipped as stale_write or deleted_later.",
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "applied": {
          "type": "boolean",
          "const": true
        },
        "user": {
          "type": "object",
          "properties": {
            "userId": {
              "type": "string"
            },
            "email": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "firstName": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "lastName": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "timezone": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "locale": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "signedUpAt": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "consent": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "consent",
                    "soft_opt_in",
                    "corporate_subscriber",
                    "none"
                  ]
                },
                {
                  "type": "null"
                }
              ]
            },
            "subscribed": {
              "type": "boolean"
            },
            "excluded": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "reason": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "reason"
                  ]
                },
                {
                  "type": "null"
                }
              ]
            },
            "steps": {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {
                "type": "string"
              },
              "maxProperties": 50
            },
            "facts": {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {
                "anyOf": [
                  {
                    "type": "string",
                    "maxLength": 200
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "maxProperties": 50
            },
            "traits": {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {
                "anyOf": [
                  {
                    "type": "string",
                    "maxLength": 500
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "maxProperties": 50
            },
            "entities": {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string"
                  },
                  "name": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "parentId": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "role": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "owner",
                          "member",
                          "invited"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "steps": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {
                      "type": "string"
                    },
                    "maxProperties": 50
                  },
                  "facts": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {
                      "anyOf": [
                        {
                          "type": "string",
                          "maxLength": 200
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    },
                    "maxProperties": 50
                  },
                  "activeAt": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "kind",
                  "name",
                  "parentId",
                  "role",
                  "steps",
                  "facts",
                  "activeAt"
                ]
              }
            },
            "updatedAt": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "required": [
            "userId",
            "email",
            "firstName",
            "lastName",
            "timezone",
            "locale",
            "signedUpAt",
            "consent",
            "subscribed",
            "excluded",
            "steps",
            "facts",
            "traits",
            "entities",
            "updatedAt"
          ]
        },
        "ignoredFields": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "path": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "path",
              "message"
            ]
          }
        }
      },
      "required": [
        "applied",
        "user"
      ]
    },
    {
      "type": "object",
      "properties": {
        "applied": {
          "type": "boolean",
          "const": false
        },
        "reason": {
          "type": "string",
          "enum": [
            "stale_write",
            "deleted_later"
          ]
        },
        "storedUpdatedAt": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "user": {
          "type": "object",
          "properties": {
            "userId": {
              "type": "string"
            },
            "email": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "firstName": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "lastName": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "timezone": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "locale": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "signedUpAt": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "consent": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "consent",
                    "soft_opt_in",
                    "corporate_subscriber",
                    "none"
                  ]
                },
                {
                  "type": "null"
                }
              ]
            },
            "subscribed": {
              "type": "boolean"
            },
            "excluded": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "reason": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "reason"
                  ]
                },
                {
                  "type": "null"
                }
              ]
            },
            "steps": {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {
                "type": "string"
              },
              "maxProperties": 50
            },
            "facts": {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {
                "anyOf": [
                  {
                    "type": "string",
                    "maxLength": 200
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "maxProperties": 50
            },
            "traits": {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {
                "anyOf": [
                  {
                    "type": "string",
                    "maxLength": 500
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "maxProperties": 50
            },
            "entities": {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string"
                  },
                  "name": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "parentId": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "role": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "owner",
                          "member",
                          "invited"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "steps": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {
                      "type": "string"
                    },
                    "maxProperties": 50
                  },
                  "facts": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {
                      "anyOf": [
                        {
                          "type": "string",
                          "maxLength": 200
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    },
                    "maxProperties": 50
                  },
                  "activeAt": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "kind",
                  "name",
                  "parentId",
                  "role",
                  "steps",
                  "facts",
                  "activeAt"
                ]
              }
            },
            "updatedAt": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "required": [
            "userId",
            "email",
            "firstName",
            "lastName",
            "timezone",
            "locale",
            "signedUpAt",
            "consent",
            "subscribed",
            "excluded",
            "steps",
            "facts",
            "traits",
            "entities",
            "updatedAt"
          ]
        }
      },
      "required": [
        "applied",
        "reason"
      ]
    }
  ]
}
