{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/telnyx/main/json-schema/telnyx-inbound-message-payload-schema.json",
  "title": "InboundMessagePayload",
  "x-generated": "2026-10-08",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/telnyx-messages-api-openapi.yml#/components/schemas/InboundMessagePayload",
  "properties": {
    "cc": {
      "items": {
        "properties": {
          "carrier": {
            "description": "The carrier of the receiver.",
            "type": "string"
          },
          "line_type": {
            "description": "The line-type of the receiver.",
            "enum": [
              "Wireline",
              "Wireless",
              "VoWiFi",
              "VoIP",
              "Pre-Paid Wireless",
              ""
            ],
            "type": "string"
          },
          "phone_number": {
            "description": "Receiving address (+E.164 formatted phone number or short code).",
            "type": "string",
            "x-format": "address"
          },
          "status": {
            "enum": [
              "queued",
              "sending",
              "sent",
              "delivered",
              "sending_failed",
              "delivery_failed",
              "delivery_unconfirmed"
            ],
            "type": "string"
          }
        },
        "type": "object"
      },
      "type": "array"
    },
    "completed_at": {
      "description": "Not used for inbound messages.",
      "format": "date-time",
      "type": [
        "string",
        "null"
      ]
    },
    "cost": {
      "properties": {
        "amount": {
          "description": "The amount deducted from your account.",
          "type": "string",
          "x-format": "decimal"
        },
        "currency": {
          "description": "The ISO 4217 currency identifier.",
          "type": "string",
          "x-format": "iso4217"
        }
      },
      "type": [
        "object",
        "null"
      ]
    },
    "cost_breakdown": {
      "description": "Detailed breakdown of the message cost components.",
      "properties": {
        "carrier_fee": {
          "properties": {
            "amount": {
              "description": "The carrier fee amount.",
              "type": "string",
              "x-format": "decimal"
            },
            "currency": {
              "description": "The ISO 4217 currency identifier.",
              "type": "string",
              "x-format": "iso4217"
            }
          },
          "type": "object"
        },
        "rate": {
          "properties": {
            "amount": {
              "description": "The rate amount applied.",
              "type": "string",
              "x-format": "decimal"
            },
            "currency": {
              "description": "The ISO 4217 currency identifier.",
              "type": "string",
              "x-format": "iso4217"
            }
          },
          "type": "object"
        }
      },
      "type": [
        "object",
        "null"
      ]
    },
    "direction": {
      "description": "The direction of the message. Inbound messages are sent to you whereas outbound messages are sent from you.",
      "enum": [
        "inbound"
      ],
      "type": "string"
    },
    "encoding": {
      "description": "Encoding scheme used for the message body.",
      "type": "string"
    },
    "errors": {
      "description": "These errors may point at addressees when referring to unsuccessful/unconfirmed delivery statuses.",
      "items": {
        "$ref": "#/$defs/messaging_Error"
      },
      "type": "array"
    },
    "from": {
      "properties": {
        "carrier": {
          "description": "The carrier of the sender.",
          "type": "string"
        },
        "line_type": {
          "description": "The line-type of the sender.",
          "enum": [
            "Wireline",
            "Wireless",
            "VoWiFi",
            "VoIP",
            "Pre-Paid Wireless",
            ""
          ],
          "type": "string"
        },
        "phone_number": {
          "description": "Sending address (+E.164 formatted phone number, alphanumeric sender ID, or short code).",
          "type": "string",
          "x-format": "address"
        },
        "status": {
          "enum": [
            "received",
            "delivered"
          ],
          "type": "string"
        }
      },
      "type": "object"
    },
    "id": {
      "description": "Identifies the type of resource.",
      "format": "uuid",
      "type": "string"
    },
    "media": {
      "items": {
        "properties": {
          "content_type": {
            "description": "The MIME type of the requested media.",
            "type": "string",
            "x-format": "mime-type"
          },
          "hash_sha256": {
            "description": "The SHA256 hash of the requested media.",
            "maxLength": 32,
            "minLength": 32,
            "type": "string"
          },
          "size": {
            "description": "The size of the requested media.",
            "type": "integer"
          },
          "url": {
            "description": "The url of the media requested to be sent.",
            "format": "url",
            "type": "string"
          }
        },
        "type": "object"
      },
      "type": "array"
    },
    "messaging_profile_id": {
      "description": "Unique identifier for a messaging profile.",
      "type": "string"
    },
    "organization_id": {
      "description": "Unique identifier for a messaging profile.",
      "type": "string"
    },
    "parts": {
      "description": "Number of parts into which the message's body must be split.",
      "maximum": 10,
      "minimum": 1,
      "type": "integer"
    },
    "received_at": {
      "description": "ISO 8601 formatted date indicating when the message request was received.",
      "format": "date-time",
      "type": "string"
    },
    "record_type": {
      "description": "Identifies the type of the resource.",
      "enum": [
        "message"
      ],
      "type": "string"
    },
    "sent_at": {
      "description": "Not used for inbound messages.",
      "format": "date-time",
      "type": [
        "string",
        "null"
      ]
    },
    "subject": {
      "description": "Message subject.",
      "type": [
        "string",
        "null"
      ]
    },
    "tags": {
      "description": "Tags associated with the resource.",
      "items": {
        "type": "string"
      },
      "type": "array"
    },
    "tcr_campaign_billable": {
      "description": "Indicates whether the TCR campaign is billable.",
      "type": "boolean"
    },
    "tcr_campaign_id": {
      "description": "The Campaign Registry (TCR) campaign ID associated with the message.",
      "type": [
        "string",
        "null"
      ]
    },
    "tcr_campaign_registered": {
      "description": "The registration status of the TCR campaign.",
      "type": [
        "string",
        "null"
      ]
    },
    "text": {
      "description": "Message body (i.e., content) as a non-empty string.\n\n**Required for SMS**",
      "type": "string"
    },
    "to": {
      "items": {
        "properties": {
          "carrier": {
            "description": "The carrier of the receiver.",
            "type": "string"
          },
          "line_type": {
            "description": "The line-type of the receiver.",
            "enum": [
              "Wireline",
              "Wireless",
              "VoWiFi",
              "VoIP",
              "Pre-Paid Wireless",
              ""
            ],
            "type": "string"
          },
          "phone_number": {
            "description": "Receiving address (+E.164 formatted phone number or short code).",
            "type": "string",
            "x-format": "address"
          },
          "status": {
            "enum": [
              "queued",
              "sending",
              "sent",
              "delivered",
              "sending_failed",
              "delivery_failed",
              "delivery_unconfirmed",
              "webhook_delivered"
            ],
            "type": "string"
          }
        },
        "type": "object"
      },
      "type": "array"
    },
    "type": {
      "description": "The type of message. This value can be either 'sms' or 'mms'.",
      "enum": [
        "SMS",
        "MMS"
      ],
      "type": "string"
    },
    "valid_until": {
      "description": "Not used for inbound messages.",
      "format": "date-time",
      "type": [
        "string",
        "null"
      ]
    },
    "webhook_failover_url": {
      "description": "The failover URL where webhooks related to this message will be sent if sending to the primary URL fails.",
      "format": "url",
      "type": [
        "string",
        "null"
      ]
    },
    "webhook_url": {
      "description": "The URL where webhooks related to this message will be sent.",
      "format": "url",
      "type": [
        "string",
        "null"
      ]
    }
  },
  "$defs": {
    "messaging_Error": {
      "properties": {
        "code": {
          "type": "string",
          "x-format": "integer"
        },
        "detail": {
          "type": "string"
        },
        "meta": {
          "type": "object"
        },
        "source": {
          "properties": {
            "parameter": {
              "description": "Indicates which query parameter caused the error.",
              "type": "string"
            },
            "pointer": {
              "description": "JSON pointer (RFC6901) to the offending entity.",
              "format": "json-pointer",
              "type": "string"
            }
          },
          "type": "object"
        },
        "title": {
          "type": "string"
        }
      },
      "required": [
        "code",
        "title"
      ]
    }
  }
}