# Update Onboarded Carrier

### **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-update-onboarded-carrier-contact` permission is required to access this endpoint.

### **Endpoint**

* **URL:**  `https://api.genlogs.io/onboarded-carrier/contacts/{contact_id}`
* **Method:** `PATCH`

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

### Path Params

* **contact\_id** (string, required): Existent contact ID, to de updated.

### **Request Body:**

* **name** (string, optional): Contact name.&#x20;
* **phone** (string, optional): Contact phone number
* **email** (string, optional): Contact email address.

### Request Example:

```shell
curl --location --request PATCH 'https://api.genlogs.io/onboarded-carrier/contacts/ca387122-4153-418b-82df-03008cc9af9b' \
--header 'access-token: <your-api-access-token>' \
--header 'x-api-key: <your-x-api-key>' \
--header 'Content-Type: application/json' \
--data '{
    "email": "peter_parker@test_email.com",
    "name": "Peter Parker",
    "phone": "3432434234"
}'
```

### **Response:**

* **200 OK:** A JSON object containing updated information of carrier contact.
* **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.
* **404 Not Found**: If the provided `contact_id` doesn't exist or is not created.
* **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": {
    "contact_id": "bd849e72-09f0-4d19-8b20-e227cd4ef455",
    "name": "Peter Parker",
    "phone": "3432434234",
    "email": "peter.parker@marvel.com"
  }
}
```

400 Bad Request

Returned when:

* All of `name`, `phone`, and `email` are null.
* `A`ll of `name`, `phone`, and `email` are empty strings.
* All the provided values are exactly the same as stored

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

401 Unauthorized

* When access-token is missing or expired

```json
{
    "detail": "Token is missing!"
}
```

403 Forbidden

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

404 Not Found

```json
{
    "detail": "Preferred carrier contact not found."
}
```

## Update an onboarded carrier contact

> Updates an existing onboarded carrier contact for the authenticated customer. Requires a valid JWT token and the appropriate permission. Only the fields provided in the request body will be updated.<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/{contact_id}":{"patch":{"summary":"Update an onboarded carrier contact","description":"Updates an existing onboarded carrier contact for the authenticated customer. Requires a valid JWT token and the appropriate permission. Only the fields provided in the request body will be updated.\n","tags":["Onboarded Carriers"],"parameters":[{"name":"contact_id","in":"path","required":true,"description":"Unique identifier of the contact to update.","schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","description":"Fields to update. At least one must be provided.","properties":{"name":{"type":"string","nullable":true,"description":"Contact name."},"email":{"type":"string","nullable":true,"description":"Contact email."},"phone":{"type":"string","nullable":true,"description":"Contact phone number."}},"minProperties":1}}}},"responses":{"200":{"description":"Contact updated 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 or does not own the contact.","content":{"application/json":{"schema":{"type":"object","properties":{"detail":{"type":"string"}}}}}},"404":{"description":"Contact not found.","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"}}}}}}}}}}}
```
