---
title: Contacts
excerpt: Gérez les contacts rattachés aux comptes clients d'un workspace.
order: 7
---

Un **contact** est une personne rattachée à un compte client (ou à une autre entité) de votre workspace : représentant légal, contact technique, comptable, etc.

> Il s'agit des contacts propres au workspace. Pour rechercher ou créer des contacts dans un CRM connecté, utilisez [CRM Lookup](/fr/docs/cx-api/lookup). Pour les contacts Smart Routings, voir [Contacts Smart Routings](/fr/docs/cx-api/smart-routings-contacts).

Tous les endpoints de cette section sont **scopés au workspace** et réservés aux **utilisateurs admin**.

**En-têtes :** `Authorization: Bearer {token-workspace}`

---

## Permissions

| Endpoint | Permission requise |
|---|---|
| `GET /api/contacts` | Utilisateur admin avec `contact.view` |
| `GET /api/contacts/{id}` | `contact.view` |
| `POST /api/contacts` | Utilisateur admin avec `contact.create` |
| `PUT /api/contacts/{id}` | Utilisateur admin avec `contact.edit` |
| `DELETE /api/contacts/{id}` | Utilisateur admin avec `contact.delete` |

---

## L'objet contact

```json
{
  "id": 41,
  "user_id": null,
  "contactable_type": "customer",
  "contactable_id": 12,
  "active": true,
  "profunction": "IT Manager",
  "first_name": "Alice",
  "last_name": "Martin",
  "email_address": "alice.martin@acme.com",
  "mobile_phone": "+33612345678",
  "landline_phone": "+33142000000",
  "is_legal": false,
  "is_technical": true,
  "is_accountant": false,
  "is_invoices_recipient": false,
  "is_sms_enabled": false,
  "cfd_token": null,
  "cfd_authorised_hosts": null,
  "comment": null,
  "created_at": "2024-03-01T09:00:00.000000Z",
  "updated_at": "2024-03-01T09:00:00.000000Z"
}
```

`contactable_type` et `contactable_id` identifient l'entité à laquelle le contact appartient. Pour un client, utilisez `customer` et l'ID du client.

---

## GET /api/contacts

Retourne tous les contacts du workspace sous forme de tableau JSON simple (non paginé).

**Réponse `200`** : tableau d'objets contact

---

## GET /api/contacts/{id}

Retourne un contact.

**Réponse `200`** : objet contact

**Réponse `403`** : accès non autorisé

---

## POST /api/contacts

Crée un contact. Le corps doit être un objet JSON.

**Corps de la requête**

| Champ | Type | Requis | Description |
|---|---|---|---|
| `last_name` | string | oui | Nom (2 à 255 caractères) |
| `email_address` | string | oui | Adresse email |
| `contactable_type` | string | oui | Type de l'entité parente, ex. `customer` |
| `contactable_id` | integer | oui | ID de l'entité parente |
| `first_name` | string | non | Prénom (2 à 255 caractères) |
| `profunction` | string | non | Fonction |
| `active` | boolean | non | Contact actif ou non |
| `mobile_phone` | string | non | Numéro de mobile |
| `landline_phone` | string | non | Numéro de téléphone fixe |
| `is_legal` | boolean | non | Représentant légal |
| `is_technical` | boolean | non | Contact technique |
| `is_accountant` | boolean | non | Contact comptable |
| `is_invoices_recipient` | boolean | non | Destinataire des factures |
| `is_sms_enabled` | boolean | non | Peut recevoir des SMS |
| `comment` | string | non | Commentaire libre |

`id`, `user_id`, `created_at` et `updated_at` ne peuvent pas être définis.

**Réponse `201`** : l'objet contact créé

**Réponse `400`** : échec de validation

```json
{
  "response": "bad request: please check body parameters.",
  "hint": ["The email address field is required."]
}
```

---

## PUT /api/contacts/{id}

Modifie un contact. Accepte les mêmes champs que `POST /api/contacts`, tous facultatifs. Seuls les champs envoyés sont modifiés.

**Réponse `201`** : l'objet contact modifié

---

## DELETE /api/contacts/{id}

Supprime un contact.

**Réponse `200`**

```json
{ "response": "element deleted" }
```
