# Exemplos de código

## Arquivo carteiro

{% hint style="success" %}
Produção Você deve usar o seguinte URL: [https://api.talentumbr.us/v1/whatsapp/numbers/](https://api.posit.us/v1/whatsapp/numbers/) incorporatemedia\_id Rafael / messages

&#x20;Ao contratar e ativar sua conta da API comercial do WhatsApp, forneceremos um número de media\_id e você poderá gerar seus tokens por meio da plataforma.
{% endhint %}

{% file src="/files/-MB1es8umYbLeC1qHPuQ" %}
API para produção
{% endfile %}

{% hint style="info" %}
Desenvolvimento Você deve usar o seguinte URL: [https://api.talentumbr.global/v2/sandbox/messages](https://api.positus.global/v2/sandbox/messages)

Não será necessário usar o media\_id; nesse caso, você só precisa criar sua conta na sandbox através do link [https://studio.talentum.br/](https://studio.posit.us/) e gerar um token seguindo as instruções na tela. No ambiente de desenvolvimento, você não poderá enviar mensagens HSM, mas todos os outros recursos estão disponíveis para envio e recebimento.
{% endhint %}

{% file src="/files/-MB1dIa9lKHKdVIZ3\_-Q" %}
API for development SandBox
{% endfile %}

### Exemplos de código

{% tabs %}
{% tab title=".NET" %}
C# - RestSharp

```
var client = new RestClient("https://api.talentumbr.global/v2/sandbox/messages");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer xxxx");
request.AddHeader("Content-Type", "text/plain");
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);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
```

{% endtab %}

{% tab title="PHP" %}
**PHP - cURL**

```
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.positus.global/v2/sandbox/messages",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS =>"{\r\n  \"to\": \"+5511999999999\",\r\n  \"type\": \"text\",\r\n  \"text\": {\r\n      \"body\": \"your-message-content\"\r\n  }\r\n}",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer xxxx",
    "Content-Type: text/plain"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="PYTHON" %}
**Python - http.client**

```
import http.client
import mimetypes
conn = http.client.HTTPSConnection("api.positus.global")
payload = "{\r\n  \"to\": \"+5511999999999\",\r\n  \"type\": \"text\",\r\n  \"text\": {\r\n      \"body\": \"your-message-content\"\r\n  }\r\n}"
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer xxxx',
  'Content-Type': 'text/plain'
}
conn.request("POST", "/v2/sandbox/messages", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
```

{% endtab %}

{% tab title="NODEJS" %}
**Nodejs - Request**

```
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://api.positus.global/v2/sandbox/messages',
  'headers': {
    'Content-Type': ['application/json', 'text/plain'],
    'Authorization': 'Bearer xxxx'
  },
  body: "{\r\n  \"to\": \"+55119999999999\",\r\n  \"type\": \"text\",\r\n  \"text\": {\r\n      \"body\": \"your-message-content\"\r\n  }\r\n}"

};
request(options, function (error, response) { 
  if (error) throw new Error(error);
  console.log(response.body);
});

```

{% endtab %}

{% tab title="JAVASCRIPT" %}
**JavaScript** - **JQuery**

```
var settings = {
  "url": "https://api.positus.global/v2/sandbox/messages",
  "method": "POST",
  "timeout": 0,
  "headers": {
    "Content-Type": ["application/json", "text/plain"],
    "Authorization": "Bearer xxxx"
  },
  "data": "{\r\n  \"to\": \"+55119999999999\",\r\n  \"type\": \"text\",\r\n  \"text\": {\r\n      \"body\": \"your-message-content\"\r\n  }\r\n}",
};

$.ajax(settings).done(function (response) {
  console.log(response);
});
```

{% endtab %}

{% tab title="POWESHELL" %}
PowerShelll - RestMethod

```
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$headers.Add("Authorization", "Bearer xxxx")
$headers.Add("Content-Type", "text/plain")

$body = "{
`n  `"to`": `"+55119999999999`",
`n  `"type`": `"text`",
`n  `"text`": {
`n      `"body`": `"your-message-content`"
`n  }
`n}"

$response = Invoke-RestMethod 'https://api.positus.global/v2/sandbox/messages' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json
```

{% endtab %}

{% tab title="GO" %}
**Go** - **Native**

```
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.positus.global/v2/sandbox/messages"
  method := "POST"

  payload := strings.NewReader("{
\n  \"to\": \"+55119999999999\",
\n  \"type\": \"text\",
\n  \"text\": {
\n      \"body\": \"your-message-content\"
\n  }
\n}")

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
  }
  req.Header.Add("Content-Type", "application/json")
  req.Header.Add("Authorization", "Bearer xxxx")
  req.Header.Add("Content-Type", "text/plain")

  res, err := client.Do(req)
  defer res.Body.Close()
  body, err := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://business-talentum.gitbook.io/talentumbr/exemplos-de-codigo.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
