## API URL
URL used to send HTTP requests:
```url
https://portal.bulkgate.com/api/1.0/address-book/add
```

> [!NOTE]
> If the request does not reach its destination, repeat it on the [backup server](https://www.bulkgate.com/en/docs/api-administration-tokens/api-backup-server/) `backup1.bulkgate.com`.


## Supported HTTP methods

- `POST` - `application/json`

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

## Parameters table

| PARAMETER NAME    | VALUE                                                           | MANDATORY | DEFAULT VALUE               |
|:------------------|:----------------------------------------------------------------|:----------|:----------------------------|
| application_id    | [Application ID](https://www.bulkgate.com/en/docs/api-administration-tokens/api-administration/)                   | **Yes**   | -                           | 
| application_token | [Application token](https://www.bulkgate.com/en/docs/api-administration-tokens/api-tokens/)	                       | **Yes**   | -                           |
| groups            | Array of group ID's in which contacts will be added             | **No**    | -                           |
| group_name        | Added contact will be added to new group with name `group_name` | **No**    | -                           |
| data              | Contact information                                             | **Yes**   | [Data object](#data-object) |
| category          | The address book to work with. Defaults to the account main one. | No       | `main`                      |
| duplicity_action  | What to do with a contact that is already there — `restrict` (reject), `skip`, `update` (fill in empty fields), `rewrite` (overwrite).  | No       | `restrict`                 |

## Data object

| PARAMETER NAME | VALUE                                                                                                                           | MANDATORY | DEFAULT VALUE |
|:---------------|:--------------------------------------------------------------------------------------------------------------------------------|:----------|:--------------|
| type           | Type of contact (person/company)                                                                                                | **No**    | -             |
| phone_mobile   | Main phone number                                                                                                               | **No**    | -             | 
| title_before   | Title before name                                                                                                               | **No**    | -             |
| first_name     | First name	                                                                                                                     | **No**    | -             |
| last_name      | Last name	                                                                                                                      | **No**    | -             |
| title_after    | Title after name	                                                                                                               | **No**    | -             |
| gender         | male / female / transgender / agender / non_binary / unknown            | **No**    | unknown       |
| company_name   | Name of your company                                                                                                            | **No**    | -             |
| email          | Email                                                                                                                           | **No**    | -             |
| url            | Url of your website                                                                                                             | **No**    | -             |
| street1        | 1. Street address                                                                                                               | **No**    | -             |
| street2        | 2. Street address                                                                                                               | **No**    | -             |
| city           | City                                                                                                                            | **No**    | -             |
| zip            | Zip code                                                                                                                        | **No**    | -             |
| state          | State                                                                                                                           | **No**    | -             |
| country        | [Country code in ISO 3166-1 alpha-2 format](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements) | **No**    | `null`        |
| company_number | Company number                                                                                                                  | **No**    | -             |
| company_vat    | Company vat                                                                                                                     | **No**    | -             |
| note           | Note                                                                                                                            | **No**    | -             |
| custom_field_0 | Custom field                                                                                                                    | **No**    | -             |
| custom_field_1 | Custom field                                                                                                                    | **No**    | -             |
| custom_field_2 | Custom field                                                                                                                    | **No**    | -             |
| custom_field_3 | Custom field                                                                                                                    | **No**    | -             |
| custom_field_4 | Custom field                                                                                                                    | **No**    | -             |
| custom_field_5 | Custom field                                                                                                                    | **No**    | -             |
| custom_field_6 | Custom field                                                                                                                    | **No**    | -             |
| custom_field_7 | Custom field                                                                                                                    | **No**    | -             |
| custom_field_8 | Custom field                                                                                                                    | **No**    | -             |
| custom_field_9 | Custom field                                                                                                                    | **No**    | -             |

## Example request

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

## Response

**In case of success:**
```json
{
    "data": {
        "message": "contact_has_been_added",
        "groups": [1,2,3]
    }
}
```


**In case of error:**
```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
}
```

Where:

- **type** and **error** (description of the error) can be found in the [error types table](https://www.bulkgate.com/en/docs/api-administration-tokens/api-error-types/)
- **code** represents http error
- **detail** is an additional info about the error
