> For the complete documentation index, see [llms.txt](https://docs.wonderchat.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wonderchat.io/api-reference/update-chatlog-info.md).

# Update Chatlog Info

Set contact and lead information on an existing chatlog: name, email, phone number, a free-form `userId`, and any of the chatbot's configured custom fields.

Only the fields present in the request body are modified — omit a field to leave its current value untouched.

## Endpoint

```
POST https://app.wonderchat.io/api/v1/update-chatlog-info
```

## Authentication

Pass your account API key in the request body as `apiKey`. The key must have `ADMIN` permission on the chatbot that owns the chatlog (same auth model as the `add-tags-to-chatlog` and `messages` endpoints). Requires a paid plan.

## Request Parameters

| Parameter      | Type                       | Required | Description                                                                      |
| -------------- | -------------------------- | -------- | -------------------------------------------------------------------------------- |
| `apiKey`       | string                     | ✅ Yes    | Your account API key                                                             |
| `chatlogId`    | string                     | ✅ Yes    | The ID of the chatlog to update                                                  |
| `name`         | string                     | No       | Contact name (`userName`)                                                        |
| `email`        | string                     | No       | Contact email (`userEmail`)                                                      |
| `phoneNumber`  | string                     | No       | Contact phone number (`userPhoneNumber`)                                         |
| `userId`       | string                     | No       | Free-form identifier for the person in the chat. Not a Wonderchat account ID.    |
| `customFields` | array of `{ name, value }` | No       | Custom field values. `name` must match a custom field configured on the chatbot. |

At least one updatable field (`name`, `email`, `phoneNumber`, `userId`, or a non-empty `customFields`) must be provided.

### Partial Update Semantics

Updates are partial. Only the fields you include in the request body are changed; any field you omit keeps its current value. To clear a value, send it explicitly (e.g. an empty string) — omitting it does **not** clear it.

### Custom Field Behavior

* Each `name` is matched against the chatbot's configured custom fields. An unknown name returns `400`.
* Custom field names are **case-sensitive** and must exactly match what's configured in the chatbot's lead / custom-field settings.
* Values are upserted per chatlog + field — calling repeatedly overwrites the existing value rather than stacking duplicates.

## Example Request

```bash
curl --location --request POST 'https://app.wonderchat.io/api/v1/update-chatlog-info' \
--header 'Content-Type: application/json' \
--data-raw '{
  "apiKey": "YOUR_API_KEY",
  "chatlogId": "clx123abc",
  "name": "Jane Doe",
  "email": "jane@example.com",
  "phoneNumber": "+15551234567",
  "userId": "crm-4821",
  "customFields": [
    { "name": "Company", "value": "Acme Inc" },
    { "name": "Plan", "value": "Enterprise" }
  ]
}'
```

## Response Format

**`200 OK`**

```json
{
  "success": true,
  "chatlogId": "clx123abc"
}
```

## Error Responses

| Status | Meaning                                                                | Example                                                            |
| ------ | ---------------------------------------------------------------------- | ------------------------------------------------------------------ |
| `400`  | Validation failed, no fields provided, or an unknown custom field name | `{ "error": "Unknown custom field(s): Foo" }`                      |
| `403`  | Invalid API key or insufficient permission on the chatbot              | `{ "error": "You do not have permission to update this chatlog" }` |
| `404`  | Chatlog does not exist                                                 | `{ "error": "Chatlog not found" }`                                 |
| `405`  | Non-POST request                                                       | Method Not Allowed                                                 |

## Use Cases

* **CRM Sync**: Attach a CRM record ID via `userId` and keep contact details in sync.
* **Lead Enrichment**: Populate custom fields (company, plan, region) collected outside the chat.
* **Post-chat Updates**: Correct or complete contact information after a conversation ends.
