{
  "$id": "https://intentschema.org/intents/productivity/contacts/contact/create/v1.json",
  "fqdn": "org.intentschema.productivity.contacts.contact.create.v1",
  "title": "Create contact",
  "description": "Creates a new contact. Payload follows a jCard-inspired subset (RFC 7095).",
  "payload": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "required": [
      "target",
      "object"
    ],
    "properties": {
      "target": {
        "$ref": "https://intentschema.org/common/target/v1.json"
      },
      "object": {
        "type": "object",
        "properties": {
          "given_name": {
            "type": "string"
          },
          "family_name": {
            "type": "string"
          },
          "display_name": {
            "type": "string"
          },
          "emails": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "email"
              ],
              "properties": {
                "email": {
                  "type": "string",
                  "format": "email"
                },
                "type": {
                  "enum": [
                    "home",
                    "work",
                    "other"
                  ]
                }
              }
            }
          },
          "phones": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "number"
              ],
              "properties": {
                "number": {
                  "type": "string"
                },
                "type": {
                  "enum": [
                    "mobile",
                    "home",
                    "work",
                    "other"
                  ]
                }
              }
            }
          },
          "organization": {
            "type": "string"
          },
          "job_title": {
            "type": "string"
          },
          "notes": {
            "type": "string"
          }
        },
        "anyOf": [
          {
            "required": [
              "given_name"
            ]
          },
          {
            "required": [
              "family_name"
            ]
          },
          {
            "required": [
              "display_name"
            ]
          },
          {
            "required": [
              "emails"
            ]
          }
        ]
      },
      "idempotency_key": {
        "type": "string"
      }
    }
  },
  "result": {
    "type": "object",
    "required": [
      "external_id"
    ],
    "properties": {
      "external_id": {
        "type": "string"
      },
      "created_at": {
        "type": "string",
        "format": "date-time"
      }
    }
  },
  "examples": [
    {
      "name": "contact with work email",
      "value": {
        "target": {
          "system": "google_contacts"
        },
        "object": {
          "given_name": "Jane",
          "family_name": "Cho",
          "emails": [
            {
              "email": "jane@example.com",
              "type": "work"
            }
          ],
          "organization": "Example Inc",
          "job_title": "VP Engineering"
        }
      }
    }
  ]
}
