> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mailbreeze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Contact

> Update an existing contact

Update properties of an existing contact. The email address cannot be changed.

## Path Parameters

<ParamField path="listId" type="string" required>
  The unique list ID (e.g., `lst_abc123`).
</ParamField>

<ParamField path="id" type="string" required>
  The unique contact ID (e.g., `cnt_abc123`).
</ParamField>

## Request Body

<ParamField body="firstName" type="string">
  Updated first name.
</ParamField>

<ParamField body="lastName" type="string">
  Updated last name.
</ParamField>

<ParamField body="phoneNumber" type="string">
  Updated phone number.
</ParamField>

<ParamField body="customFields" type="object">
  Updated custom field values. Merges with existing fields (use `null` to clear a field).
</ParamField>

<ParamField body="consentType" type="string">
  Type of consent obtained (NDPR compliance): `explicit`, `implicit`, or `legitimate_interest`.
</ParamField>

<ParamField body="consentSource" type="string">
  Where consent was collected (e.g., `signup_form`, `import`, `api`).
</ParamField>

<ParamField body="consentTimestamp" type="string">
  ISO 8601 timestamp when consent was given.
</ParamField>

<ParamField body="consentIpAddress" type="string">
  IP address from which consent was given.
</ParamField>

## Examples

<CodeGroup>
  ```typescript JavaScript theme={null}
  import { MailBreeze } from "mailbreeze";

  const mailbreeze = new MailBreeze({ apiKey: "sk_live_xxx" });
  const contacts = mailbreeze.contacts("lst_abc123");

  // Update basic info
  const contact = await contacts.update("cnt_abc123", {
    firstName: "Jonathan",
    lastName: "Doe-Smith",
  });

  // Update custom fields
  const contact = await contacts.update("cnt_abc123", {
    customFields: {
      plan: "enterprise",
      company: "New Company Inc",
    },
  });

  console.log(contact.updatedAt); // "2024-01-20T14:15:00Z"
  ```

  ```python Python theme={null}
  from mailbreeze import MailBreeze

  client = MailBreeze(api_key="sk_live_xxx")
  contacts = client.contacts("lst_abc123")

  # Update basic info
  contact = await contacts.update("cnt_abc123",
      first_name="Jonathan",
      last_name="Doe-Smith",
  )

  # Update custom fields
  contact = await contacts.update("cnt_abc123",
      custom_fields={
          "plan": "enterprise",
          "company": "New Company Inc",
      },
  )

  print(contact.updated_at)  # "2024-01-20T14:15:00Z"
  ```

  ```go Go theme={null}
  client := mailbreeze.NewClient("sk_live_xxx")
  contacts := client.Contacts("lst_abc123")

  // Update basic info
  contact, err := contacts.Update(ctx, "cnt_abc123", &mailbreeze.UpdateContactParams{
      FirstName: "Jonathan",
      LastName:  "Doe-Smith",
  })

  // Update custom fields
  contact, err := contacts.Update(ctx, "cnt_abc123", &mailbreeze.UpdateContactParams{
      CustomFields: map[string]any{
          "plan":    "enterprise",
          "company": "New Company Inc",
      },
  })

  fmt.Println(contact.UpdatedAt) // "2024-01-20T14:15:00Z"
  ```

  ```php PHP theme={null}
  $mailbreeze = new MailBreeze('sk_live_xxx');

  // Update basic info
  $response = $mailbreeze->contacts->update('lst_abc123', 'cnt_abc123', [
      'firstName' => 'Jonathan',
      'lastName' => 'Doe-Smith',
  ]);
  $contact = $response['data'];

  // Update custom fields
  $response = $mailbreeze->contacts->update('lst_abc123', 'cnt_abc123', [
      'customFields' => [
          'plan' => 'enterprise',
          'company' => 'New Company Inc',
      ],
  ]);
  $contact = $response['data'];

  echo $contact['updatedAt']; // "2024-01-20T14:15:00Z"
  ```

  ```rust Rust theme={null}
  let client = Client::new("sk_live_xxx");
  let contacts = client.contacts("lst_abc123");

  // Update basic info
  let contact = contacts.update("cnt_abc123", UpdateContactParams {
      first_name: Some("Jonathan".to_string()),
      last_name: Some("Doe-Smith".to_string()),
      ..Default::default()
  }).await?;

  // Update custom fields
  let contact = contacts.update("cnt_abc123", UpdateContactParams {
      custom_fields: Some(json!({"plan": "enterprise", "company": "New Company Inc"})),
      ..Default::default()
  }).await?;

  println!("{}", contact.updated_at); // "2024-01-20T14:15:00Z"
  ```

  ```bash cURL theme={null}
  curl -X PUT "https://api.mailbreeze.com/api/v1/contact-lists/lst_abc123/contacts/cnt_abc123" \
    -H "Authorization: Bearer sk_live_xxx" \
    -H "Content-Type: application/json" \
    -d '{
      "firstName": "Jonathan",
      "customFields": {
        "plan": "enterprise"
      }
    }'
  ```
</CodeGroup>

## Response

Returns the updated contact object.

```json Example Response theme={null}
{
  "success": true,
  "data": {
    "id": "cnt_abc123",
    "email": "john@example.com",
    "firstName": "Jonathan",
    "lastName": "Doe-Smith",
    "phoneNumber": "+1-555-0123",
    "customFields": {
      "company": "New Company Inc",
      "plan": "enterprise"
    },
    "status": "active",
    "source": "api",
    "createdAt": "2024-01-15T10:30:00Z",
    "updatedAt": "2024-01-20T14:15:00Z"
  },
  "meta": {
    "timestamp": "2024-01-20T14:15:00.000Z",
    "requestId": "req_abc123",
    "path": "/api/v1/contact-lists/lst_abc123/contacts/cnt_abc123"
  }
}
```

## Errors

| Code                   | HTTP Status | Description                              |
| ---------------------- | ----------- | ---------------------------------------- |
| `CONTACT_NOT_FOUND`    | 404         | Contact with this ID doesn't exist       |
| `LIST_NOT_FOUND`       | 404         | List with this ID doesn't exist          |
| `INVALID_CUSTOM_FIELD` | 400         | Custom field key or value is invalid     |
| `VALIDATION_ERROR`     | 400         | Required custom field missing or invalid |

<Note>
  Email addresses cannot be changed. To update an email, delete the contact and create a new one.
</Note>
