# Action Required: Create Token

Creating a token now requires a JSON body. Update by Sep 30 - see migration steps [here](https://help.genlogs.io/en/articles/15888388-updating-your-create-token-setup).

For the complete documentation index, see [llms.txt](https://docs.genlogs.io/llms.txt).  This page is also available as [Markdown](https://docs.genlogs.io/carrier/onboarded-carriers/create-onboarded-carriers.md).

## 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.

## Request Body:
- **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 '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": "123456789",
    "name": "Peter Parker",
    "phone": "3432434234",
    "email": "peter.parker@marvel.com"
}'
```

## Response:
- **200 OK:** A JSON object containing the provided information of carrier contacts.
- **400 Bad Request:** If required parameters are missing or invalid.
- **401 Unauthorized:** If the authentication credentials (Access-Token) are 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 malformed.
- `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."
}
```
```json
{
    "detail": "Value error, usdot must be at most 9 digits."
}
```

### 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. The `usdot` value must contain digits only, be greater than zero, and be at most 9 digits after normalization.

### Authorizations
- **AccessTokenAuth** & **ApiKeyAuth**

### Body
- **application/json**
    - `usdot` (string, required): Carrier USDOT number. Must contain digits only, be greater than zero, and be at most 9 digits. Leading zeroes are normalized before persistence.
    - **Example:** `1234567`
    - **Pattern:** `^[0-9]+$`
    - `name` (string, optional): Contact name. **Example:** `Peter Parker`
    - `phone` (string, optional): Contact phone number. **Example:** `3432434234`
    - `email` (string, optional): Contact email address. **Example:** `peter.parker@marvel.com`

### Responses
- **200:** Contact created successfully.
- **400:** Bad Request – Missing or invalid fields.
- **401:** Unauthorized – Invalid or missing Access-Token.
- **403:** Forbidden – The user lacks required permission.
- **500:** Internal Server Error.
