### Authentication

- Include your `Access-Token` in the header of your requests.
- Include your `x-api-key` The API key provided by GenLogs. This header must be included in the request.

### Permissions

The `external-api-create-onboarded-carrier-contact` permission is required to access this endpoint.

### Endpoint

- **URL:** `https://api.genlogs.io/onboarded-carrier/bulk/contacts`
- **Method:** `POST`

### Headers

- **Access-Token**: (string, required): Access token obtained from the "Create Access Token" endpoint.
- **X-Api-Key** (string, required): The API key provided by GenLogs.

### Request body

- **contacts** (list, object, required): List of contacts to be created. Including:
  - **usdot** (string, required): Carrier USDOT number. Must contain digits only, be greater than zero, and be at most 9 digits.
  - **name** (string, optional): Contact name.
  - **phone** (string, optional): Contact phone number.
  - **email** (string, optional): Contact email address.

### Request Example:

```bash
curl --location --request POST 'https://api.genlogs.io/onboarded-carrier/bulk/contacts' \
--header 'access-token: <your-api-access-token>' \
--header 'x-api-key: <your-x-api-key>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "contacts": [\
        {\
            "usdot": "123456789",\
            "name": "Peter Parker",\
            "phone": "3432434234",\
            "email": "peter.parker@marvel.com"\
        },\
        {\
            "usdot": "234567890",\
            "name": "Mary Jane",\
            "phone": "5423123456",\
            "email": "mary.jane@marvel.com"\
        }\
    ]
}'
```

### Response:

- **200 OK:** A JSON object containing two lists for:
  - **Success**: created carrier contact(s) with relevant information including `usdot`, `name` and `id`.
  - **Failed**: failed creation with `index` and `reason`.

- **400 Bad Request:** If required parameters are missing or invalid.
- **401 Unauthorized:** If the authentication credentials (Access-Token) is missing or incorrect.
- **403 Forbidden**: If the permission has not been added to your user.
- **500 Internal Server Error:** If there is an issue on the server that prevents processing the request.

### Response Body:

**200 OK – Contacts Deleted Successfully**
```json
{
    "contacts": [\
        {\
            "usdot": "123456789",\
            "name": "Peter Parker",\
            "phone": "3432434234",\
            "email": "peter.parker@marvel.com"\
        },\
        {\
            "usdot": "234567890",\
            "name": "Mary Jane",\
            "phone": "5423123456",\
            "email": "mary.jane@marvel.com"\
        }\
    ]
}
```

**400 Bad Request**
Returned when:
- The provided contacts list is malformed or missing
- Malformed `usdot` number
```json
{
    "detail": "Missing required field: contacts"
}
```
```json
{
    "detail": "All contacts failed to be created"
}
```
```json
{
    "detail": "Value error, usdot_number must contain only digits."
}
```
```json
{
    "detail": "contacts list must not be empty"
}
```

**401 Unauthorized**
- When access-token is missing or expired
```json
{
    "detail": "Token is missing!"
}
```
```json
{
    "detail": "Token is expired!"
}
```

**403 Forbidden**
```json
{
    "detail": "User not allowed to access this endpoint"
}
```

### Bulk create onboarded carrier contacts

Creates multiple onboarded carrier contacts for the authenticated customer in a single request. Each contact entry is validated using the same rules as the single-contact create flow. At least one contact must be valid for the operation to succeed. The operation follows the same authorization, repository, caching, and creation logic as the single-contact create flow. Each `usdot` value must contain digits only, be greater than zero, and be at most 9 digits after normalization.

#### Authorizations

AccessTokenAuth & ApiKeyAuth

#### Responses

**200**
Contacts processed successfully.
```json
{
  "created_contacts": [\
    {\
      "id": "bd849e72-09f0-4d19-8b20-e227cd4ef455",\
      "usdot": "123456",\
      "name": "Peter Parker"\
    }\
  ],\
  "failed_contacts": [\
    {\
      "index": 1,\
      "error": "invalid payload: Value error, usdot must be a positive integer."\
    },\
    {\
      "index": 2,\
      "error": "invalid payload: Value error, usdot must contain only digits."\
    },\
    {\
      "index": 3,\
      "error": "invalid payload: Value error, usdot must be at most 9 digits."\
    }\
  ]
}
```
