# Notification

Send out a Voice Notification message.

[block:tutorial-tile]
{
  "backgroundColor": "#018FF4",
  "emoji": "🦉",
  "id": "66a277d081a33600196caced",
  "link": "https://developers.cm.com/v1/recipes/sending-a-voice-notification",
  "slug": "sending-a-voice-notification",
  "title": "Sending a Voice Notification"
}
[/block]

## Application flow

[block:image]
{
  "images": [
    {
      "image": [
        "https://files.readme.io/f6bffa6-Notification.jpg",
        "",
        ""
      ],
      "align": "center"
    }
  ]
}
[/block]

## Voicemail detection

You can also determine the action when voicemail has been detected, by setting the property **voicemail-response** in your request. The voicemail detection will attempt to detect the beep of a voicemail within the first 15 seconds of a call. The following settings are supported:

| Value   | Description                                                                                    |
| ------- | ---------------------------------------------------------------------------------------------- |
| Ignore  | Do not detect voicemail. Default value when **voicemail-response** is not set in your request. |
| Restart | Restarts the whole prompt.                                                                     |
| Stop    | Stops the call.                                                                                |

# OpenAPI definition

```json
{
  "openapi": "3.0.1",
  "info": {
    "title": "Voice API",
    "version": "v2"
  },
  "servers": [
    {
      "url": "https://api.cm.com"
    }
  ],
  "paths": {
    "/voiceapi/v2/notification": {
      "post": {
        "tags": [
          "Notification"
        ],
        "summary": "Notification",
        "description": "Send out a Voice Notification message. For more information, see the [Voice Notification documentation](https://developers.cm.com/voice/docs/notification).",
        "requestBody": {
          "description": "Details of the notification instruction.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NotificationInstruction"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/NotificationInstruction"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/NotificationInstruction"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Call is queued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CallQueuedEvent"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExceptionEvent"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "CallQueuedEvent": {
        "title": "Call Queued Event",
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "description": "The Type of event.",
            "nullable": true,
            "readOnly": true
          },
          "call-id": {
            "type": "string",
            "description": "The ID of the call this event belongs to.",
            "format": "uuid"
          },
          "instruction-id": {
            "type": "string",
            "description": "The ID of the instruction the event is a result of.",
            "nullable": true
          },
          "queue-id": {
            "type": "string",
            "description": "The ID of the queue.",
            "nullable": true
          },
          "caller": {
            "type": "string",
            "description": "The id (e.g. number) of the caller.",
            "nullable": true
          },
          "callee": {
            "type": "string",
            "description": "The id (e.g. number) of the callee.",
            "nullable": true
          },
          "success": {
            "type": "boolean",
            "description": "True if the PlaceCallInstruction was accepted."
          },
          "error": {
            "type": "string",
            "description": "True if the PlaceCallInstruction was accepted.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Event that is a result (basically a direct response) to the PlaceCallInstruction.\r\nThis one is generally used in the async versions of the calls."
      },
      "ExceptionEvent": {
        "title": "Exception Event",
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "description": "The Type of event.",
            "nullable": true,
            "readOnly": true
          },
          "call-id": {
            "type": "string",
            "description": "The ID of the call this event belongs to.",
            "format": "uuid"
          },
          "instruction-id": {
            "type": "string",
            "description": "The ID of the instruction the event is a result of.",
            "nullable": true
          },
          "queue-id": {
            "type": "string",
            "description": "The ID of the queue.",
            "nullable": true
          },
          "code": {
            "$ref": "#/components/schemas/ExceptionEventCode"
          },
          "title": {
            "type": "string",
            "description": "The title of the exception.",
            "nullable": true,
            "readOnly": true
          },
          "message": {
            "type": "string",
            "description": "Some explanatory text on the exception.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "And event containing an exception."
      },
      "ExceptionEventCode": {
        "title": "Exception Event Code",
        "enum": [
          "InvalidJson",
          "SignatureError",
          "FileNotFound",
          "InvalidInstruction",
          "InvalidParameter",
          "InsufficientBalance",
          "PremiumNotAllowed",
          "CallLimitReached",
          "TooManyNumbers"
        ],
        "type": "string",
        "description": "Enum of the different codes of exceptions."
      },
      "Gender": {
        "title": "Gender",
        "enum": [
          "Male",
          "Female"
        ],
        "type": "string",
        "description": "Genders supported by TTS."
      },
      "NotificationInstruction": {
        "title": "Notification Instruction",
        "required": [
          "caller",
          "prompt"
        ],
        "type": "object",
        "properties": {
          "instruction-id": {
            "maxLength": 64,
            "type": "string",
            "description": "Optional string that allows you to uniquely identify the placed outbound call. Its value is also included\r\nin the callback and Call Detail Records (CDRs).",
            "nullable": true,
            "example": "mycustomid"
          },
          "callee": {
            "maxLength": 24,
            "pattern": "^(\\+|00)?[1-9]\\d{6,14}$",
            "type": "string",
            "description": "The number to dial. When the number is invalid, the request will be rejected. Must be in valid international\r\nE.164 format.",
            "nullable": true,
            "example": "+31612345678"
          },
          "callees": {
            "pattern": "^(\\+|00)?[1-9]\\d{6,14}$",
            "maxItems": 100,
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "List of multiple numbers to dial. When the list contains one or more invalid numbers, the request will be\r\nrejected. Must be in valid international E.164 format.",
            "nullable": true,
            "example": [
              "+31612345678",
              "+31612345679"
            ]
          },
          "caller": {
            "maxLength": 24,
            "minLength": 1,
            "pattern": "^(\\+|00)?[1-9]\\d{6,14}$",
            "type": "string",
            "description": "The caller ID to display on the recipient's phone. Must be in valid international E.164 format.",
            "example": "+31612345678"
          },
          "anonymous": {
            "type": "boolean",
            "description": "Indicates whether the caller ID should be hidden. Defaults to `false`.",
            "example": false
          },
          "callback-url": {
            "type": "string",
            "description": "URL that will be called when the call is finished. The body of this POST request will contain details about\r\nthe call or calls.",
            "format": "uri",
            "nullable": true
          },
          "max-ringing-timeout": {
            "maximum": 60,
            "minimum": 10,
            "type": "integer",
            "description": "Determines how long the Voice API will wait for the callee to answer the call. Cancels the ringing call\r\nafter the timeout period exceeded. Defaults to `60`.",
            "format": "int32",
            "nullable": true,
            "example": 60
          },
          "prompt": {
            "maxLength": 750,
            "minLength": 1,
            "type": "string",
            "description": "The prompt to play. This can be either TTS or SSML, or the path to an audio file in your Voice Audio Manager.",
            "example": "This is my Voice Notification message."
          },
          "prompt-type": {
            "$ref": "#/components/schemas/PromptType"
          },
          "voice": {
            "$ref": "#/components/schemas/Voice"
          },
          "voicemail-response": {
            "$ref": "#/components/schemas/VoicemailResponse"
          },
          "max-replays": {
            "maximum": 3,
            "minimum": 0,
            "type": "integer",
            "description": "The number of times the Notification can be replayed.",
            "format": "int32",
            "nullable": true,
            "example": 3
          },
          "auto-replay": {
            "type": "boolean",
            "description": "Whether to automatically replay the Notification. Defaults to `false`.",
            "nullable": true,
            "example": false
          },
          "replay-prompt": {
            "maxLength": 750,
            "type": "string",
            "description": "Optional prompt instructing the callee to press 1 to replay the Notification. This can be either TTS or\r\nSSML, or the path to an audio file in your Voice Audio Manager.",
            "nullable": true,
            "example": "Press 1 to replay the message."
          },
          "replay-prompt-type": {
            "$ref": "#/components/schemas/PromptType"
          }
        },
        "additionalProperties": false,
        "description": "This sends the instruction to make and outbound call and send a notification."
      },
      "PromptType": {
        "title": "Prompt Type",
        "enum": [
          "File",
          "TTS",
          "TTS_SSML"
        ],
        "type": "string",
        "description": "The type of the prompt, to distinguish between a filename and a string that needs to be tts-ed."
      },
      "Voice": {
        "title": "Voice",
        "required": [
          "gender",
          "language",
          "number"
        ],
        "type": "object",
        "properties": {
          "language": {
            "maxLength": 6,
            "minLength": 5,
            "pattern": "^[a-zA-Z]{2,3}-[a-zA-Z]{2,3}$",
            "type": "string",
            "description": "The language (5 character locale) of the voice to use. Examples: en-US, en-GB, nl-NL. Defaults to en-GB",
            "example": "en-GB"
          },
          "gender": {
            "$ref": "#/components/schemas/Gender"
          },
          "number": {
            "maximum": 2147483647,
            "minimum": 1,
            "type": "integer",
            "description": "Usually `1`, but if the selected language and gender support multiple voices, you can use this to make\r\na selection between the different ones. To see the available voices, please see the\r\n<a href=\"https://developers.cm.com/voice/docs/supported-languages\">TTS voices documentation</a>.",
            "format": "int32",
            "example": 1
          },
          "volume": {
            "maximum": 4,
            "minimum": -4,
            "type": "integer",
            "description": "The volume level of the voice. Must be a value between -4 and 4. Defaults to 0.",
            "format": "int32",
            "example": 2
          },
          "premium": {
            "type": "boolean",
            "description": "Whether to use a premium text-to-speech voice. Please be aware that additional costs will be charged for the\r\nuse of premium voices. Defaults to `false`.",
            "example": true
          }
        },
        "additionalProperties": false,
        "description": "The properties in this class are used to select the required TTS voice."
      },
      "VoicemailResponse": {
        "title": "Voicemail Response",
        "enum": [
          "Ignore",
          "Restart",
          "Stop",
          "Disconnect"
        ],
        "type": "string",
        "description": "The type that determines the flow of Voicemail detection."
      }
    },
    "securitySchemes": {
      "X-CM-PRODUCTTOKEN": {
        "type": "apiKey",
        "description": "Your producttoken",
        "name": "X-CM-PRODUCTTOKEN",
        "in": "header"
      }
    }
  },
  "security": [
    {
      "X-CM-PRODUCTTOKEN": []
    }
  ],
  "x-readme": {
    "explorer-enabled": true,
    "proxy-enabled": true
  },
  "_id": {
    "buffer": {
      "0": 102,
      "1": 176,
      "2": 134,
      "3": 124,
      "4": 188,
      "5": 187,
      "6": 41,
      "7": 0,
      "8": 24,
      "9": 5,
      "10": 92,
      "11": 28
    }
  }
}
```