{
  "$id": "https://intentschema.org/intents/communication/sms/message/list/v1.json",
  "fqdn": "org.intentschema.communication.sms.message.list.v1",
  "title": "List SMS messages",
  "description": "List inbound and outbound SMS messages, optionally filtered by phone number or date range.",
  "payload": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "required": [
      "target"
    ],
    "properties": {
      "target": {
        "$ref": "https://intentschema.org/common/target/v1.json"
      },
      "object": {
        "type": "object",
        "properties": {
          "query": {
            "type": "string"
          },
          "filter": {
            "type": "object",
            "properties": {
              "from": {
                "type": "string"
              },
              "to": {
                "type": "string"
              },
              "after": {
                "type": "string",
                "format": "date-time"
              },
              "before": {
                "type": "string",
                "format": "date-time"
              },
              "direction": {
                "enum": [
                  "inbound",
                  "outbound"
                ]
              }
            }
          },
          "limit": {
            "type": "integer",
            "minimum": 1,
            "maximum": 500,
            "default": 50
          },
          "cursor": {
            "type": "string"
          }
        }
      }
    }
  },
  "result": {
    "type": "object",
    "required": [
      "items"
    ],
    "properties": {
      "items": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "external_id": {
              "type": "string"
            },
            "from": {
              "type": "string"
            },
            "to": {
              "type": "string"
            },
            "text": {
              "type": "string"
            },
            "direction": {
              "enum": [
                "inbound",
                "outbound"
              ]
            },
            "sent_at": {
              "type": "string",
              "format": "date-time"
            },
            "status": {
              "type": "string"
            }
          }
        }
      },
      "next_cursor": {
        "type": "string"
      }
    }
  },
  "examples": [
    {
      "name": "recent inbound",
      "value": {
        "target": {
          "system": "twilio"
        },
        "object": {
          "filter": {
            "to": "+15551234567",
            "direction": "inbound"
          }
        }
      }
    }
  ]
}
