> ## Documentation Index
> Fetch the complete documentation index at: https://dev.wachap.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Récupérer photo de profil

> Récupérez la photo de profil d’un contact WhatsApp

### Endpoint

<ParamField method="POST" path="/v1/whatsapp/contacts/profile-picture" />

### Headers

<ParamField header="Authorization" type="string" required>
  Bearer token avec votre Secret Key (format: `Bearer sk_...`)
</ParamField>

### Body Parameters

<ParamField body="accountId" type="string" required>
  L'identifiant du compte WhatsApp
</ParamField>

<ParamField body="phone" type="string" required>
  Le numéro de téléphone au format international
</ParamField>

<ParamField body="preview" type="boolean">
  `true` = petite image, `false` = grande image (défaut: `false`)
</ParamField>

### Notes

* Le paramètre `preview` permet 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

<CodeGroup>
  ```bash BASH theme={null}
  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
    }'
  ```

  ```javascript JAVASCRIPT theme={null}
  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);
  ```

  ```python PYTHON theme={null}
  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 PHP theme={null}
  <?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;
  ?>
  ```
</CodeGroup>

### Exemple de réponse

```json theme={null}
{
  "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 |


## OpenAPI

````yaml POST /whatsapp/contacts/profile-picture
openapi: 3.0.3
info:
  title: WaChap API
  version: 2.0.0
servers:
  - url: https://api.wachap.com/v1
    description: WaChap API server
security:
  - BearerAuth: []
tags:
  - name: Instances
    description: Créer et gérer des instances WhatsApp
  - name: Webhook
    description: Configuration des webhooks de réception
  - name: Messages
    description: Envoyer des messages WhatsApp
  - name: Comptes
    description: Gérer vos comptes WhatsApp connectés
  - name: SMS
    description: Service SMS de WaChap (V4) via FCM
  - name: Étiquettes WhatsApp
    description: Créer et associer des étiquettes aux conversations WhatsApp
paths:
  /whatsapp/contacts/profile-picture:
    post:
      tags:
        - Contacts
      summary: Photo de profil
      description: Récupérer la photo de profil d'un contact.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                accountId:
                  type: string
                phone:
                  type: string
                preview:
                  type: boolean
      responses:
        '200':
          description: OK
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````