# Create Onboarded Carriers

### **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/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.&#x20;

### **Request Body:**

* **usdot** (string, required): Carrier USDOT number. Must be a non-empty value.
* **name** (string, optional): Contact name.&#x20;
* **phone** (string, optional): Contact phone number
* **email** (string, optional): Contact email address.

### Request Example:

```bash
curl --location 'https://api.genlogs.io/onboarded-carrier/contacts' \
--header 'access-token: <your-access-token>' \
--header 'x-api-key: <your-x-api-key>' \
--header 'Content-Type: application/json' \
--data '{
    "usdot": "1234567",
    "name": "Peter Parker",
    "phone": "3432434234",
    "email": "peter.parker@marvel.com"
}'
```

### **Response:**

* **200 OK:** A JSON object containing provided information of carrier contacts.
* **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 – Contact Created Successfully

```json
{
  "contact": {
    "id": "bd849e72-09f0-4d19-8b20-e227cd4ef455",
    "name": "Peter Parker",
    "phone": "3432434234",
    "email": "peter.parker@marvel.com"
  }
}
```

400 Bad Request

Returned when:

* `usdot` is missing.
* `usdot` is provided, but all of `name`, `phone`, and `email` are null.
* `usdot` is provided, but all of `name`, `phone`, and `email` are empty strings.

```json
{
    "detail": "Missing required field: usdot"
}
```

```json
{
    "detail": "Value error, At least one of name, email, or phone must be provided."
}
```

403 Forbidden

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

## Create an onboarded carrier contact

> Creates a new onboarded carrier contact for the authenticated customer. Requires a valid JWT token and the appropriate permission.<br>

```json
{"openapi":"3.0.3","info":{"title":"Onboarded Carrier Contacts API","version":"1.0.0"},"servers":[{"url":"https://api.genlogs.io"}],"security":[{"AccessTokenAuth":[],"ApiKeyAuth":[]}],"components":{"securitySchemes":{"AccessTokenAuth":{"type":"apiKey","in":"header","name":"Access-Token","description":"JWT provided directly in the Access-Token header. No \"Bearer\" prefix.\n"}}},"paths":{"/onboarded-carrier/contacts":{"post":{"summary":"Create an onboarded carrier contact","description":"Creates a new onboarded carrier contact for the authenticated customer. Requires a valid JWT token and the appropriate permission.\n","tags":["Onboarded Carriers"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["usdot"],"properties":{"usdot":{"type":"string","description":"Carrier USDOT number. Must be a non-empty value."},"name":{"type":"string","nullable":true,"description":"Contact name."},"phone":{"type":"string","nullable":true,"description":"Contact phone number."},"email":{"type":"string","nullable":true,"description":"Contact email address."}}}}}},"responses":{"200":{"description":"Contact created successfully.","content":{"application/json":{"schema":{"type":"object","properties":{"contact":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"phone":{"type":"string"},"email":{"type":"string"}}}}}}}},"400":{"description":"Bad Request – Missing or invalid fields.","content":{"application/json":{"schema":{"type":"object","properties":{"detail":{"type":"string"}}}}}},"401":{"description":"Unauthorized – Invalid or missing Access-Token.","content":{"application/json":{"schema":{"type":"object","properties":{"detail":{"type":"string"}}}}}},"403":{"description":"Forbidden – The user lacks required permission.","content":{"application/json":{"schema":{"type":"object","properties":{"detail":{"type":"string"}}}}}},"500":{"description":"Internal Server Error.","content":{"application/json":{"schema":{"type":"object","properties":{"detail":{"type":"string"}}}}}}}}}}}
```
