SCHEMA REFERENCE

A small envelope. Clear meanings.

The LogAPI example schema keeps shared event context separate from typed attributes. Download it, inspect the limits, and adapt it intentionally.

Download JSON Schema

The field dictionary

LogAPI example envelope fields
FieldShapeMeaning
schema_versionstring · requiredExactly 1.0 for this example contract.
event_idstring · requiredA stable event reference, 1–128 characters. Preserve it on retries.
timestampdate-time string · requiredWhen the event occurred, with a timezone. Enable format checking in the validator.
event_namestring · requiredA dotted lowercase name such as request.completed; maximum 128 characters.
severityenum · requiredTRACE, DEBUG, INFO, WARN, ERROR, or FATAL. Separate this from the business outcome.
servicestring · requiredThe emitting service, 1–128 characters.
messagestring · optionalA safe human-readable summary, no more than 1,024 characters.
attributesobject · requiredAt most 32 named scalar attributes. Strings are limited to 1,024 characters.

What the schema validates

The schema rejects unknown top-level properties. Attribute names must begin with a lowercase letter and contain only lowercase letters, digits, and underscores. Attribute values can be strings, numbers, booleans, or null; nested objects and arrays are outside this compact example format.

Those checks constrain shape. They do not establish that a route is sanitized, a timestamp is accurate, or a value is appropriate for collection. Add event-specific required attributes, numeric bounds, and privacy allowlists for your application. A schema is not a redaction engine.

JSON Schema · draft 2020-12
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://logapi.com/assets/data/logapi-event-schema.json",
  "title": "LogAPI example event envelope",
  "description": "A compact teaching schema. Not an OTLP message or a hosted API contract. Apply a per-event attribute allowlist before production use.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "event_id",
    "timestamp",
    "event_name",
    "severity",
    "service",
    "attributes"
  ],
  "properties": {
    "schema_version": {
      "type": "string",
      "const": "1.0"
    },
    "event_id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128
    },
    "timestamp": {
      "type": "string",
      "format": "date-time"
    },
    "event_name": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9_]*(\\.[a-z][a-z0-9_]*)+$",
      "maxLength": 128
    },
    "severity": {
      "type": "string",
      "enum": [
        "TRACE",
        "DEBUG",
        "INFO",
        "WARN",
        "ERROR",
        "FATAL"
      ]
    },
    "service": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128
    },
    "message": {
      "type": "string",
      "maxLength": 1024
    },
    "attributes": {
      "type": "object",
      "maxProperties": 32,
      "propertyNames": {
        "pattern": "^[a-z][a-z0-9_]*$",
        "maxLength": 64
      },
      "additionalProperties": {
        "type": [
          "string",
          "number",
          "boolean",
          "null"
        ],
        "maxLength": 1024
      }
    }
  }
}

Missing values are a design choice

A missing optional attribute, a null attribute, and a numeric zero should not automatically mean the same thing. Define whether an absent measurement is unknown, unavailable, or irrelevant to the event. Do not turn missing token usage into a zero-cost request.

Mapping and compatibility

The envelope is not an OpenTelemetry protocol message. Fields such as service and severity need a deliberate mapping when integrating with another model or SDK. Preserve source units and record the instrumentation version used by that mapping.

Fixtures worth testing

Test a valid application event, an event missing its service, an unsupported version, an extra top-level credential field, a malformed timestamp, a nested attribute, and a string where a number is expected by your event-specific contract. Verify that rejected payloads are not copied into unsafe error logs.

Compare the six synthetic event files against the contract. Read the structured schema guide before planning a migration.

Technical reference: JSON Schema object reference . Verify the version and settings used by your own implementation.