# Update contact

> PATCH https://api.nabrah.ai/api/ext/omni_v2/contact/{contact_id}

Group: Contacts. Page: https://www.nabrah.ai/en/docs/api-reference/contacts/update-contact

Performs a partial update of an existing contact identified by `contact_id`. Only the fields you include in the request body are changed; omitted fields are left untouched. You may update `name`, `email`, `phone_number`, `identifier`, the structured `additional_attributes`, and the free-form `custom_attributes`. The full updated contact is returned in `payload`.

## Authentication

- **X-API-Key header**: Send your Web API key (prefix `nb_`) in the `X-API-Key` header. The key is scoped to one project; the contact must belong to that project.

## Partial update semantics

PATCH only changes the fields you send.

- **Updatable fields**: Include any subset of `name`, `email`, `phone_number`, `identifier`, `additional_attributes`, and `custom_attributes`. Fields you leave out keep their current values. Fields: `name`, `email`, `phone_number`, `identifier`, `additional_attributes`, `custom_attributes`.
- **additional_attributes**: Structured profile object with `city`, `country`, `description`, `company_name`, `country_code`, and `social_profiles`. Fields: `city`, `country`, `description`, `company_name`, `country_code`, `social_profiles`.

Get a contact_id from the list or search endpoints, or from payload.contact.id when creating a contact.

## Authorization

- `X-API-Key` (string, header, required): your workspace API key.

## Path parameters

- `contact_id` (integer, required): Numeric identifier of the contact to update. Obtained from `GET /api/ext/omni_v2/contact` or `GET /api/ext/omni_v2/contact/search` (the contact `id` field).

## Body (application/json)

### Example: Update attributes

Update profile and custom attributes along with core fields.

```json
{
  "name": "Sarah Johnson",
  "email": "sarah.johnson@example.com",
  "phone_number": "+15551234567",
  "identifier": "crm-7831",
  "additional_attributes": {
    "city": "Jeddah",
    "country": "Saudi Arabia",
    "description": "Upgraded to enterprise plan",
    "company_name": "Acme Corp",
    "country_code": "SA",
    "social_profiles": {
      "linkedin": "in/sarahjohnson"
    }
  },
  "custom_attributes": {
    "account_tier": "platinum"
  }
}
```

### Example: Email only

Partial update changing just the email address.

```json
{
  "email": "sarah.j@newcompany.com"
}
```

## Response

### 200 Successful Response

Content type: `application/json`

```json
{
  "payload": {
    "id": 0,
    "additional_attributes": {
      "city": "string",
      "country": "string",
      "description": "string",
      "company_name": "string",
      "country_code": "string",
      "social_profiles": {}
    },
    "availability_status": "string",
    "email": "string",
    "name": "string",
    "phone_number": "string",
    "blocked": false,
    "identifier": "string",
    "thumbnail": "string",
    "custom_attributes": {},
    "last_activity_at": 0,
    "created_at": 0
  }
}
```

### 422 Validation Error

Content type: `application/json`

```json
{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string"
    }
  ]
}
```

## Request examples

### cURL

```bash
curl --request PATCH \
  --url 'https://api.nabrah.ai/api/ext/omni_v2/contact/<contact_id>' \
  --header 'X-API-Key: <your-api-key>' \
  --header 'Content-Type: application/json' \
  --data '{
  "name": "Sarah Johnson",
  "email": "sarah.johnson@example.com",
  "phone_number": "+15551234567",
  "identifier": "crm-7831",
  "additional_attributes": {
    "city": "Jeddah",
    "country": "Saudi Arabia",
    "description": "Upgraded to enterprise plan",
    "company_name": "Acme Corp",
    "country_code": "SA",
    "social_profiles": {
      "linkedin": "in/sarahjohnson"
    }
  },
  "custom_attributes": {
    "account_tier": "platinum"
  }
}'
```

### Python

```python
import requests

url = "https://api.nabrah.ai/api/ext/omni_v2/contact/<contact_id>"
headers = {
    "X-API-Key": "<your-api-key>",
}
payload = {
    "name": "Sarah Johnson",
    "email": "sarah.johnson@example.com",
    "phone_number": "+15551234567",
    "identifier": "crm-7831",
    "additional_attributes": {
        "city": "Jeddah",
        "country": "Saudi Arabia",
        "description": "Upgraded to enterprise plan",
        "company_name": "Acme Corp",
        "country_code": "SA",
        "social_profiles": {
            "linkedin": "in/sarahjohnson"
        }
    },
    "custom_attributes": {
        "account_tier": "platinum"
    }
}

response = requests.patch(url, headers=headers, json=payload)
response.raise_for_status()
print(response.json())
```

### JavaScript

```javascript
const response = await fetch("https://api.nabrah.ai/api/ext/omni_v2/contact/<contact_id>", {
  method: "PATCH",
  headers: {
    "X-API-Key": "<your-api-key>",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "name": "Sarah Johnson",
    "email": "sarah.johnson@example.com",
    "phone_number": "+15551234567",
    "identifier": "crm-7831",
    "additional_attributes": {
      "city": "Jeddah",
      "country": "Saudi Arabia",
      "description": "Upgraded to enterprise plan",
      "company_name": "Acme Corp",
      "country_code": "SA",
      "social_profiles": {
        "linkedin": "in/sarahjohnson"
      }
    },
    "custom_attributes": {
      "account_tier": "platinum"
    }
  }),
});

const data = await response.json();
console.log(data);
```

### Go

```go
package main

import (
	"fmt"
	"io"
	"net/http"
	"strings"
)

func main() {
	payload := strings.NewReader(`{
  "name": "Sarah Johnson",
  "email": "sarah.johnson@example.com",
  "phone_number": "+15551234567",
  "identifier": "crm-7831",
  "additional_attributes": {
    "city": "Jeddah",
    "country": "Saudi Arabia",
    "description": "Upgraded to enterprise plan",
    "company_name": "Acme Corp",
    "country_code": "SA",
    "social_profiles": {
      "linkedin": "in/sarahjohnson"
    }
  },
  "custom_attributes": {
    "account_tier": "platinum"
  }
}`)

	req, _ := http.NewRequest("PATCH", "https://api.nabrah.ai/api/ext/omni_v2/contact/<contact_id>", payload)
	req.Header.Set("X-API-Key", "<your-api-key>")
	req.Header.Set("Content-Type", "application/json")

	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()

	out, _ := io.ReadAll(res.Body)
	fmt.Println(string(out))
}
```
