{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/n0t1fy-dev/json-schema/n0t1fy-dev-message-response-schema.json",
  "title": "MessageResponse",
  "description": "One message resource. Text, full recipient, and provider internals are never included.",
  "x-generated": "2026-10-31",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/n0t1fy-dev-api-openapi.json#/components/schemas/MessageResponse",
  "properties": {
    "id": {
      "type": "string",
      "title": "Id",
      "description": "Opaque message identifier. Store it to read the status later."
    },
    "object": {
      "type": "string",
      "const": "message",
      "title": "Object",
      "description": "Always `message`."
    },
    "to": {
      "type": "string",
      "title": "To",
      "description": "Masked recipient: country code and first digit, then the last two digits."
    },
    "status": {
      "type": "string",
      "enum": [
        "queued",
        "submitted",
        "delivered",
        "undeliverable",
        "failed",
        "unknown"
      ],
      "title": "Status",
      "description": "Normalized delivery state. `submitted` means the provider accepted the request, not that a handset received it."
    },
    "segments": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Segments",
      "description": "SMS segments this message occupies — the unit the provider bills. `null` only for messages created before segment counting existed."
    },
    "error": {
      "anyOf": [
        {
          "$ref": "#/$defs/MessageError"
        },
        {
          "type": "null"
        }
      ],
      "description": "`null` unless the message failed or was undeliverable."
    },
    "created_at": {
      "type": "string",
      "title": "Created At",
      "description": "ISO 8601 UTC, second precision, `Z` suffix."
    },
    "updated_at": {
      "type": "string",
      "title": "Updated At",
      "description": "ISO 8601 UTC time of the most recent change."
    }
  },
  "type": "object",
  "required": [
    "id",
    "object",
    "to",
    "status",
    "segments",
    "created_at",
    "updated_at"
  ],
  "$defs": {
    "MessageError": {
      "properties": {
        "code": {
          "type": "string",
          "title": "Code",
          "description": "Stable machine-readable code, safe to branch on."
        },
        "message": {
          "type": "string",
          "title": "Message",
          "description": "Human-readable explanation. Wording may change; the code will not."
        }
      },
      "type": "object",
      "required": [
        "code",
        "message"
      ],
      "title": "MessageError",
      "description": "A safe, provider-neutral explanation attached to a message."
    }
  }
}