# PATCH /api/v2/contacts/{contact}

Update a contact

- MCP id: contacts.update
- Scope: api:write:customers
- Permission: customers::update
- Rate cost: 1 unit, write bucket. A write costs the same whatever `view` you ask for.
- Cache-Control: private, no-store

Partially updates a contact: absent keys are untouched and an empty body is a `422`.

`contactable_type` and `contactable_id` are not accepted: re-parenting a contact is not supported, so sending either is a `422`. Send `If-Match` with the `ETag` from your last read to detect a concurrent edit, which answers `412`.

## Parameters
- contact (integer, path): The Contact's numeric id.
- view (string, optional): Which field set to render.
- X-Request-Id (header, optional): A correlation id of your own. It is recorded in our logs next to the server's request id but never returned: the response header always carries the server's id. A value that does not match the pattern is discarded silently, never rejected.
- If-Match (header, optional): The ETag a write is conditional on. A stale validator is 412 precondition-failed.

## Request body
- name (string ≤ 255, optional): Contact name. This is the default sort key and one of the fields `?q=` searches.
- email (email or null ≤ 255, optional): Email address. The second field `?q=` searches; not unique.
- phone (string or null ≤ 255, optional): Phone number.
- contact_role_id (integer or null → ContactRole.id, optional): Assigned contact role, or `null`. Deleting a role unassigns it rather than refusing.
- address (string or null ≤ 255, optional): Street address. plnnrly pre-fills this from the customer when adding a contact, but the API fills in no default for it.
- zip (string or null ≤ 255, optional): Postal code.
- city (string or null ≤ 255, optional): City.
- country (string or null ≤ 255, optional): Country as an ISO 3166-1 alpha-2 code, e.g. NL, as plnnrly writes it. Older records may hold any string.
- position (integer or null, optional): Display order within one parent, ascending. Null where unset.
- comment (string or null, optional): Free-form note, sanitised HTML. The emergency-contact form uses it for the relationship to the employee, e.g. Partner.

Unknown keys are refused with `422` validation-failed, naming the key.

## Response 200
- id (integer, required): Unique identifier.
- contactable_type (string, required): The kind of record `contactable` points at; it says which branch of `contactable` applies.
- contactable_id (integer, required): The id of the record `contactable` points at.
- contactable (Ref or CustomerSummary or UserSummary, required): The record this contact belongs to: a customer for a CRM contact, a user for an employee's emergency contact. Rendered as {"id": N} until named in `?include=contactable`, and still as {"id": N} where the caller may not read the parent's prefix. `contactable_type` and `contactable_id` are always present, so the parent can be found without the include, and the reference form shows nothing `contactable_id` does not.
- contact_role_id (integer or null, required): Assigned contact role, or `null`. Deleting a role unassigns it rather than refusing.
- role (Ref or ContactRoleSummary or null, required): The contact's role. Rendered as {"id": N} until named in `?include=role`, and `null` where no role is assigned.
- name (string ≤ 255, required): Contact name. This is the default sort key and one of the fields `?q=` searches.
- email (string or null ≤ 255, required): Email address. The second field `?q=` searches; not unique.
- phone (string or null ≤ 255, required): Phone number.
- address (string or null ≤ 255, required): Street address. plnnrly pre-fills this from the customer when adding a contact, but the API fills in no default for it.
- zip (string or null ≤ 255, required): Postal code.
- city (string or null ≤ 255, required): City.
- country (string or null ≤ 255, required): Country as an ISO 3166-1 alpha-2 code, e.g. NL, as plnnrly writes it. Older records may hold any string.
- position (integer or null, required): Display order within one parent, ascending. Null where unset.
- comment (html or null, required): Free-form note, sanitised HTML. The emergency-contact form uses it for the relationship to the employee, e.g. Partner.
- created_at (timestamp (YYYY-MM-DDThh:mm:ssZ), required): Creation timestamp.
- updated_at (timestamp (YYYY-MM-DDThh:mm:ssZ), required): Last-write timestamp; use for incremental sync.
- links (ContactLinks, required)
  - self (url, required): The canonical URI of this record.

## Errors
- 403 forbidden-by-policy | insufficient-permission | insufficient-token-scope: Forbidden.
- 412 precondition-failed: Precondition failed.
- 415 unsupported-media-type: Unsupported media type.
- 422 unprocessable-relationship | validation-failed: Unprocessable content.
- 400 idempotency-key-required | invalid-cursor | invalid-query-parameter | malformed-request | unsupported-parameter: Bad request.
- 401 token-expired | unauthenticated: Unauthenticated.
- 404 endpoint-not-found | resource-not-found: Not found.
- 406 not-acceptable: Not acceptable.
- 429 rate-limit-exceeded: Too many requests.
- 500 internal-error: Server error.
- 503 tenant-unavailable: Service unavailable.

## Example
```bash
curl -X PATCH \
  'https://<your-url>/api/v2/contacts/1' \
  -H 'Authorization: Bearer <token>' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'If-Match: *' \
  -d '{
    "phone": "+31 20 765 4321"
  }'
```
