# importContactNote

Create-or-get a historical note on a contact, attributed to a real member of the organization (authorUserId). Keyed on (sourceSystem, externalId): replays return the existing note. Honors historical createdAt so the note interleaves into the timeline at its true position; publishes no notifications. Optional metadata carries structured source-system provenance; the result echoes the STORED metadata, which a replay never overwrites.

- Call: `POST https://server.goliathdata.com/api/v1/call` with `{ "operationId": "importContactNote", "variables": {...} }`
- Scope: `IMPORT`
- Type: mutation
- Idempotency: honors `Idempotency-Key` (24 h)
- Rate-limited: no

## Variables

- `input`: `ImportContactNoteInput!` (required)
  - `contactId`: `ID!` (required)
  - `body`: `String!` (required). The note text, at most 20,000 characters. Stored verbatim as a normal note body.
  - `authorUserId`: `ID!` (required). The organization member the note is attributed to. Must be an existing user of the importing organization: historical notes whose author is no longer a member should be attributed to whoever owns the migration, with the original author named in the body.
  - `sourceSystem`: `String!` (required). Short slug identifying the system this record came from. Lowercase letters, digits, and hyphens only, at most 32 characters. Part of the idempotency key.
  - `externalId`: `String!` (required). The note's id in the source system. At most 256 characters. Part of the idempotency key: importing the same (sourceSystem, externalId) twice returns the existing note.
  - `createdAt`: `DateTime`. When the note was written in the source system. Must be in the past. The note interleaves into the contact timeline at this position. Omitted = now.
  - `isInternal`: `Boolean`. Internal notes are hidden from shared-contact viewers. Defaults to false.
  - `metadata`: `JSON`. Optional structured provenance from the source system (e.g. an Aircall call id), stored on the note as data instead of being folded into the body text. Must be a JSON object (not an array or scalar) nesting at most 2 levels deep, serializing to at most 4,096 bytes, with no control characters in keys or string values. Written once at creation: replaying the same (sourceSystem, externalId) returns the existing note with its ORIGINAL metadata: a replay never overwrites it.

## Response (data, an example)

```json
{
  "crmImportMutation": {
    "importContactNote": {
      "noteId": "<ID>",
      "contactId": "<ID>",
      "metadata": "…"
    }
  }
}
```

## Example

```bash
curl https://server.goliathdata.com/api/v1/call \
  -H "Authorization: Bearer $GOLIATH_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "operationId": "importContactNote",
    "variables": {
      "input": {
        "contactId": "<contactId>",
        "body": "<String>",
        "authorUserId": "<authorUserId>",
        "sourceSystem": "<String>",
        "externalId": "<String>"
      }
    }
  }'
```
