## API-URL
URL zum Senden von HTTP-Anfragen:
```url
https://portal.bulkgate.com/api/1.0/address-book/add
```

> [!NOTE]
> Erreicht die Anfrage ihr Ziel nicht, wiederholen Sie sie auf dem [Backup-Server](https://www.bulkgate.com/de/dokumentation/api-verwaltung-und-tokens/backup-server/) `backup1.bulkgate.com`.


## Unterstützte HTTP-Methoden

- `POST` - `application/json`

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

## Parametertabelle

| PARAMETERNAME | WERT | PFLICHT | STANDARDWERT |
|:------------------|:----------------------------------------------------------------|:----------|:----------------------------|
| application_id | [Anwendungs-ID](https://www.bulkgate.com/de/dokumentation/api-verwaltung-und-tokens/api-verwaltung/) | **Ja** | - |
| application_token | [Anwendungstoken](https://www.bulkgate.com/de/dokumentation/api-verwaltung-und-tokens/api-tokens/) | **Ja** | - |
| groups | Array der IDs der Gruppen, in die die Kontakte hinzugefügt werden | **Nein** | - |
| group_name | Der Kontakt wird einer neuen Gruppe mit dem Namen `group_name` hinzugefügt | **Nein** | - |
| data | Kontaktangaben | **Ja** | [Datenobjekt](#datenobjekt) |
| category | Das Adressbuch, mit dem gearbeitet wird. Standardmäßig das Hauptadressbuch des Kontos. | Nein | `main` |
| duplicity_action | Was mit einem bereits vorhandenen Kontakt geschieht — `restrict` (ablehnen), `skip` (überspringen), `update` (leere Felder ergänzen), `rewrite` (überschreiben). | Nein | `restrict` |

## Datenobjekt

| PARAMETERNAME | WERT | PFLICHT | STANDARDWERT |
|:---------------|:--------------------------------------------------------------------------------------------------------------------------------|:----------|:--------------|
| type | Art des Kontakts (Person/Firma) | **Nein** | - |
| phone_mobile | Haupttelefonnummer | **Nein** | - |
| title_before | Titel vor dem Namen | **Nein** | - |
| first_name | Vorname | **Nein** | - |
| last_name | Nachname | **Nein** | - |
| title_after | Titel nach dem Namen | **Nein** | - |
| gender | male / female / transgender / agender / non_binary / unknown | **Nein** | unknown |
| company_name | Name Ihrer Firma | **Nein** | - |
| email | E-Mail | **Nein** | - |
| url | URL Ihrer Website | **Nein** | - |
| street1 | Adresse (Straße) 1 | **Nein** | - |
| street2 | Adresse (Straße) 2 | **Nein** | - |
| city | Stadt | **Nein** | - |
| zip | Postleitzahl | **Nein** | - |
| state | Bundesland/Staat | **Nein** | - |
| country | [Ländercode im Format ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements) | **Nein** | `null` |
| company_number | Handelsregisternummer | **Nein** | - |
| company_vat | USt-IdNr. der Firma | **Nein** | - |
| note | Notiz | **Nein** | - |
| custom_field_0 | Benutzerdefiniertes Feld | **Nein** | - |
| custom_field_1 | Benutzerdefiniertes Feld | **Nein** | - |
| custom_field_2 | Benutzerdefiniertes Feld | **Nein** | - |
| custom_field_3 | Benutzerdefiniertes Feld | **Nein** | - |
| custom_field_4 | Benutzerdefiniertes Feld | **Nein** | - |
| custom_field_5 | Benutzerdefiniertes Feld | **Nein** | - |
| custom_field_6 | Benutzerdefiniertes Feld | **Nein** | - |
| custom_field_7 | Benutzerdefiniertes Feld | **Nein** | - |
| custom_field_8 | Benutzerdefiniertes Feld | **Nein** | - |
| custom_field_9 | Benutzerdefiniertes Feld | **Nein** | - |

## Beispielanfrage

```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"
	}
}
```

## Antwort

**Bei Erfolg:**
```json
{
    "data": {
        "message": "contact_has_been_added",
        "groups": [1,2,3]
    }
}
```


**Bei einem Fehler:**
```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
}
```

Dabei gilt:

- **type** und **error** (Beschreibung des Fehlers) finden Sie in der [Tabelle der Fehlertypen](https://www.bulkgate.com/de/dokumentation/api-verwaltung-und-tokens/api-fehlertypen/)
- **code** steht für den HTTP-Fehler
- **detail** enthält zusätzliche Informationen zum Fehler
