Mettre à jour un contact
curl --request PUT \
--url https://api.wachap.com/v1/contact-groups/{id}/contacts/{contactIndex} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"phone": "<string>",
"name": "<string>"
}
'const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({phone: '<string>', name: '<string>'})
};
fetch('https://api.wachap.com/v1/contact-groups/{id}/contacts/{contactIndex}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({phone: '<string>', name: '<string>'})
};
fetch('https://api.wachap.com/v1/contact-groups/{id}/contacts/{contactIndex}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.wachap.com/v1/contact-groups/{id}/contacts/{contactIndex}"
payload = {
"phone": "<string>",
"name": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.wachap.com/v1/contact-groups/{id}/contacts/{contactIndex}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'phone' => '<string>',
'name' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.wachap.com/v1/contact-groups/{id}/contacts/{contactIndex}"
payload := strings.NewReader("{\n \"phone\": \"<string>\",\n \"name\": \"<string>\"\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}Listes de contacts
Mettre à jour un contact
Modifiez les champs d’un contact spécifique dans une liste. Vous pouvez modifier des champs existants ou ajouter de nouveaux champs personnalisés.
PUT
/
contact-groups
/
{id}
/
contacts
/
{contactIndex}
Mettre à jour un contact
curl --request PUT \
--url https://api.wachap.com/v1/contact-groups/{id}/contacts/{contactIndex} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"phone": "<string>",
"name": "<string>"
}
'const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({phone: '<string>', name: '<string>'})
};
fetch('https://api.wachap.com/v1/contact-groups/{id}/contacts/{contactIndex}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({phone: '<string>', name: '<string>'})
};
fetch('https://api.wachap.com/v1/contact-groups/{id}/contacts/{contactIndex}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.wachap.com/v1/contact-groups/{id}/contacts/{contactIndex}"
payload = {
"phone": "<string>",
"name": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.wachap.com/v1/contact-groups/{id}/contacts/{contactIndex}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'phone' => '<string>',
'name' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.wachap.com/v1/contact-groups/{id}/contacts/{contactIndex}"
payload := strings.NewReader("{\n \"phone\": \"<string>\",\n \"name\": \"<string>\"\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}Endpoint
Headers
string
requis
Bearer token avec votre Secret Key (format:
Bearer sk_...)URL Parameters
string
requis
L’identifiant de la liste
number
requis
L’index du contact à modifier
Body Parameters
Tous les paramètres sont optionnels. Seuls les champs fournis seront mis à jour ou ajoutés.| Paramètre | Type | Description |
|---|---|---|
phone | string | Nouveau numéro de téléphone |
name | string | Nouveau nom |
email | string | Nouvel email |
... | any | N’importe quel autre champ personnalisé |
Exemples de requêtes
curl -X PUT https://api.wachap.com/v1/contact-groups/65f1234567890abcdef12345/contacts/5 \
-H "Content-Type: application/json" \
-H "Authorization: Bearer token" \
-d '{
"name": "John Doe Updated",
"email": "john.new@example.com",
"company": "WaChap Inc"
}'
// Exemple de mise à jour partielle
const response = await fetch('https://api.wachap.com/v1/contact-groups/65f1234567890abcdef12345/contacts/5', {
method: 'PUT',
headers: {
'Authorization': 'Bearer token',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'John Doe Updated',
company: 'WaChap Inc'
})
});
const data = await response.json();
console.log(data);
Exemple de réponse
{
"success": true,
"message": "Contact mis à jour avec succès",
"contactIndex": 5,
"updatedColumns": 2,
"addedColumns": 1
}
Notes importantes
- Modification partielle : Seuls les champs fournis sont mis à jour
- Nouveaux champs : Vous pouvez ajouter n’importe quel nouveau champ personnalisé
- Conservation : Les champs non mentionnés restent inchangés
- Index : L’index du contact ne change pas
Codes d’erreur
| Code | Description |
|---|---|
400 | INVALID_DATA - Données de mise à jour requises |
401 | INVALID_SECRET_KEY - Clé secrète invalide |
404 | CONTACT_NOT_FOUND - Contact non trouvé à cet index |
500 | UPDATE_CONTACT_ERROR - Erreur lors de la mise à jour |
