Introduction
Welcome to the Connexa API! This documentation provides details about our API, which facilitates communication and automation through WhatsApp.
Authentication
Example of Basic Authentication:
curl -X POST "https://api.example.com/api/v1/message/text"
-u "<user_id>:<instance_token>"
-H "Content-Type: application/json"
-d '{"phone": "554499999999", "data": {"text": "Hello!"}}'
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
url := "https://api.example.com/api/v1/message/text"
username := "<user_id>"
password := "<instance_token>"
data := map[string]interface{}{
"phone": "554499999999",
"data": map[string]string{"text": "Hello!"},
}
payload, _ := json.Marshal(data)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(payload))
req.SetBasicAuth(username, password)
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
fmt.Println(resp.Status)
}
Connexa uses Basic Authentication. Use your user_id as the username and instance_token as the password in your API requests.
Messaging
HTTP Request
POST /api/v1/message/<message_type>
HTTP Request
| Parameter | Description |
|---|---|
message_type |
Specifies the type of message to send. Supported values: text, image, video, audio, document. |
HTTP Request
The request payload must include the following parameters:
| Field | Type | Description |
|---|---|---|
phone |
string |
The recipient's phone number in international format. |
data |
object |
An object containing the message details. The structure depends on the message_type. |
The data object
For text Message
| Field | Type | Description |
|---|---|---|
text |
string |
The message text |
For media Message (image, video, audio or document)
For all media messages, you can send with a URL or base64 data.
Base64
| Field | Type | Description |
|---|---|---|
text |
string |
The message text |
base64 |
string |
Base64 from file |
URL
| Field | Type | Description |
|---|---|---|
text |
string |
The message text |
url |
string |
URL from the file |
Response
Example of a successful response:
{
"message_id": "fc21e5b5-b79b-4eaa-a81a-bc12a754e129"
}
A successful response returns the unique message_id for the sent message.
Error Codes
| Error Code | Description |
|---|---|
| 401 | Unauthorized. Verify your credentials. |
| 400 | Bad Request. Check the request payload. |
| 500 | Internal Server Error. |
Examples
// Text message
curl -X POST "https://api.example.com/api/v1/message/<message_type>" -u "<user_id>:<instance_token>" -H "Content-Type: application/json" -d '{
"phone": "554499999999",
"data": {
"text": "Hello from Connexa!"
}
}'
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
url := "https://api.example.com/api/v1/message/text"
username := "<user_id>"
password := "<instance_token>"
data := map[string]interface{}{
"phone": "554499999999",
"data": map[string]string{"text": "Hello from Connexa!"},
}
payload, _ := json.Marshal(data)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(payload))
req.SetBasicAuth(username, password)
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
fmt.Println(resp.Status)
}
// Image message
curl -X POST "https://api.example.com/api/v1/message/image" -u "<user_id>:<instance_token>" -H "Content-Type: application/json" -d '{
"phone": "554499999999",
"data": {
"text": "Hello from Connexa!",
"base64": "url_base64_data"
}
}'
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
/*
Send image with golang
*/
func main() {
url := "https://api.example.com/api/v1/message/image"
username := "<user_id>"
password := "<instance_token>"
data := map[string]interface{}{
"phone": "554499999999",
"data": map[string]string{"text": "Hello from Connexa!", "base64": "url_base64_data"},
}
payload, _ := json.Marshal(data)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(payload))
req.SetBasicAuth(username, password)
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
fmt.Println(resp.Status)
}