{
  "openapi": "3.0.1",
  "info": {
    "title": "Twilio - Messaging",
    "description": "This is the public Twilio REST API.",
    "termsOfService": "https://www.twilio.com/legal/tos",
    "contact": {
      "name": "Twilio Support",
      "url": "https://support.twilio.com",
      "email": "support@twilio.com"
    },
    "license": {
      "name": "Apache 2.0",
      "url": "https://www.apache.org/licenses/LICENSE-2.0.html"
    },
    "version": "1.0.0",
    "x-twilio": {
      "apiStandards": "v0.1"
    }
  },
  "security": [
    {
      "accountSid_authToken": []
    }
  ],
  "servers": [
    {
      "url": "https://messaging.twilio.com"
    }
  ],
  "paths": {
    "/v3/OptOuts/DefaultKeywordsMessages": {},
    "/v3/OptOuts": {},
    "/v3/OptOuts/{OptOutSid}": {},
    "/v3/OptOuts/Configurations/Languages": {},
    "/v3/OptOuts/Configurations/MessageTypes": {},
    "/v3/OptOuts/{OptOutSid}/MessageTypes": {},
    "/v3/OptOuts/{OptOutSid}/Messages": {},
    "/v3/OptOuts/{OptOutSid}/Keywords": {}
  },
  "components": {
    "securitySchemes": {
      "accountSid_authToken": {
        "scheme": "basic",
        "type": "http"
      }
    },
    "schemas": {
      "KeywordConfigurationResponse": {
        "type": "object",
        "description": "Response containing keyword configurations organized by keyword type",
        "additionalProperties": {
          "$ref": "#/components/schemas/KeywordTypeConfig"
        },
        "example": {
          "STOP": {
            "keywords": [
              {
                "keyword": "OPTOUT",
                "reserved": false
              },
              {
                "keyword": "STOP",
                "reserved": true
              }
            ],
            "message": "You have successfully been unsubscribed. You will not receive any more messages from this number. Reply START to resubscribe."
          },
          "START": {
            "keywords": [
              {
                "keyword": "START",
                "reserved": true
              },
              {
                "keyword": "YES",
                "reserved": false
              }
            ],
            "message": "You have successfully been re-subscribed to messages from this number. Reply HELP for help. Reply STOP to unsubscribe. Msg&Data Rates May Apply."
          }
        }
      },
      "KeywordTypeConfig": {
        "type": "object",
        "description": "Configuration for a specific keyword type (STOP, START, HELP, etc.)",
        "required": [
          "keywords",
          "message"
        ],
        "properties": {
          "keywords": {
            "type": "array",
            "description": "List of keywords associated with this keyword type",
            "items": {
              "$ref": "#/components/schemas/KeywordItem"
            },
            "minItems": 1
          },
          "message": {
            "type": "string",
            "description": "The response message sent when any keyword of this type is received",
            "minLength": 1,
            "maxLength": 1600,
            "example": "You have successfully been unsubscribed. You will not receive any more messages from this number. Reply START to resubscribe."
          }
        }
      },
      "KeywordItem": {
        "type": "object",
        "description": "Individual keyword configuration",
        "required": [
          "keyword",
          "reserved"
        ],
        "properties": {
          "keyword": {
            "type": "string",
            "description": "The actual keyword text",
            "minLength": 1,
            "maxLength": 34,
            "pattern": "^[A-Z0-9]+$",
            "example": "STOP"
          },
          "reserved": {
            "type": "boolean",
            "description": "Indicates whether this keyword is reserved by the system and cannot be modified",
            "example": true
          }
        }
      },
      "OptOutDefaultKeywordMessageResponse": {
        "type": "object",
        "properties": {
          "defaultKeywords": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "keyword": {
                  "type": "string",
                  "description": "The opt-out keyword",
                  "example": "STOP"
                },
                "messageType": {
                  "type": "string",
                  "description": "The type of message (SMS, etc.)",
                  "example": "SMS"
                },
                "language": {
                  "type": "string",
                  "description": "Language code for the message",
                  "example": "en"
                },
                "message": {
                  "type": "string",
                  "description": "The default response message sent when this keyword is used",
                  "example": "You have successfully opted out from receiving messages."
                }
              }
            }
          }
        }
      },
      "OptOutConfig": {
        "type": "object",
        "required": [
          "opt_out_sid",
          "account_sid"
        ],
        "properties": {
          "opt_out_sid": {
            "type": "string",
            "description": "The unique SID identifier for the opt-out configuration",
            "pattern": "^OO[0-9a-fA-F]{32}$",
            "example": "OO1234567890abcdef1234567890abcdef"
          },
          "account_sid": {
            "type": "string",
            "description": "The SID of the account that owns this opt-out configuration",
            "pattern": "^AC[0-9a-fA-F]{32}$",
            "example": "AC1234567890abcdef1234567890abcdef"
          },
          "friendly_name": {
            "type": "string",
            "description": "A human-readable name for the opt-out configuration",
            "nullable": true,
            "example": "Customer Service Opt-Out"
          },
          "date_created": {
            "type": "string",
            "format": "date-time",
            "description": "The date and time when the opt-out configuration was created",
            "nullable": true,
            "example": "2023-10-01T12:00:00Z"
          },
          "date_updated": {
            "type": "string",
            "format": "date-time",
            "description": "The date and time when the opt-out configuration was last updated",
            "nullable": true,
            "example": "2023-10-15T14:30:00Z"
          }
        }
      },
      "LocaleResponse": {
        "type": "object",
        "required": [
          "languages"
        ],
        "properties": {
          "languages": {
            "type": "array",
            "description": "List of supported languages for opt-out configurations",
            "items": {
              "$ref": "#/components/schemas/LanguageProperties"
            },
            "example": [
              {
                "key": "ENGLISH",
                "friendly_name": "English"
              },
              {
                "key": "SPANISH",
                "friendly_name": "Spanish"
              },
              {
                "key": "FRENCH",
                "friendly_name": "French"
              }
            ]
          }
        }
      },
      "LanguageProperties": {
        "type": "object",
        "required": [
          "key",
          "friendly_name"
        ],
        "properties": {
          "key": {
            "type": "string",
            "description": "The language key/identifier (typically uppercase)",
            "enum": [
              "ALL",
              "AFRIKAANS",
              "ARABIC",
              "BENGALI",
              "CHINESE",
              "CROATIAN",
              "CZECH",
              "DANISH",
              "DUTCH",
              "ENGLISH",
              "ESTONIAN",
              "FINNISH",
              "FRENCH",
              "GERMAN",
              "GREEK",
              "HEBREW",
              "HINDI",
              "HUNGARIAN",
              "ITALIAN",
              "JAPANESE",
              "KOREAN",
              "LATVIAN",
              "LITHUANIAN",
              "MALAY",
              "MALAYSIAN",
              "NORWEGIAN",
              "POLISH",
              "PORTUGUESE",
              "RUSSIAN",
              "SLOVAK",
              "SLOVENE",
              "SPANISH",
              "SOUTHERN_NDEBELE",
              "SOUTHERN_SOTHO",
              "SWATI",
              "SWEDISH",
              "TAMIL",
              "TSWANA",
              "TSONGA",
              "VENDA",
              "XHOSA",
              "ZULU"
            ],
            "example": "ENGLISH"
          },
          "friendly_name": {
            "type": "string",
            "description": "Human-readable display name for the language",
            "example": "English"
          }
        }
      },
      "KeywordLocaleType": {
        "type": "string",
        "pattern": "^(STOP|START|HELP)\\.(ALL|AFRIKAANS|ARABIC|BENGALI|CHINESE|CROATIAN|CZECH|DANISH|DUTCH|ENGLISH|ESTONIAN|FINNISH|FRENCH|GERMAN|GREEK|HEBREW|HINDI|HUNGARIAN|ITALIAN|JAPANESE|KOREAN|LATVIAN|LITHUANIAN|MALAY|MALAYSIAN|NORWEGIAN|POLISH|PORTUGUESE|RUSSIAN|SLOVAK|SLOVENE|SPANISH|SOUTHERN_NDEBELE|SOUTHERN_SOTHO|SWATI|SWEDISH|TAMIL|TSWANA|TSONGA|VENDA|XHOSA|ZULU)$",
        "description": "Combination of KeywordType and Locale in format: {KeywordType}.{Locale}\n\nValid KeywordTypes: STOP, START, HELP\nValid Locales: See LocaleEnum for full list\n\nExamples: STOP.ENGLISH, START.SPANISH, HELP.FRENCH\n"
      },
      "SupportedMessageTypes": {
        "type": "object",
        "required": [
          "message_types"
        ],
        "properties": {
          "message_types": {
            "type": "array",
            "description": "List of supported message types for opt-out configurations",
            "items": {
              "$ref": "#/components/schemas/MessageTypeConfig"
            },
            "example": [
              {
                "key": "ALL",
                "friendly_name": "Global Default Settings"
              },
              {
                "key": "US",
                "friendly_name": "United States"
              },
              {
                "key": "CA",
                "friendly_name": "Canada"
              }
            ]
          }
        }
      },
      "MessageTypeConfig": {
        "type": "object",
        "required": [
          "key",
          "friendly_name"
        ],
        "properties": {
          "key": {
            "type": "string",
            "description": "The message type key/identifier (typically country codes or special identifiers)",
            "example": "US"
          },
          "friendly_name": {
            "type": "string",
            "description": "Human-readable display name for the message type",
            "example": "United States"
          }
        }
      },
      "MessageTypesResponse": {
        "type": "object",
        "required": [
          "account_sid",
          "opt_out_sid",
          "message_types"
        ],
        "properties": {
          "account_sid": {
            "type": "string",
            "description": "The SID of the account that owns this opt-out configuration",
            "pattern": "^AC[0-9a-fA-F]{32}$",
            "example": "AC1234567890abcdef1234567890abcdef"
          },
          "opt_out_sid": {
            "type": "string",
            "description": "The SID of the opt-out configuration",
            "pattern": "^OO[0-9a-fA-F]{32}$",
            "example": "OO1234567890abcdef1234567890abcdef"
          },
          "message_types": {
            "type": "array",
            "description": "List of message types associated with this opt-out configuration",
            "items": {
              "$ref": "#/components/schemas/MessageTypeConfig"
            },
            "example": [
              {
                "key": "ALL",
                "friendly_name": "Global Default Settings"
              },
              {
                "key": "US",
                "friendly_name": "United States"
              },
              {
                "key": "CA",
                "friendly_name": "Canada"
              }
            ]
          }
        }
      },
      "MessagesResponse": {
        "type": "object",
        "required": [
          "account_sid",
          "opt_out_sid",
          "config"
        ],
        "properties": {
          "account_sid": {
            "type": "string",
            "description": "The SID of the account that owns this opt-out configuration",
            "pattern": "^AC[0-9a-fA-F]{32}$",
            "example": "AC1234567890abcdef1234567890abcdef"
          },
          "opt_out_sid": {
            "type": "string",
            "description": "The SID of the opt-out configuration",
            "pattern": "^OO[0-9a-fA-F]{32}$",
            "example": "OO1234567890abcdef1234567890abcdef"
          },
          "config": {
            "type": "array",
            "description": "List of message configurations for different keyword types",
            "items": {
              "$ref": "#/components/schemas/MessageProperties"
            }
          }
        }
      },
      "MessageProperties": {
        "type": "object",
        "required": [
          "keyword_type",
          "message_type",
          "message"
        ],
        "properties": {
          "keyword_type": {
            "type": "string",
            "description": "The keyword type in format KeywordType.Locale (e.g., STOP.ENGLISH, HELP.FRENCH)",
            "example": "STOP.ENGLISH"
          },
          "message_type": {
            "type": "string",
            "description": "The message type identifier (typically country codes or special identifiers)",
            "example": "US"
          },
          "message": {
            "type": "string",
            "description": "The actual opt-out message text to be sent",
            "example": "Reply STOP to unsubscribe. Msg&data rates may apply."
          }
        }
      },
      "OptOutMessagesEntity": {
        "type": "object",
        "required": [
          "keywordType",
          "messageType",
          "message"
        ],
        "properties": {
          "keywordType": {
            "$ref": "#/components/schemas/KeywordLocaleType"
          },
          "messageType": {
            "type": "string",
            "description": "Message type (typically country code or region identifier)",
            "example": "US"
          },
          "message": {
            "type": "string",
            "maxLength": 320,
            "minLength": 1,
            "description": "The message text content (max 320 characters)",
            "example": "You have been successfully unsubscribed. Reply START to resubscribe."
          }
        }
      },
      "KeywordsResponse": {
        "type": "object",
        "required": [
          "account_sid",
          "opt_out_sid",
          "config"
        ],
        "properties": {
          "account_sid": {
            "type": "string",
            "description": "The SID of the account that owns this opt-out configuration",
            "pattern": "^AC[0-9a-fA-F]{32}$",
            "example": "AC1234567890abcdef1234567890abcdef"
          },
          "opt_out_sid": {
            "type": "string",
            "description": "The SID of the opt-out configuration",
            "pattern": "^OO[0-9a-fA-F]{32}$",
            "example": "OO1234567890abcdef1234567890abcdef"
          },
          "config": {
            "type": "array",
            "description": "List of keyword configurations for different keyword types",
            "items": {
              "$ref": "#/components/schemas/KeywordConfiguration"
            }
          }
        }
      },
      "KeywordConfiguration": {
        "type": "object",
        "required": [
          "keyword_type",
          "message_type",
          "keywords"
        ],
        "properties": {
          "keyword_type": {
            "type": "string",
            "description": "The keyword type in format KeywordType.Locale (e.g., STOP.ENGLISH, HELP.FRENCH)",
            "example": "STOP.ENGLISH"
          },
          "message_type": {
            "type": "string",
            "description": "The message type identifier (typically country codes or special identifiers)",
            "example": "US"
          },
          "keywords": {
            "type": "array",
            "description": "Array of keyword strings for this configuration",
            "items": {
              "type": "string"
            },
            "example": [
              "STOP",
              "QUIT",
              "END"
            ]
          }
        }
      },
      "OptOutKeywordsEntity": {
        "type": "object",
        "required": [
          "keywordType",
          "messageType",
          "keyword"
        ],
        "properties": {
          "keywordType": {
            "$ref": "#/components/schemas/KeywordLocaleType"
          },
          "messageType": {
            "type": "string",
            "description": "The message type identifier (typically country codes or special identifiers)",
            "example": "US"
          },
          "keyword": {
            "type": "string",
            "description": "The keyword to add",
            "minLength": 1,
            "maxLength": 34,
            "example": "STOP"
          }
        }
      }
    }
  }
}