Documentation API

L'API REST de Le Commercial vous permet d'envoyer des messages WhatsApp, de gérer vos contacts et vos listes depuis n'importe quelle application externe.

BASE URL https://lecommercial.app/api

🔑 Authentification

Chaque requête doit inclure votre authkey personnel, disponible dans Paramètres → Auth Key de votre compte.
Pour les endpoints d'envoi de message, ajoutez également l'appkey de l'application concernée (visible dans Mes Apps → REST API).

POST

Envoyer un message

https://lecommercial.app/api/create-message

Envoie un message WhatsApp (texte, média ou template) à un numéro de téléphone.

Paramètre Type Requis Description
appkey string Oui Clé de l'application (App Key)
authkey string Oui Clé d'authentification de l'utilisateur
to string Oui Numéro destinataire avec indicatif pays (ex: 33612345678)
message string Non Contenu du message texte (max 1000 caractères)
file string Non URL du fichier joint (jpg, jpeg, png, webp, pdf, docx, xlsx, csv, txt)
template_id string Non UUID du template à utiliser
variables array Non Variables de remplacement du template
curl --location --request POST 'https://lecommercial.app/api/create-message' \
--form 'appkey="YOUR_APPKEY"' \
--form 'authkey="YOUR_AUTHKEY"' \
--form 'to="YOUR_TO"' \
--form 'message="YOUR_MESSAGE"' \
--form 'file="YOUR_FILE"' \
--form 'template_id="YOUR_TEMPLATE_ID"' \
--form 'variables="YOUR_VARIABLES"'
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://lecommercial.app/api/create-message',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array(
  'appkey' => 'YOUR_APPKEY',
  'authkey' => 'YOUR_AUTHKEY',
  'to' => 'YOUR_TO',
  'message' => 'YOUR_MESSAGE',
  'file' => 'YOUR_FILE',
  'template_id' => 'YOUR_TEMPLATE_ID',
  'variables' => 'YOUR_VARIABLES',
  ),
));

$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://lecommercial.app/api/create-message',
  formData: {
    'appkey':  'YOUR_APPKEY',
    'authkey':  'YOUR_AUTHKEY',
    'to':  'YOUR_TO',
    'message':  'YOUR_MESSAGE',
    'file':  'YOUR_FILE',
    'template_id':  'YOUR_TEMPLATE_ID',
    'variables':  'YOUR_VARIABLES',
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
Réponse attendue
{
    "message_status": "Success",
    "data": {
        "from": "SENDER_NUMBER",
        "to": "RECEIVER_NUMBER",
        "status_code": 200
    }
}

POST

Ajouter un contact à une liste

https://lecommercial.app/api/add-contact

Enregistre un nouveau contact dans une liste sans envoyer de message. Utile depuis un formulaire externe.

Paramètre Type Requis Description
authkey string Oui Clé d'authentification de l'utilisateur
list_id integer Oui Identifiant de la liste cible
phone string Oui Numéro de téléphone avec indicatif pays
name string Non Prénom du contact
lastname string Non Nom de famille du contact
curl --location --request POST 'https://lecommercial.app/api/add-contact' \
--form 'authkey="YOUR_AUTHKEY"' \
--form 'list_id="YOUR_LIST_ID"' \
--form 'phone="YOUR_PHONE"' \
--form 'name="YOUR_NAME"' \
--form 'lastname="YOUR_LASTNAME"'
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://lecommercial.app/api/add-contact',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array(
  'authkey' => 'YOUR_AUTHKEY',
  'list_id' => 'YOUR_LIST_ID',
  'phone' => 'YOUR_PHONE',
  'name' => 'YOUR_NAME',
  'lastname' => 'YOUR_LASTNAME',
  ),
));

$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://lecommercial.app/api/add-contact',
  formData: {
    'authkey':  'YOUR_AUTHKEY',
    'list_id':  'YOUR_LIST_ID',
    'phone':  'YOUR_PHONE',
    'name':  'YOUR_NAME',
    'lastname':  'YOUR_LASTNAME',
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
Réponse attendue
{
    "success": true,
    "message": "Contact added to list successfully",
    "data": {
        "contact_id": 42,
        "list_id": 3
    }
}

GET

Récupérer les listes

https://lecommercial.app/api/lists?authkey=YOUR_AUTHKEY

Retourne toutes les listes de contacts de l'utilisateur avec leur nombre de contacts.

Paramètre Type Requis Description
authkey string Oui Clé d'authentification de l'utilisateur
curl --location --request GET 'https://lecommercial.app/api/lists?authkey=YOUR_AUTHKEY'
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://lecommercial.app/api/lists?authkey=YOUR_AUTHKEY',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'GET',
));

$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://lecommercial.app/api/lists?authkey=YOUR_AUTHKEY',
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
Réponse attendue
{
    "success": true,
    "data": [
        { "id": 3, "name": "Prospects", "contacts_count": 42 },
        { "id": 7, "name": "Clients VIP", "contacts_count": 15 }
    ]
}

GET

Lister les contacts d'une liste

https://lecommercial.app/api/contacts?authkey=YOUR_AUTHKEY&list_id=YOUR_LIST_ID&page=YOUR_PAGE

Retourne les contacts d'une liste, paginés par 50.

Paramètre Type Requis Description
authkey string Oui Clé d'authentification de l'utilisateur
list_id integer Oui Identifiant de la liste
page integer Non Numéro de page (50 contacts par page)
curl --location --request GET 'https://lecommercial.app/api/contacts?authkey=YOUR_AUTHKEY&list_id=YOUR_LIST_ID&page=YOUR_PAGE'
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://lecommercial.app/api/contacts?authkey=YOUR_AUTHKEY&list_id=YOUR_LIST_ID&page=YOUR_PAGE',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'GET',
));

$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://lecommercial.app/api/contacts?authkey=YOUR_AUTHKEY&list_id=YOUR_LIST_ID&page=YOUR_PAGE',
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
Réponse attendue
{
    "success": true,
    "data": [
        { "id": 1, "phone": "33612345678", "name": "Jean", "lastname": "Dupont" }
    ],
    "meta": { "total": 42, "per_page": 50, "current_page": 1, "last_page": 1 }
}

PUT

Mettre à jour un contact

https://lecommercial.app/api/update-contact

Met à jour le prénom et/ou le nom d'un contact identifié par son numéro de téléphone.

Paramètre Type Requis Description
authkey string Oui Clé d'authentification de l'utilisateur
phone string Oui Numéro de téléphone du contact à modifier
name string Non Nouveau prénom
lastname string Non Nouveau nom de famille
curl --location --request PUT 'https://lecommercial.app/api/update-contact' \
--form 'authkey="YOUR_AUTHKEY"' \
--form 'phone="YOUR_PHONE"' \
--form 'name="YOUR_NAME"' \
--form 'lastname="YOUR_LASTNAME"'
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://lecommercial.app/api/update-contact',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'PUT',
  CURLOPT_POSTFIELDS => array(
  'authkey' => 'YOUR_AUTHKEY',
  'phone' => 'YOUR_PHONE',
  'name' => 'YOUR_NAME',
  'lastname' => 'YOUR_LASTNAME',
  ),
));

$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
  'method': 'PUT',
  'url': 'https://lecommercial.app/api/update-contact',
  formData: {
    'authkey':  'YOUR_AUTHKEY',
    'phone':  'YOUR_PHONE',
    'name':  'YOUR_NAME',
    'lastname':  'YOUR_LASTNAME',
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
Réponse attendue
{
    "success": true,
    "message": "Contact updated successfully",
    "data": {
        "contact_id": 1,
        "phone": "33612345678",
        "name": "Jean",
        "lastname": "Martin"
    }
}

DELETE

Retirer un contact d'une liste

https://lecommercial.app/api/remove-contact

Retire un contact d'une liste sans le supprimer définitivement.

Paramètre Type Requis Description
authkey string Oui Clé d'authentification de l'utilisateur
list_id integer Oui Identifiant de la liste
phone string Oui Numéro de téléphone du contact à retirer
curl --location --request DELETE 'https://lecommercial.app/api/remove-contact' \
--form 'authkey="YOUR_AUTHKEY"' \
--form 'list_id="YOUR_LIST_ID"' \
--form 'phone="YOUR_PHONE"'
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://lecommercial.app/api/remove-contact',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'DELETE',
  CURLOPT_POSTFIELDS => array(
  'authkey' => 'YOUR_AUTHKEY',
  'list_id' => 'YOUR_LIST_ID',
  'phone' => 'YOUR_PHONE',
  ),
));

$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
  'method': 'DELETE',
  'url': 'https://lecommercial.app/api/remove-contact',
  formData: {
    'authkey':  'YOUR_AUTHKEY',
    'list_id':  'YOUR_LIST_ID',
    'phone':  'YOUR_PHONE',
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
Réponse attendue
{
    "success": true,
    "message": "Contact removed from list successfully"
}