# Contact

A contact person: either a customer's contact (the CRM address book) or an employee's emergency contact, distinguished by `contactable_type`. Emergency contacts are personal data: they are visible and writable only to the employee they belong to, whatever the customers permission. Contacts are not soft-deleted, so deleting one is permanent.

## Used by
- GET /api/v2/contacts: List contacts (ContactList)
- POST /api/v2/contacts: Create a contact (Contact)
- GET /api/v2/contacts/{contact}: Read a contact (Contact)
- PATCH /api/v2/contacts/{contact}: Update a contact (Contact)

## Contact fields
- 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.

## Variants

### ContactList

What a collection returns, and what `?view=summary` returns on a single record.

18 fields.
Identical to the detail object above.

### ContactLinks

The `links` object on this resource.

Keys: self

## Polymorphic fields
- contactable: discriminated on `contactable_type`

## Example
```json
{
  "id": 1,
  "contactable_type": "customer",
  "contactable_id": 1,
  "contactable": {
    "id": 1
  },
  "contact_role_id": 1,
  "role": null,
  "name": "Marieke de Vries",
  "email": "marieke@example.test",
  "phone": "+31 20 123 4567",
  "address": "…",
  "zip": "…",
  "city": "…",
  "country": "…",
  "position": 1,
  "comment": "<p>Prefers email.</p>",
  "created_at": "2026-03-04T09:15:00Z",
  "updated_at": "2026-03-04T09:15:00Z",
  "links": {
    "self": "https://<your-url>/api/v2/work-items/1"
  }
}
```
