## API URL
URL utilisée pour envoyer les requêtes HTTP :
```url
https://portal.bulkgate.com/api/1.0/address-book/add
```

> [!NOTE]
> Si la requête n'atteint pas sa destination, renvoyez-la sur le [serveur de secours](https://www.bulkgate.com/fr/documentation/administration-api-et-tokens/serveur-de-secours/) `backup1.bulkgate.com`.


## Méthodes HTTP prises en charge

- `POST` - `application/json`

```http
POST /api/1.0/address-book/add HTTP/1.1
Host: portal.bulkgate.com
Content-Type: application/json
```

## Tableau des paramètres

| NOM DU PARAMÈTRE  | VALEUR                                                          | OBLIGATOIRE | VALEUR PAR DÉFAUT           |
|:------------------|:----------------------------------------------------------------|:----------|:----------------------------|
| application_id    | [Application ID](https://www.bulkgate.com/fr/documentation/administration-api-et-tokens/administration-api/)                   | **Oui**   | -                           | 
| application_token | [Jeton d'application](https://www.bulkgate.com/fr/documentation/administration-api-et-tokens/tokens-d-api/)	                       | **Oui**   | -                           |
| groups            | Tableau des ID des groupes auxquels les contacts seront ajoutés | **Non**   | -                           |
| group_name        | Le contact sera ajouté à un nouveau groupe nommé `group_name`   | **Non**   | -                           |
| data              | Informations du contact                                         | **Oui**   | [Objet data](#objet-data)   |
| category          | Le carnet d'adresses à utiliser. Par défaut, le carnet principal du compte. | Non      | `main`                      |
| duplicity_action  | Que faire d'un contact qui existe déjà — `restrict` (rejeter), `skip` (ignorer), `update` (compléter les champs vides), `rewrite` (écraser). | Non      | `restrict`                 |

## Objet data

| NOM DU PARAMÈTRE | VALEUR                                                                                                                          | OBLIGATOIRE | VALEUR PAR DÉFAUT |
|:---------------|:--------------------------------------------------------------------------------------------------------------------------------|:----------|:--------------|
| type           | Type de contact (personne/entreprise)                                                                                           | **Non**   | -             |
| phone_mobile   | Numéro de téléphone principal                                                                                                   | **Non**   | -             | 
| title_before   | Titre avant le nom                                                                                                              | **Non**   | -             |
| first_name     | Prénom	                                                                                                                     | **Non**   | -             |
| last_name      | Nom	                                                                                                                      | **Non**   | -             |
| title_after    | Titre après le nom	                                                                                                               | **Non**   | -             |
| gender         | male / female / transgender / agender / non_binary / unknown            | **Non**   | unknown       |
| company_name   | Nom de votre entreprise                                                                                                         | **Non**   | -             |
| email          | E-mail                                                                                                                          | **Non**   | -             |
| url            | URL de votre site web                                                                                                           | **Non**   | -             |
| street1        | Adresse (ligne 1)                                                                                                               | **Non**   | -             |
| street2        | Adresse (ligne 2)                                                                                                               | **Non**   | -             |
| city           | Ville                                                                                                                           | **Non**   | -             |
| zip            | Code postal                                                                                                                     | **Non**   | -             |
| state          | État / région                                                                                                                   | **Non**   | -             |
| country        | [Code pays au format ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements)    | **Non**   | `null`        |
| company_number | Numéro d'identification de l'entreprise                                                                                         | **Non**   | -             |
| company_vat    | Numéro de TVA de l'entreprise                                                                                                   | **Non**   | -             |
| note           | Note                                                                                                                            | **Non**   | -             |
| custom_field_0 | Champ personnalisé                                                                                                              | **Non**   | -             |
| custom_field_1 | Champ personnalisé                                                                                                              | **Non**   | -             |
| custom_field_2 | Champ personnalisé                                                                                                              | **Non**   | -             |
| custom_field_3 | Champ personnalisé                                                                                                              | **Non**   | -             |
| custom_field_4 | Champ personnalisé                                                                                                              | **Non**   | -             |
| custom_field_5 | Champ personnalisé                                                                                                              | **Non**   | -             |
| custom_field_6 | Champ personnalisé                                                                                                              | **Non**   | -             |
| custom_field_7 | Champ personnalisé                                                                                                              | **Non**   | -             |
| custom_field_8 | Champ personnalisé                                                                                                              | **Non**   | -             |
| custom_field_9 | Champ personnalisé                                                                                                              | **Non**   | -             |

## Exemple de requête

```http-json
POST /api/1.0/address-book/add HTTP/1.1
Host: portal.bulkgate.com
Content-Type: application/json

{
	"application_id": 451,
	"application_token": "NKN02TWE6NfBkfl-your-secret-token-Wf05GaqLIWLW4aBj",
	"groups": [1, 2],
	"group_name": "Talos 1",
	"data": {
	     "first_name": "Morgan",
	     "last_name": "Yu",
	     "phone_mobile": "123456789",
	     "street1": "Crew's quarters",
	     "street2": "Executive suite",
	     "country": "Talos 1",
	     "email": "morganyu@talos.com"
	}
}
```

## Réponse

**En cas de succès :**
```json
{
    "data": {
        "message": "contact_has_been_added",
        "groups": [1,2,3]
    }
}
```


**En cas d'erreur :**
```json
{
    "type": "contact_with_this_phone_number_already_exists",
    "code": 400,
    "error": "Contact with this phone number already exists",
    "detail": null
}
```

```json
{
    "type": "invalid_phone_mobile",
    "code": 400,
    "error": "Invalid phone mobile",
    "detail": null
}
```

```json
{
    "type": "group_not_found",
    "code": 400,
    "error": "Group not found",
    "detail": null
}
```

Où :

- **type** et **error** (description de l'erreur) figurent dans le [tableau des types d'erreurs](https://www.bulkgate.com/fr/documentation/administration-api-et-tokens/types-d-erreurs-api/)
- **code** représente le code d'erreur HTTP
- **detail** est une information complémentaire sur l'erreur
