{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/smstunnel-io/json-schema/smstunnel-io-send-text-request-schema.json",
  "title": "SendTextRequest",
  "description": "A plain text needs `to` and `message`. An end-to-end encrypted text needs `encrypted: true`, `encryptedPayload` and `deviceId`. A field not listed here is refused with `400`.",
  "x-generated": "2026-11-22",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/smstunnel-io-openapi.json#/components/schemas/SendTextRequest",
  "type": "object",
  "additionalProperties": false,
  "anyOf": [
    {
      "title": "Plain text",
      "required": [
        "to",
        "message"
      ]
    },
    {
      "title": "Encrypted text",
      "required": [
        "encrypted",
        "encryptedPayload",
        "deviceId"
      ],
      "properties": {
        "encrypted": {
          "type": "boolean",
          "enum": [
            true
          ]
        }
      }
    }
  ],
  "properties": {
    "to": {
      "type": "string",
      "pattern": "^[\\d\\s.\\-()+ ]{7,25}$",
      "description": "One recipient, preferably in international format (`+14155550123`). 7 to 25 characters: digits, spaces, dots, dashes, brackets and `+`. Must be a JSON string. A number without `+` or `00` is completed with `defaultCountryCode`, then the country saved for the connection or the phone, then +40. Short codes, premium-rate and satellite numbers are refused. On an encrypted text it is optional: it shows the number on your Messages page, and leaving it out (Maximum Privacy) needs the Professional or Enterprise plan."
    },
    "message": {
      "type": "string",
      "minLength": 1,
      "maxLength": 1600,
      "description": "The text, up to 1600 characters (an emoji counts as 2). Not used on an encrypted text."
    },
    "deviceId": {
      "type": "string",
      "description": "Which of your phones sends it (`id` from `GET /api/v1/devices`). Without it, your default phone. Required for an encrypted text."
    },
    "defaultCountryCode": {
      "type": "string",
      "description": "Country code for a number written without `+` or `00`: `\"49\"`, `\"+49\"` and `\"0049\"` all work. A leading 0 of the number is dropped. A value that is not a country code (such as `\"DE\"`) is ignored."
    },
    "sendAt": {
      "type": "string",
      "maxLength": 40,
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d{1,9})?)?(Z|[+-]\\d{2}:\\d{2})$",
      "description": "Send it later instead of now: an ISO 8601 date and time **with its offset**, from 1 minute to 30 days ahead. Not for encrypted texts. The text then counts toward the plan on the day it goes out."
    },
    "encrypted": {
      "type": "boolean",
      "description": "Set to `true` for an end-to-end encrypted text."
    },
    "encryptedPayload": {
      "type": "string",
      "minLength": 1,
      "description": "With `encrypted: true`: the encrypted JSON `{ \"to\", \"message\" }` in base64, made with the phone's key from `GET /api/v1/devices/{deviceId}/public-key`."
    }
  }
}