# API - Documentación

## Arquitectura Positus - WhatsApp Business API

![](https://3453736291-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M5U3fCsSqARlRQj4_jN%2F-MDX_9GRsZnbudrpX3wX%2F-MDX_G5N5fCdkbvTMhSQ%2FPositus%20-%20Arq%20Whats%20Business%20\(Final\)%2002.png?alt=media\&token=a10caacf-0c1b-47d5-80c9-71e65abb5f41)

| SDK                                                         |                        |                                                        |
| ----------------------------------------------------------- | ---------------------- | ------------------------------------------------------ |
| <https://github.com/positusapps/positus-api-laravel-client> | Laravel / PHP          | Youtube                                                |
| <https://github.com/positusapps/positus-api-php-client>     | PHP                    | [Youtube](https://www.youtube.com/watch?v=6hhHz73bsc4) |
| <https://www.nuget.org/packages/positus-api-csharp-client/> | Nuget .NET / .NET Core | [YouTube](https://www.youtube.com/watch?v=E8MZWwfQSZY) |
| <https://github.com/positusapps/positus-api-csharp-client>  | Github para .NET       |                                                        |

{% hint style="info" %}
**Token de producción:** Positus generará su token y le dará acceso a todos sus números API de WhatsApp Business. "Chave" se proporcionará después de la activación de cada número de API empresarial de WhatsApp.&#x20;

**Sandbox (Token de desarrollo):** puede generar su token directamente en <http://studio.posit.us/>.
{% endhint %}

## Postman file

*Postman es una herramienta que tiene como objetivo probar los servicios RESTful (API web) enviando solicitudes HTTP y analizando sus comentarios.* \
[Descargar la aplicación Postman](https://www.postman.com/downloads/)<br>

{% file src="<https://3453736291-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M5U3fCsSqARlRQj4_jN%2F-MKodNlo6vZpcDGixNXK%2F-MKodWFxEgEaSdPVNCJD%2FPositus%20API%20(October%202020).postman_collection.json?alt=media&token=b0574fef-ae27-440c-8457-6a5d00b231fc>" %}
API for production
{% endfile %}

{% file src="<https://3453736291-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M5U3fCsSqARlRQj4_jN%2F-MLmCS0sFe_jT1TD64__%2F-MLmCWqi29iLjMwzHb2V%2FPositus%20API%20Sandbox%20(November%202020).postman_collection.json?alt=media&token=78cba0a6-3b45-410b-b61f-ee066c03f414>" %}
API for development SandBox
{% endfile %}

## mensaje

<mark style="color:green;">`POST`</mark> `https://api.positus.global/v2/whatsapp/numbers/{{chave}}/messages`

Use esta ruta para enviar mensajes de texto a través de WhatsAppWhatsApp.

#### Path Parameters

| Name  | Type   | Description                         |
| ----- | ------ | ----------------------------------- |
| Chave | string | Código único por número de WhatsApp |

#### Headers

| Name           | Type   | Description                       |
| -------------- | ------ | --------------------------------- |
| Content-Type   | string | application/json                  |
| Authentication | string | Autenticación usando Bearer Token |

#### Request Body

| Name | Type   | Description                                                                            |
| ---- | ------ | -------------------------------------------------------------------------------------- |
|      | object | { "to": "+5511999999999", "type": "text", "text": { "body": "your-message-content" } } |

{% tabs %}
{% tab title="200 " %}

```
{
    "messages": [
        {
            "id": "gBGHVRGZmZmZnwIJpWDiExk7olMZ"
        }
    ],
    "message": "The message was successfully sent"
}
```

{% endtab %}

{% tab title="500 " %}

```
{
    "errors": [
        {
            "code": ,
            "title": "",
            "details": ""
        }
    ],
    "message": ""
}
```

{% endtab %}
{% endtabs %}

## HSM

<mark style="color:green;">`POST`</mark> `https://api.positus.global/v2/whatsapp/numbers/{{chave}}/messages`

Use esta ruta para enviar mensajes de notificación via WhatsApp\
HSM - Son plantillas de mensajes preaprobadas pelo Facebook, pueden enviar mensajes de texto, midia ou arquivos.

#### Path Parameters

| Name  | Type   | Description |
| ----- | ------ | ----------- |
| Chave | string |             |

#### Headers

| Name           | Type   | Description                      |
| -------------- | ------ | -------------------------------- |
| Authentication | string | Autenticação usando Bearer Token |
| Content-Type   | string | application/json                 |

#### Request Body

| Name      | Type   | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| --------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Full Body | string | { "to": "+551199999999", "type": "template", "template": { "namespace": "xxxxxxx", "language": { "policy": "deterministic", "code": "pt\_BR" }, "name": "xxxxxx", "components": \[ { "type": "header", "parameters": \[ { "type": "image", "image": { "link": "<https://dealers.rewebmkt.com/images/20190417084518-actros-3-1280.jpg>" } } ] }, { "type": "body", "parameters": \[ { "type": "text", "text": "Rafael" }, { "type": "text", "text": "Mercedes-Benz" }, { "type": "text", "text": "Actros" }, { "type": "text", "text": "Cardiesel - Belo Horizonte" }, { "type": "text", "text": "08/05/2020" } ] }, { "type": "button", "sub\_type" : "url", "index": "0", "parameters": \[ { "type": "text", "text": "fMYMyV8x" } ] } ] } } |
| Botões    | string | { "to": "+5511999999999", "type": "template", "template": { "namespace": "dc730af3\_d5a86", "language": { "policy": "deterministic", "code": "pt\_BR" }, "name": "carteiro\_botoes", "components": \[ { "type": "body", "parameters": \[ { "type": "text", "text": "Robbu" }, { "type": "text", "text": "Thiago Thamiel" } ] }, { "type": "button", "sub\_type": "quick\_reply", "index": "0" } ] } }                                                                                                                                                                                                                                                                                                                                        |
| Texto     | object | <p>{ "to": "+55119999999999", "type": "hsm", "hsm": { "namespace": "52\_2bca4fad4c4a", "element\_name": "fgv\_3", "language": { "policy": "deterministic", "code": "pt\_BR" }, "localizable\_params": \[ { "default": "Thiago" } ] }<br>}</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |

{% tabs %}
{% tab title="200 " %}

```
{
    "messages": [
        {
            "id": "gBGHVRGZmZmZnwIJpWDiExk7olMZ"
        }
    ],
    "message": "The message was successfully sent"
}
```

{% endtab %}

{% tab title="500 " %}

```
{
    "errors": [
        {
            "code": ,
            "title": "",
            "details": ""
        }
    ],
    "message": ""
}
```

{% endtab %}
{% endtabs %}

## Contact

<mark style="color:green;">`POST`</mark> `https://api.positus.global/v2/whatsapp/numbers/{{chave}}/messages`

Compartir contactos

#### Path Parameters

| Name  | Type   | Description                         |
| ----- | ------ | ----------------------------------- |
| Chave | string | Código único por número de WhatsApp |

#### Headers

| Name           | Type   | Description                       |
| -------------- | ------ | --------------------------------- |
| Authentication | string | Autenticación usando Bearer Token |
| Content-Type   | string | application/json                  |

#### Request Body

| Name | Type   | Description                                                                                                                                                                                                                                                                                                          |
| ---- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|      | object | { "to": "+5511999999999", "type": "contacts", "contacts":\[{ "addresses": \[], "emails": \[], "ims": \[], "name": { "first\_name": "Positus Provider", "formatted\_name": "Positus Provider" }, "org": \[], "phones": \[{ "phone": "+55 11 2626-4234", "type": "CELL", "wa\_id": "551126264234" }], "urls": \[] }] } |

{% tabs %}
{% tab title="200 " %}

```
{
    "messages": [
        {
            "id": "gBGHVRGZmZmZnwIJpWDiExk7olMZ"
        }
    ],
    "message": "The message was successfully sent"
}
```

{% endtab %}

{% tab title="500 " %}

```
{
    "errors": [
        {
            "code": ,
            "title": "",
            "details": ""
        }
    ],
    "message": ""
}
```

{% endtab %}
{% endtabs %}

## Location

<mark style="color:green;">`POST`</mark> `https://api.positus.global/v2/whatsapp/numbers/{{chave}}/messages`

Compartir ubicaciones

#### Path Parameters

| Name  | Type   | Description                         |
| ----- | ------ | ----------------------------------- |
| Chave | string | Código único por número de WhatsApp |

#### Headers

| Name           | Type   | Description                       |
| -------------- | ------ | --------------------------------- |
| Authentication | string | Autenticación usando Bearer Token |
| Content-Type   | string | application/json                  |

#### Request Body

| Name | Type   | Description                                                                                                                                                                                                      |
| ---- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|      | object | { "to": "+5511999999999", "type": "location", "location": { "longitude": -46.662787, "latitude": -23.553610, "name": "Robbu Brazil", "address": "Av. Angélica, 2530 - Bela Vista, São Paulo - SP, 01228-200" } } |

{% tabs %}
{% tab title="200 " %}

```
{
    "messages": [
        {
            "id": "gBGHVRGZmZmZnwIJpWDiExk7olMZ"
        }
    ],
    "message": "The message was successfully sent"
}
```

{% endtab %}

{% tab title="500 " %}

```
{
    "errors": [
        {
            "code": ,
            "title": "",
            "details": ""
        }
    ],
    "message": ""
}
```

{% endtab %}
{% endtabs %}

## Image

<mark style="color:green;">`POST`</mark> `https://api.positus.global/v2/whatsapp/numbers/{{chave}}/messages`

Compartir imágenes

#### Path Parameters

| Name  | Type   | Description                         |
| ----- | ------ | ----------------------------------- |
| Chave | string | Código único por número de WhatsApp |

#### Headers

| Name           | Type   | Description                       |
| -------------- | ------ | --------------------------------- |
| Authentication | string | Autenticación usando Bearer Token |
| Content-Type   | string | application/json                  |

#### Request Body

| Name | Type   | Description                                                                                                                        |
| ---- | ------ | ---------------------------------------------------------------------------------------------------------------------------------- |
|      | object | {  "to": "+5511999999999", "type": "image", "image": { "link": "<https://picsum.photos/200>", "caption": "your-document-caption" } |

{% tabs %}
{% tab title="200 " %}

```
{
    "messages": [
        {
            "id": "gBGHVRGZmZmZnwIJpWDiExk7olMZ"
        }
    ],
    "message": "The message was successfully sent"
}
```

{% endtab %}

{% tab title="500 " %}

```
{
    "errors": [
        {
            "code": ,
            "title": "",
            "details": ""
        }
    ],
    "message": ""
}
```

{% endtab %}
{% endtabs %}

## Document

<mark style="color:green;">`POST`</mark> `https://api.positus.global/v2/whatsapp/numbers/{{chave}}/messages`

Compartr imágenes

#### Path Parameters

| Name  | Type   | Description                         |
| ----- | ------ | ----------------------------------- |
| Chave | string | Código único por número de WhatsApp |

#### Headers

| Name           | Type   | Description                       |
| -------------- | ------ | --------------------------------- |
| Authentication | string | Autenticación usando Bearer Token |
| Content-Type   | string | application/json                  |

#### Request Body

| Name | Type   | Description                                                                                                                                          |
| ---- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
|      | object | {  "to": "+5511941489395", "type": "document", "document": { "link": "<http://www.pdf995.com/samples/pdf.pdf>", "caption": "your-document-caption" } |

{% tabs %}
{% tab title="200 " %}

```
{
    "messages": [
        {
            "id": "gBGHVRGZmZmZnwIJpWDiExk7olMZ"
        }
    ],
    "message": "The message was successfully sent"
}
```

{% endtab %}

{% tab title="500 " %}

```
{
    "errors": [
        {
            "code": ,
            "title": "",
            "details": ""
        }
    ],
    "message": ""
}
```

{% endtab %}
{% endtabs %}

## Video

<mark style="color:green;">`POST`</mark> `https://api.positus.global/v2/whatsapp/numbers/{{chave}}/messages`

Compartir videos

#### Path Parameters

| Name  | Type   | Description                         |
| ----- | ------ | ----------------------------------- |
| Chave | string | Código único por número de WhatsApp |

#### Headers

| Name           | Type   | Description                       |
| -------------- | ------ | --------------------------------- |
| Authentication | string | Autenticación usando Bearer Token |
| Content-Type   | string | application/json                  |

#### Request Body

| Name | Type   | Description                                                                                                                                                                             |
| ---- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|      | object | {  "to": "+5511999999999", "type": "video", "video": { "link": "<https://sample-videos.com/video123/mp4/720/big\\_buck\\_bunny\\_720p\\_1mb.mp4>", "caption": "your-document-caption" } |

{% tabs %}
{% tab title="200 " %}

```
{
    "messages": [
        {
            "id": "gBGHVRGZmZmZnwIJpWDiExk7olMZ"
        }
    ],
    "message": "The message was successfully sent"
}
```

{% endtab %}

{% tab title="500 " %}

```
{
    "errors": [
        {
            "code": ,
            "title": "",
            "details": ""
        }
    ],
    "message": ""
}
```

{% endtab %}
{% endtabs %}

## Audio

<mark style="color:green;">`POST`</mark> `https://api.positus.global/v2/whatsapp/numbers/{{chave}}/messages`

Compartir audios

#### Path Parameters

| Name  | Type   | Description                         |
| ----- | ------ | ----------------------------------- |
| Chave | string | Código único por número de WhatsApp |

#### Headers

| Name           | Type   | Description                       |
| -------------- | ------ | --------------------------------- |
| Authentication | string | Autenticación usando Bearer Token |
| Content-Type   | string | application/json                  |

#### Request Body

| Name | Type   | Description                                                                                                                |
| ---- | ------ | -------------------------------------------------------------------------------------------------------------------------- |
|      | object | { "to": "+5511999999999", "type": "audio", "audio": { "link": "<https://sample-videos.com/audio/mp3/crowd-cheering.mp3>" } |

{% tabs %}
{% tab title="200 " %}

```
{
    "messages": [
        {
            "id": "gBGHVRGZmZmZnwIJpWDiExk7olMZ"
        }
    ],
    "message": "The message was successfully sent"
}
```

{% endtab %}

{% tab title="500 " %}

```
{
    "errors": [
        {
            "code": ,
            "title": "",
            "details": ""
        }
    ],
    "message": ""
}
```

{% endtab %}
{% endtabs %}

## Sticker

<mark style="color:green;">`POST`</mark> `https://api.positus.global/v2/whatsapp/numbers/{{chave}}/messages`

Comparte pegatinas. El formato de la etiqueta debe ser exactamente 512x512

#### Path Parameters

| Name  | Type   | Description                         |
| ----- | ------ | ----------------------------------- |
| Chave | string | Código único por número de WhatsApp |

#### Headers

| Name           | Type   | Description                       |
| -------------- | ------ | --------------------------------- |
| Authentication | string | Autenticación usando Bearer Token |
| Content-Type   | string | application/json                  |

#### Request Body

| Name | Type   | Description                                                                                                              |
| ---- | ------ | ------------------------------------------------------------------------------------------------------------------------ |
|      | object | { "to": "+5511999999999", "type": "sticker", "sticker": { "link": "<https://studio.posit.us/api/samples/sticker.webp>" } |

{% tabs %}
{% tab title="200 " %}

```
```

{% endtab %}
{% endtabs %}

## Download Midia

<mark style="color:blue;">`GET`</mark> `https://api.positus.global/v2/whatsapp/numbers/{{chave}}/media/{{messages.type.id}}`

Descargar los medios

#### Path Parameters

| Name  | Type   | Description                         |
| ----- | ------ | ----------------------------------- |
| chave | string | Código único por número de WhatsApp |

#### Headers

| Name           | Type   | Description                       |
| -------------- | ------ | --------------------------------- |
| Authentication | string | Autenticación usando Bearer Token |
| Content-Type   | string | application/json                  |

{% tabs %}
{% tab title="200 " %}

```
{
    "messages": [
        {
            "id": "gBGHVRGZmZmZnwIJpWDiExk7olMZ"
        }
    ],
    "message": "The message was successfully sent"
}
```

{% endtab %}

{% tab title="500 " %}

```
{
    "errors": [
        {
            "code": ,
            "title": "",
            "details": ""
        }
    ],
    "message": ""
}
```

{% endtab %}
{% endtabs %}

## Mensajería interactiva: lista

<mark style="color:green;">`POST`</mark> `https://api.positus.global/v2/whatsapp/numbers/{{chave}}/messages`

Lista de mensajes: mensajes que incluyen un menú de hasta 10 opciones. Este tipo de mensaje ofrece una forma más sencilla y coherente para que los usuarios realicen una selección al interactuar con una empresa.\
\
El botón de lista o los mensajes de respuesta no se pueden utilizar como notificaciones. Actualmente, solo se pueden enviar dentro de las 24 horas posteriores al último mensaje enviado por el usuario. Si intenta enviar un mensaje fuera del período de 24 horas, recibirá un mensaje de error.

#### Path Parameters

| Name  | Type   | Description                         |
| ----- | ------ | ----------------------------------- |
| Chave | string | Código único por número de WhatsApp |

#### Headers

| Name           | Type   | Description                      |
| -------------- | ------ | -------------------------------- |
| Authentication | string | Autenticação usando Bearer Token |
| Content-Type   | string | application/json                 |

#### Request Body

| Name | Type   | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ---- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|      | string | {"to":"+5511999999999","type":"interactive","interactive":{"type":"list","header":{"type":"text","text":"CryptoBank"},"body":{"text":"Olá senhor Thiago Thamiel, me chamo Francisco Dabus estou falando referente ao Banco CryptoBank e você já pode regular sua pendência financeira por aqui. Veja as opções que preparamos para você!\n\n💼 Contrato: 82782361236213\n🗓️ Vencimento: 01/01/2021\n💰 Valor Atualizado: 232,83"},"footer":{"text":"Demonstração Robbu"},"action":{"button":"Opções de pagamento","sections":\[{"title":"Atualização","rows":\[{"id":"7","title":"Vencimento Hoje","description":"💰 R$ 201,23 - Parcelas 17 até 19 de 24"},{"id":"1","title":"Vencimento Amanha","description":"💰 R$ 219,32 - Parcelas 17 até 19 de 24"}]},{"title":"Quitação","rows":\[{"id":"3","title":"Vencimento Hoje","description":"💰 R$ 1.323,21 - Todas as parcelas restantes"},{"id":"4","title":"Vencimento Amanha","description":"💰 R$ 1.382,34 - Todas as parcelas restantes"}]}]}}} |

{% tabs %}
{% tab title="200 " %}

```
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Documentación completa: <https://developers.facebook.com/docs/whatsapp/guides/interactive-messages>
{% endhint %}

## Mensajería interactiva: botones

<mark style="color:green;">`POST`</mark> `https://api.positus.global/v2/whatsapp/numbers/{{chave}}/messages`

Botones de respuesta: mensajes que incluyen hasta 3 opciones; cada opción es un botón. Este tipo de mensaje ofrece una forma más rápida para que los usuarios realicen una selección de un menú cuando interactúan con una empresa. Los botones de respuesta tienen la misma experiencia de usuario que los modelos de botones interactivos.

#### Path Parameters

| Name  | Type   | Description                         |
| ----- | ------ | ----------------------------------- |
| Chave | string | Código único por número de WhatsApp |

#### Headers

| Name           | Type   | Description                      |
| -------------- | ------ | -------------------------------- |
| Authentication | string | Autenticação usando Bearer Token |
| Content-Type   | string | application/json                 |

#### Request Body

| Name | Type   | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| ---- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|      | string | {"to":"+5511999999999","type":"interactive","recipient\_type":"individual","interactive":{"type":"button","header":{"type":"text","text":"1 mês grátis"},"body":{"text":"Ótima escolha, agora você já pode ativar o seu número e realizar testes por 1 mês sem compromisso."},"footer":{"text":"[https://posit.us"},"action":{"buttons":\\\[{"type":"reply","reply":{"id":"unique-postback-id-1","title":"Criar](https://docs.es.posit.us/https:/posit.us"},"action":{"buttons":\\\[{"type":"reply","reply":{"id":"unique-postback-id-1","title":"Criar) conta grátis"}},{"type":"reply","reply":{"id":"unique-postback-id-2","title":"Falar com atendente"}}]}}} |

{% tabs %}
{% tab title="200 " %}

```
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Documentación completa: <https://developers.facebook.com/docs/whatsapp/guides/interactive-messages>
{% endhint %}
