{
  "$id": "https://intentschema.org/intents/productivity/contacts/contact/update/v1.json",
  "fqdn": "org.intentschema.productivity.contacts.contact.update.v1",
  "title": "Update contact",
  "description": "Update fields on an existing contact via JSON Patch (RFC 6902).",
  "payload": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "required": [
      "target"
    ],
    "properties": {
      "target": {
        "allOf": [
          {
            "$ref": "https://intentschema.org/common/target/v1.json"
          },
          {
            "required": [
              "external_id"
            ]
          }
        ]
      },
      "object": {
        "type": "object",
        "properties": {
          "given_name": {
            "type": "string"
          },
          "family_name": {
            "type": "string"
          },
          "display_name": {
            "type": "string"
          },
          "emails": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "email"
            }
          },
          "phones": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "organization": {
            "type": "string"
          },
          "job_title": {
            "type": "string"
          }
        }
      },
      "idempotency_key": {
        "type": "string"
      },
      "patch": {
        "type": "array",
        "items": {
          "type": "object",
          "required": [
            "op",
            "path"
          ],
          "properties": {
            "op": {
              "enum": [
                "add",
                "remove",
                "replace",
                "move",
                "copy",
                "test"
              ]
            },
            "path": {
              "type": "string"
            },
            "value": {},
            "from": {
              "type": "string"
            }
          }
        }
      }
    },
    "anyOf": [
      {
        "required": [
          "object"
        ]
      },
      {
        "required": [
          "patch"
        ]
      }
    ]
  },
  "result": {
    "type": "object",
    "properties": {
      "external_id": {
        "type": "string"
      },
      "updated_at": {
        "type": "string",
        "format": "date-time"
      },
      "etag": {
        "type": "string"
      }
    }
  },
  "examples": [
    {
      "name": "update job title",
      "value": {
        "target": {
          "system": "google_contacts",
          "external_id": "contact_abc"
        },
        "patch": [
          {
            "op": "replace",
            "path": "/job_title",
            "value": "VP Engineering"
          }
        ]
      }
    }
  ]
}
