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

> [!NOTE]
> Wenn die Anfrage ihr Ziel nicht erreicht, 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/import HTTP/1.1
Host: portal.bulkgate.com
Content-Type: application/json
```

## Parametertabelle

| PARAMETERNAME     | WERT                                                        | PFLICHT   | STANDARDWERT                          |
|:------------------|:------------------------------------------------------------|:----------|:--------------------------------------|
| application_id    | [Application ID](https://www.bulkgate.com/de/dokumentation/api-verwaltung-und-tokens/api-verwaltung/)               | **Ja**    | -                                     | 
| application_token | [Application token](https://www.bulkgate.com/de/dokumentation/api-verwaltung-und-tokens/api-tokens/)	                   | **Ja**    | -                                     |
| groups            | Array der IDs der Gruppen, zu denen die Kontakte hinzugefügt werden | **Nein** | -                                     |
| group_name        | Die importierten Kontakte werden einer neuen Gruppe mit diesem Namen hinzugefügt | **Nein** | -                                     |
| data              | Kontaktdaten                                                | **Ja**    | Array von [Datenobjekten](#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       | `skip`                 |

## Datenobjekt

| PARAMETERNAME  | WERT                                                                                                                            | PFLICHT   | STANDARDWERT  |
|:---------------|:--------------------------------------------------------------------------------------------------------------------------------|:----------|:--------------|
| type           | Typ 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        | Adresszeile 1                                                                                                                   | **Nein**  | -             |
| street2        | Adresszeile 2                                                                                                                   | **Nein**  | -             |
| city           | Ort                                                                                                                             | **Nein**  | -             |
| zip            | Postleitzahl                                                                                                                        | **Nein**  | -             |
| state          | Bundesland/Region                                                                                                                        | **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 | Identifikationsnummer der Firma                                                                                                                 | **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/import 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": "789456123"
    },
    {
        "first_name": "Alex",
        "last_name": "Yu",
        "phone_mobile": "123456789"
    }
  ]
}
```

## Antwort

**Im Erfolgsfall:**
```json
{
    "data": {
        "message": "contacts_have_been_imported",
        "imported": 3,
        "groups": [1,2,3]
    }
}
```


**Im Fehlerfall:**
```json
{
    "type": "no_valid_contacts_found",
    "code": 400,
    "error": "No valid contacts 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-Fehlercode
- **detail** enthält zusätzliche Informationen zum Fehler
