Code Samples
See some code samples to integrate your API.

Postman file

Postman is a tool that aims to test RESTful services (Web APIs) by sending HTTP requests and analyzing their feedback. Download Postman App
Production You should use the following URL: https://api.positus.global/v2/whatsapp/numbers/{{chave}}/messages
Once hiring and activating your WhatsApp Business API account, we will provide a media_id by number and you will be able to generate your tokens through the platform.
Positus API (October 2020).postman_collection.json
32KB
Binary
API for production
Development You should use the following URL: https://api.positus.global/v2/sandbox/whatsapp/numbers/{{chave}}/messages
Create your sandbox account through the link https://studio.posit.us/ and generate a token following the instructions on the screen. Navigate to the "webhook" menu and copy the POST URL in it, this one uses "Key". In the development environment you will not be able to send HSM messages, but all other resources are available for sending and receiving.
Positus API Sandbox (November 2020).postman_collection.json
9KB
Binary
API for development SandBox

Code Samples

.NET
PHP
PYTHON
NODEJS
JAVASCRIPT
POWESHELL
GO

C# - RestSharp

1
var client = new RestClient("https://api.positus.global/v2/sandbox/whatsapp/numbers/{{chave}}/messages");
2
client.Timeout = -1;
3
var request = new RestRequest(Method.POST);
4
request.AddHeader("Content-Type", "application/json");
5
request.AddHeader("Authorization", "Bearer xxxx");
6
request.AddParameter("application/json,text/plain", "{\r\n \"to\": \"+5511999999999\",\r\n \"type\": \"text\",\r\n \"text\": {\r\n \"body\": \"your-message-content\"\r\n }\r\n}", ParameterType.RequestBody);
7
IRestResponse response = client.Execute(request);
8
Console.WriteLine(response.Content);
Copied!

PHP - cURL

1
<?php
2
3
$curl = curl_init();
4
5
curl_setopt_array($curl, array(
6
CURLOPT_URL => "https://api.positus.global/v2/sandbox/whatsapp/numbers/{{chave}}/messages",
7
CURLOPT_RETURNTRANSFER => true,
8
CURLOPT_ENCODING => "",
9
CURLOPT_MAXREDIRS => 10,
10
CURLOPT_TIMEOUT => 0,
11
CURLOPT_FOLLOWLOCATION => true,
12
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
13
CURLOPT_CUSTOMREQUEST => "POST",
14
CURLOPT_POSTFIELDS =>"{\r\n \"to\": \"+5511999999999\",\r\n \"type\": \"text\",\r\n \"text\": {\r\n \"body\": \"your-message-content\"\r\n }\r\n}",
15
CURLOPT_HTTPHEADER => array(
16
"Content-Type: application/json",
17
"Authorization: Bearer xxxx"
18
),
19
));
20
21
$response = curl_exec($curl);
22
23
curl_close($curl);
24
echo $response;
25
Copied!

Python - http.client

1
import http.client
2
import mimetypes
3
conn = http.client.HTTPSConnection("api.positus.global")
4
payload = "{\r\n \"to\": \"+5511999999999\",\r\n \"type\": \"text\",\r\n \"text\": {\r\n \"body\": \"your-message-content\"\r\n }\r\n}"
5
headers = {
6
'Content-Type': 'application/json',
7
'Authorization': 'Bearer xxxx'
8
}
9
conn.request("POST", "/v2/sandbox/whatsapp/numbers/{{chave}}/messages", payload, headers)
10
res = conn.getresponse()
11
data = res.read()
12
print(data.decode("utf-8"))
Copied!

Nodejs - Request

1
var request = require('request');
2
var options = {
3
'method': 'POST',
4
'url': 'https://api.positus.global/v2/sandbox/whatsapp/numbers/{{chave}}/messages',
5
'headers': {
6
'Content-Type': ['application/json'],
7
'Authorization': 'Bearer xxxx'
8
},
9
body: "{\r\n \"to\": \"+55119999999999\",\r\n \"type\": \"text\",\r\n \"text\": {\r\n \"body\": \"your-message-content\"\r\n }\r\n}"
10
11
};
12
request(options, function (error, response) {
13
if (error) throw new Error(error);
14
console.log(response.body);
15
});
16
Copied!

JavaScript - JQuery

1
var settings = {
2
"url": "https://api.positus.global/v2/sandbox/whatsapp/numbers/{{chave}}/messages",
3
"method": "POST",
4
"timeout": 0,
5
"headers": {
6
"Content-Type": ["application/json"],
7
"Authorization": "Bearer xxxx"
8
},
9
"data": "{\r\n \"to\": \"+55119999999999\",\r\n \"type\": \"text\",\r\n \"text\": {\r\n \"body\": \"your-message-content\"\r\n }\r\n}",
10
};
11
12
$.ajax(settings).done(function (response) {
13
console.log(response);
14
});
Copied!

PowerShelll - RestMethod

1
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
2
$headers.Add("Content-Type", "application/json")
3
$headers.Add("Authorization", "Bearer xxxx")
4
5
$body = "{
6
`n `"to`": `"+55119999999999`",
7
`n `"type`": `"text`",
8
`n `"text`": {
9
`n `"body`": `"your-message-content`"
10
`n }
11
`n}"
12
13
$response = Invoke-RestMethod 'https://api.positus.global/v2/sandbox/whatsapp/numbers/{{chave}}/messages' -Method 'POST' -Headers $headers -Body $body
14
$response | ConvertTo-Json
Copied!

Go - Native

1
package main
2
3
import (
4
"fmt"
5
"strings"
6
"net/http"
7
"io/ioutil"
8
)
9
10
func main() {
11
12
url := "https://api.positus.global/v2/sandbox/messages"
13
method := "POST"
14
15
payload := strings.NewReader("{
16
\n \"to\": \"+55119999999999\",
17
\n \"type\": \"text\",
18
\n \"text\": {
19
\n \"body\": \"your-message-content\"
20
\n }
21
\n}")
22
23
client := &http.Client {
24
}
25
req, err := http.NewRequest(method, url, payload)
26
27
if err != nil {
28
fmt.Println(err)
29
}
30
req.Header.Add("Content-Type", "application/json")
31
req.Header.Add("Authorization", "Bearer xxxx")
32
33
res, err := client.Do(req)
34
defer res.Body.Close()
35
body, err := ioutil.ReadAll(res.Body)
36
37
fmt.Println(string(body))
38
}
Copied!
Last modified 11mo ago
Copy link