# REST API — Sending Viber message


Source: https://vertexsms.com/en/api/viber

```
POST https://api.vertexsms.com/viber
```

Submits Viber message(s) for sending. On success returns HTTP `200 OK` and an array of IDs of messages added to the sending queue.

## Required parameters

| Field | Type | Description |
|-------|------|-------------|
| to | string | Destination address (recipient). |
| from | string | Source address (originator). The `from` must be approved in advance by VertexSMS. Register new senders via the [senderID API](https://vertexsms.com/en/api/senderid). |
| message | string | Message body. Maximum length 1000 characters. |

## Optional parameters

| Field | Type | Description |
|-------|------|-------------|
| dlrUrl | url | Delivery-report URL. |
| priority | string | `high`, `normal` (default), `low`. |
| scheduled | string | ISO 8601 timestamp. |
| testMode | string | `1` = emulate success, `2` = emulate failure. |
| correctBy | string | Country-based number correction; ISO 3166-1 alpha-2 code. |

### Request example

```
POST /viber HTTP/1.1
Host: api.vertexsms.com
Content-Type: application/json
Accept: application/json
X-VertexSMS-Token: eB52vNTPL9fO3rDrx8pYmVnj6nqceHNhnqceHNh

{ "to": "37069912345", "from": "Test", "message": "Test Viber message" }
```

### Response example

```
HTTP/1.1 200 OK
Content-Type: application/json
Cache-control: no-cache
X-VertexSMS-Amount-Sent: 1

["1281532560"]
```

## Button

To send a message with a button, supply the `im` (interactive message) option:

```json
"im": {
  "action": {
    "url": "https://example.com",
    "title": "go to example.com"
  }
}
```

Button parameters: `url` (valid URL), `title` (button label).

Full request example with a button:

```json
{
  "to": "+370...",
  "from": "Test",
  "message": "Hello World!",
  "im": {
    "action": {
      "url": "https://example.com",
      "title": "go to example.com"
    }
  }
}
```

## Image

```json
"im": {
  "image": {
    "url": "https://example-cdn.com/image.png"
  }
}
```

`url` must be a valid URL whose last path segment ends in `.jpeg`, `.png`, or `.gif`. Max image size 1 MB. Image and button can be combined:

```json
{
  "to": "+370...",
  "from": "Test",
  "message": "Hello World!",
  "im": {
    "image": { "url": "https://example-cdn.com/image.png" },
    "action": {
      "url": "https://example.com",
      "title": "go to example.com"
    }
  }
}
```
