{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/smstunnel-io/json-schema/smstunnel-io-twilio-message-schema.json",
  "title": "TwilioMessage",
  "description": "Twilio's Message resource.",
  "x-generated": "2026-11-22",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/smstunnel-io-openapi.json#/components/schemas/TwilioMessage",
  "type": "object",
  "required": [
    "sid",
    "account_sid",
    "messaging_service_sid",
    "to",
    "from",
    "body",
    "status",
    "num_segments",
    "num_media",
    "direction",
    "api_version",
    "price",
    "price_unit",
    "error_code",
    "error_message",
    "date_created",
    "date_updated",
    "date_sent",
    "uri",
    "subresource_uris"
  ],
  "properties": {
    "sid": {
      "type": "string",
      "pattern": "^SM[0-9a-f]{32}$"
    },
    "account_sid": {
      "type": "string",
      "description": "The `AccountSid` of the request."
    },
    "messaging_service_sid": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        null
      ]
    },
    "to": {
      "type": "string",
      "description": "The recipient. Empty for a received text in the list. On a fetch by SID: a received text's sender, or, for an encrypted text sent without a number, its id in square brackets."
    },
    "from": {
      "type": "string",
      "description": "On create, the `From` you sent, unused. Empty on a fetch and on a sent text in the list: the phone's own number is not known. In the list, a received text's sender."
    },
    "body": {
      "type": [
        "string",
        "null"
      ],
      "description": "The text. Always `null` on a fetch by SID, and for an encrypted text in the list."
    },
    "status": {
      "type": "string",
      "enum": [
        "queued",
        "sent",
        "failed",
        "received",
        "delivered"
      ],
      "description": "`queued`: waiting for your phone or on its way to it (always the answer to a create). `sent`: **the last good status**. `failed`. `received`: a received text, in the list. A text you send never reaches `delivered`; that value appears only when you fetch a *received* text by its SID. **An unconfirmed text reads `sent` with an `error_message` starting \"Not confirmed by the phone\": it may have gone out, so never resend it automatically.**"
    },
    "num_segments": {
      "type": "string",
      "description": "The SMS parts, as a string. On a fetch by SID it is always `\"1\"`."
    },
    "num_media": {
      "type": "string",
      "enum": [
        "0"
      ]
    },
    "direction": {
      "type": "string",
      "enum": [
        "outbound-api",
        "inbound"
      ],
      "description": "A fetch by SID always says `outbound-api`."
    },
    "api_version": {
      "type": "string",
      "enum": [
        "2010-04-01"
      ]
    },
    "price": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        null
      ],
      "description": "Always `null`: SMSTunnel does not price per message."
    },
    "price_unit": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        null
      ]
    },
    "error_code": {
      "type": [
        "integer",
        "null"
      ],
      "enum": [
        null
      ],
      "description": "Always `null`: read `error_message`."
    },
    "error_message": {
      "type": [
        "string",
        "null"
      ],
      "description": "Why it failed, or \"Not confirmed by the phone…\" for an unconfirmed text."
    },
    "date_created": {
      "type": "string",
      "pattern": "^[A-Z][a-z]{2}, \\d{2} [A-Z][a-z]{2} \\d{4} \\d{2}:\\d{2}:\\d{2} \\+0000$",
      "description": "RFC 2822. On a fetch by SID: when it was sent, or the time of this request until then."
    },
    "date_updated": {
      "type": "string",
      "pattern": "^[A-Z][a-z]{2}, \\d{2} [A-Z][a-z]{2} \\d{4} \\d{2}:\\d{2}:\\d{2} \\+0000$",
      "description": "RFC 2822. On a fetch by SID, the same as `date_created`."
    },
    "date_sent": {
      "type": [
        "string",
        "null"
      ],
      "pattern": "^[A-Z][a-z]{2}, \\d{2} [A-Z][a-z]{2} \\d{4} \\d{2}:\\d{2}:\\d{2} \\+0000$",
      "description": "RFC 2822. `null` until the phone confirms it."
    },
    "uri": {
      "type": "string"
    },
    "subresource_uris": {
      "type": "object",
      "required": [
        "media"
      ],
      "properties": {
        "media": {
          "type": "string"
        }
      }
    }
  }
}