Photo de profil
curl --request POST \
--url https://api.wachap.com/v1/whatsapp/contacts/profile-picture \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"accountId": "<string>",
"phone": "<string>",
"preview": true
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({accountId: '<string>', phone: '<string>', preview: true})
};
fetch('https://api.wachap.com/v1/whatsapp/contacts/profile-picture', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({accountId: '<string>', phone: '<string>', preview: true})
};
fetch('https://api.wachap.com/v1/whatsapp/contacts/profile-picture', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.wachap.com/v1/whatsapp/contacts/profile-picture"
payload = {
"accountId": "<string>",
"phone": "<string>",
"preview": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.wachap.com/v1/whatsapp/contacts/profile-picture",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'accountId' => '<string>',
'phone' => '<string>',
'preview' => true
]),
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/whatsapp/contacts/profile-picture"
payload := strings.NewReader("{\n \"accountId\": \"<string>\",\n \"phone\": \"<string>\",\n \"preview\": true\n}")
req, _ := http.NewRequest("POST", 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))
}Contacts WhatsApp
Récupérer photo de profil
Récupérez la photo de profil d’un contact WhatsApp
POST
/
whatsapp
/
contacts
/
profile-picture
Photo de profil
curl --request POST \
--url https://api.wachap.com/v1/whatsapp/contacts/profile-picture \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"accountId": "<string>",
"phone": "<string>",
"preview": true
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({accountId: '<string>', phone: '<string>', preview: true})
};
fetch('https://api.wachap.com/v1/whatsapp/contacts/profile-picture', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({accountId: '<string>', phone: '<string>', preview: true})
};
fetch('https://api.wachap.com/v1/whatsapp/contacts/profile-picture', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.wachap.com/v1/whatsapp/contacts/profile-picture"
payload = {
"accountId": "<string>",
"phone": "<string>",
"preview": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.wachap.com/v1/whatsapp/contacts/profile-picture",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'accountId' => '<string>',
'phone' => '<string>',
'preview' => true
]),
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/whatsapp/contacts/profile-picture"
payload := strings.NewReader("{\n \"accountId\": \"<string>\",\n \"phone\": \"<string>\",\n \"preview\": true\n}")
req, _ := http.NewRequest("POST", 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
/v1/whatsapp/contacts/profile-picture
Headers
Bearer token avec votre Secret Key (format:
Bearer sk_...)Body Parameters
L’identifiant du compte WhatsApp
Le numéro de téléphone au format international
true = petite image, false = grande image (défaut: false)Notes
- Le paramètre
previewpermet de choisir entre :true: Image en basse résolution (plus rapide à charger)false: Image en haute résolution (défaut)
- Si le contact n’a pas de photo de profil, une erreur sera retournée
Exemples de requêtes
curl -X POST https://api.wachap.com/v1/whatsapp/contacts/profile-picture \
-H "Content-Type: application/json" \
-H "Authorization: Bearer token" \
-d '{
"accountId": "a1233b-a1233b-a1233b-a1233b-a1233bcdjdg9878",
"phone": "+2290112345678",
"preview": false
}'
const response = await fetch('https://api.wachap.com/v1/whatsapp/contacts/profile-picture', {
method: 'POST',
headers: {
'Authorization': 'Bearer token',
'Content-Type': 'application/json'
},
body: JSON.stringify({
accountId: 'a1233b-a1233b-a1233b-a1233b-a1233bcdjdg9878',
phone: '+2290112345678',
preview: false
})
});
const data = await response.json();
console.log(data);
import requests
url = "https://api.wachap.com/v1/whatsapp/contacts/profile-picture"
headers = {
"Authorization": "Bearer token",
"Content-Type": "application/json"
}
payload = {
"accountId": "a1233b-a1233b-a1233b-a1233b-a1233bcdjdg9878",
"phone": "+2290112345678",
"preview": False
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
<?php
$curl = curl_init();
$payload = [
"accountId" => "a1233b-a1233b-a1233b-a1233b-a1233bcdjdg9878",
"phone" => "+2290112345678",
"preview" => false
];
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.wachap.com/v1/whatsapp/contacts/profile-picture",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer token",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
Exemple de réponse
{
"success": true,
"message": "Photo de profil récupérée",
"url": "https://pps.whatsapp.net/v/t61.24694-24/123456789_abcdefghijk.jpg",
"id": "1234567890",
"type": "image",
"directUrl": "/v/t61.24694-24/123456789_abcdefghijk.jpg"
}
Champs de la réponse
| Champ | Type | Description |
|---|---|---|
url | string | URL complète de la photo de profil |
id | string | ID unique de la photo |
type | string | Type de média (toujours “image”) |
directUrl | string | Chemin relatif de l’URL |
Codes d’erreur
| Code | Description |
|---|---|
400 | MISSING_ACCOUNT_ID - accountId manquant |
400 | MISSING_PHONE - phone manquant |
401 | INVALID_SECRET_KEY - Clé secrète invalide |
404 | ACCOUNT_NOT_FOUND - Compte WhatsApp non trouvé |
404 | PROFILE_PICTURE_NOT_FOUND - Photo de profil non disponible |
⌘I
