{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/elocuenti-com/json-schema/elocuenti-com-events-body-schema.json",
  "title": "EventsBody",
  "description": "The events to record.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/elocuenti-com-events-api-openapi.yml#/components/schemas/EventsBody",
  "type": "object",
  "properties": {
    "events": {
      "minItems": 1,
      "maxItems": 100,
      "type": "array",
      "items": {
        "$ref": "#/$defs/EventItem"
      },
      "description": "The events to record, from 1 to 100. Each one is checked on its own: the ones that pass are recorded and the answer lists, by position, the ones that did not.",
      "title": "Events"
    }
  },
  "required": [
    "events"
  ],
  "additionalProperties": false,
  "$defs": {
    "EventItem": {
      "type": "object",
      "properties": {
        "contact_id": {
          "type": "string",
          "format": "uuid",
          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$",
          "description": "The identifier of the contact, as returned by the contacts operations.",
          "title": "Contact Id"
        },
        "external_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 255,
          "description": "The identifier the contact has in your own system, the same one you sent when you created the contact (`external_id`).",
          "title": "External Id"
        },
        "phone": {
          "type": "string",
          "pattern": "^\\+[1-9]\\d{6,14}$",
          "description": "The contact's phone number in international format (E.164): a plus sign, the country code and the number, with no spaces or dashes. Old regional formats (for example a Mexican mobile written with the extra 1 after +52) are matched to the same contact as the current one.",
          "title": "Phone"
        },
        "email": {
          "type": "string",
          "maxLength": 254,
          "format": "email",
          "description": "The contact's email address. If two contacts share it, the event is refused as `ambiguous`: name the contact with `phone`, `external_id` or `contact_id` instead.",
          "title": "Email"
        },
        "event": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9_.]{0,63}$",
          "description": "The name of the event: lowercase letters, digits, `_` and `.`, from a letter, up to 64 characters. Use the same name every time the same thing happens. `purchase` and `lead` are the usual ones. A new name needs no setup: it exists from the first time you send it.",
          "title": "Event"
        },
        "event_id": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_.:-]{1,128}$",
          "description": "Your own identifier for this occurrence (an order number, a form id): letters, digits and `_ . : -`, from 1 to 128 characters. Sending the same `event` with the same `event_id` again never records it twice, so you can retry safely. The same `event_id` under another `event` name is another event.",
          "title": "Event Id"
        },
        "properties": {
          "$ref": "#/$defs/EventProperties"
        },
        "occurred_at": {
          "type": "string",
          "format": "date-time",
          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$",
          "description": "When it happened (ISO 8601, with a time zone). Up to 30 days in the past and 24 hours ahead. An event outside that window is rejected, unless it was already recorded (then it comes back as a duplicate). If you leave it out, it is the moment we receive the event.",
          "title": "Occurred At"
        }
      },
      "required": [
        "event",
        "event_id"
      ],
      "additionalProperties": false,
      "description": "One event of one contact. Name the contact with at least one of `contact_id`, `external_id`, `phone` or `email`; if you send several, they must all be the same contact.",
      "title": "EventItem"
    },
    "EventProperties": {
      "type": "object",
      "propertyNames": {
        "type": "string",
        "pattern": "^[a-z][a-z0-9_]{0,63}$"
      },
      "additionalProperties": {
        "anyOf": [
          {
            "type": "string",
            "maxLength": 500
          },
          {
            "type": "number"
          },
          {
            "type": "boolean"
          },
          {
            "type": "null"
          }
        ]
      },
      "description": "What happened, as a flat object of up to 30 keys. Keys are lowercase letters, digits and underscores, from a letter, up to 64 characters. Each value is a text (up to 500 characters), a number, `true`/`false` or `null`; nested objects and lists are refused. All of it, as JSON, fits in 4096 bytes.",
      "title": "EventProperties"
    }
  }
}