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

# Update Contact

> Update an existing contact's information

Update any fields for an existing contact. Only include fields you want to change.

## Request Body

<ParamField body="contact_id" type="string" required>
  The unique identifier of the contact to update.
</ParamField>

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

<ParamField body="email" type="string">
  Updated email.
</ParamField>

<ParamField body="company" type="string">
  Updated company.
</ParamField>

<ParamField body="notes" type="string">
  Updated notes.
</ParamField>

<ParamField body="tags" type="array">
  Updated tags (replaces existing tags).
</ParamField>

<ParamField body="add_tags" type="array">
  Tags to add (appends to existing tags).
</ParamField>

<ParamField body="remove_tags" type="array">
  Tags to remove.
</ParamField>

<ParamField body="metadata" type="object">
  Metadata to merge (existing keys are overwritten, new keys are added).
</ParamField>

## Response

Returns the updated contact object.

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api.magpipe.ai/functions/v1/update-contact \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "contact_id": "c1d2e3f4-5678-9abc-def0-123456789abc",
      "notes": "Prefers afternoon appointments",
      "add_tags": ["premium"]
    }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch(
    'https://api.magpipe.ai/functions/v1/update-contact',
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        contact_id: 'c1d2e3f4-5678-9abc-def0-123456789abc',
        notes: 'Prefers afternoon appointments',
        add_tags: ['premium']
      }),
    }
  );

  const contact = await response.json();
  console.log('Updated:', contact.updated_at);
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      'https://api.magpipe.ai/functions/v1/update-contact',
      headers={
          'Authorization': 'Bearer YOUR_API_KEY',
          'Content-Type': 'application/json',
      },
      json={
          'contact_id': 'c1d2e3f4-5678-9abc-def0-123456789abc',
          'notes': 'Prefers afternoon appointments',
          'add_tags': ['premium']
      }
  )

  contact = response.json()
  print(f"Updated: {contact['updated_at']}")
  ```
</RequestExample>

<ResponseExample>
  ```json Success Response theme={null}
  {
    "id": "c1d2e3f4-5678-9abc-def0-123456789abc",
    "phone_number": "+14155551234",
    "name": "John Smith",
    "email": "john@example.com",
    "company": "Acme Corp",
    "notes": "Prefers afternoon appointments",
    "tags": ["customer", "vip", "premium"],
    "updated_at": "2024-01-16T09:00:00Z"
  }
  ```
</ResponseExample>
