> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.callix.dev.br/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.callix.dev.br/_mcp/server.

# Click to chat

POST https://sua-conta.callix.com.br/api/v1/click_to_chat
Content-Type: application/vnd.api+json

Inicia um atendimento de WhatsApp via API (click-to-chat). `type: "click_to_chat"`.

**Atributos**

* `phone` (string): Telefone que receberá a mensagem. Obrigatório se `meta_user_id` não for fornecido. Para celulares brasileiros, o dígito 9 pode ser adicionado automaticamente; nesse caso message e phone retornam na resposta com a correção aplicada.
* `meta_user_id` (string): Identificador Meta (BSUID) do destinatário; alternativa ao telefone para clientes sem número vinculado. Obrigatório se phone não for fornecido.
* `inbound_number_id` (number): Id do número WhatsApp usado para enviar. Obrigatório se `inbound_number_phone` não for fornecido.
* `inbound_number_phone` (string): Telefone do número WhatsApp usado para enviar. Obrigatório se `inbound_number_id` não for fornecido.
* `template_id` (number, opcional): Id do template WhatsApp a usar na mensagem.
* `queue_id` (number): Id da Fila de WhatsApp para encaminhar o atendimento. Obrigatório se `target_type` = `1`.
* `workflow_id` (number): Id do Fluxo para encaminhar. Obrigatório se `target_type` = `2`.
* `user_id` (number): Id do agente para encaminhar. Obrigatório se `target_type` = `3` ou `4`.
* `customer_id` (number, opcional): Cliente a associar ao atendimento e popular variáveis de template.
* `template_variables` (JSON, opcional): Valores das variáveis do template. Formato \{ "body": \{ "1": "Valor 1", "2": "Valor 2" } } onde a chave é o nome da variável.
* `target_type` (enum): Para onde encaminhar o atendimento:
  * `1` — Fila de WhatsApp
  * `2` — Fluxo
  * `3` — Agente (sem confirmação)
  * `4` — Agente (com confirmação)
* `terminate_ongoing_conversation` (boolean, opcional): Encerra o atendimento em andamento do destino (só se estiver em 'Esperando resposta'). `true` encerra; `false` mantém.

**Resposta:** protocol (number, exceto `target_type` = `4`), success (boolean), message (string, quando dígito 9 é adicionado), phone (string, idem), `error_code` (string, em falha).

Reference: https://docs.callix.dev.br/api-reference/click-to-call-chat-sms/post-click-to-chat

## Authentication

- `Authorization` header (bearer token, required) — Token de API da conta do tenant.

## Response

### 200

Atendimento iniciado.

- `protocol` (integer, optional) — Protocolo do atendimento (exceto quando target_type = 4).
- `success` (boolean, optional) — Indica se a solicitação foi aceita.

## Examples

**Request**

```json
{
  "data": {
    "attributes": {
      "customer_id": 87,
      "inbound_number_id": 12,
      "phone": "5521991234567",
      "queue_id": 3,
      "target_type": 1,
      "template_id": 5,
      "template_variables": {
        "body": {
          "1": "Marina",
          "2": "15/01/2026"
        }
      }
    },
    "type": "click_to_chat"
  }
}
```

**Response**

```json
{
  "protocol": 20260115142233,
  "success": true
}
```

**SDK Code**

```python Click to Call/Chat/SMS_post_click_to_chat_example
import requests

url = "https://sua-conta.callix.com.br/api/v1/click_to_chat"

payload = "{\n  \"data\": {\n    \"attributes\": {\n      \"customer_id\": 87,\n      \"inbound_number_id\": 12,\n      \"phone\": \"5521991234567\",\n      \"queue_id\": 3,\n      \"target_type\": 1,\n      \"template_id\": 5,\n      \"template_variables\": {\n        \"body\": {\n          \"1\": \"Marina\",\n          \"2\": \"15/01/2026\"\n        }\n      }\n    },\n    \"type\": \"click_to_chat\"\n  }\n}"
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/vnd.api+json"
}

response = requests.post(url, data=payload, headers=headers)

print(response.json())
```

```javascript Click to Call/Chat/SMS_post_click_to_chat_example
const url = 'https://sua-conta.callix.com.br/api/v1/click_to_chat';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/vnd.api+json'},
  body: '{\n  "data": {\n    "attributes": {\n      "customer_id": 87,\n      "inbound_number_id": 12,\n      "phone": "5521991234567",\n      "queue_id": 3,\n      "target_type": 1,\n      "template_id": 5,\n      "template_variables": {\n        "body": {\n          "1": "Marina",\n          "2": "15/01/2026"\n        }\n      }\n    },\n    "type": "click_to_chat"\n  }\n}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Click to Call/Chat/SMS_post_click_to_chat_example
package main

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

func main() {

	url := "https://sua-conta.callix.com.br/api/v1/click_to_chat"

	payload := strings.NewReader("{\n  \"data\": {\n    \"attributes\": {\n      \"customer_id\": 87,\n      \"inbound_number_id\": 12,\n      \"phone\": \"5521991234567\",\n      \"queue_id\": 3,\n      \"target_type\": 1,\n      \"template_id\": 5,\n      \"template_variables\": {\n        \"body\": {\n          \"1\": \"Marina\",\n          \"2\": \"15/01/2026\"\n        }\n      }\n    },\n    \"type\": \"click_to_chat\"\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/vnd.api+json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Click to Call/Chat/SMS_post_click_to_chat_example
require 'uri'
require 'net/http'

url = URI("https://sua-conta.callix.com.br/api/v1/click_to_chat")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/vnd.api+json'
request.body = "{\n  \"data\": {\n    \"attributes\": {\n      \"customer_id\": 87,\n      \"inbound_number_id\": 12,\n      \"phone\": \"5521991234567\",\n      \"queue_id\": 3,\n      \"target_type\": 1,\n      \"template_id\": 5,\n      \"template_variables\": {\n        \"body\": {\n          \"1\": \"Marina\",\n          \"2\": \"15/01/2026\"\n        }\n      }\n    },\n    \"type\": \"click_to_chat\"\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java Click to Call/Chat/SMS_post_click_to_chat_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://sua-conta.callix.com.br/api/v1/click_to_chat")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/vnd.api+json")
  .body("{\n  \"data\": {\n    \"attributes\": {\n      \"customer_id\": 87,\n      \"inbound_number_id\": 12,\n      \"phone\": \"5521991234567\",\n      \"queue_id\": 3,\n      \"target_type\": 1,\n      \"template_id\": 5,\n      \"template_variables\": {\n        \"body\": {\n          \"1\": \"Marina\",\n          \"2\": \"15/01/2026\"\n        }\n      }\n    },\n    \"type\": \"click_to_chat\"\n  }\n}")
  .asString();
```

```php Click to Call/Chat/SMS_post_click_to_chat_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://sua-conta.callix.com.br/api/v1/click_to_chat', [
  'body' => '{
  "data": {
    "attributes": {
      "customer_id": 87,
      "inbound_number_id": 12,
      "phone": "5521991234567",
      "queue_id": 3,
      "target_type": 1,
      "template_id": 5,
      "template_variables": {
        "body": {
          "1": "Marina",
          "2": "15/01/2026"
        }
      }
    },
    "type": "click_to_chat"
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/vnd.api+json',
  ],
]);

echo $response->getBody();
```

```csharp Click to Call/Chat/SMS_post_click_to_chat_example
using RestSharp;

var client = new RestClient("https://sua-conta.callix.com.br/api/v1/click_to_chat");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/vnd.api+json");
request.AddParameter("application/vnd.api+json", "{\n  \"data\": {\n    \"attributes\": {\n      \"customer_id\": 87,\n      \"inbound_number_id\": 12,\n      \"phone\": \"5521991234567\",\n      \"queue_id\": 3,\n      \"target_type\": 1,\n      \"template_id\": 5,\n      \"template_variables\": {\n        \"body\": {\n          \"1\": \"Marina\",\n          \"2\": \"15/01/2026\"\n        }\n      }\n    },\n    \"type\": \"click_to_chat\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Click to Call/Chat/SMS_post_click_to_chat_example
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/vnd.api+json"
]

let postData = NSData(data: "{
  "data": {
    "attributes": {
      "customer_id": 87,
      "inbound_number_id": 12,
      "phone": "5521991234567",
      "queue_id": 3,
      "target_type": 1,
      "template_id": 5,
      "template_variables": {
        "body": {
          "1": "Marina",
          "2": "15/01/2026"
        }
      }
    },
    "type": "click_to_chat"
  }
}".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://sua-conta.callix.com.br/api/v1/click_to_chat")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```